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/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..e0840f65 --- /dev/null +++ b/src/test/tpkg/100-compile.tpkg/100-compile.pre @@ -0,0 +1,10 @@ +# #-- 100-compile.pre--# +# 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 + +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..77d59847 --- /dev/null +++ b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.pre @@ -0,0 +1,10 @@ +# #-- 200-stub-only-compile.pre--# +# 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 + +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/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..85bbe341 --- /dev/null +++ b/src/test/tpkg/300-event-loops-compile.tpkg/300-event-loops-compile.pre @@ -0,0 +1,16 @@ +# #-- 300-event-loops-compile.pre--# +# 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 + +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..931aa5f3 --- /dev/null +++ b/src/test/tpkg/setup-env.sh @@ -0,0 +1,26 @@ +#!/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 .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..ab825b53 --- /dev/null +++ b/src/test/tpkg/tpkg @@ -0,0 +1,921 @@ +#!/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 { #