diff --git a/.gitignore b/.gitignore index 337ff82e..0f8bfbbe 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,4 @@ m4/ltversion.m4 m4/lt~obsolete.m4 src/config.h.in build/ +getdns.pc diff --git a/.travis.yml b/.travis.yml index 5300388a..ab8ed989 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,21 @@ +sudo: false language: c compiler: - gcc - clang -before_script: - - sudo apt-get update - - sudo apt-get install libunbound-dev libldns-dev libidn11-dev check libevent-dev +addons: + apt: + packages: + - libunbound-dev + - libldns-dev + - libidn11-dev + - check + - libevent-dev + - libev-dev + - bc script: - libtoolize -fic - autoreconf -fi - - ./configure --with-libevent - - make - - sudo PATH=$PATH make install - - make test - - sudo make uninstall + - mkdir tests + - cd tests + - ../src/test/tpkg/run-all.sh diff --git a/src/test/Makefile.in b/src/test/Makefile.in index f05cee3a..c6d76aa2 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -73,11 +73,11 @@ CHECK_OBJS=check_getdns_common.lo check_getdns_context_set_timeout.lo \ ALL_OBJS=$(CHECK_OBJS) check_getdns_libevent.lo check_getdns_libev.lo \ check_getdns_selectloop.lo getdns_query.lo scratchpad.lo \ testmessages.lo tests_dict.lo tests_list.lo tests_namespaces.lo \ - tests_stub_async.lo tests_stub_sync.lo tests_json-pointers.lo + tests_stub_async.lo tests_stub_sync.lo NON_C99_OBJS=check_getdns_libuv.lo -PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync tests_json-pointers getdns_query $(CHECK_GETDNS) $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG) +PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync getdns_query $(CHECK_GETDNS) $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG) .SUFFIXES: .c .o .a .lo .h @@ -113,9 +113,6 @@ tests_stub_async: tests_stub_async.lo testmessages.lo tests_stub_sync: tests_stub_sync.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_sync.lo -tests_json-pointers: tests_json-pointers.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_json-pointers.lo - check_getdns_common: check_getdns_common.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns_common.lo @@ -281,8 +278,6 @@ scratchpad.template.lo scratchpad.template.o: scratchpad.template.c ../getdns/ge ../getdns/getdns_extra.h testmessages.lo testmessages.o: $(srcdir)/testmessages.c $(srcdir)/testmessages.h tests_dict.lo tests_dict.o: $(srcdir)/tests_dict.c $(srcdir)/testmessages.h ../getdns/getdns.h -tests_json-pointers.lo tests_json-pointers.o: $(srcdir)/tests_json-pointers.c ../getdns/getdns.h \ - ../getdns/getdns_extra.h tests_list.lo tests_list.o: $(srcdir)/tests_list.c $(srcdir)/testmessages.h ../getdns/getdns.h tests_namespaces.lo tests_namespaces.o: $(srcdir)/tests_namespaces.c $(srcdir)/testmessages.h ../getdns/getdns.h tests_stub_async.lo tests_stub_async.o: $(srcdir)/tests_stub_async.c ../config.h $(srcdir)/testmessages.h \ diff --git a/src/test/check_getdns_context_set_upstream_recursive_servers.h b/src/test/check_getdns_context_set_upstream_recursive_servers.h index f5ba3eac..e1bb359f 100644 --- a/src/test/check_getdns_context_set_upstream_recursive_servers.h +++ b/src/test/check_getdns_context_set_upstream_recursive_servers.h @@ -331,6 +331,10 @@ } END_TEST +/* This test disabled because travis does not support IPv6 in their + * container based infrastructure! + */ +#if 0 START_TEST (getdns_context_set_upstream_recursive_servers_10) { /* @@ -345,7 +349,7 @@ struct getdns_dict *dict = NULL; struct getdns_dict *response = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv6" }; - struct getdns_bindata address_data = { 16, (void *)"\x20\x01\x48\x60\x48\x60\x00\x00\x00\x00\x00\x00\x00\x00\x88\x44" }; + struct getdns_bindata address_data = { 16, (void *)"\x26\x20\x00\x74\x00\x1b\x00\x00\x00\x00\x00\x00\x00\x01\x00\x01" }; size_t index = 0; CONTEXT_CREATE(TRUE); @@ -379,7 +383,7 @@ DICT_DESTROY(response); } END_TEST - +#endif START_TEST (getdns_context_set_upstream_recursive_servers_11) { /* @@ -460,7 +464,7 @@ /* Positive test cases */ TCase *tc_pos = tcase_create("Positive"); tcase_add_test(tc_pos, getdns_context_set_upstream_recursive_servers_9); - tcase_add_test(tc_pos, getdns_context_set_upstream_recursive_servers_10); +/***** tcase_add_test(tc_pos, getdns_context_set_upstream_recursive_servers_10); *****/ tcase_add_test(tc_pos, getdns_context_set_upstream_recursive_servers_11); suite_add_tcase(s, tc_pos); diff --git a/src/test/tpkg/100-compile.tpkg/100-compile.dsc b/src/test/tpkg/100-compile.tpkg/100-compile.dsc new file mode 100644 index 00000000..7bd90bd4 --- /dev/null +++ b/src/test/tpkg/100-compile.tpkg/100-compile.dsc @@ -0,0 +1,16 @@ +BaseName: 100-compile +Version: 1.0 +Description: Create a builddir and compile +CreationDate: do dec 10 11:09:43 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: +Help: 100-compile.help +Pre: 100-compile.pre +Post: +Test: 100-compile.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/100-compile.tpkg/100-compile.help b/src/test/tpkg/100-compile.tpkg/100-compile.help new file mode 100644 index 00000000..535bbaca --- /dev/null +++ b/src/test/tpkg/100-compile.tpkg/100-compile.help @@ -0,0 +1 @@ +The library is compiled without eventloop extensions. diff --git a/src/test/tpkg/100-compile.tpkg/100-compile.pre b/src/test/tpkg/100-compile.tpkg/100-compile.pre new file mode 100644 index 00000000..1c71f4c7 --- /dev/null +++ b/src/test/tpkg/100-compile.tpkg/100-compile.pre @@ -0,0 +1,19 @@ +# #-- 100-compile.pre--# +# source the master var file when it's there +if [ -f ../.tpkg.var.master ] +then + source ../.tpkg.var.master +else + ( + cd .. + [ -f "${TPKG_SRCDIR}/setup-env.sh" ] \ + && sh "${TPKG_SRCDIR}/setup-env.sh" + ) && source ../.tpkg.var.master +fi +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +rm -fr "${BUILDDIR}/build" +mkdir "${BUILDDIR}/build" +cd "${BUILDDIR}/build" +"${SRCROOT}/configure" diff --git a/src/test/tpkg/100-compile.tpkg/100-compile.test b/src/test/tpkg/100-compile.tpkg/100-compile.test new file mode 100644 index 00000000..e527192b --- /dev/null +++ b/src/test/tpkg/100-compile.tpkg/100-compile.test @@ -0,0 +1,8 @@ +# #-- 100-compile.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +cd "${BUILDDIR}/build" +make diff --git a/src/test/tpkg/110-link.tpkg/110-link.dsc b/src/test/tpkg/110-link.tpkg/110-link.dsc new file mode 100644 index 00000000..b10cf7b2 --- /dev/null +++ b/src/test/tpkg/110-link.tpkg/110-link.dsc @@ -0,0 +1,16 @@ +BaseName: 110-link +Version: 1.0 +Description: Link getdns_query program +CreationDate: do dec 10 11:10:11 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: 100-compile.tpkg +Help: 110-link.help +Pre: +Post: +Test: 110-link.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/110-link.tpkg/110-link.help b/src/test/tpkg/110-link.tpkg/110-link.help new file mode 100644 index 00000000..36ba881b --- /dev/null +++ b/src/test/tpkg/110-link.tpkg/110-link.help @@ -0,0 +1 @@ +Try to link the getdns_query program diff --git a/src/test/tpkg/110-link.tpkg/110-link.test b/src/test/tpkg/110-link.tpkg/110-link.test new file mode 100644 index 00000000..c0d77db0 --- /dev/null +++ b/src/test/tpkg/110-link.tpkg/110-link.test @@ -0,0 +1,10 @@ +# #-- 110-link.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +cd "${BUILDDIR}/build" +make getdns_query \ + && echo "export GETDNS_QUERY=\"${BUILDDIR}/build/src/test/getdns_query\"" \ + >> ../.tpkg.var.master diff --git a/src/test/tpkg/120-run-getdns_query.tpkg/120-run-getdns_query.dsc b/src/test/tpkg/120-run-getdns_query.tpkg/120-run-getdns_query.dsc new file mode 100644 index 00000000..a76ecfd2 --- /dev/null +++ b/src/test/tpkg/120-run-getdns_query.tpkg/120-run-getdns_query.dsc @@ -0,0 +1,16 @@ +BaseName: 120-run-getdns_query +Version: 1.0 +Description: Run the getdns_query program +CreationDate: do dec 10 11:09:59 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: 110-link.tpkg +Help: 120-run-getdns_query.help +Pre: +Post: +Test: 120-run-getdns_query.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/120-run-getdns_query.tpkg/120-run-getdns_query.help b/src/test/tpkg/120-run-getdns_query.tpkg/120-run-getdns_query.help new file mode 100644 index 00000000..b86b07f0 --- /dev/null +++ b/src/test/tpkg/120-run-getdns_query.tpkg/120-run-getdns_query.help @@ -0,0 +1 @@ +Run the getdns_query test program diff --git a/src/test/tpkg/120-run-getdns_query.tpkg/120-run-getdns_query.test b/src/test/tpkg/120-run-getdns_query.tpkg/120-run-getdns_query.test new file mode 100644 index 00000000..5d779a5a --- /dev/null +++ b/src/test/tpkg/120-run-getdns_query.tpkg/120-run-getdns_query.test @@ -0,0 +1,7 @@ +# #-- 120-run-getdns_query.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +"${GETDNS_QUERY}" -i diff --git a/src/test/tpkg/130-run-unit-tests.tpkg/130-run-unit-tests.dsc b/src/test/tpkg/130-run-unit-tests.tpkg/130-run-unit-tests.dsc new file mode 100644 index 00000000..5e97843a --- /dev/null +++ b/src/test/tpkg/130-run-unit-tests.tpkg/130-run-unit-tests.dsc @@ -0,0 +1,16 @@ +BaseName: 130-run-unit-tests +Version: 1.0 +Description: Run the getdns_query program +CreationDate: do dec 10 11:10:29 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: 110-link.tpkg +Help: 130-run-unit-tests.help +Pre: +Post: +Test: 130-run-unit-tests.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/130-run-unit-tests.tpkg/130-run-unit-tests.help b/src/test/tpkg/130-run-unit-tests.tpkg/130-run-unit-tests.help new file mode 100644 index 00000000..b86b07f0 --- /dev/null +++ b/src/test/tpkg/130-run-unit-tests.tpkg/130-run-unit-tests.help @@ -0,0 +1 @@ +Run the getdns_query test program diff --git a/src/test/tpkg/130-run-unit-tests.tpkg/130-run-unit-tests.test b/src/test/tpkg/130-run-unit-tests.tpkg/130-run-unit-tests.test new file mode 100644 index 00000000..541936dd --- /dev/null +++ b/src/test/tpkg/130-run-unit-tests.tpkg/130-run-unit-tests.test @@ -0,0 +1,8 @@ +# #-- 130-run-unit-tests.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +cd "${BUILDDIR}/build" +make test diff --git a/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.dsc b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.dsc new file mode 100644 index 00000000..e690db4b --- /dev/null +++ b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.dsc @@ -0,0 +1,16 @@ +BaseName: 200-stub-only-compile +Version: 1.0 +Description: Create a builddir and compile simple +CreationDate: do dec 10 11:08:24 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: +Help: 200-stub-only-compile.help +Pre: 200-stub-only-compile.pre +Post: +Test: 200-stub-only-compile.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.help b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.help new file mode 100644 index 00000000..35b616f0 --- /dev/null +++ b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.help @@ -0,0 +1 @@ +The library is compiled as stub only and without eventloop extensions. diff --git a/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.pre b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.pre new file mode 100644 index 00000000..e95a7446 --- /dev/null +++ b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.pre @@ -0,0 +1,19 @@ +# #-- 200-stub-only-compile.pre--# +# source the master var file when it's there +if [ -f ../.tpkg.var.master ] +then + source ../.tpkg.var.master +else + ( + cd .. + [ -f "${TPKG_SRCDIR}/setup-env.sh" ] \ + && sh "${TPKG_SRCDIR}/setup-env.sh" + ) && source ../.tpkg.var.master +fi +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +rm -fr "${BUILDDIR}/build-stub-only" +mkdir "${BUILDDIR}/build-stub-only" +cd "${BUILDDIR}/build-stub-only" +"${SRCROOT}/configure" --enable-stub-only diff --git a/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test new file mode 100644 index 00000000..369379c4 --- /dev/null +++ b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test @@ -0,0 +1,8 @@ +# #-- 200-stub-only-compile.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +cd "${BUILDDIR}/build-stub-only" +make diff --git a/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.dsc b/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.dsc new file mode 100644 index 00000000..6a6cb61e --- /dev/null +++ b/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.dsc @@ -0,0 +1,16 @@ +BaseName: 210-stub-only-link +Version: 1.0 +Description: Link getdns_query program +CreationDate: do dec 10 11:08:37 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: 200-stub-only-compile.tpkg +Help: 210-stub-only-link.help +Pre: +Post: +Test: 210-stub-only-link.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.help b/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.help new file mode 100644 index 00000000..36ba881b --- /dev/null +++ b/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.help @@ -0,0 +1 @@ +Try to link the getdns_query program diff --git a/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.test b/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.test new file mode 100644 index 00000000..33379762 --- /dev/null +++ b/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.test @@ -0,0 +1,10 @@ +# #-- 210-stub-only-link.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +cd "${BUILDDIR}/build-stub-only" +make getdns_query \ + && echo "export GETDNS_STUB_QUERY=\"${BUILDDIR}/build-stub-only/src/test/getdns_query\"" \ + >> ../.tpkg.var.master diff --git a/src/test/tpkg/220-stub-only-run-getdns_query.tpkg/220-stub-only-run-getdns_query.dsc b/src/test/tpkg/220-stub-only-run-getdns_query.tpkg/220-stub-only-run-getdns_query.dsc new file mode 100644 index 00000000..159de209 --- /dev/null +++ b/src/test/tpkg/220-stub-only-run-getdns_query.tpkg/220-stub-only-run-getdns_query.dsc @@ -0,0 +1,16 @@ +BaseName: 220-stub-only-run-getdns_query +Version: 1.0 +Description: Run the getdns_query program +CreationDate: do dec 10 11:08:51 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: 210-stub-only-link.tpkg +Help: 220-stub-only-run-getdns_query.help +Pre: +Post: +Test: 220-stub-only-run-getdns_query.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/220-stub-only-run-getdns_query.tpkg/220-stub-only-run-getdns_query.help b/src/test/tpkg/220-stub-only-run-getdns_query.tpkg/220-stub-only-run-getdns_query.help new file mode 100644 index 00000000..b86b07f0 --- /dev/null +++ b/src/test/tpkg/220-stub-only-run-getdns_query.tpkg/220-stub-only-run-getdns_query.help @@ -0,0 +1 @@ +Run the getdns_query test program diff --git a/src/test/tpkg/220-stub-only-run-getdns_query.tpkg/220-stub-only-run-getdns_query.test b/src/test/tpkg/220-stub-only-run-getdns_query.tpkg/220-stub-only-run-getdns_query.test new file mode 100644 index 00000000..8f28d43d --- /dev/null +++ b/src/test/tpkg/220-stub-only-run-getdns_query.tpkg/220-stub-only-run-getdns_query.test @@ -0,0 +1,7 @@ +# #-- 220-stub-only-run-getdns_query.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +"${GETDNS_STUB_QUERY}" -i diff --git a/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.dsc b/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.dsc new file mode 100644 index 00000000..2fa8ed12 --- /dev/null +++ b/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.dsc @@ -0,0 +1,16 @@ +BaseName: 230-stub-only-run-unit-tests +Version: 1.0 +Description: Run the getdns_query program +CreationDate: do dec 10 11:09:02 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: 210-stub-only-link.tpkg +Help: 230-stub-only-run-unit-tests.help +Pre: +Post: +Test: 230-stub-only-run-unit-tests.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.help b/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.help new file mode 100644 index 00000000..b86b07f0 --- /dev/null +++ b/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.help @@ -0,0 +1 @@ +Run the getdns_query test program diff --git a/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.test b/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.test new file mode 100644 index 00000000..1dee289d --- /dev/null +++ b/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.test @@ -0,0 +1,8 @@ +# #-- 230-stub-only-run-unit-tests.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +cd "${BUILDDIR}/build-stub-only" +make test diff --git a/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.Makefile b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.Makefile new file mode 100644 index 00000000..fe7d1f28 --- /dev/null +++ b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.Makefile @@ -0,0 +1,15 @@ +builddir = @BUILDDIR@ +testname = @TPKG_NAME@ +LIBTOOL = $(builddir)/libtool + +CFLAGS=-I$(builddir)/src/getdns +LDLIBS=$(builddir)/src/libgetdns.la + +.SUFFIXES: .c .o .a .lo .h + +.c.lo: + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@ + +$(testname): $(testname).lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDLIBS) $(LDFLAGS) -o $@ $< + diff --git a/src/test/tests_json-pointers.c b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.c similarity index 100% rename from src/test/tests_json-pointers.c rename to src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.c diff --git a/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.dsc b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.dsc new file mode 100644 index 00000000..0b3ab66a --- /dev/null +++ b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.dsc @@ -0,0 +1,16 @@ +BaseName: 250-json-pointers +Version: 1.0 +Description: Test json pointers +CreationDate: vr dec 11 11:09:57 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: 200-stub-only-compile.tpkg +Help: 250-json-pointers.help +Pre: 250-json-pointers.pre +Post: +Test: 250-json-pointers.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tests_json-pointers.good b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.good similarity index 100% rename from src/test/tests_json-pointers.good rename to src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.good diff --git a/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.help b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.help new file mode 100644 index 00000000..d9deefa2 --- /dev/null +++ b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.help @@ -0,0 +1,2 @@ +Compile a program that setups a dict with json pointers and pretty prints the dict. +Then compare the output to the known to be good output. diff --git a/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.pre b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.pre new file mode 100644 index 00000000..55d1c0d0 --- /dev/null +++ b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.pre @@ -0,0 +1,14 @@ +# #-- 250-json-pointers.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +( + grep '^CC=' "${BUILDDIR}/build-stub-only/src/Makefile" + grep '^LDFLAGS=' "${BUILDDIR}/build-stub-only/src/Makefile" + + BUILDDIR4SED=`echo "${BUILDDIR}/build-stub-only" | sed 's/\//\\\\\//g'` + sed -e "s/@BUILDDIR@/${BUILDDIR4SED}/g" \ + -e "s/@TPKG_NAME@/${TPKG_NAME}/g" "${TPKG_NAME}.Makefile" +) > Makefile diff --git a/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.test b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.test new file mode 100644 index 00000000..dca4965d --- /dev/null +++ b/src/test/tpkg/250-json-pointers.tpkg/250-json-pointers.test @@ -0,0 +1,7 @@ +# #-- 250-json-pointers.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +make && "./${TPKG_NAME}" | tee out && diff out "${TPKG_NAME}.good" diff --git a/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.dsc b/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.dsc new file mode 100644 index 00000000..a94ef7a8 --- /dev/null +++ b/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.dsc @@ -0,0 +1,16 @@ +BaseName: 300-event-loops-compile +Version: 1.0 +Description: Create a builddir and compile with event loops +CreationDate: do dec 10 11:38:35 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: +Help: 300-event-loops-compile.help +Pre: 300-event-loops-compile.pre +Post: +Test: 300-event-loops-compile.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.help b/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.help new file mode 100644 index 00000000..ad31b011 --- /dev/null +++ b/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.help @@ -0,0 +1 @@ +The library is compiled with eventloop extensions for all event loops available. diff --git a/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.pre b/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.pre new file mode 100644 index 00000000..87dfe2c6 --- /dev/null +++ b/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.pre @@ -0,0 +1,25 @@ +# #-- 300-event-loops-compile.pre--# +# source the master var file when it's there +if [ -f ../.tpkg.var.master ] +then + source ../.tpkg.var.master +else + ( + cd .. + [ -f "${TPKG_SRCDIR}/setup-env.sh" ] \ + && sh "${TPKG_SRCDIR}/setup-env.sh" + ) && source ../.tpkg.var.master +fi +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +rm -fr "${BUILDDIR}/build-event-loops" +mkdir "${BUILDDIR}/build-event-loops" +cd "${BUILDDIR}/build-event-loops" +"${SRCROOT}/configure" --with-libevent --with-libev --with-libuv \ + || "${SRCROOT}/configure" --with-libevent --with-libev \ + || "${SRCROOT}/configure" --with-libevent --with-libuv \ + || "${SRCROOT}/configure" --with-libev --with-libuv \ + || "${SRCROOT}/configure" --with-libevent \ + || "${SRCROOT}/configure" --with-libev \ + || "${SRCROOT}/configure" --with-libuv diff --git a/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.test b/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.test new file mode 100644 index 00000000..94c8ac4d --- /dev/null +++ b/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.test @@ -0,0 +1,8 @@ +# #-- 300-event-loops-compile.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +cd "${BUILDDIR}/build-event-loops" +make diff --git a/src/test/tpkg/330-event-loops-unit-tests.tpkg/330-event-loops-unit-tests.dsc b/src/test/tpkg/330-event-loops-unit-tests.tpkg/330-event-loops-unit-tests.dsc new file mode 100644 index 00000000..0ae2a358 --- /dev/null +++ b/src/test/tpkg/330-event-loops-unit-tests.tpkg/330-event-loops-unit-tests.dsc @@ -0,0 +1,16 @@ +BaseName: 330-event-loops-unit-tests +Version: 1.0 +Description: Run the unit tests +CreationDate: do dec 10 11:40:16 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: 300-event-loops-compile.tpkg +Help: 330-event-loops-unit-tests.help +Pre: +Post: +Test: 330-event-loops-unit-tests.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/330-event-loops-unit-tests.tpkg/330-event-loops-unit-tests.help b/src/test/tpkg/330-event-loops-unit-tests.tpkg/330-event-loops-unit-tests.help new file mode 100644 index 00000000..b86b07f0 --- /dev/null +++ b/src/test/tpkg/330-event-loops-unit-tests.tpkg/330-event-loops-unit-tests.help @@ -0,0 +1 @@ +Run the getdns_query test program diff --git a/src/test/tpkg/330-event-loops-unit-tests.tpkg/330-event-loops-unit-tests.test b/src/test/tpkg/330-event-loops-unit-tests.tpkg/330-event-loops-unit-tests.test new file mode 100644 index 00000000..e80948e0 --- /dev/null +++ b/src/test/tpkg/330-event-loops-unit-tests.tpkg/330-event-loops-unit-tests.test @@ -0,0 +1,8 @@ +# #-- 330-event-loops-unit-tests.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +cd "${BUILDDIR}/build-event-loops" +make test diff --git a/src/test/tpkg/run-all.sh b/src/test/tpkg/run-all.sh new file mode 100755 index 00000000..863500e1 --- /dev/null +++ b/src/test/tpkg/run-all.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +export SRCDIR=`dirname $0` +. `dirname $0`/setup-env.sh + +for TEST_PKG in ${SRCDIR}/*.tpkg +do + "${TPKG}" $* exe "${TEST_PKG}" +done +"${TPKG}" r diff --git a/src/test/tpkg/setup-env.sh b/src/test/tpkg/setup-env.sh new file mode 100755 index 00000000..8a23fc71 --- /dev/null +++ b/src/test/tpkg/setup-env.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +export SRCDIR=`dirname $0` +export SRCROOT=`(cd "${SRCDIR}/../../.."; pwd)` +export TPKG="${SRCDIR}/tpkg" +export BUILDDIR=`pwd` +export BUILDROOT=`(cd "${BUILDDIR}/../../.."; pwd)` +export LIBTOOL="${BUILDROOT}/libtool" + +if [ ! -f "${SRCROOT}/libtool" ] +then + (cd "${SRCROOT}"; libtoolize -fic) +fi +if [ ! -f "${SRCROOT}/configure" ] +then + (cd "${SRCROOT}"; autoreconf -fi) +fi +if [ -f .tpkg.var.master ] +then + cat .tpkg.var.master \ + | egrep -v '^export SRCDIR=|^export SRCROOT=|^export TPKG=' \ + | egrep -v 'export BUILDDIR|^export BUILDROOT=|^export LIBTOOL=' \ + >.tpkg.var.master.cleanup + mv .tpkg.var.master.cleanup .tpkg.var.master +fi +cat >>.tpkg.var.master << END_OF_TPKG_VAR_MASTER +export SRCDIR="${SRCDIR}" +export SRCROOT="${SRCROOT}" +export BUILDDIR="${BUILDDIR}" +export BUILDROOT="${BUILDROOT}" +export TPKG="${TPKG}" +export LIBTOOL="${LIBTOOL}" +END_OF_TPKG_VAR_MASTER + diff --git a/src/test/tpkg/tpkg b/src/test/tpkg/tpkg new file mode 100755 index 00000000..1117a012 --- /dev/null +++ b/src/test/tpkg/tpkg @@ -0,0 +1,922 @@ +#!/usr/bin/env bash + +# a utlity to run a shar test archive (aka tpkg) +# Created by Miek Gieben, NLnetLabs, (c) 2005, 2006 +# Licensed under GPL version 2 + +export TPKG_VAR_MASTER="../.tpkg.var.master" +export TPKG_VAR_TEST=".tpkg.var.test" +export TPKG_VERSION="1.12"; +export SHELL="/bin/sh" +TPKG_LOGGER=/usr/bin/logger +TPKG_BASE="." +TPKG_ARGS="" +TPKG_CURRENT=`pwd` +TPKG_QUIET=0 # only output err() msgs +TPKG_KEEP=0 # tpkg create doesn't remove dir/ +TPKG_PASS=0 # how much must succeed +TPKG_LOG=0 # don't log +TPKG_PRI="" # log facility +TPKG_FORMAT="targz" # format of underlying tpkg files +TPKG_FORCE=0 # execute tests even when .done file is found + +_DESC_WIDTH=${COLUMNS:-55} +if [ $_DESC_WIDTH -ge 70 ]; then + _DESC_WIDTH=70 +fi + +### Helper functions +function cleanup() { + out "[log] Cleaning up" + [[ -f result.$dsc_basename ]] && cp result.$dsc_basename ../ + cd .. + if [[ ! -z "$dir" ]]; then + rm -rf `basename $dir` + fi + cd $TPKG_CURRENT +} + +function cleanup_and_exit() { + cleanup; exit 1 +} + +function err() { + if [[ -z $testname ]]; then + echo -e " $1" + else + echo -e "[$testname] $1" + fi +} + +function tpkg_log() { + if [[ $TPKG_LOG -eq 0 ]]; then + return + fi + + if [[ -e $TPKG_LOGGER ]]; then + if [[ -z $TPKG_PRI ]]; then + $TPKG_LOGGER "$1" + else + $TPKG_LOGGER -p "$TPKG_PRI" "$1" + fi + fi +} + +function out() { + if [[ $TPKG_QUIET -eq 1 ]]; then + return + fi + if [[ -z $testname ]]; then + echo -e " $1" + else + echo -e "[$testname] $1" + fi +} + +function epoch() { + # make this sorta portable allthough not needed now + epoch=0 + case $OSTYPE in + linux*) + epoch=`date +%s` + ;; + freebsd*) + epoch=`date +%s` + ;; + esac +} + +function post() { + if [ -f "${dsc_post}" ]; then + err "[log] Executing post script: ${dsc_post} ${TPKG_ARGS}" + echo "--------- Start Post Output ------------------ " >> result.$dsc_basename + ${SHELL} ${dsc_post} ${TPKG_ARGS} >> result.$dsc_basename + echo "----------- End Post Output ------------------ " >> result.$dsc_basename + result=$? + if [ $result -ne 0 ]; then + err "[warning] Post-script executed with errors: $result." + fi + fi +} + +function pre() { + if [ -f "${dsc_pre}" ]; then + err "[log] Executing pre script: ${dsc_pre} ${TPKG_ARGS}" + echo "--------- Start Pre Output ------------------- " >> result.$dsc_basename + ${SHELL} ${dsc_pre} ${TPKG_ARGS} >> result.$dsc_basename + echo "----------- End Pre Output ------------------- " >> result.$dsc_basename + result=$? + if [ $result -ne 0 ]; then + err "[warning] Pre-script executed with errors: $result." + fi + fi +} + +function write_done() { + # we are executing in a subdir + if [ -f "../.done-${testname}" -a $TPKG_FORCE -ne 1 ]; then + err "[warning] Overwriting .done-${testname}" + fi + > ../.done-${testname} +} + +# write done file in current dir +function write_fake_done() { + if [ -f ".done-${testname}" -a $TPKG_FORCE -ne 1 ]; then + err "[warning] Overwriting .done-${testname}" + fi + > .done-${testname} +} + +function mktempdir() { + # check if mktemp is there, if not use plain mkdir with $$ + # as a side effect set $dir + dir= + case $OSTYPE in + solaris*) + # use mkdir + dir="$1.$$" + mkdir "$dir" + return + ;; + *) + dir=`mktemp -d "$1"` + return + ;; + esac +} + +function usage() { + out "Usage:" + out "$0 [OPTIONS] [exe|create|extract|tmpl|fake] test.tpkg" + out "or:" + out "$0 [OPTIONS] [report|clean|list|desc|help] test.tpkg" + out "or:" + out "$0 [OPTIONS] clone test1.tpkg test2.tpkg" + out + out "Testing" + out " exe.........:\texecute a test, safe the result result.testname" + out " c | create..:\tcreate a .tpkg out of the test.{pre, post, test} files" + out " e | extract.:\textract a .tpkg to tmp. dir" + out " t | tmpl....:\tcreate empty template files for a new test" + out " f | fake....:\tfake the running of test, but do create a .done file" + out + out "When no action is given a test is executed" + out + out "Reporting/Cleanup" + out " clean........:\tremove all the result files" + out " cd | cleandir:\tremove all .dir directories" + out " r | report..:\tcreate a nice report from all the result files" + out " cl | clone...:\tclone test1.tpkg to test2.tkpg" + out " l | list....:\tprint the files of the test to stdout" + out " d | desc....:\tprint the test's description to stdout" + out " h | help....:\tprint the help message for this test, if available" + out + out " When multiple tests depend on a single other test, this" + out " other test is only executed once." + out + out "OPTIONS" + out " -h\t\tshow this help" + out " -v\t\tshow version" + out " -q\t\tonly print errors" + out " -l\t\tlog test name to syslog when starting the test (using logger)" + out " -p PRI\tlog using PRI as priority" + out " -k\t\tdon't remove test directory when creating/executing a tpkg package" + out " -n NUM\tif less than NUM of the tests are passed exit with 1" + out " \t\tOtherwise exit with 0. Only valid when running tpkg report" + out " -b DIR\tuse DIR is a base directory in stead of ." + out " -a ARGS\tpass the string ARGS through to the test scripts" + out " -d\t\tUse directories instead of tar.gz for tpkg archive format" + out + out " (C) NLnetLabs, Miek Gieben. Licensed under the GPL version 2." +} + +function version() { + out "tpkg (test package), version $TPKG_VERSION" + out "Written by Miek Gieben, NLnet Labs" + out + out "Copyright (C) 2005, 2006 NLnet Labs" + out + out "This is free software; see the source for copying conditions. There is no" + out "warranty; even not for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE" +} + +function cleanreport() { + # cleanup all the result. files + for result in `ls result.* 2>/dev/null`; do + err "[log] rm $result" + rm $result + done + # rm any .var files + out "[log] rm `basename $TPKG_VAR_MASTER`" + rm -f `basename $TPKG_VAR_MASTER` + rm -f $TPKG_VAR_TEST + out "[log] rm .done files" + rm -f .done* + cd $TPKG_CURRENT +} + +function cleandirs() { + for result in `ls -d *.dir 2> /dev/null`; do + err "[log] rm -rf $result" + rm -rf $result + done +} + +function report() { + # generate a report from the result. files. + passed=0 + failed=0 + unknown=0 + first=0 + + tp="passed" + tf="failed" + tu="unknown" + for result in `ls result.* 2>/dev/null` ; do + passfailed=`head -1 $result | awk ' { print $2 }'` + basename=`head -3 $result | grep BaseName | awk -F': ?' ' { print $2 }'` + description=`head -4 $result | grep Description | awk -F': ?' ' { print $2 }'` + runend=`head -2 $result | grep DateRunEnd | awk -F': ?' ' { print $2 }'` + runstart=`head -5 $result | grep DateRunStart | awk -F': ?' ' { print $2 }'` + + # truncate the description to 35 chars + if [ ${#description} -gt $_DESC_WIDTH ]; then + description=${description:0:$_DESC_WIDTH} + description=$description"..." + fi + + if [ -z $runend ]; then + runend=0 + fi + if [ -z $runstart ]; then + runstart=0 + fi + + ((period=$runend - $runstart)) + # prefix period if < 9 + if [ $period -lt 10 ]; then + period="0$period" + fi + + case $passfailed in + "FAILED") + if [ $first -eq 0 ]; then + echo " STATUS : ELAPSED : TESTNAME : TESTDESCRIPTION" + first=1 + fi + echo -e "!! $passfailed !! : $period s : $basename : $description" + ((failed=$failed + 1)) + failed_tests="$failed_tests $basename" + tf="FAILED" + ;; + "PASSED") + if [ $TPKG_QUIET -eq 0 ]; then + if [ $first -eq 0 ]; then + echo " STATUS : ELAPSED : TESTNAME : TESTDESCRIPTION" + first=1 + fi + echo -e "** $passfailed ** : $period s : $basename : $description" + fi + ((passed=$passed + 1)) + tp="PASSED" + ;; + *) + if [ $first -eq 0 ]; then + echo " STATUS : ELAPSED : TESTNAME : TESTDESCRIPTION" + first=1 + fi + echo -e "-- $passfailed -- : $period s : $basename : $description" + ((unknown=$unknown + 1)) + failed_tests="$failed_tests $basename" + tu="UNKNOWN" + ;; + esac + done + ((total=$passed + $failed + $unknown)) + if [[ $total -eq 0 ]]; then + fper=0 + pper=0 + uper=0 + else + fper=`echo -e "scale=4\n$failed/$total*100" | bc | sed 's/00$//'` + pper=`echo -e "scale=4\n$passed/$total*100" | bc | sed 's/00$//'` + uper=`echo -e "scale=4\n$unknown/$total*100" | bc | sed 's/00$//'` + fi + echo + echo -e "$tp: $passed ($pper %)\t$tf: $failed ($fper %)\t$tu: $unknown ($uper %)" + + # for each failed test include the complete result file + # $i is basename + echo + for i in $failed_tests; do + echo --------------- Start Output: $i ------------------ + cat result.$i + echo --------------- End Output: $i ------------------ + done + cd $NT + if [[ $TPKG_PASS -gt 0 ]]; then + if [[ $passed -lt $TPKG_PASS ]]; then + exit 1 + fi + elif [[ $failed -gt 0 ]]; then + exit 1 + else + exit 0 + fi +} + +# clone test1 to test2 +function clone() { + $0 extract $test1.tpkg + if [ $? -ne 0 ]; then + err "[fatal] Extract of $test1.tpkg failed. Abort." + exit 1 + fi + + if [ ! -d "$test1.dir" ]; then + err "[fatal] No $test1.dir directory? Abort." + exit 1 + fi + cd $test1.dir + for i in $test1.* ; do + ext=`echo $i | sed s/$test1//` + if [ ! -z "$ext" ]; then + # rename the content of the files too + sed "s/$test1/$test2/g" < $i > $i.$$ + mv $i.$$ $i + # rename + mv $i $test2$ext + fi + done + # edit the dsc file too + # update the date + sed "s/^CreationDate:.*/CreationDate: `date`/" < $test2.dsc > $test2.dsc.$$ + mv $test2.dsc.$$ $test2.dsc + + cd .. + # rename the dir + mv $test1.dir $test2.dir + if [ $TPKG_KEEP -eq 0 ]; then + if [ $TPKG_FORMAT = "dir" ]; then + $0 -d create $test2.tpkg + else + $0 create $test2.tpkg + fi + else + if [ $TPKG_FORMAT = "dir" ]; then + $0 -d -k create $test2.tpkg + else + $0 -k create $test2.tpkg + fi + fi + if [ $? -ne 0 ]; then + err "[warning] Creating of $test2.tpkg failed." + fi + cd $TPKG_CURRENT +} + +# try to find the specific cmd +function find_cmd { + which "${i}" >/dev/null + if [ $? -ne 0 ]; then + err "[fatal] CmdDepend \"$i\" could not be satisfied: not found. Abort." + cleanup; exit 1 + fi +} + +# extract a tpkg to the given dir. The dir must exist already. +function extract_tpkg_to { #