Browse Source

[tests] combine tests into test_common.c

combine common components tests into test_common.c

combine into a single executable to reduce compilation/link redundancy
master
Glenn Strauss 3 weeks ago
parent
commit
bab0e5d084
  1. 7
      .gitignore
  2. 76
      src/CMakeLists.txt
  3. 49
      src/Makefile.am
  4. 77
      src/meson.build
  5. 8
      src/t/test_array.c
  6. 7
      src/t/test_base64.c
  7. 8
      src/t/test_buffer.c
  8. 7
      src/t/test_burl.c
  9. 22
      src/t/test_common.c
  10. 5
      src/t/test_keyvalue.c
  11. 5
      src/t/test_request.c

7
.gitignore

@ -46,12 +46,7 @@ mod_ssi_exprparser.h
scgi-responder
sconsbuild/
stamp-h1
test_array
test_base64
test_buffer
test_burl
test_keyvalue
test_common
test_configfile
test_mod
test_request
versionstamp.h

76
src/CMakeLists.txt

@ -848,38 +848,6 @@ add_and_install_library(mod_vhostdb "mod_vhostdb.c;mod_vhostdb_api.c")
add_and_install_library(mod_webdav mod_webdav.c)
add_and_install_library(mod_wstunnel mod_wstunnel.c)
add_executable(test_array
t/test_array.c
array.c
buffer.c
ck.c
)
add_test(NAME test_array COMMAND test_array)
add_executable(test_buffer
t/test_buffer.c
buffer.c
ck.c
)
add_test(NAME test_buffer COMMAND test_buffer)
add_executable(test_burl
t/test_burl.c
burl.c
buffer.c
base64.c
ck.c
)
add_test(NAME test_burl COMMAND test_burl)
add_executable(test_base64
t/test_base64.c
buffer.c
base64.c
ck.c
)
add_test(NAME test_base64 COMMAND test_base64)
add_executable(test_configfile
t/test_configfile.c
buffer.c
@ -895,18 +863,6 @@ add_executable(test_configfile
)
add_test(NAME test_configfile COMMAND test_configfile)
add_executable(test_keyvalue
t/test_keyvalue.c
burl.c
buffer.c
base64.c
array.c
log.c
fdlog.c
ck.c
)
add_test(NAME test_keyvalue COMMAND test_keyvalue)
add_executable(test_mod
${COMMON_SRC}
t/test_mod.c
@ -922,12 +878,14 @@ add_executable(test_mod
)
add_test(NAME test_mod COMMAND test_mod)
add_executable(test_request
add_executable(test_common
t/test_common.c
t/test_array.c
t/test_base64.c
t/test_buffer.c
t/test_burl.c
t/test_keyvalue.c
t/test_request.c
base64.c
buffer.c
burl.c
array.c
http_header.c
http_kv.c
log.c
@ -935,15 +893,15 @@ add_executable(test_request
sock_addr.c
ck.c
)
add_test(NAME test_request COMMAND test_request)
add_test(NAME test_common COMMAND test_common)
if(HAVE_PCRE_H)
target_link_libraries(lighttpd ${PCRE_LDFLAGS})
add_target_properties(lighttpd COMPILE_FLAGS ${PCRE_CFLAGS})
target_link_libraries(test_common ${PCRE_LDFLAGS})
add_target_properties(test_common COMPILE_FLAGS ${PCRE_CFLAGS})
target_link_libraries(test_configfile ${PCRE_LDFLAGS})
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()
@ -1181,22 +1139,12 @@ if(WITH_LIBUNWIND)
target_link_libraries(lighttpd ${LIBUNWIND_LDFLAGS})
add_target_properties(lighttpd COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_array ${LIBUNWIND_LDFLAGS})
add_target_properties(test_array COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_buffer ${LIBUNWIND_LDFLAGS})
add_target_properties(test_buffer COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_burl ${LIBUNWIND_LDFLAGS})
add_target_properties(test_burl COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_base64 ${LIBUNWIND_LDFLAGS})
add_target_properties(test_base64 COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_common ${LIBUNWIND_LDFLAGS})
add_target_properties(test_common COMPILE_FLAGS ${LIBUNWIND_CFLAGS})
target_link_libraries(test_configfile ${PCRE_LDFLAGS} ${LIBUNWIND_LDFLAGS})
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 ${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()
if(NOT WIN32)

49
src/Makefile.am

@ -1,27 +1,17 @@
AM_CFLAGS = $(FAM_CFLAGS) $(LIBUNWIND_CFLAGS)
noinst_PROGRAMS=\
t/test_array \
t/test_buffer \
t/test_burl \
t/test_base64 \
t/test_common \
t/test_configfile \
t/test_keyvalue \
t/test_mod \
t/test_request
t/test_mod
sbin_PROGRAMS=lighttpd lighttpd-angel
LEMON=$(top_builddir)/src/lemon$(BUILD_EXEEXT)
TESTS=\
t/test_array$(EXEEXT) \
t/test_buffer$(EXEEXT) \
t/test_burl$(EXEEXT) \
t/test_base64$(EXEEXT) \
t/test_common$(EXEEXT) \
t/test_configfile$(EXEEXT) \
t/test_keyvalue$(EXEEXT) \
t/test_mod$(EXEEXT) \
t/test_request$(EXEEXT)
t/test_mod$(EXEEXT)
lemon$(BUILD_EXEEXT): lemon.c
$(AM_V_CC)$(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $(srcdir)/lemon.c
@ -624,24 +614,24 @@ lighttpd_LDFLAGS = -export-dynamic
endif
t_test_array_SOURCES = t/test_array.c array.c buffer.c ck.c
t_test_array_LDADD = $(LIBUNWIND_LIBS)
t_test_buffer_SOURCES = t/test_buffer.c buffer.c ck.c
t_test_buffer_LDADD = $(LIBUNWIND_LIBS)
t_test_base64_SOURCES = t/test_base64.c base64.c buffer.c ck.c
t_test_base64_LDADD = $(LIBUNWIND_LIBS)
t_test_burl_SOURCES = t/test_burl.c burl.c buffer.c base64.c ck.c
t_test_burl_LDADD = $(LIBUNWIND_LIBS)
t_test_common_SOURCES = t/test_common.c \
t/test_array.c \
t/test_base64.c \
t/test_buffer.c \
t/test_burl.c \
t/test_keyvalue.c \
t/test_request.c \
http_header.c \
http_kv.c \
log.c \
fdlog.c \
sock_addr.c \
ck.c
t_test_common_LDADD = $(LIBUNWIND_LIBS) $(PCRE_LIB)
t_test_configfile_SOURCES = t/test_configfile.c buffer.c array.c data_config.c http_header.c http_kv.c vector.c log.c fdlog.c sock_addr.c ck.c
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_SOURCES = $(common_src) t/test_mod.c \
t/test_mod_access.c \
t/test_mod_alias.c \
@ -655,9 +645,6 @@ t_test_mod_SOURCES = $(common_src) t/test_mod.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)
noinst_HEADERS = $(hdr)
EXTRA_DIST = \
t/README \

77
src/meson.build

@ -860,39 +860,17 @@ executable('lighttpd', configparser,
install_dir: sbinddir,
)
test('test_array', executable('test_array',
sources: ['t/test_array.c', 'array.c', 'buffer.c', 'ck.c'],
dependencies: common_flags + libunwind,
build_by_default: false,
))
test('test_buffer', executable('test_buffer',
sources: ['t/test_buffer.c', 'buffer.c', 'ck.c'],
dependencies: common_flags + libunwind,
build_by_default: false,
))
test('test_burl', executable('test_burl',
sources: ['t/test_burl.c', 'burl.c', 'buffer.c', 'base64.c', 'ck.c'],
dependencies: common_flags + libunwind,
build_by_default: false,
))
test('test_base64', executable('test_base64',
sources: ['t/test_base64.c', 'buffer.c', 'base64.c', 'ck.c'],
dependencies: common_flags + libunwind,
build_by_default: false,
))
test('test_configfile', executable('test_configfile',
test('test_common', executable('test_common',
sources: [
't/test_configfile.c',
'buffer.c',
'array.c',
'data_config.c',
't/test_common.c',
't/test_array.c',
't/test_base64.c',
't/test_buffer.c',
't/test_burl.c',
't/test_keyvalue.c',
't/test_request.c',
'http_header.c',
'http_kv.c',
'vector.c',
'log.c',
'fdlog.c',
'sock_addr.c',
@ -906,18 +884,25 @@ test('test_configfile', executable('test_configfile',
build_by_default: false,
))
test('test_keyvalue', executable('test_keyvalue',
test('test_configfile', executable('test_configfile',
sources: [
't/test_keyvalue.c',
'burl.c',
't/test_configfile.c',
'buffer.c',
'base64.c',
'array.c',
'data_config.c',
'http_header.c',
'http_kv.c',
'vector.c',
'log.c',
'fdlog.c',
'sock_addr.c',
'ck.c',
],
dependencies: common_flags + libpcre + libunwind,
dependencies: [ common_flags
, libpcre
, libunwind
, libws2_32
],
build_by_default: false,
))
@ -949,28 +934,6 @@ test('test_mod', executable('test_mod',
build_by_default: false,
))
test('test_request', executable('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',
],
dependencies: [ common_flags
, libpcre
, libunwind
, libws2_32
],
build_by_default: false,
))
modules = [
[ 'mod_access', [ 'mod_access.c' ] ],
[ 'mod_accesslog', [ 'mod_accesslog.c' ] ],

8
src/t/test_array.c

@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "array.h"
#include "array.c"
#include "buffer.h"
static void test_array_get_int_ptr (void) {
@ -63,10 +63,10 @@ static void test_array_set_key_value (void) {
array_free(a);
}
int main() {
void test_array (void);
void test_array (void)
{
test_array_get_int_ptr();
test_array_insert_value();
test_array_set_key_value();
return 0;
}

7
src/t/test_base64.c

@ -1,6 +1,6 @@
#include "first.h"
#include "base64.h"
#include "base64.c"
static const base64_charset encs[] = { BASE64_STANDARD, BASE64_URL };
static buffer *check;
@ -43,7 +43,9 @@ static void check_all_len_3 (const base64_charset enc) {
}
}
int main() {
void test_base64 (void);
void test_base64 (void)
{
check = buffer_init();
for (unsigned int enc = 0; enc < sizeof(encs)/sizeof(*encs); ++enc) {
@ -54,5 +56,4 @@ int main() {
}
buffer_free(check);
return 0;
}

8
src/t/test_buffer.c

@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "buffer.h"
#include "buffer.c"
static void run_buffer_path_simplify(buffer *psrc, buffer *pdest, const char *in, size_t in_len, const char *out, size_t out_len) {
buffer_copy_string_len(psrc, in, in_len);
@ -144,11 +144,11 @@ static void test_buffer_append_path_len(void) {
buffer_free(b);
}
int main() {
void test_buffer (void);
void test_buffer (void)
{
test_buffer_path_simplify();
test_buffer_to_lower_upper();
test_buffer_string_space();
test_buffer_append_path_len();
return 0;
}

7
src/t/test_burl.c

@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "burl.h"
#include "burl.c"
static void run_burl_normalize (buffer *psrc, buffer *ptmp, int flags, int line, const char *in, size_t in_len, const char *out, size_t out_len) {
int qs;
@ -146,7 +146,8 @@ static void test_burl_normalize (void) {
buffer_free(ptmp);
}
int main (void) {
void test_burl (void);
void test_burl (void)
{
test_burl_normalize();
return 0;
}

22
src/t/test_common.c

@ -0,0 +1,22 @@
#include "first.h"
#undef NDEBUG
#include <assert.h>
void test_array (void);
void test_base64 (void);
void test_buffer (void);
void test_burl (void);
void test_keyvalue (void);
void test_request (void);
int main() {
test_array();
test_base64();
test_buffer();
test_burl();
test_keyvalue();
test_request();
return 0;
}

5
src/t/test_keyvalue.c

@ -119,9 +119,10 @@ static void test_keyvalue_pcre_keyvalue_buffer_process (void) {
}
#endif
int main (void) {
void test_keyvalue (void);
void test_keyvalue (void)
{
#ifdef HAVE_PCRE_H
test_keyvalue_pcre_keyvalue_buffer_process();
#endif
return 0;
}

5
src/t/test_request.c

@ -601,7 +601,8 @@ static void test_request_http_request_parse(request_st * const r)
#include "burl.h"
#include "log.h"
int main (void)
void test_request (void);
void test_request (void)
{
request_st r;
@ -620,6 +621,4 @@ int main (void)
array_free_data(&r.rqst_headers);
fdlog_free(r.conf.errh);
return 0;
}

Loading…
Cancel
Save