[tests] t/test_mod now runs all t/test_mod_*.c

combine into a single executable to reduce compilation/link redundancy
master
Glenn Strauss 1 year ago
parent 05dc3d123a
commit 9b3fa6eb2b
  1. 8
      .gitignore
  2. 134
      src/CMakeLists.txt
  3. 46
      src/Makefile.am
  4. 143
      src/meson.build
  5. 24
      src/t/test_mod.c
  6. 24
      src/t/test_mod_access.c
  7. 29
      src/t/test_mod_evhost.c
  8. 23
      src/t/test_mod_indexfile.c
  9. 29
      src/t/test_mod_simple_vhost.c
  10. 23
      src/t/test_mod_ssi.c
  11. 23
      src/t/test_mod_staticfile.c
  12. 42
      src/t/test_mod_userdir.c

8
.gitignore vendored

@ -52,12 +52,6 @@ test_buffer
test_burl
test_keyvalue
test_configfile
test_mod_access
test_mod_evhost
test_mod_indexfile
test_mod_simple_vhost
test_mod_ssi
test_mod_staticfile
test_mod_userdir
test_mod
test_request
versionstamp.h

@ -907,118 +907,18 @@ add_executable(test_keyvalue
)
add_test(NAME test_keyvalue COMMAND test_keyvalue)
add_executable(test_mod_access
add_executable(test_mod
${COMMON_SRC}
t/test_mod.c
t/test_mod_access.c
buffer.c
array.c
log.c
fdlog.c
ck.c
)
add_test(NAME test_mod_access COMMAND test_mod_access)
add_executable(test_mod_evhost
t/test_mod_evhost.c
buffer.c
array.c
log.c
fdlog.c
ck.c
)
add_test(NAME test_mod_evhost COMMAND test_mod_evhost)
add_executable(test_mod_indexfile
t/test_mod_indexfile.c
request.c
base64.c
buffer.c
burl.c
array.c
fdevent.c
http_etag.c
http_header.c
http_kv.c
log.c
fdlog.c
sock_addr.c
stat_cache.c
fdevent_fdnode.c
algo_splaytree.c
ck.c
)
add_test(NAME test_mod_indexfile COMMAND test_mod_indexfile)
add_executable(test_mod_simple_vhost
t/test_mod_simple_vhost.c
buffer.c
array.c
log.c
fdlog.c
ck.c
)
add_test(NAME test_mod_simple_vhost COMMAND test_mod_simple_vhost)
add_executable(test_mod_ssi
t/test_mod_ssi.c
request.c
base64.c
buffer.c
burl.c
array.c
chunk.c
fdevent.c
http-header-glue.c
http_cgi.c
http_chunk.c
http_date.c
http_etag.c
http_header.c
http_kv.c
log.c
fdlog.c
sock_addr.c
stat_cache.c
fdevent_fdnode.c
algo_splaytree.c
ck.c
)
add_test(NAME test_mod_ssi COMMAND test_mod_ssi)
add_executable(test_mod_staticfile
t/test_mod_staticfile.c
request.c
base64.c
buffer.c
burl.c
array.c
chunk.c
fdevent.c
http-header-glue.c
http_cgi.c
http_chunk.c
http_date.c
http_etag.c
http_header.c
http_kv.c
log.c
fdlog.c
sock_addr.c
stat_cache.c
fdevent_fdnode.c
algo_splaytree.c
ck.c
)
add_test(NAME test_mod_staticfile COMMAND test_mod_staticfile)
add_executable(test_mod_userdir
t/test_mod_userdir.c
buffer.c
array.c
log.c
fdlog.c
ck.c
)
add_test(NAME test_mod_userdir COMMAND test_mod_userdir)
add_test(NAME test_mod COMMAND test_mod)
add_executable(test_request
t/test_request.c
@ -1042,6 +942,8 @@ if(HAVE_PCRE_H)
add_target_properties(test_configfile COMPILE_FLAGS ${PCRE_CFLAGS})
target_link_libraries(test_keyvalue ${PCRE_LDFLAGS})
add_target_properties(test_keyvalue COMPILE_FLAGS ${PCRE_CFLAGS})
target_link_libraries(test_mod ${PCRE_LDFLAGS})
add_target_properties(test_mod COMPILE_FLAGS ${PCRE_CFLAGS})
endif()
if(WITH_PCRE AND (WITH_MEMCACHED OR WITH_GDBM))
@ -1169,8 +1071,7 @@ endif()
if(HAVE_LIBFAM)
target_link_libraries(lighttpd fam)
target_link_libraries(test_mod_ssi fam)
target_link_libraries(test_mod_staticfile fam)
target_link_libraries(test_mod fam)
endif()
if(HAVE_GDBM_H)
@ -1183,10 +1084,12 @@ endif()
if(HAVE_XATTR)
target_link_libraries(lighttpd attr)
target_link_libraries(test_mod attr)
endif()
if(HAVE_XXHASH)
target_link_libraries(lighttpd xxhash)
target_link_libraries(test_mod xxhash)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
@ -1233,6 +1136,7 @@ if(NOT ${CRYPTO_LIBRARY} EQUAL "")
target_link_libraries(mod_secdownload ${CRYPTO_LIBRARY})
target_link_libraries(mod_usertrack ${CRYPTO_LIBRARY})
target_link_libraries(mod_wstunnel ${CRYPTO_LIBRARY})
target_link_libraries(test_mod ${CRYPTO_LIBRARY})
endif()
if(HAVE_OPENSSL)
@ -1267,6 +1171,8 @@ endif()
if(WITH_LIBEV)
target_link_libraries(lighttpd ${LIBEV_LDFLAGS})
add_target_properties(lighttpd COMPILE_FLAGS ${LIBEV_CFLAGS})
target_link_libraries(test_mod ${LIBEV_LDFLAGS})
add_target_properties(test_mod COMPILE_FLAGS ${LIBEV_CFLAGS})
endif()
if(WITH_LIBUNWIND)
@ -1285,20 +1191,8 @@ if(WITH_LIBUNWIND)
add_target_properties(test_configfile COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS})
target_link_libraries(test_keyvalue ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS})
add_target_properties(test_keyvalue COMPILE_FLAGS ${PCRE_CFLAGS} ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod_access ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod_access COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod_evhost ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod_evhost COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod_indexfile ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod_indexfile COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod_simple_vhost ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod_simple_vhost COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod_ssi ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod_ssi COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod_staticfile ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod_staticfile COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod_userdir ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod_userdir COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_mod ${LIBUNWIND_LDFLAGS})
add_target_properties(test_mod COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_request ${LIBUNWIND_LDFLAGS})
add_target_properties(test_request COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
endif()

@ -7,13 +7,7 @@ noinst_PROGRAMS=\
t/test_base64 \
t/test_configfile \
t/test_keyvalue \
t/test_mod_access \
t/test_mod_evhost \
t/test_mod_indexfile \
t/test_mod_simple_vhost \
t/test_mod_ssi \
t/test_mod_staticfile \
t/test_mod_userdir \
t/test_mod \
t/test_request
sbin_PROGRAMS=lighttpd lighttpd-angel
@ -26,13 +20,7 @@ TESTS=\
t/test_base64$(EXEEXT) \
t/test_configfile$(EXEEXT) \
t/test_keyvalue$(EXEEXT) \
t/test_mod_access$(EXEEXT) \
t/test_mod_evhost$(EXEEXT) \
t/test_mod_indexfile$(EXEEXT) \
t/test_mod_simple_vhost$(EXEEXT) \
t/test_mod_ssi$(EXEEXT) \
t/test_mod_staticfile$(EXEEXT) \
t/test_mod_userdir$(EXEEXT) \
t/test_mod$(EXEEXT) \
t/test_request$(EXEEXT)
lemon$(BUILD_EXEEXT): lemon.c
@ -654,26 +642,16 @@ t_test_configfile_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_keyvalue_SOURCES = t/test_keyvalue.c burl.c buffer.c base64.c array.c log.c fdlog.c ck.c
t_test_keyvalue_LDADD = $(PCRE_LIB) $(LIBUNWIND_LIBS)
t_test_mod_access_SOURCES = t/test_mod_access.c buffer.c array.c log.c fdlog.c ck.c
t_test_mod_access_LDADD = $(LIBUNWIND_LIBS)
t_test_mod_evhost_SOURCES = t/test_mod_evhost.c buffer.c array.c log.c fdlog.c ck.c
t_test_mod_evhost_LDADD = $(LIBUNWIND_LIBS)
t_test_mod_indexfile_SOURCES = t/test_mod_indexfile.c request.c base64.c buffer.c burl.c array.c fdevent.c http_etag.c http_header.c http_kv.c log.c fdlog.c sock_addr.c stat_cache.c fdevent_fdnode.c algo_splaytree.c ck.c
t_test_mod_indexfile_LDADD = $(LIBUNWIND_LIBS) $(FAM_LIBS)
t_test_mod_simple_vhost_SOURCES = t/test_mod_simple_vhost.c buffer.c array.c log.c fdlog.c ck.c
t_test_mod_simple_vhost_LDADD = $(LIBUNWIND_LIBS)
t_test_mod_ssi_SOURCES = t/test_mod_ssi.c request.c base64.c buffer.c burl.c array.c chunk.c fdevent.c http-header-glue.c http_cgi.c http_chunk.c http_date.c http_etag.c http_header.c http_kv.c log.c fdlog.c sock_addr.c stat_cache.c fdevent_fdnode.c algo_splaytree.c ck.c
t_test_mod_ssi_LDADD = $(LIBUNWIND_LIBS) $(FAM_LIBS)
t_test_mod_staticfile_SOURCES = t/test_mod_staticfile.c request.c base64.c buffer.c burl.c array.c chunk.c fdevent.c http-header-glue.c http_cgi.c http_chunk.c http_date.c http_etag.c http_header.c http_kv.c log.c fdlog.c sock_addr.c stat_cache.c fdevent_fdnode.c algo_splaytree.c ck.c
t_test_mod_staticfile_LDADD = $(LIBUNWIND_LIBS) $(FAM_LIBS)
t_test_mod_userdir_SOURCES = t/test_mod_userdir.c buffer.c array.c log.c fdlog.c ck.c
t_test_mod_userdir_LDADD = $(LIBUNWIND_LIBS)
t_test_mod_SOURCES = $(common_src) t/test_mod.c \
t/test_mod_access.c \
t/test_mod_evhost.c \
t/test_mod_indexfile.c \
t/test_mod_simple_vhost.c \
t/test_mod_ssi.c \
t/test_mod_staticfile.c \
t/test_mod_userdir.c
t_test_mod_CFLAGS = $(AM_CFLAGS) $(LIBEV_CFLAGS)
t_test_mod_LDADD = $(LIBUNWIND_LIBS) $(PCRE_LIB) $(CRYPTO_LIB) $(FAM_LIBS) $(LIBEV_LIBS) $(ATTR_LIB)
t_test_request_SOURCES = t/test_request.c base64.c buffer.c burl.c array.c http_header.c http_kv.c log.c fdlog.c sock_addr.c ck.c
t_test_request_LDADD = $(LIBUNWIND_LIBS)

@ -921,155 +921,32 @@ test('test_keyvalue', executable('test_keyvalue',
build_by_default: false,
))
test('test_mod_access', executable('test_mod_access',
test('test_mod', executable('test_mod',
sources: [
common_src,
't/test_mod.c',
't/test_mod_access.c',
'buffer.c',
'array.c',
'log.c',
'fdlog.c',
'ck.c',
],
dependencies: common_flags + libunwind,
build_by_default: false,
))
test('test_mod_evhost', executable('test_mod_evhost',
sources: [
't/test_mod_evhost.c',
'buffer.c',
'array.c',
'log.c',
'fdlog.c',
'ck.c',
],
dependencies: common_flags + libunwind,
build_by_default: false,
))
test('test_mod_indexfile', executable('test_mod_indexfile',
sources: [
't/test_mod_indexfile.c',
'request.c',
'base64.c',
'buffer.c',
'burl.c',
'array.c',
'fdevent.c',
'http_etag.c',
'http_header.c',
'http_kv.c',
'log.c',
'fdlog.c',
'sock_addr.c',
'stat_cache.c',
'fdevent_fdnode.c',
'algo_splaytree.c',
'ck.c'
],
dependencies: [ common_flags
, libfam
, libpcre
, libunwind
, libws2_32
],
build_by_default: false,
))
test('test_mod_simple_vhost', executable('test_mod_simple_vhost',
sources: [
't/test_mod_simple_vhost.c',
'buffer.c',
'array.c',
'log.c',
'fdlog.c',
'ck.c',
],
dependencies: common_flags + libunwind,
build_by_default: false,
))
test('test_mod_ssi', executable('test_mod_ssi',
sources: [
't/test_mod_ssi.c',
'request.c',
'base64.c',
'buffer.c',
'burl.c',
'array.c',
'chunk.c',
'fdevent.c',
'http-header-glue.c',
'http_cgi.c',
'http_chunk.c',
'http_date.c',
'http_etag.c',
'http_header.c',
'http_kv.c',
'log.c',
'fdlog.c',
'sock_addr.c',
'stat_cache.c',
'fdevent_fdnode.c',
'algo_splaytree.c',
'ck.c'
],
dependencies: [ common_flags
, libfam
, libpcre
, libunwind
, libws2_32
],
build_by_default: false,
))
test('test_mod_staticfile', executable('test_mod_staticfile',
sources: [
't/test_mod_staticfile.c',
'request.c',
'base64.c',
'buffer.c',
'burl.c',
'array.c',
'chunk.c',
'fdevent.c',
'http-header-glue.c',
'http_cgi.c',
'http_chunk.c',
'http_date.c',
'http_etag.c',
'http_header.c',
'http_kv.c',
'log.c',
'fdlog.c',
'sock_addr.c',
'stat_cache.c',
'fdevent_fdnode.c',
'algo_splaytree.c',
'ck.c'
't/test_mod_userdir.c',
],
dependencies: [ common_flags
dependencies: [ common_flags, lighttpd_flags
, libattr
, libcrypto
, libdl
, libev
, libfam
, libpcre
, libunwind
, libxxhash
, libws2_32
],
build_by_default: false,
))
test('test_mod_userdir', executable('test_mod_userdir',
sources: [
't/test_mod_userdir.c',
'buffer.c',
'array.c',
'log.c',
'fdlog.c',
'ck.c',
],
dependencies: common_flags + libunwind,
build_by_default: false,
))
test('test_request', executable('test_request',
sources: [
't/test_request.c',

@ -0,0 +1,24 @@
#include "first.h"
#undef NDEBUG
#include <assert.h>
void test_mod_access (void);
void test_mod_evhost (void);
void test_mod_indexfile (void);
void test_mod_simple_vhost (void);
void test_mod_ssi (void);
void test_mod_staticfile (void);
void test_mod_userdir (void);
int main() {
test_mod_access();
test_mod_evhost();
test_mod_indexfile();
test_mod_simple_vhost();
test_mod_ssi();
test_mod_staticfile();
test_mod_userdir();
return 0;
}

@ -48,26 +48,8 @@ static void test_mod_access_check(void) {
buffer_free(urlpath);
}
int main (void) {
void test_mod_access (void);
void test_mod_access (void)
{
test_mod_access_check();
return 0;
}
/*
* stub functions
*/
int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) {
UNUSED(srv);
UNUSED(p_d);
UNUSED(cpk);
UNUSED(mname);
return 0;
}
int config_check_cond(request_st *r, int context_ndx) {
UNUSED(r);
UNUSED(context_ndx);
return 0;
}

@ -65,31 +65,8 @@ static void test_mod_evhost_build_doc_root_path(void) {
array_free(a);
}
int main (void) {
void test_mod_evhost (void);
void test_mod_evhost (void)
{
test_mod_evhost_build_doc_root_path();
return 0;
}
/*
* stub functions
*/
int stat_cache_path_isdir(const buffer *name) {
UNUSED(name);
return 1;
}
int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) {
UNUSED(srv);
UNUSED(p_d);
UNUSED(cpk);
UNUSED(mname);
return 0;
}
int config_check_cond(request_st *r, int context_ndx) {
UNUSED(r);
UNUSED(context_ndx);
return 0;
}

@ -88,7 +88,8 @@ test_mod_indexfile_tryfiles (request_st * const r)
unlink(fn);
}
int main (void)
void test_mod_indexfile (void);
void test_mod_indexfile (void)
{
request_st r;
@ -109,24 +110,4 @@ int main (void)
free(r.physical.doc_root.ptr);
stat_cache_free();
return 0;
}
/*
* stub functions
*/
int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) {
UNUSED(srv);
UNUSED(p_d);
UNUSED(cpk);
UNUSED(mname);
return 0;
}
int config_check_cond(request_st *r, int context_ndx) {
UNUSED(r);
UNUSED(context_ndx);
return 0;
}

@ -33,31 +33,8 @@ static void test_mod_simple_vhost_build_doc_root_path(void) {
buffer_free(result);
}
int main (void) {
void test_mod_simple_vhost (void);
void test_mod_simple_vhost (void)
{
test_mod_simple_vhost_build_doc_root_path();
return 0;
}
/*
* stub functions
*/
int stat_cache_path_isdir(const buffer *name) {
UNUSED(name);
return 1;
}
int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) {
UNUSED(srv);
UNUSED(p_d);
UNUSED(cpk);
UNUSED(mname);
return 0;
}
int config_check_cond(request_st *r, int context_ndx) {
UNUSED(r);
UNUSED(context_ndx);
return 0;
}

@ -137,7 +137,8 @@ test_mod_ssi_read_fd (request_st * const r, handler_ctx * const hctx)
close(fd);
}
int main (void)
void test_mod_ssi (void);
void test_mod_ssi (void)
{
plugin_data * const p = mod_ssi_init();
assert(NULL != p);
@ -169,24 +170,4 @@ int main (void)
mod_ssi_free(p);
free(p);
stat_cache_free();
return 0;
}
/*
* stub functions
*/
int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) {
UNUSED(srv);
UNUSED(p_d);
UNUSED(cpk);
UNUSED(mname);
return 0;
}
int config_check_cond(request_st *r, int context_ndx) {
UNUSED(r);
UNUSED(context_ndx);
return 0;
}

@ -368,7 +368,8 @@ test_mod_staticfile_process (request_st * const r, plugin_config * const pconf)
#include <unistd.h> /* unlink() */
int main (void)
void test_mod_staticfile (void);
void test_mod_staticfile (void)
{
char fn[] = "/tmp/lighttpd_mod_staticfile.XXXXXX";
#ifdef __COVERITY__
@ -431,24 +432,4 @@ int main (void)
free(p);
stat_cache_free();
unlink(fn);
return 0;
}
/*
* stub functions
*/
int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) {
UNUSED(srv);
UNUSED(p_d);
UNUSED(cpk);
UNUSED(mname);
return 0;
}
int config_check_cond(request_st *r, int context_ndx) {
UNUSED(r);
UNUSED(context_ndx);
return 0;
}

@ -151,7 +151,10 @@ test_mod_userdir_docroot_handler(request_st * const r, plugin_data * const p)
array_free(exclude_user);
}
int main (void)
#include "base.h"
void test_mod_userdir (void);
void test_mod_userdir (void)
{
plugin_data * const p = mod_userdir_init();
assert(NULL != p);
@ -162,11 +165,19 @@ int main (void)
p->defaults.path = path;
request_st r;
connection con;
server srv;
memset(&r, 0, sizeof(request_st));
memset(&con, 0, sizeof(connection));
memset(&srv, 0, sizeof(server));
r.tmp_buf = buffer_init();
r.conf.errh = fdlog_init(NULL, -1, FDLOG_FD);
r.conf.errh->fd = -1; /* (disable) */
/* r->con->srv->srvconf.absolute_dir_redirect
* in http_response_redirect_to_directory() */
r.con = &con;
con.srv = &srv;
test_mod_userdir_docroot_handler(&r, p);
@ -181,33 +192,4 @@ int main (void)
buffer_free(basepath);
buffer_free(path);
free(p);
return 0;
}
/*
* stub functions
*/
int http_response_redirect_to_directory(request_st *r, int status) {
r->http_status = status;
return 0;
}
int stat_cache_path_isdir(const buffer *name) {
UNUSED(name);
return 1;
}
int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname) {
UNUSED(srv);
UNUSED(p_d);
UNUSED(cpk);
UNUSED(mname);
return 0;
}
int config_check_cond(request_st *r, int context_ndx) {
UNUSED(r);
UNUSED(context_ndx);
return 0;
}

Loading…
Cancel
Save