Skip to content

Commit

Permalink
Remove embedded atf-src and enforce atf >= 0.20 + kyua as execution e…
Browse files Browse the repository at this point in the history
…ngine
  • Loading branch information
oerdnj committed Nov 15, 2018
1 parent e31e573 commit de219b8
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 88 deletions.
29 changes: 0 additions & 29 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,6 @@ gen.dSYM/
.deps/
.dirstamp
.libs/
unit/atf-src/atf-c++/atf-c++.pc
unit/atf-src/atf-c/atf-c.pc
unit/atf-src/atf-c/defs.h
unit/atf-src/atf-c/detail/process_helpers
unit/atf-src/atf-config/atf-config
unit/atf-src/atf-report/atf-report
unit/atf-src/atf-report/fail_helper
unit/atf-src/atf-report/misc_helpers
unit/atf-src/atf-report/pass_helper
unit/atf-src/atf-run/atf-run
unit/atf-src/atf-run/bad_metadata_helper
unit/atf-src/atf-run/expect_helpers
unit/atf-src/atf-run/misc_helpers
unit/atf-src/atf-run/pass_helper
unit/atf-src/atf-run/several_tcs_helper
unit/atf-src/atf-run/zero_tcs_helper
unit/atf-src/atf-sh/atf-check
unit/atf-src/atf-sh/atf-sh
unit/atf-src/atf-sh/misc_helpers
unit/atf-src/atf-version/atf-version
unit/atf-src/atf-version/revision.h
unit/atf-src/atf-version/revision.h.stamp
unit/atf-src/bconfig.h
unit/atf-src/bootstrap/atconfig
unit/atf-src/doc/atf.7
unit/atf-src/stamp-h1
unit/atf-src/test-programs/c_helpers
unit/atf-src/test-programs/cpp_helpers
unit/atf-src/test-programs/sh_helpers
# ccc-analyzer store its results in .plist directories
*.plist/
*~
Expand Down
3 changes: 0 additions & 3 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
/* Use AES for Client Cookie generation */
#undef AES_CC

/* define if ATF unit tests are to be built. */
#undef ATF_TEST

/* Define if you cannot bind() before connect() for TCP sockets. */
#undef BROKEN_TCP_BIND_BEFORE_CONNECT

Expand Down
81 changes: 66 additions & 15 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ BIND9_ISCCC_BUILDINCLUDE
BIND9_ISC_BUILDINCLUDE
BIND9_TOP_BUILDDIR
LD_WRAP_TESTS
KYUA
UNITTESTS
CMOCKA_LIBS
CMOCKA_CFLAGS
Expand Down Expand Up @@ -841,7 +842,6 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
Expand Down Expand Up @@ -961,7 +961,8 @@ OPENSSL_LIBS
LIBIDN2_CFLAGS
LIBIDN2_LIBS
CMOCKA_CFLAGS
CMOCKA_LIBS'
CMOCKA_LIBS
KYUA'


# Initialize some variables set by options.
Expand Down Expand Up @@ -1000,7 +1001,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
Expand Down Expand Up @@ -1253,15 +1253,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;

-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;

-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
Expand Down Expand Up @@ -1399,7 +1390,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir runstatedir
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
Expand Down Expand Up @@ -1552,7 +1543,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
Expand Down Expand Up @@ -1715,6 +1705,7 @@ Some influential environment variables:
CMOCKA_CFLAGS
C compiler flags for CMOCKA, overriding pkg-config
CMOCKA_LIBS linker flags for CMOCKA, overriding pkg-config
KYUA path to kyua execution engine

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Expand Down Expand Up @@ -11916,7 +11907,6 @@ yes)
STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1 -DNS_HOOKS_ENABLE=1"
test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
test "${enable_querytrace+set}" = set || enable_querytrace=yes
test "${with_atf+set}" = set || with_atf=yes
test "${with_cmocka+set}" = set || with_cmocka=yes
test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes
test "${enable_symtable+set}" = set || enable_symtable=all
Expand Down Expand Up @@ -19884,6 +19874,64 @@ esac



#
# Check for kyua execution engine if ATF was requested
# and bail out if execution engine was not found
#

if test "$with_cmocka" != "no"; then :
for ac_prog in kyua
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_KYUA+:} false; then :
$as_echo_n "(cached) " >&6
else
case $KYUA in
[\\/]* | ?:[\\/]*)
ac_cv_path_KYUA="$KYUA" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_KYUA="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS

;;
esac
fi
KYUA=$ac_cv_path_KYUA
if test -n "$KYUA"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $KYUA" >&5
$as_echo "$KYUA" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


test -n "$KYUA" && break
done

if test -z "$KYUA"; then :
as_fn_error $? "kyua test execution engine not found" "$LINENO" 5
fi
fi



#
# Check for -Wl,--wrap= support
#
Expand Down Expand Up @@ -19925,6 +19973,9 @@ rm -f core conftest.err conftest.$ac_objext \

LDFLAGS=$save_LDFLAGS

#
# Check for i18n
#
for ac_header in locale.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default"
Expand Down
16 changes: 15 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ yes)
STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1 -DNS_HOOKS_ENABLE=1"
test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
test "${enable_querytrace+set}" = set || enable_querytrace=yes
test "${with_atf+set}" = set || with_atf=yes
test "${with_cmocka+set}" = set || with_cmocka=yes
test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes
test "${enable_symtable+set}" = set || enable_symtable=all
Expand Down Expand Up @@ -2436,6 +2435,18 @@ AC_SUBST([CMOCKA_CFLAGS])
AC_SUBST([CMOCKA_LIBS])
AC_SUBST(UNITTESTS)

#
# Check for kyua execution engine if ATF was requested
# and bail out if execution engine was not found
#
AC_ARG_VAR([KYUA], [path to kyua execution engine])
AS_IF([test "$with_cmocka" != "no"],
[AC_PATH_PROGS([KYUA], [kyua], [])
AS_IF([test -z "$KYUA"],
[AC_MSG_ERROR([kyua test execution engine not found])])])

AC_SUBST([KYUA])

#
# Check for -Wl,--wrap= support
#
Expand All @@ -2458,6 +2469,9 @@ AC_SUBST([LD_WRAP_TESTS])

LDFLAGS=$save_LDFLAGS

#
# Check for i18n
#
AC_CHECK_HEADERS(locale.h)
AC_CHECK_FUNCS(setlocale)

Expand Down
19 changes: 17 additions & 2 deletions lib/ns/tests/listenlist_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@

#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <setjmp.h>

#include <stdlib.h>
#include <isc/util.h>

#ifdef NS_HOOKS_ENABLE

#include <stdio.h>
#include <string.h>
#include <unistd.h>
Expand Down Expand Up @@ -122,6 +126,17 @@ main(void) {

return (cmocka_run_group_tests(tests, NULL, NULL));
}
#else

#include <stdio.h>

int
main(void) {
printf("1..0 # Skipped: libns hooks not enabled\n");
return (0);
}

#endif /* NS_HOOKS_ENABLE */

#else /* HAVE_CMOCKA */

Expand All @@ -133,4 +148,4 @@ main(void) {
return (0);
}

#endif
#endif /* HAVE_CMOCKA */
17 changes: 16 additions & 1 deletion lib/ns/tests/notify_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@

#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <setjmp.h>

#include <stdlib.h>
#include <isc/util.h>

#ifdef NS_HOOKS_ENABLE

#include <stdio.h>
#include <string.h>
#include <unistd.h>
Expand Down Expand Up @@ -150,6 +154,17 @@ main(void) {

return (cmocka_run_group_tests(tests, NULL, NULL));
}
#else

#include <stdio.h>

int
main(void) {
printf("1..0 # Skipped: libns hooks not enabled\n");
return (0);
}

#endif /* NS_HOOKS_ENABLE */

#else /* HAVE_CMOCKA */

Expand Down
3 changes: 3 additions & 0 deletions lib/ns/tests/nstest.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include <config.h>

#ifdef NS_HOOKS_ENABLE

#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
Expand Down Expand Up @@ -925,3 +927,4 @@ ns_test_getdata(const char *file, unsigned char *buf,
isc_stdio_close(f);
return (result);
}
#endif
18 changes: 16 additions & 2 deletions lib/ns/tests/query_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
#include <stddef.h>
#include <setjmp.h>

#include <isc/util.h>

#ifdef NS_HOOKS_ENABLE

#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
Expand All @@ -27,7 +31,6 @@

#include <dns/badcache.h>
#include <dns/view.h>
#include <isc/util.h>
#include <ns/client.h>
#include <ns/query.h>
#include <isc/util.h>
Expand Down Expand Up @@ -601,6 +604,17 @@ main(void) {

return (cmocka_run_group_tests(tests, NULL, NULL));
}
#else

#include <stdio.h>

int
main(void) {
printf("1..0 # Skipped: libns hooks not enabled\n");
return (0);
}

#endif /* NS_HOOKS_ENABLE */

#else /* HAVE_CMOCKA */

Expand All @@ -612,4 +626,4 @@ main(void) {
return (0);
}

#endif
#endif /* HAVE_CMOCKA */
26 changes: 7 additions & 19 deletions unit/README
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
These unit tests for BIND 9 are based on the NetBSD Automated Test Framework
release 0.17.
Unit tests for BIND 9 are based on NetBSD Automated Test Framework, cmocka and
test execution engine Kyua.

To build an external copy of ATF for use by BIND 9:
If your distribution of choice doesn't include packages for atf, kyua and
cmocka, the sources can be found here:

$ cd atf-src
$ configure --prefix=<prefix> --enable-tools --disable-shared
$ make
$ make install

Subsequently, specify the ATF prefix when building BIND 9:

$ configure --with-atf=<prefix>

ATF can also be built automatically during the BIND 9 build,
by specifying --with-atf without an argument:

$ configure --with-atf

This causes BIND 9 to build ATF in the atf-src directory and
link to it directly.
* ATF 0.20 - https://github.com/jmmv/atf/releases
* Kyua 0.13 - https://github.com/jmmv/kyua/releases
* CMocka 1.0 - https://cmocka.org/files/
Loading

0 comments on commit de219b8

Please sign in to comment.