diff options
Diffstat (limited to 'src/libstrongswan/tests')
39 files changed, 8420 insertions, 906 deletions
diff --git a/src/libstrongswan/tests/Makefile.am b/src/libstrongswan/tests/Makefile.am index c3d41a1cd..331a5480d 100644 --- a/src/libstrongswan/tests/Makefile.am +++ b/src/libstrongswan/tests/Makefile.am @@ -1,23 +1,62 @@ -TESTS = test_runner +check_LTLIBRARIES = libtest.la + +libtest_la_SOURCES = \ + test_suite.c test_suite.h \ + test_runner.c test_runner.h \ + utils/test_rng.c utils/test_rng.h + +libtest_la_CFLAGS = \ + -I$(top_srcdir)/src/libstrongswan \ + @COVERAGE_CFLAGS@ + +libtest_la_LDFLAGS = @COVERAGE_LDFLAGS@ +libtest_la_LIBADD = \ + $(top_builddir)/src/libstrongswan/libstrongswan.la \ + $(PTHREADLIB) + + +TESTS = tests check_PROGRAMS = $(TESTS) -test_runner_SOURCES = \ - test_runner.c test_runner.h test_suite.h \ - test_linked_list.c test_enumerator.c test_linked_list_enumerator.c \ - test_bio_reader.c test_bio_writer.c test_chunk.c test_enum.c test_hashtable.c \ - test_identification.c test_threading.c test_utils.c test_vectors.c \ - test_array.c test_ecdsa.c test_rsa.c test_host.c test_printf.c +tests_SOURCES = tests.h tests.c \ + suites/test_linked_list.c \ + suites/test_enumerator.c \ + suites/test_linked_list_enumerator.c \ + suites/test_bio_reader.c \ + suites/test_bio_writer.c \ + suites/test_chunk.c \ + suites/test_enum.c \ + suites/test_hashtable.c \ + suites/test_identification.c \ + suites/test_threading.c \ + suites/test_watcher.c \ + suites/test_stream.c \ + suites/test_fetch_http.c \ + suites/test_utils.c \ + suites/test_settings.c \ + suites/test_vectors.c \ + suites/test_array.c \ + suites/test_ecdsa.c \ + suites/test_rsa.c \ + suites/test_host.c \ + suites/test_hasher.c \ + suites/test_crypter.c \ + suites/test_pen.c \ + suites/test_asn1.c \ + suites/test_asn1_parser.c \ + suites/test_printf.c \ + suites/test_test_rng.c \ + suites/test_ntru.c -test_runner_CFLAGS = \ +tests_CFLAGS = \ -I$(top_srcdir)/src/libstrongswan \ + -I$(top_srcdir)/src/libstrongswan/tests \ -DPLUGINDIR=\""$(top_builddir)/src/libstrongswan/plugins\"" \ -DPLUGINS=\""${s_plugins}\"" \ - @COVERAGE_CFLAGS@ \ - @CHECK_CFLAGS@ + @COVERAGE_CFLAGS@ -test_runner_LDFLAGS = @COVERAGE_LDFLAGS@ -test_runner_LDADD = \ +tests_LDFLAGS = @COVERAGE_LDFLAGS@ +tests_LDADD = \ $(top_builddir)/src/libstrongswan/libstrongswan.la \ - $(PTHREADLIB) \ - @CHECK_LIBS@ + libtest.la diff --git a/src/libstrongswan/tests/Makefile.in b/src/libstrongswan/tests/Makefile.in index adeae1a81..656be4efb 100644 --- a/src/libstrongswan/tests/Makefile.in +++ b/src/libstrongswan/tests/Makefile.in @@ -77,11 +77,11 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -TESTS = test_runner$(EXEEXT) +TESTS = tests$(EXEEXT) check_PROGRAMS = $(am__EXEEXT_1) subdir = src/libstrongswan/tests DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/depcomp $(top_srcdir)/test-driver + $(top_srcdir)/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \ $(top_srcdir)/m4/config/ltoptions.m4 \ @@ -99,36 +99,57 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -am__EXEEXT_1 = test_runner$(EXEEXT) -am_test_runner_OBJECTS = test_runner-test_runner.$(OBJEXT) \ - test_runner-test_linked_list.$(OBJEXT) \ - test_runner-test_enumerator.$(OBJEXT) \ - test_runner-test_linked_list_enumerator.$(OBJEXT) \ - test_runner-test_bio_reader.$(OBJEXT) \ - test_runner-test_bio_writer.$(OBJEXT) \ - test_runner-test_chunk.$(OBJEXT) \ - test_runner-test_enum.$(OBJEXT) \ - test_runner-test_hashtable.$(OBJEXT) \ - test_runner-test_identification.$(OBJEXT) \ - test_runner-test_threading.$(OBJEXT) \ - test_runner-test_utils.$(OBJEXT) \ - test_runner-test_vectors.$(OBJEXT) \ - test_runner-test_array.$(OBJEXT) \ - test_runner-test_ecdsa.$(OBJEXT) \ - test_runner-test_rsa.$(OBJEXT) test_runner-test_host.$(OBJEXT) \ - test_runner-test_printf.$(OBJEXT) -test_runner_OBJECTS = $(am_test_runner_OBJECTS) am__DEPENDENCIES_1 = -test_runner_DEPENDENCIES = \ +libtest_la_DEPENDENCIES = \ $(top_builddir)/src/libstrongswan/libstrongswan.la \ $(am__DEPENDENCIES_1) +am__dirstamp = $(am__leading_dot)dirstamp +am_libtest_la_OBJECTS = libtest_la-test_suite.lo \ + libtest_la-test_runner.lo utils/libtest_la-test_rng.lo +libtest_la_OBJECTS = $(am_libtest_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = -test_runner_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_runner_CFLAGS) \ - $(CFLAGS) $(test_runner_LDFLAGS) $(LDFLAGS) -o $@ +libtest_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libtest_la_CFLAGS) \ + $(CFLAGS) $(libtest_la_LDFLAGS) $(LDFLAGS) -o $@ +am__EXEEXT_1 = tests$(EXEEXT) +am_tests_OBJECTS = tests-tests.$(OBJEXT) \ + suites/tests-test_linked_list.$(OBJEXT) \ + suites/tests-test_enumerator.$(OBJEXT) \ + suites/tests-test_linked_list_enumerator.$(OBJEXT) \ + suites/tests-test_bio_reader.$(OBJEXT) \ + suites/tests-test_bio_writer.$(OBJEXT) \ + suites/tests-test_chunk.$(OBJEXT) \ + suites/tests-test_enum.$(OBJEXT) \ + suites/tests-test_hashtable.$(OBJEXT) \ + suites/tests-test_identification.$(OBJEXT) \ + suites/tests-test_threading.$(OBJEXT) \ + suites/tests-test_watcher.$(OBJEXT) \ + suites/tests-test_stream.$(OBJEXT) \ + suites/tests-test_fetch_http.$(OBJEXT) \ + suites/tests-test_utils.$(OBJEXT) \ + suites/tests-test_settings.$(OBJEXT) \ + suites/tests-test_vectors.$(OBJEXT) \ + suites/tests-test_array.$(OBJEXT) \ + suites/tests-test_ecdsa.$(OBJEXT) \ + suites/tests-test_rsa.$(OBJEXT) \ + suites/tests-test_host.$(OBJEXT) \ + suites/tests-test_hasher.$(OBJEXT) \ + suites/tests-test_crypter.$(OBJEXT) \ + suites/tests-test_pen.$(OBJEXT) \ + suites/tests-test_asn1.$(OBJEXT) \ + suites/tests-test_asn1_parser.$(OBJEXT) \ + suites/tests-test_printf.$(OBJEXT) \ + suites/tests-test_test_rng.$(OBJEXT) \ + suites/tests-test_ntru.$(OBJEXT) +tests_OBJECTS = $(am_tests_OBJECTS) +tests_DEPENDENCIES = \ + $(top_builddir)/src/libstrongswan/libstrongswan.la libtest.la +tests_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(tests_CFLAGS) $(CFLAGS) \ + $(tests_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -163,8 +184,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(test_runner_SOURCES) -DIST_SOURCES = $(test_runner_SOURCES) +SOURCES = $(libtest_la_SOURCES) $(tests_SOURCES) +DIST_SOURCES = $(libtest_la_SOURCES) $(tests_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -211,188 +232,6 @@ am__tty_colors = { \ std='[m'; \ fi; \ } -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver -LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ @@ -408,8 +247,6 @@ BTLIB = @BTLIB@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CHECK_CFLAGS = @CHECK_CFLAGS@ -CHECK_LIBS = @CHECK_LIBS@ COVERAGE_CFLAGS = @COVERAGE_CFLAGS@ COVERAGE_LDFLAGS = @COVERAGE_LDFLAGS@ CPP = @CPP@ @@ -477,6 +314,11 @@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREADLIB = @PTHREADLIB@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ RTLIB = @RTLIB@ RUBY = @RUBY@ @@ -565,12 +407,16 @@ pcsclite_CFLAGS = @pcsclite_CFLAGS@ pcsclite_LIBS = @pcsclite_LIBS@ pdfdir = @pdfdir@ piddir = @piddir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ pki_plugins = @pki_plugins@ plugindir = @plugindir@ pool_plugins = @pool_plugins@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ random_device = @random_device@ resolv_conf = @resolv_conf@ routing_table = @routing_table@ @@ -585,6 +431,7 @@ soup_LIBS = @soup_LIBS@ srcdir = @srcdir@ starter_plugins = @starter_plugins@ strongswan_conf = @strongswan_conf@ +strongswan_options = @strongswan_options@ sysconfdir = @sysconfdir@ systemdsystemunitdir = @systemdsystemunitdir@ t_plugins = @t_plugins@ @@ -595,30 +442,67 @@ top_srcdir = @top_srcdir@ urandom_device = @urandom_device@ xml_CFLAGS = @xml_CFLAGS@ xml_LIBS = @xml_LIBS@ -test_runner_SOURCES = \ - test_runner.c test_runner.h test_suite.h \ - test_linked_list.c test_enumerator.c test_linked_list_enumerator.c \ - test_bio_reader.c test_bio_writer.c test_chunk.c test_enum.c test_hashtable.c \ - test_identification.c test_threading.c test_utils.c test_vectors.c \ - test_array.c test_ecdsa.c test_rsa.c test_host.c test_printf.c - -test_runner_CFLAGS = \ +check_LTLIBRARIES = libtest.la +libtest_la_SOURCES = \ + test_suite.c test_suite.h \ + test_runner.c test_runner.h \ + utils/test_rng.c utils/test_rng.h + +libtest_la_CFLAGS = \ + -I$(top_srcdir)/src/libstrongswan \ + @COVERAGE_CFLAGS@ + +libtest_la_LDFLAGS = @COVERAGE_LDFLAGS@ +libtest_la_LIBADD = \ + $(top_builddir)/src/libstrongswan/libstrongswan.la \ + $(PTHREADLIB) + +tests_SOURCES = tests.h tests.c \ + suites/test_linked_list.c \ + suites/test_enumerator.c \ + suites/test_linked_list_enumerator.c \ + suites/test_bio_reader.c \ + suites/test_bio_writer.c \ + suites/test_chunk.c \ + suites/test_enum.c \ + suites/test_hashtable.c \ + suites/test_identification.c \ + suites/test_threading.c \ + suites/test_watcher.c \ + suites/test_stream.c \ + suites/test_fetch_http.c \ + suites/test_utils.c \ + suites/test_settings.c \ + suites/test_vectors.c \ + suites/test_array.c \ + suites/test_ecdsa.c \ + suites/test_rsa.c \ + suites/test_host.c \ + suites/test_hasher.c \ + suites/test_crypter.c \ + suites/test_pen.c \ + suites/test_asn1.c \ + suites/test_asn1_parser.c \ + suites/test_printf.c \ + suites/test_test_rng.c \ + suites/test_ntru.c + +tests_CFLAGS = \ -I$(top_srcdir)/src/libstrongswan \ + -I$(top_srcdir)/src/libstrongswan/tests \ -DPLUGINDIR=\""$(top_builddir)/src/libstrongswan/plugins\"" \ -DPLUGINS=\""${s_plugins}\"" \ - @COVERAGE_CFLAGS@ \ - @CHECK_CFLAGS@ + @COVERAGE_CFLAGS@ -test_runner_LDFLAGS = @COVERAGE_LDFLAGS@ -test_runner_LDADD = \ +tests_LDFLAGS = @COVERAGE_LDFLAGS@ +tests_LDADD = \ $(top_builddir)/src/libstrongswan/libstrongswan.la \ - $(PTHREADLIB) \ - @CHECK_LIBS@ + libtest.la all: all-am .SUFFIXES: -.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs +.SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -650,6 +534,28 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): +clean-checkLTLIBRARIES: + -test -z "$(check_LTLIBRARIES)" || rm -f $(check_LTLIBRARIES) + @list='$(check_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } +utils/$(am__dirstamp): + @$(MKDIR_P) utils + @: > utils/$(am__dirstamp) +utils/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) utils/$(DEPDIR) + @: > utils/$(DEPDIR)/$(am__dirstamp) +utils/libtest_la-test_rng.lo: utils/$(am__dirstamp) \ + utils/$(DEPDIR)/$(am__dirstamp) + +libtest.la: $(libtest_la_OBJECTS) $(libtest_la_DEPENDENCIES) $(EXTRA_libtest_la_DEPENDENCIES) + $(AM_V_CCLD)$(libtest_la_LINK) $(libtest_la_OBJECTS) $(libtest_la_LIBADD) $(LIBS) + clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ @@ -658,35 +564,114 @@ clean-checkPROGRAMS: list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list - -test_runner$(EXEEXT): $(test_runner_OBJECTS) $(test_runner_DEPENDENCIES) $(EXTRA_test_runner_DEPENDENCIES) - @rm -f test_runner$(EXEEXT) - $(AM_V_CCLD)$(test_runner_LINK) $(test_runner_OBJECTS) $(test_runner_LDADD) $(LIBS) +suites/$(am__dirstamp): + @$(MKDIR_P) suites + @: > suites/$(am__dirstamp) +suites/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) suites/$(DEPDIR) + @: > suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_linked_list.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_enumerator.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_linked_list_enumerator.$(OBJEXT): \ + suites/$(am__dirstamp) suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_bio_reader.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_bio_writer.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_chunk.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_enum.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_hashtable.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_identification.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_threading.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_watcher.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_stream.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_fetch_http.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_utils.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_settings.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_vectors.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_array.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_ecdsa.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_rsa.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_host.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_hasher.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_crypter.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_pen.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_asn1.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_asn1_parser.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_printf.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_test_rng.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) +suites/tests-test_ntru.$(OBJEXT): suites/$(am__dirstamp) \ + suites/$(DEPDIR)/$(am__dirstamp) + +tests$(EXEEXT): $(tests_OBJECTS) $(tests_DEPENDENCIES) $(EXTRA_tests_DEPENDENCIES) + @rm -f tests$(EXEEXT) + $(AM_V_CCLD)$(tests_LINK) $(tests_OBJECTS) $(tests_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) + -rm -f suites/*.$(OBJEXT) + -rm -f utils/*.$(OBJEXT) + -rm -f utils/*.lo distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_array.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_bio_reader.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_bio_writer.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_chunk.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_ecdsa.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_enum.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_enumerator.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_hashtable.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_host.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_identification.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_linked_list.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_linked_list_enumerator.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_printf.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_rsa.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_runner.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_threading.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_utils.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_runner-test_vectors.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtest_la-test_runner.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libtest_la-test_suite.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tests-tests.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_array.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_asn1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_asn1_parser.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_bio_reader.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_bio_writer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_chunk.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_crypter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_ecdsa.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_enum.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_enumerator.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_fetch_http.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_hasher.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_hashtable.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_host.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_identification.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_linked_list.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_linked_list_enumerator.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_ntru.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_pen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_printf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_rsa.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_settings.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_stream.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_test_rng.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_threading.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_utils.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_vectors.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@suites/$(DEPDIR)/tests-test_watcher.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@utils/$(DEPDIR)/libtest_la-test_rng.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -712,263 +697,439 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< -test_runner-test_runner.o: test_runner.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_runner.o -MD -MP -MF $(DEPDIR)/test_runner-test_runner.Tpo -c -o test_runner-test_runner.o `test -f 'test_runner.c' || echo '$(srcdir)/'`test_runner.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_runner.Tpo $(DEPDIR)/test_runner-test_runner.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_runner.c' object='test_runner-test_runner.o' libtool=no @AMDEPBACKSLASH@ +libtest_la-test_suite.lo: test_suite.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -MT libtest_la-test_suite.lo -MD -MP -MF $(DEPDIR)/libtest_la-test_suite.Tpo -c -o libtest_la-test_suite.lo `test -f 'test_suite.c' || echo '$(srcdir)/'`test_suite.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtest_la-test_suite.Tpo $(DEPDIR)/libtest_la-test_suite.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_suite.c' object='libtest_la-test_suite.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -c -o libtest_la-test_suite.lo `test -f 'test_suite.c' || echo '$(srcdir)/'`test_suite.c + +libtest_la-test_runner.lo: test_runner.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -MT libtest_la-test_runner.lo -MD -MP -MF $(DEPDIR)/libtest_la-test_runner.Tpo -c -o libtest_la-test_runner.lo `test -f 'test_runner.c' || echo '$(srcdir)/'`test_runner.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libtest_la-test_runner.Tpo $(DEPDIR)/libtest_la-test_runner.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_runner.c' object='libtest_la-test_runner.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -c -o libtest_la-test_runner.lo `test -f 'test_runner.c' || echo '$(srcdir)/'`test_runner.c + +utils/libtest_la-test_rng.lo: utils/test_rng.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -MT utils/libtest_la-test_rng.lo -MD -MP -MF utils/$(DEPDIR)/libtest_la-test_rng.Tpo -c -o utils/libtest_la-test_rng.lo `test -f 'utils/test_rng.c' || echo '$(srcdir)/'`utils/test_rng.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) utils/$(DEPDIR)/libtest_la-test_rng.Tpo utils/$(DEPDIR)/libtest_la-test_rng.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utils/test_rng.c' object='utils/libtest_la-test_rng.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libtest_la_CFLAGS) $(CFLAGS) -c -o utils/libtest_la-test_rng.lo `test -f 'utils/test_rng.c' || echo '$(srcdir)/'`utils/test_rng.c + +tests-tests.o: tests.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT tests-tests.o -MD -MP -MF $(DEPDIR)/tests-tests.Tpo -c -o tests-tests.o `test -f 'tests.c' || echo '$(srcdir)/'`tests.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tests-tests.Tpo $(DEPDIR)/tests-tests.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests.c' object='tests-tests.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o tests-tests.o `test -f 'tests.c' || echo '$(srcdir)/'`tests.c + +tests-tests.obj: tests.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT tests-tests.obj -MD -MP -MF $(DEPDIR)/tests-tests.Tpo -c -o tests-tests.obj `if test -f 'tests.c'; then $(CYGPATH_W) 'tests.c'; else $(CYGPATH_W) '$(srcdir)/tests.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tests-tests.Tpo $(DEPDIR)/tests-tests.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='tests.c' object='tests-tests.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o tests-tests.obj `if test -f 'tests.c'; then $(CYGPATH_W) 'tests.c'; else $(CYGPATH_W) '$(srcdir)/tests.c'; fi` + +suites/tests-test_linked_list.o: suites/test_linked_list.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_linked_list.o -MD -MP -MF suites/$(DEPDIR)/tests-test_linked_list.Tpo -c -o suites/tests-test_linked_list.o `test -f 'suites/test_linked_list.c' || echo '$(srcdir)/'`suites/test_linked_list.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_linked_list.Tpo suites/$(DEPDIR)/tests-test_linked_list.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_linked_list.c' object='suites/tests-test_linked_list.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_linked_list.o `test -f 'suites/test_linked_list.c' || echo '$(srcdir)/'`suites/test_linked_list.c + +suites/tests-test_linked_list.obj: suites/test_linked_list.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_linked_list.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_linked_list.Tpo -c -o suites/tests-test_linked_list.obj `if test -f 'suites/test_linked_list.c'; then $(CYGPATH_W) 'suites/test_linked_list.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_linked_list.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_linked_list.Tpo suites/$(DEPDIR)/tests-test_linked_list.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_linked_list.c' object='suites/tests-test_linked_list.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_linked_list.obj `if test -f 'suites/test_linked_list.c'; then $(CYGPATH_W) 'suites/test_linked_list.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_linked_list.c'; fi` + +suites/tests-test_enumerator.o: suites/test_enumerator.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_enumerator.o -MD -MP -MF suites/$(DEPDIR)/tests-test_enumerator.Tpo -c -o suites/tests-test_enumerator.o `test -f 'suites/test_enumerator.c' || echo '$(srcdir)/'`suites/test_enumerator.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_enumerator.Tpo suites/$(DEPDIR)/tests-test_enumerator.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_enumerator.c' object='suites/tests-test_enumerator.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_enumerator.o `test -f 'suites/test_enumerator.c' || echo '$(srcdir)/'`suites/test_enumerator.c + +suites/tests-test_enumerator.obj: suites/test_enumerator.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_enumerator.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_enumerator.Tpo -c -o suites/tests-test_enumerator.obj `if test -f 'suites/test_enumerator.c'; then $(CYGPATH_W) 'suites/test_enumerator.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_enumerator.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_enumerator.Tpo suites/$(DEPDIR)/tests-test_enumerator.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_enumerator.c' object='suites/tests-test_enumerator.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_enumerator.obj `if test -f 'suites/test_enumerator.c'; then $(CYGPATH_W) 'suites/test_enumerator.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_enumerator.c'; fi` + +suites/tests-test_linked_list_enumerator.o: suites/test_linked_list_enumerator.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_linked_list_enumerator.o -MD -MP -MF suites/$(DEPDIR)/tests-test_linked_list_enumerator.Tpo -c -o suites/tests-test_linked_list_enumerator.o `test -f 'suites/test_linked_list_enumerator.c' || echo '$(srcdir)/'`suites/test_linked_list_enumerator.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_linked_list_enumerator.Tpo suites/$(DEPDIR)/tests-test_linked_list_enumerator.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_linked_list_enumerator.c' object='suites/tests-test_linked_list_enumerator.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_linked_list_enumerator.o `test -f 'suites/test_linked_list_enumerator.c' || echo '$(srcdir)/'`suites/test_linked_list_enumerator.c + +suites/tests-test_linked_list_enumerator.obj: suites/test_linked_list_enumerator.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_linked_list_enumerator.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_linked_list_enumerator.Tpo -c -o suites/tests-test_linked_list_enumerator.obj `if test -f 'suites/test_linked_list_enumerator.c'; then $(CYGPATH_W) 'suites/test_linked_list_enumerator.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_linked_list_enumerator.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_linked_list_enumerator.Tpo suites/$(DEPDIR)/tests-test_linked_list_enumerator.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_linked_list_enumerator.c' object='suites/tests-test_linked_list_enumerator.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_linked_list_enumerator.obj `if test -f 'suites/test_linked_list_enumerator.c'; then $(CYGPATH_W) 'suites/test_linked_list_enumerator.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_linked_list_enumerator.c'; fi` + +suites/tests-test_bio_reader.o: suites/test_bio_reader.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_bio_reader.o -MD -MP -MF suites/$(DEPDIR)/tests-test_bio_reader.Tpo -c -o suites/tests-test_bio_reader.o `test -f 'suites/test_bio_reader.c' || echo '$(srcdir)/'`suites/test_bio_reader.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_bio_reader.Tpo suites/$(DEPDIR)/tests-test_bio_reader.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_bio_reader.c' object='suites/tests-test_bio_reader.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_bio_reader.o `test -f 'suites/test_bio_reader.c' || echo '$(srcdir)/'`suites/test_bio_reader.c + +suites/tests-test_bio_reader.obj: suites/test_bio_reader.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_bio_reader.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_bio_reader.Tpo -c -o suites/tests-test_bio_reader.obj `if test -f 'suites/test_bio_reader.c'; then $(CYGPATH_W) 'suites/test_bio_reader.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_bio_reader.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_bio_reader.Tpo suites/$(DEPDIR)/tests-test_bio_reader.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_bio_reader.c' object='suites/tests-test_bio_reader.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_bio_reader.obj `if test -f 'suites/test_bio_reader.c'; then $(CYGPATH_W) 'suites/test_bio_reader.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_bio_reader.c'; fi` + +suites/tests-test_bio_writer.o: suites/test_bio_writer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_bio_writer.o -MD -MP -MF suites/$(DEPDIR)/tests-test_bio_writer.Tpo -c -o suites/tests-test_bio_writer.o `test -f 'suites/test_bio_writer.c' || echo '$(srcdir)/'`suites/test_bio_writer.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_bio_writer.Tpo suites/$(DEPDIR)/tests-test_bio_writer.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_bio_writer.c' object='suites/tests-test_bio_writer.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_bio_writer.o `test -f 'suites/test_bio_writer.c' || echo '$(srcdir)/'`suites/test_bio_writer.c + +suites/tests-test_bio_writer.obj: suites/test_bio_writer.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_bio_writer.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_bio_writer.Tpo -c -o suites/tests-test_bio_writer.obj `if test -f 'suites/test_bio_writer.c'; then $(CYGPATH_W) 'suites/test_bio_writer.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_bio_writer.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_bio_writer.Tpo suites/$(DEPDIR)/tests-test_bio_writer.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_bio_writer.c' object='suites/tests-test_bio_writer.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_bio_writer.obj `if test -f 'suites/test_bio_writer.c'; then $(CYGPATH_W) 'suites/test_bio_writer.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_bio_writer.c'; fi` + +suites/tests-test_chunk.o: suites/test_chunk.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_chunk.o -MD -MP -MF suites/$(DEPDIR)/tests-test_chunk.Tpo -c -o suites/tests-test_chunk.o `test -f 'suites/test_chunk.c' || echo '$(srcdir)/'`suites/test_chunk.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_chunk.Tpo suites/$(DEPDIR)/tests-test_chunk.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_chunk.c' object='suites/tests-test_chunk.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_runner.o `test -f 'test_runner.c' || echo '$(srcdir)/'`test_runner.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_chunk.o `test -f 'suites/test_chunk.c' || echo '$(srcdir)/'`suites/test_chunk.c -test_runner-test_runner.obj: test_runner.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_runner.obj -MD -MP -MF $(DEPDIR)/test_runner-test_runner.Tpo -c -o test_runner-test_runner.obj `if test -f 'test_runner.c'; then $(CYGPATH_W) 'test_runner.c'; else $(CYGPATH_W) '$(srcdir)/test_runner.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_runner.Tpo $(DEPDIR)/test_runner-test_runner.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_runner.c' object='test_runner-test_runner.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_chunk.obj: suites/test_chunk.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_chunk.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_chunk.Tpo -c -o suites/tests-test_chunk.obj `if test -f 'suites/test_chunk.c'; then $(CYGPATH_W) 'suites/test_chunk.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_chunk.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_chunk.Tpo suites/$(DEPDIR)/tests-test_chunk.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_chunk.c' object='suites/tests-test_chunk.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_runner.obj `if test -f 'test_runner.c'; then $(CYGPATH_W) 'test_runner.c'; else $(CYGPATH_W) '$(srcdir)/test_runner.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_chunk.obj `if test -f 'suites/test_chunk.c'; then $(CYGPATH_W) 'suites/test_chunk.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_chunk.c'; fi` -test_runner-test_linked_list.o: test_linked_list.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_linked_list.o -MD -MP -MF $(DEPDIR)/test_runner-test_linked_list.Tpo -c -o test_runner-test_linked_list.o `test -f 'test_linked_list.c' || echo '$(srcdir)/'`test_linked_list.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_linked_list.Tpo $(DEPDIR)/test_runner-test_linked_list.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_linked_list.c' object='test_runner-test_linked_list.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_enum.o: suites/test_enum.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_enum.o -MD -MP -MF suites/$(DEPDIR)/tests-test_enum.Tpo -c -o suites/tests-test_enum.o `test -f 'suites/test_enum.c' || echo '$(srcdir)/'`suites/test_enum.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_enum.Tpo suites/$(DEPDIR)/tests-test_enum.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_enum.c' object='suites/tests-test_enum.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_linked_list.o `test -f 'test_linked_list.c' || echo '$(srcdir)/'`test_linked_list.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_enum.o `test -f 'suites/test_enum.c' || echo '$(srcdir)/'`suites/test_enum.c -test_runner-test_linked_list.obj: test_linked_list.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_linked_list.obj -MD -MP -MF $(DEPDIR)/test_runner-test_linked_list.Tpo -c -o test_runner-test_linked_list.obj `if test -f 'test_linked_list.c'; then $(CYGPATH_W) 'test_linked_list.c'; else $(CYGPATH_W) '$(srcdir)/test_linked_list.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_linked_list.Tpo $(DEPDIR)/test_runner-test_linked_list.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_linked_list.c' object='test_runner-test_linked_list.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_enum.obj: suites/test_enum.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_enum.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_enum.Tpo -c -o suites/tests-test_enum.obj `if test -f 'suites/test_enum.c'; then $(CYGPATH_W) 'suites/test_enum.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_enum.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_enum.Tpo suites/$(DEPDIR)/tests-test_enum.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_enum.c' object='suites/tests-test_enum.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_linked_list.obj `if test -f 'test_linked_list.c'; then $(CYGPATH_W) 'test_linked_list.c'; else $(CYGPATH_W) '$(srcdir)/test_linked_list.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_enum.obj `if test -f 'suites/test_enum.c'; then $(CYGPATH_W) 'suites/test_enum.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_enum.c'; fi` -test_runner-test_enumerator.o: test_enumerator.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_enumerator.o -MD -MP -MF $(DEPDIR)/test_runner-test_enumerator.Tpo -c -o test_runner-test_enumerator.o `test -f 'test_enumerator.c' || echo '$(srcdir)/'`test_enumerator.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_enumerator.Tpo $(DEPDIR)/test_runner-test_enumerator.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_enumerator.c' object='test_runner-test_enumerator.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_hashtable.o: suites/test_hashtable.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_hashtable.o -MD -MP -MF suites/$(DEPDIR)/tests-test_hashtable.Tpo -c -o suites/tests-test_hashtable.o `test -f 'suites/test_hashtable.c' || echo '$(srcdir)/'`suites/test_hashtable.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_hashtable.Tpo suites/$(DEPDIR)/tests-test_hashtable.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_hashtable.c' object='suites/tests-test_hashtable.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_enumerator.o `test -f 'test_enumerator.c' || echo '$(srcdir)/'`test_enumerator.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_hashtable.o `test -f 'suites/test_hashtable.c' || echo '$(srcdir)/'`suites/test_hashtable.c -test_runner-test_enumerator.obj: test_enumerator.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_enumerator.obj -MD -MP -MF $(DEPDIR)/test_runner-test_enumerator.Tpo -c -o test_runner-test_enumerator.obj `if test -f 'test_enumerator.c'; then $(CYGPATH_W) 'test_enumerator.c'; else $(CYGPATH_W) '$(srcdir)/test_enumerator.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_enumerator.Tpo $(DEPDIR)/test_runner-test_enumerator.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_enumerator.c' object='test_runner-test_enumerator.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_hashtable.obj: suites/test_hashtable.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_hashtable.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_hashtable.Tpo -c -o suites/tests-test_hashtable.obj `if test -f 'suites/test_hashtable.c'; then $(CYGPATH_W) 'suites/test_hashtable.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_hashtable.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_hashtable.Tpo suites/$(DEPDIR)/tests-test_hashtable.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_hashtable.c' object='suites/tests-test_hashtable.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_enumerator.obj `if test -f 'test_enumerator.c'; then $(CYGPATH_W) 'test_enumerator.c'; else $(CYGPATH_W) '$(srcdir)/test_enumerator.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_hashtable.obj `if test -f 'suites/test_hashtable.c'; then $(CYGPATH_W) 'suites/test_hashtable.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_hashtable.c'; fi` -test_runner-test_linked_list_enumerator.o: test_linked_list_enumerator.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_linked_list_enumerator.o -MD -MP -MF $(DEPDIR)/test_runner-test_linked_list_enumerator.Tpo -c -o test_runner-test_linked_list_enumerator.o `test -f 'test_linked_list_enumerator.c' || echo '$(srcdir)/'`test_linked_list_enumerator.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_linked_list_enumerator.Tpo $(DEPDIR)/test_runner-test_linked_list_enumerator.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_linked_list_enumerator.c' object='test_runner-test_linked_list_enumerator.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_identification.o: suites/test_identification.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_identification.o -MD -MP -MF suites/$(DEPDIR)/tests-test_identification.Tpo -c -o suites/tests-test_identification.o `test -f 'suites/test_identification.c' || echo '$(srcdir)/'`suites/test_identification.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_identification.Tpo suites/$(DEPDIR)/tests-test_identification.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_identification.c' object='suites/tests-test_identification.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_linked_list_enumerator.o `test -f 'test_linked_list_enumerator.c' || echo '$(srcdir)/'`test_linked_list_enumerator.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_identification.o `test -f 'suites/test_identification.c' || echo '$(srcdir)/'`suites/test_identification.c -test_runner-test_linked_list_enumerator.obj: test_linked_list_enumerator.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_linked_list_enumerator.obj -MD -MP -MF $(DEPDIR)/test_runner-test_linked_list_enumerator.Tpo -c -o test_runner-test_linked_list_enumerator.obj `if test -f 'test_linked_list_enumerator.c'; then $(CYGPATH_W) 'test_linked_list_enumerator.c'; else $(CYGPATH_W) '$(srcdir)/test_linked_list_enumerator.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_linked_list_enumerator.Tpo $(DEPDIR)/test_runner-test_linked_list_enumerator.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_linked_list_enumerator.c' object='test_runner-test_linked_list_enumerator.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_identification.obj: suites/test_identification.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_identification.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_identification.Tpo -c -o suites/tests-test_identification.obj `if test -f 'suites/test_identification.c'; then $(CYGPATH_W) 'suites/test_identification.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_identification.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_identification.Tpo suites/$(DEPDIR)/tests-test_identification.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_identification.c' object='suites/tests-test_identification.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_linked_list_enumerator.obj `if test -f 'test_linked_list_enumerator.c'; then $(CYGPATH_W) 'test_linked_list_enumerator.c'; else $(CYGPATH_W) '$(srcdir)/test_linked_list_enumerator.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_identification.obj `if test -f 'suites/test_identification.c'; then $(CYGPATH_W) 'suites/test_identification.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_identification.c'; fi` -test_runner-test_bio_reader.o: test_bio_reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_bio_reader.o -MD -MP -MF $(DEPDIR)/test_runner-test_bio_reader.Tpo -c -o test_runner-test_bio_reader.o `test -f 'test_bio_reader.c' || echo '$(srcdir)/'`test_bio_reader.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_bio_reader.Tpo $(DEPDIR)/test_runner-test_bio_reader.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_bio_reader.c' object='test_runner-test_bio_reader.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_threading.o: suites/test_threading.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_threading.o -MD -MP -MF suites/$(DEPDIR)/tests-test_threading.Tpo -c -o suites/tests-test_threading.o `test -f 'suites/test_threading.c' || echo '$(srcdir)/'`suites/test_threading.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_threading.Tpo suites/$(DEPDIR)/tests-test_threading.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_threading.c' object='suites/tests-test_threading.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_bio_reader.o `test -f 'test_bio_reader.c' || echo '$(srcdir)/'`test_bio_reader.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_threading.o `test -f 'suites/test_threading.c' || echo '$(srcdir)/'`suites/test_threading.c -test_runner-test_bio_reader.obj: test_bio_reader.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_bio_reader.obj -MD -MP -MF $(DEPDIR)/test_runner-test_bio_reader.Tpo -c -o test_runner-test_bio_reader.obj `if test -f 'test_bio_reader.c'; then $(CYGPATH_W) 'test_bio_reader.c'; else $(CYGPATH_W) '$(srcdir)/test_bio_reader.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_bio_reader.Tpo $(DEPDIR)/test_runner-test_bio_reader.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_bio_reader.c' object='test_runner-test_bio_reader.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_threading.obj: suites/test_threading.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_threading.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_threading.Tpo -c -o suites/tests-test_threading.obj `if test -f 'suites/test_threading.c'; then $(CYGPATH_W) 'suites/test_threading.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_threading.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_threading.Tpo suites/$(DEPDIR)/tests-test_threading.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_threading.c' object='suites/tests-test_threading.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_bio_reader.obj `if test -f 'test_bio_reader.c'; then $(CYGPATH_W) 'test_bio_reader.c'; else $(CYGPATH_W) '$(srcdir)/test_bio_reader.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_threading.obj `if test -f 'suites/test_threading.c'; then $(CYGPATH_W) 'suites/test_threading.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_threading.c'; fi` -test_runner-test_bio_writer.o: test_bio_writer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_bio_writer.o -MD -MP -MF $(DEPDIR)/test_runner-test_bio_writer.Tpo -c -o test_runner-test_bio_writer.o `test -f 'test_bio_writer.c' || echo '$(srcdir)/'`test_bio_writer.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_bio_writer.Tpo $(DEPDIR)/test_runner-test_bio_writer.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_bio_writer.c' object='test_runner-test_bio_writer.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_watcher.o: suites/test_watcher.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_watcher.o -MD -MP -MF suites/$(DEPDIR)/tests-test_watcher.Tpo -c -o suites/tests-test_watcher.o `test -f 'suites/test_watcher.c' || echo '$(srcdir)/'`suites/test_watcher.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_watcher.Tpo suites/$(DEPDIR)/tests-test_watcher.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_watcher.c' object='suites/tests-test_watcher.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_bio_writer.o `test -f 'test_bio_writer.c' || echo '$(srcdir)/'`test_bio_writer.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_watcher.o `test -f 'suites/test_watcher.c' || echo '$(srcdir)/'`suites/test_watcher.c -test_runner-test_bio_writer.obj: test_bio_writer.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_bio_writer.obj -MD -MP -MF $(DEPDIR)/test_runner-test_bio_writer.Tpo -c -o test_runner-test_bio_writer.obj `if test -f 'test_bio_writer.c'; then $(CYGPATH_W) 'test_bio_writer.c'; else $(CYGPATH_W) '$(srcdir)/test_bio_writer.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_bio_writer.Tpo $(DEPDIR)/test_runner-test_bio_writer.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_bio_writer.c' object='test_runner-test_bio_writer.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_watcher.obj: suites/test_watcher.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_watcher.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_watcher.Tpo -c -o suites/tests-test_watcher.obj `if test -f 'suites/test_watcher.c'; then $(CYGPATH_W) 'suites/test_watcher.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_watcher.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_watcher.Tpo suites/$(DEPDIR)/tests-test_watcher.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_watcher.c' object='suites/tests-test_watcher.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_bio_writer.obj `if test -f 'test_bio_writer.c'; then $(CYGPATH_W) 'test_bio_writer.c'; else $(CYGPATH_W) '$(srcdir)/test_bio_writer.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_watcher.obj `if test -f 'suites/test_watcher.c'; then $(CYGPATH_W) 'suites/test_watcher.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_watcher.c'; fi` -test_runner-test_chunk.o: test_chunk.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_chunk.o -MD -MP -MF $(DEPDIR)/test_runner-test_chunk.Tpo -c -o test_runner-test_chunk.o `test -f 'test_chunk.c' || echo '$(srcdir)/'`test_chunk.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_chunk.Tpo $(DEPDIR)/test_runner-test_chunk.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_chunk.c' object='test_runner-test_chunk.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_stream.o: suites/test_stream.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_stream.o -MD -MP -MF suites/$(DEPDIR)/tests-test_stream.Tpo -c -o suites/tests-test_stream.o `test -f 'suites/test_stream.c' || echo '$(srcdir)/'`suites/test_stream.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_stream.Tpo suites/$(DEPDIR)/tests-test_stream.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_stream.c' object='suites/tests-test_stream.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_chunk.o `test -f 'test_chunk.c' || echo '$(srcdir)/'`test_chunk.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_stream.o `test -f 'suites/test_stream.c' || echo '$(srcdir)/'`suites/test_stream.c -test_runner-test_chunk.obj: test_chunk.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_chunk.obj -MD -MP -MF $(DEPDIR)/test_runner-test_chunk.Tpo -c -o test_runner-test_chunk.obj `if test -f 'test_chunk.c'; then $(CYGPATH_W) 'test_chunk.c'; else $(CYGPATH_W) '$(srcdir)/test_chunk.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_chunk.Tpo $(DEPDIR)/test_runner-test_chunk.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_chunk.c' object='test_runner-test_chunk.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_stream.obj: suites/test_stream.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_stream.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_stream.Tpo -c -o suites/tests-test_stream.obj `if test -f 'suites/test_stream.c'; then $(CYGPATH_W) 'suites/test_stream.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_stream.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_stream.Tpo suites/$(DEPDIR)/tests-test_stream.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_stream.c' object='suites/tests-test_stream.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_chunk.obj `if test -f 'test_chunk.c'; then $(CYGPATH_W) 'test_chunk.c'; else $(CYGPATH_W) '$(srcdir)/test_chunk.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_stream.obj `if test -f 'suites/test_stream.c'; then $(CYGPATH_W) 'suites/test_stream.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_stream.c'; fi` -test_runner-test_enum.o: test_enum.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_enum.o -MD -MP -MF $(DEPDIR)/test_runner-test_enum.Tpo -c -o test_runner-test_enum.o `test -f 'test_enum.c' || echo '$(srcdir)/'`test_enum.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_enum.Tpo $(DEPDIR)/test_runner-test_enum.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_enum.c' object='test_runner-test_enum.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_fetch_http.o: suites/test_fetch_http.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_fetch_http.o -MD -MP -MF suites/$(DEPDIR)/tests-test_fetch_http.Tpo -c -o suites/tests-test_fetch_http.o `test -f 'suites/test_fetch_http.c' || echo '$(srcdir)/'`suites/test_fetch_http.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_fetch_http.Tpo suites/$(DEPDIR)/tests-test_fetch_http.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_fetch_http.c' object='suites/tests-test_fetch_http.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_enum.o `test -f 'test_enum.c' || echo '$(srcdir)/'`test_enum.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_fetch_http.o `test -f 'suites/test_fetch_http.c' || echo '$(srcdir)/'`suites/test_fetch_http.c -test_runner-test_enum.obj: test_enum.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_enum.obj -MD -MP -MF $(DEPDIR)/test_runner-test_enum.Tpo -c -o test_runner-test_enum.obj `if test -f 'test_enum.c'; then $(CYGPATH_W) 'test_enum.c'; else $(CYGPATH_W) '$(srcdir)/test_enum.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_enum.Tpo $(DEPDIR)/test_runner-test_enum.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_enum.c' object='test_runner-test_enum.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_fetch_http.obj: suites/test_fetch_http.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_fetch_http.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_fetch_http.Tpo -c -o suites/tests-test_fetch_http.obj `if test -f 'suites/test_fetch_http.c'; then $(CYGPATH_W) 'suites/test_fetch_http.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_fetch_http.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_fetch_http.Tpo suites/$(DEPDIR)/tests-test_fetch_http.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_fetch_http.c' object='suites/tests-test_fetch_http.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_enum.obj `if test -f 'test_enum.c'; then $(CYGPATH_W) 'test_enum.c'; else $(CYGPATH_W) '$(srcdir)/test_enum.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_fetch_http.obj `if test -f 'suites/test_fetch_http.c'; then $(CYGPATH_W) 'suites/test_fetch_http.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_fetch_http.c'; fi` -test_runner-test_hashtable.o: test_hashtable.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_hashtable.o -MD -MP -MF $(DEPDIR)/test_runner-test_hashtable.Tpo -c -o test_runner-test_hashtable.o `test -f 'test_hashtable.c' || echo '$(srcdir)/'`test_hashtable.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_hashtable.Tpo $(DEPDIR)/test_runner-test_hashtable.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_hashtable.c' object='test_runner-test_hashtable.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_utils.o: suites/test_utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_utils.o -MD -MP -MF suites/$(DEPDIR)/tests-test_utils.Tpo -c -o suites/tests-test_utils.o `test -f 'suites/test_utils.c' || echo '$(srcdir)/'`suites/test_utils.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_utils.Tpo suites/$(DEPDIR)/tests-test_utils.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_utils.c' object='suites/tests-test_utils.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_hashtable.o `test -f 'test_hashtable.c' || echo '$(srcdir)/'`test_hashtable.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_utils.o `test -f 'suites/test_utils.c' || echo '$(srcdir)/'`suites/test_utils.c -test_runner-test_hashtable.obj: test_hashtable.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_hashtable.obj -MD -MP -MF $(DEPDIR)/test_runner-test_hashtable.Tpo -c -o test_runner-test_hashtable.obj `if test -f 'test_hashtable.c'; then $(CYGPATH_W) 'test_hashtable.c'; else $(CYGPATH_W) '$(srcdir)/test_hashtable.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_hashtable.Tpo $(DEPDIR)/test_runner-test_hashtable.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_hashtable.c' object='test_runner-test_hashtable.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_utils.obj: suites/test_utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_utils.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_utils.Tpo -c -o suites/tests-test_utils.obj `if test -f 'suites/test_utils.c'; then $(CYGPATH_W) 'suites/test_utils.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_utils.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_utils.Tpo suites/$(DEPDIR)/tests-test_utils.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_utils.c' object='suites/tests-test_utils.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_hashtable.obj `if test -f 'test_hashtable.c'; then $(CYGPATH_W) 'test_hashtable.c'; else $(CYGPATH_W) '$(srcdir)/test_hashtable.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_utils.obj `if test -f 'suites/test_utils.c'; then $(CYGPATH_W) 'suites/test_utils.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_utils.c'; fi` -test_runner-test_identification.o: test_identification.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_identification.o -MD -MP -MF $(DEPDIR)/test_runner-test_identification.Tpo -c -o test_runner-test_identification.o `test -f 'test_identification.c' || echo '$(srcdir)/'`test_identification.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_identification.Tpo $(DEPDIR)/test_runner-test_identification.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_identification.c' object='test_runner-test_identification.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_settings.o: suites/test_settings.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_settings.o -MD -MP -MF suites/$(DEPDIR)/tests-test_settings.Tpo -c -o suites/tests-test_settings.o `test -f 'suites/test_settings.c' || echo '$(srcdir)/'`suites/test_settings.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_settings.Tpo suites/$(DEPDIR)/tests-test_settings.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_settings.c' object='suites/tests-test_settings.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_identification.o `test -f 'test_identification.c' || echo '$(srcdir)/'`test_identification.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_settings.o `test -f 'suites/test_settings.c' || echo '$(srcdir)/'`suites/test_settings.c -test_runner-test_identification.obj: test_identification.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_identification.obj -MD -MP -MF $(DEPDIR)/test_runner-test_identification.Tpo -c -o test_runner-test_identification.obj `if test -f 'test_identification.c'; then $(CYGPATH_W) 'test_identification.c'; else $(CYGPATH_W) '$(srcdir)/test_identification.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_identification.Tpo $(DEPDIR)/test_runner-test_identification.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_identification.c' object='test_runner-test_identification.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_settings.obj: suites/test_settings.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_settings.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_settings.Tpo -c -o suites/tests-test_settings.obj `if test -f 'suites/test_settings.c'; then $(CYGPATH_W) 'suites/test_settings.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_settings.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_settings.Tpo suites/$(DEPDIR)/tests-test_settings.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_settings.c' object='suites/tests-test_settings.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_identification.obj `if test -f 'test_identification.c'; then $(CYGPATH_W) 'test_identification.c'; else $(CYGPATH_W) '$(srcdir)/test_identification.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_settings.obj `if test -f 'suites/test_settings.c'; then $(CYGPATH_W) 'suites/test_settings.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_settings.c'; fi` -test_runner-test_threading.o: test_threading.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_threading.o -MD -MP -MF $(DEPDIR)/test_runner-test_threading.Tpo -c -o test_runner-test_threading.o `test -f 'test_threading.c' || echo '$(srcdir)/'`test_threading.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_threading.Tpo $(DEPDIR)/test_runner-test_threading.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_threading.c' object='test_runner-test_threading.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_vectors.o: suites/test_vectors.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_vectors.o -MD -MP -MF suites/$(DEPDIR)/tests-test_vectors.Tpo -c -o suites/tests-test_vectors.o `test -f 'suites/test_vectors.c' || echo '$(srcdir)/'`suites/test_vectors.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_vectors.Tpo suites/$(DEPDIR)/tests-test_vectors.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_vectors.c' object='suites/tests-test_vectors.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_threading.o `test -f 'test_threading.c' || echo '$(srcdir)/'`test_threading.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_vectors.o `test -f 'suites/test_vectors.c' || echo '$(srcdir)/'`suites/test_vectors.c -test_runner-test_threading.obj: test_threading.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_threading.obj -MD -MP -MF $(DEPDIR)/test_runner-test_threading.Tpo -c -o test_runner-test_threading.obj `if test -f 'test_threading.c'; then $(CYGPATH_W) 'test_threading.c'; else $(CYGPATH_W) '$(srcdir)/test_threading.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_threading.Tpo $(DEPDIR)/test_runner-test_threading.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_threading.c' object='test_runner-test_threading.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_vectors.obj: suites/test_vectors.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_vectors.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_vectors.Tpo -c -o suites/tests-test_vectors.obj `if test -f 'suites/test_vectors.c'; then $(CYGPATH_W) 'suites/test_vectors.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_vectors.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_vectors.Tpo suites/$(DEPDIR)/tests-test_vectors.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_vectors.c' object='suites/tests-test_vectors.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_threading.obj `if test -f 'test_threading.c'; then $(CYGPATH_W) 'test_threading.c'; else $(CYGPATH_W) '$(srcdir)/test_threading.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_vectors.obj `if test -f 'suites/test_vectors.c'; then $(CYGPATH_W) 'suites/test_vectors.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_vectors.c'; fi` -test_runner-test_utils.o: test_utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_utils.o -MD -MP -MF $(DEPDIR)/test_runner-test_utils.Tpo -c -o test_runner-test_utils.o `test -f 'test_utils.c' || echo '$(srcdir)/'`test_utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_utils.Tpo $(DEPDIR)/test_runner-test_utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_utils.c' object='test_runner-test_utils.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_array.o: suites/test_array.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_array.o -MD -MP -MF suites/$(DEPDIR)/tests-test_array.Tpo -c -o suites/tests-test_array.o `test -f 'suites/test_array.c' || echo '$(srcdir)/'`suites/test_array.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_array.Tpo suites/$(DEPDIR)/tests-test_array.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_array.c' object='suites/tests-test_array.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_utils.o `test -f 'test_utils.c' || echo '$(srcdir)/'`test_utils.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_array.o `test -f 'suites/test_array.c' || echo '$(srcdir)/'`suites/test_array.c -test_runner-test_utils.obj: test_utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_utils.obj -MD -MP -MF $(DEPDIR)/test_runner-test_utils.Tpo -c -o test_runner-test_utils.obj `if test -f 'test_utils.c'; then $(CYGPATH_W) 'test_utils.c'; else $(CYGPATH_W) '$(srcdir)/test_utils.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_utils.Tpo $(DEPDIR)/test_runner-test_utils.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_utils.c' object='test_runner-test_utils.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_array.obj: suites/test_array.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_array.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_array.Tpo -c -o suites/tests-test_array.obj `if test -f 'suites/test_array.c'; then $(CYGPATH_W) 'suites/test_array.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_array.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_array.Tpo suites/$(DEPDIR)/tests-test_array.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_array.c' object='suites/tests-test_array.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_utils.obj `if test -f 'test_utils.c'; then $(CYGPATH_W) 'test_utils.c'; else $(CYGPATH_W) '$(srcdir)/test_utils.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_array.obj `if test -f 'suites/test_array.c'; then $(CYGPATH_W) 'suites/test_array.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_array.c'; fi` -test_runner-test_vectors.o: test_vectors.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_vectors.o -MD -MP -MF $(DEPDIR)/test_runner-test_vectors.Tpo -c -o test_runner-test_vectors.o `test -f 'test_vectors.c' || echo '$(srcdir)/'`test_vectors.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_vectors.Tpo $(DEPDIR)/test_runner-test_vectors.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_vectors.c' object='test_runner-test_vectors.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_ecdsa.o: suites/test_ecdsa.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_ecdsa.o -MD -MP -MF suites/$(DEPDIR)/tests-test_ecdsa.Tpo -c -o suites/tests-test_ecdsa.o `test -f 'suites/test_ecdsa.c' || echo '$(srcdir)/'`suites/test_ecdsa.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_ecdsa.Tpo suites/$(DEPDIR)/tests-test_ecdsa.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_ecdsa.c' object='suites/tests-test_ecdsa.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_vectors.o `test -f 'test_vectors.c' || echo '$(srcdir)/'`test_vectors.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_ecdsa.o `test -f 'suites/test_ecdsa.c' || echo '$(srcdir)/'`suites/test_ecdsa.c -test_runner-test_vectors.obj: test_vectors.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_vectors.obj -MD -MP -MF $(DEPDIR)/test_runner-test_vectors.Tpo -c -o test_runner-test_vectors.obj `if test -f 'test_vectors.c'; then $(CYGPATH_W) 'test_vectors.c'; else $(CYGPATH_W) '$(srcdir)/test_vectors.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_vectors.Tpo $(DEPDIR)/test_runner-test_vectors.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_vectors.c' object='test_runner-test_vectors.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_ecdsa.obj: suites/test_ecdsa.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_ecdsa.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_ecdsa.Tpo -c -o suites/tests-test_ecdsa.obj `if test -f 'suites/test_ecdsa.c'; then $(CYGPATH_W) 'suites/test_ecdsa.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_ecdsa.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_ecdsa.Tpo suites/$(DEPDIR)/tests-test_ecdsa.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_ecdsa.c' object='suites/tests-test_ecdsa.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_vectors.obj `if test -f 'test_vectors.c'; then $(CYGPATH_W) 'test_vectors.c'; else $(CYGPATH_W) '$(srcdir)/test_vectors.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_ecdsa.obj `if test -f 'suites/test_ecdsa.c'; then $(CYGPATH_W) 'suites/test_ecdsa.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_ecdsa.c'; fi` -test_runner-test_array.o: test_array.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_array.o -MD -MP -MF $(DEPDIR)/test_runner-test_array.Tpo -c -o test_runner-test_array.o `test -f 'test_array.c' || echo '$(srcdir)/'`test_array.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_array.Tpo $(DEPDIR)/test_runner-test_array.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_array.c' object='test_runner-test_array.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_rsa.o: suites/test_rsa.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_rsa.o -MD -MP -MF suites/$(DEPDIR)/tests-test_rsa.Tpo -c -o suites/tests-test_rsa.o `test -f 'suites/test_rsa.c' || echo '$(srcdir)/'`suites/test_rsa.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_rsa.Tpo suites/$(DEPDIR)/tests-test_rsa.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_rsa.c' object='suites/tests-test_rsa.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_array.o `test -f 'test_array.c' || echo '$(srcdir)/'`test_array.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_rsa.o `test -f 'suites/test_rsa.c' || echo '$(srcdir)/'`suites/test_rsa.c -test_runner-test_array.obj: test_array.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_array.obj -MD -MP -MF $(DEPDIR)/test_runner-test_array.Tpo -c -o test_runner-test_array.obj `if test -f 'test_array.c'; then $(CYGPATH_W) 'test_array.c'; else $(CYGPATH_W) '$(srcdir)/test_array.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_array.Tpo $(DEPDIR)/test_runner-test_array.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_array.c' object='test_runner-test_array.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_rsa.obj: suites/test_rsa.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_rsa.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_rsa.Tpo -c -o suites/tests-test_rsa.obj `if test -f 'suites/test_rsa.c'; then $(CYGPATH_W) 'suites/test_rsa.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_rsa.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_rsa.Tpo suites/$(DEPDIR)/tests-test_rsa.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_rsa.c' object='suites/tests-test_rsa.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_array.obj `if test -f 'test_array.c'; then $(CYGPATH_W) 'test_array.c'; else $(CYGPATH_W) '$(srcdir)/test_array.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_rsa.obj `if test -f 'suites/test_rsa.c'; then $(CYGPATH_W) 'suites/test_rsa.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_rsa.c'; fi` -test_runner-test_ecdsa.o: test_ecdsa.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_ecdsa.o -MD -MP -MF $(DEPDIR)/test_runner-test_ecdsa.Tpo -c -o test_runner-test_ecdsa.o `test -f 'test_ecdsa.c' || echo '$(srcdir)/'`test_ecdsa.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_ecdsa.Tpo $(DEPDIR)/test_runner-test_ecdsa.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_ecdsa.c' object='test_runner-test_ecdsa.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_host.o: suites/test_host.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_host.o -MD -MP -MF suites/$(DEPDIR)/tests-test_host.Tpo -c -o suites/tests-test_host.o `test -f 'suites/test_host.c' || echo '$(srcdir)/'`suites/test_host.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_host.Tpo suites/$(DEPDIR)/tests-test_host.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_host.c' object='suites/tests-test_host.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_ecdsa.o `test -f 'test_ecdsa.c' || echo '$(srcdir)/'`test_ecdsa.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_host.o `test -f 'suites/test_host.c' || echo '$(srcdir)/'`suites/test_host.c -test_runner-test_ecdsa.obj: test_ecdsa.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_ecdsa.obj -MD -MP -MF $(DEPDIR)/test_runner-test_ecdsa.Tpo -c -o test_runner-test_ecdsa.obj `if test -f 'test_ecdsa.c'; then $(CYGPATH_W) 'test_ecdsa.c'; else $(CYGPATH_W) '$(srcdir)/test_ecdsa.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_ecdsa.Tpo $(DEPDIR)/test_runner-test_ecdsa.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_ecdsa.c' object='test_runner-test_ecdsa.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_host.obj: suites/test_host.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_host.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_host.Tpo -c -o suites/tests-test_host.obj `if test -f 'suites/test_host.c'; then $(CYGPATH_W) 'suites/test_host.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_host.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_host.Tpo suites/$(DEPDIR)/tests-test_host.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_host.c' object='suites/tests-test_host.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_ecdsa.obj `if test -f 'test_ecdsa.c'; then $(CYGPATH_W) 'test_ecdsa.c'; else $(CYGPATH_W) '$(srcdir)/test_ecdsa.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_host.obj `if test -f 'suites/test_host.c'; then $(CYGPATH_W) 'suites/test_host.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_host.c'; fi` -test_runner-test_rsa.o: test_rsa.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_rsa.o -MD -MP -MF $(DEPDIR)/test_runner-test_rsa.Tpo -c -o test_runner-test_rsa.o `test -f 'test_rsa.c' || echo '$(srcdir)/'`test_rsa.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_rsa.Tpo $(DEPDIR)/test_runner-test_rsa.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_rsa.c' object='test_runner-test_rsa.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_hasher.o: suites/test_hasher.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_hasher.o -MD -MP -MF suites/$(DEPDIR)/tests-test_hasher.Tpo -c -o suites/tests-test_hasher.o `test -f 'suites/test_hasher.c' || echo '$(srcdir)/'`suites/test_hasher.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_hasher.Tpo suites/$(DEPDIR)/tests-test_hasher.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_hasher.c' object='suites/tests-test_hasher.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_rsa.o `test -f 'test_rsa.c' || echo '$(srcdir)/'`test_rsa.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_hasher.o `test -f 'suites/test_hasher.c' || echo '$(srcdir)/'`suites/test_hasher.c -test_runner-test_rsa.obj: test_rsa.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_rsa.obj -MD -MP -MF $(DEPDIR)/test_runner-test_rsa.Tpo -c -o test_runner-test_rsa.obj `if test -f 'test_rsa.c'; then $(CYGPATH_W) 'test_rsa.c'; else $(CYGPATH_W) '$(srcdir)/test_rsa.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_rsa.Tpo $(DEPDIR)/test_runner-test_rsa.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_rsa.c' object='test_runner-test_rsa.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_hasher.obj: suites/test_hasher.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_hasher.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_hasher.Tpo -c -o suites/tests-test_hasher.obj `if test -f 'suites/test_hasher.c'; then $(CYGPATH_W) 'suites/test_hasher.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_hasher.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_hasher.Tpo suites/$(DEPDIR)/tests-test_hasher.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_hasher.c' object='suites/tests-test_hasher.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_rsa.obj `if test -f 'test_rsa.c'; then $(CYGPATH_W) 'test_rsa.c'; else $(CYGPATH_W) '$(srcdir)/test_rsa.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_hasher.obj `if test -f 'suites/test_hasher.c'; then $(CYGPATH_W) 'suites/test_hasher.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_hasher.c'; fi` -test_runner-test_host.o: test_host.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_host.o -MD -MP -MF $(DEPDIR)/test_runner-test_host.Tpo -c -o test_runner-test_host.o `test -f 'test_host.c' || echo '$(srcdir)/'`test_host.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_host.Tpo $(DEPDIR)/test_runner-test_host.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_host.c' object='test_runner-test_host.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_crypter.o: suites/test_crypter.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_crypter.o -MD -MP -MF suites/$(DEPDIR)/tests-test_crypter.Tpo -c -o suites/tests-test_crypter.o `test -f 'suites/test_crypter.c' || echo '$(srcdir)/'`suites/test_crypter.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_crypter.Tpo suites/$(DEPDIR)/tests-test_crypter.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_crypter.c' object='suites/tests-test_crypter.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_host.o `test -f 'test_host.c' || echo '$(srcdir)/'`test_host.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_crypter.o `test -f 'suites/test_crypter.c' || echo '$(srcdir)/'`suites/test_crypter.c -test_runner-test_host.obj: test_host.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_host.obj -MD -MP -MF $(DEPDIR)/test_runner-test_host.Tpo -c -o test_runner-test_host.obj `if test -f 'test_host.c'; then $(CYGPATH_W) 'test_host.c'; else $(CYGPATH_W) '$(srcdir)/test_host.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_host.Tpo $(DEPDIR)/test_runner-test_host.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_host.c' object='test_runner-test_host.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_crypter.obj: suites/test_crypter.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_crypter.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_crypter.Tpo -c -o suites/tests-test_crypter.obj `if test -f 'suites/test_crypter.c'; then $(CYGPATH_W) 'suites/test_crypter.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_crypter.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_crypter.Tpo suites/$(DEPDIR)/tests-test_crypter.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_crypter.c' object='suites/tests-test_crypter.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_host.obj `if test -f 'test_host.c'; then $(CYGPATH_W) 'test_host.c'; else $(CYGPATH_W) '$(srcdir)/test_host.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_crypter.obj `if test -f 'suites/test_crypter.c'; then $(CYGPATH_W) 'suites/test_crypter.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_crypter.c'; fi` -test_runner-test_printf.o: test_printf.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_printf.o -MD -MP -MF $(DEPDIR)/test_runner-test_printf.Tpo -c -o test_runner-test_printf.o `test -f 'test_printf.c' || echo '$(srcdir)/'`test_printf.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_printf.Tpo $(DEPDIR)/test_runner-test_printf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_printf.c' object='test_runner-test_printf.o' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_pen.o: suites/test_pen.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_pen.o -MD -MP -MF suites/$(DEPDIR)/tests-test_pen.Tpo -c -o suites/tests-test_pen.o `test -f 'suites/test_pen.c' || echo '$(srcdir)/'`suites/test_pen.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_pen.Tpo suites/$(DEPDIR)/tests-test_pen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_pen.c' object='suites/tests-test_pen.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_printf.o `test -f 'test_printf.c' || echo '$(srcdir)/'`test_printf.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_pen.o `test -f 'suites/test_pen.c' || echo '$(srcdir)/'`suites/test_pen.c -test_runner-test_printf.obj: test_printf.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -MT test_runner-test_printf.obj -MD -MP -MF $(DEPDIR)/test_runner-test_printf.Tpo -c -o test_runner-test_printf.obj `if test -f 'test_printf.c'; then $(CYGPATH_W) 'test_printf.c'; else $(CYGPATH_W) '$(srcdir)/test_printf.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_runner-test_printf.Tpo $(DEPDIR)/test_runner-test_printf.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_printf.c' object='test_runner-test_printf.obj' libtool=no @AMDEPBACKSLASH@ +suites/tests-test_pen.obj: suites/test_pen.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_pen.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_pen.Tpo -c -o suites/tests-test_pen.obj `if test -f 'suites/test_pen.c'; then $(CYGPATH_W) 'suites/test_pen.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_pen.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_pen.Tpo suites/$(DEPDIR)/tests-test_pen.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_pen.c' object='suites/tests-test_pen.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_runner_CFLAGS) $(CFLAGS) -c -o test_runner-test_printf.obj `if test -f 'test_printf.c'; then $(CYGPATH_W) 'test_printf.c'; else $(CYGPATH_W) '$(srcdir)/test_printf.c'; fi` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_pen.obj `if test -f 'suites/test_pen.c'; then $(CYGPATH_W) 'suites/test_pen.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_pen.c'; fi` + +suites/tests-test_asn1.o: suites/test_asn1.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_asn1.o -MD -MP -MF suites/$(DEPDIR)/tests-test_asn1.Tpo -c -o suites/tests-test_asn1.o `test -f 'suites/test_asn1.c' || echo '$(srcdir)/'`suites/test_asn1.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_asn1.Tpo suites/$(DEPDIR)/tests-test_asn1.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_asn1.c' object='suites/tests-test_asn1.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_asn1.o `test -f 'suites/test_asn1.c' || echo '$(srcdir)/'`suites/test_asn1.c + +suites/tests-test_asn1.obj: suites/test_asn1.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_asn1.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_asn1.Tpo -c -o suites/tests-test_asn1.obj `if test -f 'suites/test_asn1.c'; then $(CYGPATH_W) 'suites/test_asn1.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_asn1.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_asn1.Tpo suites/$(DEPDIR)/tests-test_asn1.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_asn1.c' object='suites/tests-test_asn1.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_asn1.obj `if test -f 'suites/test_asn1.c'; then $(CYGPATH_W) 'suites/test_asn1.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_asn1.c'; fi` + +suites/tests-test_asn1_parser.o: suites/test_asn1_parser.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_asn1_parser.o -MD -MP -MF suites/$(DEPDIR)/tests-test_asn1_parser.Tpo -c -o suites/tests-test_asn1_parser.o `test -f 'suites/test_asn1_parser.c' || echo '$(srcdir)/'`suites/test_asn1_parser.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_asn1_parser.Tpo suites/$(DEPDIR)/tests-test_asn1_parser.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_asn1_parser.c' object='suites/tests-test_asn1_parser.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_asn1_parser.o `test -f 'suites/test_asn1_parser.c' || echo '$(srcdir)/'`suites/test_asn1_parser.c + +suites/tests-test_asn1_parser.obj: suites/test_asn1_parser.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_asn1_parser.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_asn1_parser.Tpo -c -o suites/tests-test_asn1_parser.obj `if test -f 'suites/test_asn1_parser.c'; then $(CYGPATH_W) 'suites/test_asn1_parser.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_asn1_parser.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_asn1_parser.Tpo suites/$(DEPDIR)/tests-test_asn1_parser.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_asn1_parser.c' object='suites/tests-test_asn1_parser.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_asn1_parser.obj `if test -f 'suites/test_asn1_parser.c'; then $(CYGPATH_W) 'suites/test_asn1_parser.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_asn1_parser.c'; fi` + +suites/tests-test_printf.o: suites/test_printf.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_printf.o -MD -MP -MF suites/$(DEPDIR)/tests-test_printf.Tpo -c -o suites/tests-test_printf.o `test -f 'suites/test_printf.c' || echo '$(srcdir)/'`suites/test_printf.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_printf.Tpo suites/$(DEPDIR)/tests-test_printf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_printf.c' object='suites/tests-test_printf.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_printf.o `test -f 'suites/test_printf.c' || echo '$(srcdir)/'`suites/test_printf.c + +suites/tests-test_printf.obj: suites/test_printf.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_printf.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_printf.Tpo -c -o suites/tests-test_printf.obj `if test -f 'suites/test_printf.c'; then $(CYGPATH_W) 'suites/test_printf.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_printf.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_printf.Tpo suites/$(DEPDIR)/tests-test_printf.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_printf.c' object='suites/tests-test_printf.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_printf.obj `if test -f 'suites/test_printf.c'; then $(CYGPATH_W) 'suites/test_printf.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_printf.c'; fi` + +suites/tests-test_test_rng.o: suites/test_test_rng.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_test_rng.o -MD -MP -MF suites/$(DEPDIR)/tests-test_test_rng.Tpo -c -o suites/tests-test_test_rng.o `test -f 'suites/test_test_rng.c' || echo '$(srcdir)/'`suites/test_test_rng.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_test_rng.Tpo suites/$(DEPDIR)/tests-test_test_rng.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_test_rng.c' object='suites/tests-test_test_rng.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_test_rng.o `test -f 'suites/test_test_rng.c' || echo '$(srcdir)/'`suites/test_test_rng.c + +suites/tests-test_test_rng.obj: suites/test_test_rng.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_test_rng.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_test_rng.Tpo -c -o suites/tests-test_test_rng.obj `if test -f 'suites/test_test_rng.c'; then $(CYGPATH_W) 'suites/test_test_rng.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_test_rng.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_test_rng.Tpo suites/$(DEPDIR)/tests-test_test_rng.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_test_rng.c' object='suites/tests-test_test_rng.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_test_rng.obj `if test -f 'suites/test_test_rng.c'; then $(CYGPATH_W) 'suites/test_test_rng.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_test_rng.c'; fi` + +suites/tests-test_ntru.o: suites/test_ntru.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_ntru.o -MD -MP -MF suites/$(DEPDIR)/tests-test_ntru.Tpo -c -o suites/tests-test_ntru.o `test -f 'suites/test_ntru.c' || echo '$(srcdir)/'`suites/test_ntru.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_ntru.Tpo suites/$(DEPDIR)/tests-test_ntru.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_ntru.c' object='suites/tests-test_ntru.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_ntru.o `test -f 'suites/test_ntru.c' || echo '$(srcdir)/'`suites/test_ntru.c + +suites/tests-test_ntru.obj: suites/test_ntru.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -MT suites/tests-test_ntru.obj -MD -MP -MF suites/$(DEPDIR)/tests-test_ntru.Tpo -c -o suites/tests-test_ntru.obj `if test -f 'suites/test_ntru.c'; then $(CYGPATH_W) 'suites/test_ntru.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_ntru.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) suites/$(DEPDIR)/tests-test_ntru.Tpo suites/$(DEPDIR)/tests-test_ntru.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='suites/test_ntru.c' object='suites/tests-test_ntru.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tests_CFLAGS) $(CFLAGS) -c -o suites/tests-test_ntru.obj `if test -f 'suites/test_ntru.c'; then $(CYGPATH_W) 'suites/test_ntru.c'; else $(CYGPATH_W) '$(srcdir)/suites/test_ntru.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs + -rm -rf utils/.libs utils/_libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique @@ -1022,168 +1183,98 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - else \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ else \ - color_start= color_end=; \ + skipped="($$skip tests were not run)"; \ fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all $(check_PROGRAMS) - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -test_runner.log: test_runner$(EXEEXT) - @p='test_runner$(EXEEXT)'; \ - b='test_runner'; \ - $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -1216,7 +1307,7 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) $(check_LTLIBRARIES) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile @@ -1241,26 +1332,27 @@ install-strip: "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f suites/$(DEPDIR)/$(am__dirstamp) + -rm -f suites/$(am__dirstamp) + -rm -f utils/$(DEPDIR)/$(am__dirstamp) + -rm -f utils/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ - mostlyclean-am +clean-am: clean-checkLTLIBRARIES clean-checkPROGRAMS clean-generic \ + clean-libtool mostlyclean-am distclean: distclean-am - -rm -rf ./$(DEPDIR) + -rm -rf ./$(DEPDIR) suites/$(DEPDIR) utils/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -1306,7 +1398,7 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) + -rm -rf ./$(DEPDIR) suites/$(DEPDIR) utils/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1328,18 +1420,18 @@ uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ - clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ - ctags ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - recheck tags tags-am uninstall uninstall-am + clean-checkLTLIBRARIES clean-checkPROGRAMS clean-generic \ + clean-libtool cscopelist-am ctags ctags-am distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/src/libstrongswan/tests/test_array.c b/src/libstrongswan/tests/suites/test_array.c index 2220d5a2b..ba2aff460 100644 --- a/src/libstrongswan/tests/test_array.c +++ b/src/libstrongswan/tests/suites/test_array.c @@ -1,4 +1,7 @@ /* + * Copyright (C) 2014 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * * Copyright (C) 2013 Martin Willi * Copyright (C) 2013 revosec AG * @@ -35,6 +38,14 @@ START_TEST(test_append_ptr) /* 3, 4 */ + ck_assert(array_get(array, ARRAY_HEAD, &x)); + ck_assert_int_eq(x, 3); + ck_assert(array_get(array, 1, &x)); + ck_assert_int_eq(x, 4); + ck_assert(array_get(array, ARRAY_TAIL, &x)); + ck_assert_int_eq(x, 4); + ck_assert(!array_get(array, 3, &x)); + array_insert(array, ARRAY_HEAD, (void*)(uintptr_t)1); array_insert(array, 1, (void*)(uintptr_t)2); ck_assert_int_eq(array_count(array), 4); @@ -108,6 +119,14 @@ START_TEST(test_append_obj) /* 3, 4 */ + ck_assert(array_get(array, ARRAY_HEAD, &x)); + ck_assert_int_eq(x, 3); + ck_assert(array_get(array, 1, &x)); + ck_assert_int_eq(x, 4); + ck_assert(array_get(array, ARRAY_TAIL, &x)); + ck_assert_int_eq(x, 4); + ck_assert(!array_get(array, 3, &x)); + array_insert(array, ARRAY_HEAD, &y[1]); array_insert(array, 1, &y[2]); ck_assert_int_eq(array_count(array), 4); @@ -258,6 +277,149 @@ START_TEST(test_enumerate) } END_TEST +static int comp_obj(const void *a, const void *b, void *arg) +{ + ck_assert_str_eq(arg, "arg"); + return *(int*)a - *(int*)b; +} + +START_TEST(test_sort_obj) +{ + array_t *array; + int x[][3] = { + {1, 2, 3}, + {1, 3, 2}, + {2, 1, 3}, + {2, 3, 1}, + {3, 1, 2}, + {3, 2, 1}, + }; + char *arg = "arg"; + int i, v; + + for (i = 0; i < countof(x); i++) + { + array = array_create(sizeof(x[i][0]), 0); + array_insert(array, ARRAY_TAIL, &x[i][0]); + array_insert(array, ARRAY_TAIL, &x[i][1]); + array_insert(array, ARRAY_TAIL, &x[i][2]); + + array_sort(array, comp_obj, arg); + + ck_assert(array_get(array, 0, &v)); + ck_assert_int_eq(v, 1); + ck_assert(array_get(array, 1, &v)); + ck_assert_int_eq(v, 2); + ck_assert(array_get(array, 2, &v)); + ck_assert_int_eq(v, 3); + + array_destroy(array); + } +} +END_TEST + +static int comp_ptr(const void *a, const void *b, void *arg) +{ + ck_assert_str_eq(arg, "arg"); + return strcmp(a, b); +} + +START_TEST(test_sort_ptr) +{ + array_t *array; + char *x[][3] = { + {"a", "b", "c"}, + {"a", "c", "b"}, + {"b", "a", "c"}, + {"b", "c", "a"}, + {"c", "a", "b"}, + {"c", "b", "a"}, + }; + char *v, *arg = "arg"; + int i; + + for (i = 0; i < countof(x); i++) + { + array = array_create(0, 0); + array_insert(array, ARRAY_TAIL, x[i][0]); + array_insert(array, ARRAY_TAIL, x[i][1]); + array_insert(array, ARRAY_TAIL, x[i][2]); + + array_sort(array, comp_ptr, arg); + + ck_assert(array_get(array, 0, &v)); + ck_assert_str_eq(v, "a"); + ck_assert(array_get(array, 1, &v)); + ck_assert_str_eq(v, "b"); + ck_assert(array_get(array, 2, &v)); + ck_assert_str_eq(v, "c"); + + array_destroy(array); + } +} +END_TEST + +static int comp_search_obj(const void *a, const void *b) +{ + return *(int*)a - *(int*)b; +} + +START_TEST(test_bsearch_obj) +{ + array_t *array; + int x[] = { 3, 2, 1 }; + int k, v; + + array = array_create(sizeof(x[0]), 0); + array_insert(array, ARRAY_TAIL, &x[0]); + array_insert(array, ARRAY_TAIL, &x[1]); + array_insert(array, ARRAY_TAIL, &x[2]); + + array_sort(array, (void*)comp_search_obj, NULL); + + k = 0; + ck_assert_int_eq(array_bsearch(array, &k, comp_search_obj, &v), -1); + for (k = 1; k < 4; k++) + { + ck_assert_int_eq(array_bsearch(array, &k, comp_search_obj, &v), k-1); + ck_assert_int_eq(v, k); + } + k = 4; + ck_assert_int_eq(array_bsearch(array, &k, comp_search_obj, &v), -1); + array_destroy(array); +} +END_TEST + +static int comp_search_ptr(const void *a, const void *b) +{ + return strcmp(a, b); +} + +START_TEST(test_bsearch_ptr) +{ + array_t *array; + char *x[] = {"c", "b", "a"}; + char *v; + + array = array_create(0, 0); + array_insert(array, ARRAY_TAIL, x[0]); + array_insert(array, ARRAY_TAIL, x[1]); + array_insert(array, ARRAY_TAIL, x[2]); + + array_sort(array, (void*)comp_search_ptr, NULL); + + ck_assert_int_eq(array_bsearch(array, "abc", comp_search_ptr, &v), -1); + ck_assert_int_eq(array_bsearch(array, "a", comp_search_ptr, &v), 0); + ck_assert_str_eq(v, "a"); + ck_assert_int_eq(array_bsearch(array, "b", comp_search_ptr, &v), 1); + ck_assert_str_eq(v, "b"); + ck_assert_int_eq(array_bsearch(array, "c", comp_search_ptr, &v), 2); + ck_assert_str_eq(v, "c"); + + array_destroy(array); +} +END_TEST + static void invoke(void *data, int idx, void *user) { int *y = user, *x = data; @@ -336,11 +498,11 @@ Suite *array_suite_create() s = suite_create("array"); - tc = tcase_create("add/remove ptr"); + tc = tcase_create("add/get/remove ptr"); tcase_add_test(tc, test_append_ptr); suite_add_tcase(s, tc); - tc = tcase_create("add/remove obj"); + tc = tcase_create("add/get/remove obj"); tcase_add_test(tc, test_append_obj); suite_add_tcase(s, tc); @@ -348,6 +510,16 @@ Suite *array_suite_create() tcase_add_test(tc, test_enumerate); suite_add_tcase(s, tc); + tc = tcase_create("sort"); + tcase_add_test(tc, test_sort_obj); + tcase_add_test(tc, test_sort_ptr); + suite_add_tcase(s, tc); + + tc = tcase_create("bsearch"); + tcase_add_test(tc, test_bsearch_obj); + tcase_add_test(tc, test_bsearch_ptr); + suite_add_tcase(s, tc); + tc = tcase_create("invoke"); tcase_add_test(tc, test_invoke); suite_add_tcase(s, tc); diff --git a/src/libstrongswan/tests/suites/test_asn1.c b/src/libstrongswan/tests/suites/test_asn1.c new file mode 100644 index 000000000..d0cd7e6e4 --- /dev/null +++ b/src/libstrongswan/tests/suites/test_asn1.c @@ -0,0 +1,869 @@ +/* + * Copyright (C) 2013 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + + +#include "test_suite.h" + +#include <asn1/asn1.h> +#include <asn1/oid.h> +#include <utils/chunk.h> + +/******************************************************************************* + * algorithm_identifier + */ + +START_TEST(test_asn1_algorithmIdentifier) +{ + typedef struct { + int n; + chunk_t algid; + } testdata_t; + + testdata_t test[] = { + { OID_ECDSA_WITH_SHA1, chunk_from_chars(0x30, 0x09, 0x06, 0x07, + 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x01) }, + { OID_SHA1_WITH_RSA, chunk_from_chars(0x30, 0x0d, 0x06, 0x09, + 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00) }, + }; + + chunk_t algid; + int i; + + for (i = 0; i < countof(test); i++) + { + algid = asn1_algorithmIdentifier(test[i].n); + ck_assert(chunk_equals(algid, test[i].algid)); + free(algid.ptr); + } +} +END_TEST + +/******************************************************************************* + * parse_algorithm_identifier + */ + +START_TEST(test_asn1_parse_algorithmIdentifier) +{ + typedef struct { + int alg; + bool empty; + chunk_t parameters; + } testdata_t; + + testdata_t test[] = { + { OID_ECDSA_WITH_SHA1, TRUE, chunk_empty }, + { OID_SHA1_WITH_RSA, TRUE, chunk_from_chars(0x05, 0x00) }, + { OID_3DES_EDE_CBC, FALSE, chunk_from_chars(0x04, 0x01, 0xaa) }, + { OID_PBKDF2, FALSE, chunk_from_chars(0x30, 0x01, 0xaa) } + }; + + chunk_t algid, parameters; + int i, alg; + + for (i = 0; i < countof(test); i++) + { + algid = asn1_wrap(ASN1_SEQUENCE, "mc", + asn1_build_known_oid(test[i].alg), test[i].parameters); + parameters = chunk_empty; + if (i == 2) + { + alg = asn1_parse_algorithmIdentifier(algid, 0, NULL); + } + else + { + alg = asn1_parse_algorithmIdentifier(algid, 0, ¶meters); + if (test[i].empty) + { + ck_assert(parameters.len == 0 && parameters.ptr == NULL); + } + else + { + ck_assert(chunk_equals(parameters, test[i].parameters)); + } + } + ck_assert(alg == test[i].alg); + chunk_free(&algid); + } +} +END_TEST + +/******************************************************************************* + * known_oid + */ + +START_TEST(test_asn1_known_oid) +{ + typedef struct { + int n; + chunk_t oid; + } testdata_t; + + testdata_t test[] = { + { OID_UNKNOWN, chunk_empty }, + { OID_UNKNOWN, chunk_from_chars(0x55, 0x04, 0x02) }, + { OID_COUNTRY, chunk_from_chars(0x55, 0x04, 0x06) }, + { OID_STRONGSWAN, chunk_from_chars(0x2b, 0x06, 0x01, 0x04, 0x01, + 0x82, 0xa0, 0x2a, 0x01) } + }; + + int i; + + for (i = 0; i < countof(test); i++) + { + ck_assert(asn1_known_oid(test[i].oid) == test[i].n); + } +} +END_TEST + +/******************************************************************************* + * build_known_oid + */ + +START_TEST(test_asn1_build_known_oid) +{ + typedef struct { + int n; + chunk_t oid; + } testdata_t; + + testdata_t test[] = { + { OID_UNKNOWN, chunk_empty }, + { OID_MAX, chunk_empty }, + { OID_COUNTRY, chunk_from_chars(0x06, 0x03, 0x55, 0x04, 0x06) }, + { OID_STRONGSWAN, chunk_from_chars(0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, + 0x01, 0x82, 0xa0, 0x2a, 0x01) } + }; + + int i; + chunk_t oid = chunk_empty; + + for (i = 0; i < countof(test); i++) + { + oid = asn1_build_known_oid(test[i].n); + if (test[i].oid.len == 0) + { + ck_assert(oid.len == 0 && oid.ptr == NULL); + } + else + { + ck_assert(chunk_equals(oid, test[i].oid)); + chunk_free(&oid); + } + } +} +END_TEST + +/******************************************************************************* + * oid_from_string + */ + +START_TEST(test_asn1_oid_from_string) +{ + typedef struct { + char *string; + chunk_t oid; + } testdata_t; + + testdata_t test[] = { + { "", chunk_empty }, + { " ", chunk_empty }, + { "0.2.262.1", chunk_from_chars( + 0x02, 0x82, 0x06, 0x01) }, + { "1.2.840.10045.4.1", chunk_from_chars( + 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x01) }, + { "1.3.6.1.4.1.36906.1", chunk_from_chars( + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa0, 0x2a, 0x01) }, + { "2.16.840.1.101.3.4.2.1", chunk_from_chars( + 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01) }, + { "0.10.100.1000.10000.100000.1000000.10000000.100000000.268435455", + chunk_from_chars(0x0a,0x64, 0x87, 0x68, 0xce, 0x10, 0x86, 0x8d, + 0x20, 0xbd, 0x84, 0x40, 0x84, 0xe2, 0xad, 0x00, + 0xaf, 0xd7, 0xc2, 0x00, 0xff, 0xff, 0xff, 0x7f) }, + { "0.1.2.3.4.5.6.7.8.9.10.128.129.130.131.132.133.134.135.136.137." + "256.257.258.259.260.261.262.263.264.265.384.385.386.387.388." + "2097153", chunk_from_chars( + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, + 0x81, 0x00, 0x81, 0x01, 0x81, 0x02, 0x81, 0x03, 0x81, 0x04, + 0x81, 0x05, 0x81, 0x06, 0x81, 0x07, 0x81, 0x08, 0x81, 0x09, + 0x82, 0x00, 0x82, 0x01, 0x82, 0x02, 0x82, 0x03, 0x82, 0x04, + 0x82, 0x05, 0x82, 0x06, 0x82, 0x07, 0x82, 0x08, 0x82, 0x09, + 0x83, 0x00, 0x83, 0x01, 0x83, 0x02, 0x83, 0x03, 0x83, 0x04, + 0x81, 0x80, 0x80, 0x01) }, + { "0.1.2.3.4.5.6.7.8.9.10.128.129.130.131.132.133.134.135.136.137." + "256.257.258.259.260.261.262.263.264.265.384.385.386.387.388." + "1.2097153", chunk_empty }, + { "1.a.2.b.3", chunk_empty } + }; + + int i; + chunk_t oid = chunk_empty; + + for (i = 0; i < countof(test); i++) + { + oid = asn1_oid_from_string(test[i].string); + if (test[i].oid.len == 0) + { + ck_assert(oid.len == 0 && oid.ptr == NULL); + } + else + { + ck_assert(chunk_equals(oid, test[i].oid)); + chunk_free(&oid); + } + } +} +END_TEST + +/******************************************************************************* + * oid_to_string + */ + +START_TEST(test_asn1_oid_to_string) +{ + typedef struct { + char *string; + chunk_t oid; + } testdata_t; + + testdata_t test[] = { + { NULL, chunk_empty }, + { "0.2.262.1", chunk_from_chars( + 0x02, 0x82, 0x06, 0x01) }, + { "1.2.840.10045.4.1", chunk_from_chars( + 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x01) }, + { "1.3.6.1.4.1.36906.1", chunk_from_chars( + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa0, 0x2a, 0x01) }, + { "2.16.840.1.101.3.4.2.1", chunk_from_chars( + 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01) }, + { "0.10.100.1000.10000.100000.1000000.10000000.100000000.268435455", + chunk_from_chars( 0x0a, 0x64, 0x87, 0x68, 0xce, 0x10, 0x86, 0x8d, + 0x20, 0xbd, 0x84, 0x40, 0x84, 0xe2, 0xad, 0x00, + 0xaf, 0xd7, 0xc2, 0x00, 0xff, 0xff, 0xff, 0x7f) }, + { NULL, chunk_from_chars( + 0x0a, 0x02, 0x64, 0x87, 0x68, 0xce, 0x10, 0x86, 0x8d, 0x20, + 0xbd, 0x84, 0x40, 0x84, 0xe2, 0xad, 0x00, 0xaf, 0xd7, 0xc2, 0x00, + 0xff, 0xff, 0xff, 0x7f) }, + { NULL, chunk_from_chars(0x0a, 0x87) } + }; + + int i; + char *string = NULL; + + for (i = 0; i < countof(test); i++) + { + string = asn1_oid_to_string(test[i].oid); + if (test[i].string == NULL) + { + ck_assert(string == NULL); + } + else + { + ck_assert(streq(string, test[i].string)); + free(string); + } + } +} +END_TEST + +/******************************************************************************* + * length + */ + +START_TEST(test_asn1_length) +{ + chunk_t a; + + a = chunk_empty; + ck_assert(asn1_length(&a) == ASN1_INVALID_LENGTH); + + a = chunk_from_chars(0x04); + ck_assert(asn1_length(&a) == ASN1_INVALID_LENGTH); + + a = chunk_from_chars(0x04, 0x00); + ck_assert(asn1_length(&a) == 0); + + a = chunk_from_chars(0x04, 0x01); + ck_assert(asn1_length(&a) == ASN1_INVALID_LENGTH); + + a = chunk_from_chars(0x04, 0x01, 0xaa); + ck_assert(asn1_length(&a) == 1); + + a = chunk_from_chars(0x04, 0x7f, 0xaa); + a.len = 2 + 127; + ck_assert(asn1_length(&a) == 127); + + a = chunk_from_chars(0x04, 0x80, 0xaa); + a.len = 2 + 128; + ck_assert(asn1_length(&a) == ASN1_INVALID_LENGTH); + + a = chunk_from_chars(0x04, 0x81); + ck_assert(asn1_length(&a) == ASN1_INVALID_LENGTH); + + a = chunk_from_chars(0x04, 0x81, 0x00); + ck_assert(asn1_length(&a) == 0); + + a = chunk_from_chars(0x04, 0x81, 0x80, 0xaa); + ck_assert(asn1_length(&a) == ASN1_INVALID_LENGTH); + + a = chunk_from_chars(0x04, 0x81, 0x80, 0xaa); + a.len = 3 + 128; + ck_assert(asn1_length(&a) == 128); + + a = chunk_from_chars(0x04, 0x82, 0x01, 0x02, 0xaa); + a.len = 4 + 258; + ck_assert(asn1_length(&a) == 258); + + a = chunk_from_chars(0x04, 0x83, 0x01, 0x02, 0x03, 0xaa); + a.len = 5 + 66051; + ck_assert(asn1_length(&a) == 66051); + + a = chunk_from_chars(0x04, 0x84, 0x01, 0x02, 0x03, 0x04, 0xaa); + a.len = 6 + 16909060; + ck_assert(asn1_length(&a) == 16909060); + + /* largest chunk on 32 bit system */ + a = chunk_from_chars(0x04, 0x84, 0xff, 0xff, 0xff, 0xf9, 0xaa); + a.len = 4294967295; + ck_assert(asn1_length(&a) == 4294967289); + +} +END_TEST + +/******************************************************************************* + * unwrap + */ + +START_TEST(test_asn1_unwrap) +{ + chunk_t c0 = chunk_from_chars(0x30); + chunk_t c1 = chunk_from_chars(0x30, 0x01, 0xaa); + chunk_t c2 = chunk_from_chars(0x30, 0x80); + chunk_t c3 = chunk_from_chars(0x30, 0x81); + chunk_t c4 = chunk_from_chars(0x30, 0x81, 0x01, 0xaa); + chunk_t c5 = chunk_from_chars(0x30, 0x81, 0x02, 0xaa); + + chunk_t inner; + chunk_t inner_ref = chunk_from_chars(0xaa); + + ck_assert(asn1_unwrap(&c0, &inner) == ASN1_INVALID); + + ck_assert(asn1_unwrap(&c1, &inner) == ASN1_SEQUENCE); + + ck_assert(chunk_equals(inner, inner_ref)); + + ck_assert(asn1_unwrap(&c2, &inner) == ASN1_INVALID); + + ck_assert(asn1_unwrap(&c3, &inner) == ASN1_INVALID); + + ck_assert(asn1_unwrap(&c4, &inner) == ASN1_SEQUENCE); + + ck_assert(chunk_equals(inner, inner_ref)); + + ck_assert(asn1_unwrap(&c5, &inner) == ASN1_INVALID); +} +END_TEST + +/******************************************************************************* + * is_asn1 + */ + +START_TEST(test_is_asn1) +{ + typedef struct { + bool asn1; + chunk_t chunk; + } testdata_t; + + u_char buf[8]; + chunk_t chunk_zero = { buf, 0 }; + chunk_t chunk_mean = { 0, 1 }; + + testdata_t test[] = { + { FALSE, chunk_zero }, + { FALSE, chunk_empty }, + { FALSE, chunk_mean }, + { TRUE, chunk_from_chars(0x30, 0x00) }, + { TRUE, chunk_from_chars(0x31, 0x00) }, + { TRUE, chunk_from_chars(0x04, 0x00) }, + { FALSE, chunk_from_chars(0x02, 0x00) }, + { FALSE, chunk_from_chars(0x30, 0x01) }, + { FALSE, chunk_from_chars(0x30, 0x80) }, + { TRUE, chunk_from_chars(0x30, 0x01, 0xa1) }, + { FALSE, chunk_from_chars(0x30, 0x01, 0xa1, 0xa2) }, + { TRUE, chunk_from_chars(0x30, 0x01, 0xa1, 0x0a) }, + { FALSE, chunk_from_chars(0x30, 0x01, 0xa1, 0xa2, 0x0a) }, + }; + + int i; + + for (i = 0; i < countof(test); i++) + { + ck_assert(is_asn1(test[i].chunk) == test[i].asn1); + } +} +END_TEST + +/******************************************************************************* + * is_printablestring + */ + +START_TEST(test_asn1_is_printablestring) +{ + typedef struct { + bool printable; + char *string; + } testdata_t; + + + testdata_t test[] = { + { TRUE, "" }, + { TRUE, "Z" }, + { FALSE, "Z#" }, + { FALSE, "&Z" }, + { FALSE, "Z@z" }, + { FALSE, "!" }, { FALSE, "*" }, { FALSE, "$" }, { FALSE, "%" }, + { FALSE, "[" }, { FALSE, "]" }, { FALSE, "{" }, { FALSE, "}" }, + { FALSE, "|" }, { FALSE, "~" }, { FALSE, "^" }, { FALSE, "_" }, + { FALSE, "\"" }, { FALSE, "\\" }, { FALSE, "ä" }, { FALSE, "à " }, + { TRUE, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + "0123456789 '()+,-./:=?" }, + }; + + chunk_t chunk; + int i; + + ck_assert(asn1_is_printablestring(chunk_empty)); + + for (i = 0; i < countof(test); i++) + { + chunk = chunk_from_str(test[i].string); + ck_assert(asn1_is_printablestring(chunk) == test[i].printable); + } +} +END_TEST + +/******************************************************************************* + * to_time + */ + +START_TEST(test_asn1_to_time) +{ + typedef struct { + time_t time; + u_int8_t type; + char *string; + } testdata_t; + + testdata_t test[] = { + { 352980, 0x18, "197001050203Z" }, + { 352984, 0x18, "19700105020304Z" }, + { 352980, 0x17, "7001050203Z" }, + { 347580, 0x17, "7001050203+0130" }, + { 358380, 0x17, "7001050203-0130" }, + { 352984, 0x17, "700105020304Z" }, + { 347584, 0x17, "700105020304+0130" }, + { 358384, 0x17, "700105020304-0130" }, + { 0, 0x17, "700105020304+01" }, + { 0, 0x17, "700105020304-01" }, + { 0, 0x17, "700105020304" }, + { 0, 0x17, "70010502Z" }, + { 0, 0x17, "7001050203xxZ" }, + { 0, 0x17, "7000050203Z" }, + { 0, 0x17, "7013050203Z" }, + { 0, 0x17, "7001004203Z" }, + { 0, 0x17, "7001320203Z" }, + { 0, 0x17, "700101-103Z" }, + { 0, 0x17, "7001016003Z" }, + { 0, 0x17, "70010102-1Z" }, + { 0, 0x17, "7001010260Z" }, + { 0, 0x17, "7001010203-1Z" }, + { 0, 0x17, "700101020361Z" }, + { -631152000, 0x17, "500101000000Z" }, /* UTCTime min */ + { 59, 0x17, "691231235959-0001" }, + { -1, 0x17, "691231235959Z" }, + { 0, 0x17, "700101000000Z" }, + { -60, 0x17, "700101000000+0001" }, + { 2524607999UL, 0x17, "491231235959Z" }, /* UTCTime max */ + { 5097600, 0x17, "7003010000Z" }, + { 68256000, 0x17, "7203010000Z" }, + { 951868800, 0x17, "0003010000Z" }, + { 4107542400UL, 0x18, "210003010000Z" } + }; + + int i; + chunk_t chunk; + + for (i = 0; i < countof(test); i++) + { + if (sizeof(time_t) == 4 && test[i].time < 0) + { + continue; + } + chunk = chunk_from_str(test[i].string); + ck_assert(asn1_to_time(&chunk, test[i].type) == test[i].time); + } +} +END_TEST + +/******************************************************************************* + * from_time + */ + +START_TEST(test_asn1_from_time) +{ + typedef struct { + time_t time; + u_int8_t type; + chunk_t chunk; + } testdata_t; + + testdata_t test[] = { + { 352984, 0x18, chunk_from_chars( + 0x18, 0x0f, 0x31, 0x39, 0x37, 0x30, 0x30, 0x31, 0x30, 0x35, + 0x30, 0x32, 0x30, 0x33, 0x30, 0x34, 0x5a) }, + { 352984, 0x17, chunk_from_chars( + 0x17, 0x0d, 0x37, 0x30, 0x30, 0x31, 0x30, 0x35, + 0x30, 0x32, 0x30, 0x33, 0x30, 0x34, 0x5a) }, + { 1078099200, 0x17, chunk_from_chars( + 0x17, 0x0d, 0x30, 0x34, 0x30, 0x33, 0x30, 0x31, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a) }, + { 4107542400UL, 0x18, chunk_from_chars( + 0x18, 0x0f, 0x32, 0x31, 0x30, 0x30, 0x30, 0x33, 0x30, 0x31, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a) } + }; + + int i; + chunk_t chunk; + + for (i = 0; i < countof(test); i++) + { + if (sizeof(time_t) == 4 && test[i].time < 0) + { + continue; + } + chunk = asn1_from_time(&test[i].time, test[i].type); + ck_assert(chunk_equals(chunk, test[i].chunk)); + free(chunk.ptr); + } +} +END_TEST + +/******************************************************************************* + * parse_time + */ + +START_TEST(test_asn1_parse_time) +{ + typedef struct { + time_t time; + chunk_t chunk; + } testdata_t; + + testdata_t test[] = { + { 352984, chunk_from_chars( + 0x18, 0x0f, 0x31, 0x39, 0x37, 0x30, 0x30, 0x31, 0x30, 0x35, + 0x30, 0x32, 0x30, 0x33, 0x30, 0x34, 0x5a) }, + { 352984, chunk_from_chars( + 0x17, 0x0d, 0x37, 0x30, 0x30, 0x31, 0x30, 0x35, + 0x30, 0x32, 0x30, 0x33, 0x30, 0x34, 0x5a) }, + { 0, chunk_from_chars(0x05, 0x00) } + }; + + int i; + + for (i = 0; i < countof(test); i++) + { + ck_assert(asn1_parse_time(test[i].chunk, 0) == test[i].time); + } +} +END_TEST + +/******************************************************************************* + * build_object + */ + +START_TEST(test_asn1_build_object) +{ + typedef struct { + size_t len; + size_t size; + u_char *b; + } testdata_t; + + u_char b0[] = { 0x05, 0x00 }; + u_char b1[] = { 0x04, 0x7f }; + u_char b2[] = { 0x04, 0x81, 0x80 }; + u_char b3[] = { 0x04, 0x81, 0xff }; + u_char b4[] = { 0x04, 0x82, 0x01, 0x00 }; + u_char b5[] = { 0x04, 0x82, 0xff, 0xff }; + u_char b6[] = { 0x04, 0x83, 0x01, 0x00, 0x00 }; + + testdata_t test[] = { + { 0, sizeof(b0), b0 }, + { 127, sizeof(b1), b1 }, + { 128, sizeof(b2), b2 }, + { 255, sizeof(b3), b3 }, + { 256, sizeof(b4), b4 }, + { 65535, sizeof(b5), b5 }, + { 65536, sizeof(b6), b6 } + }; + + chunk_t a = chunk_empty; + u_char *pos; + int i; + + for (i = 0; i < countof(test); i++) + { + pos = asn1_build_object(&a, test[i].b[0], test[i].len); + ck_assert(pos == (a.ptr + test[i].size)); + ck_assert(a.len == test[i].size + test[i].len); + ck_assert(memeq(a.ptr, test[i].b, test[i].size)); + chunk_free(&a); + } +} +END_TEST + +/******************************************************************************* + * simple_object + */ + +START_TEST(test_asn1_simple_object) +{ + chunk_t a = chunk_empty; + chunk_t b = chunk_from_chars(0x04, 0x05, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5); + chunk_t c = chunk_from_chars(0xa1, 0xa2, 0xa3, 0xa4, 0xa5); + + a = asn1_simple_object(0x04, c); + ck_assert(chunk_equals(a, b)); + chunk_free(&a); +} +END_TEST + +/******************************************************************************* + * parse_simple_object + */ + +START_TEST(test_asn1_parse_simple_object) +{ + typedef struct { + bool res; + int type; + chunk_t chunk; + } testdata_t; + + testdata_t test[] = { + { FALSE, 0x04, chunk_from_chars(0x04) }, + { FALSE, 0x04, chunk_from_chars(0x02, 0x01, 0x55) }, + { FALSE, 0x04, chunk_from_chars(0x04, 0x01) }, + { TRUE, 0x04, chunk_from_chars(0x04, 0x01, 0x55) }, + { TRUE, 0x06, chunk_from_chars(0x06, 0x02, 0x55, 0x03) }, + { TRUE, 0x06, chunk_from_chars(0x06, 0x00) }, + { TRUE, 0x13, chunk_from_chars(0x13, 0x01, 0x55), } + }; + + int i; + bool res; + + for (i = 0; i < countof(test); i++) + { + res = asn1_parse_simple_object(&test[i].chunk, test[i].type, 0, "test"); + ck_assert(res == test[i].res); + if (res && test[i].chunk.len) + { + ck_assert(*test[i].chunk.ptr == 0x55); + } + } +} +END_TEST + +/******************************************************************************* + * bitstring + */ + +START_TEST(test_asn1_bitstring) +{ + chunk_t a = chunk_empty; + chunk_t b = chunk_from_chars(0x03, 0x05, 0x00, 0xa1, 0xa2, 0xa3, 0xa4); + chunk_t c = chunk_from_chars(0xa1, 0xa2, 0xa3, 0xa4); + chunk_t d = chunk_clone(c); + + a = asn1_bitstring("c", c); + ck_assert(chunk_equals(a, b)); + chunk_free(&a); + + a = asn1_bitstring("m", d); + ck_assert(chunk_equals(a, b)); + chunk_free(&a); +} +END_TEST + +/******************************************************************************* + * integer + */ + +START_TEST(test_asn1_integer) +{ + typedef struct { + chunk_t b; + chunk_t c; + } testdata_t; + + chunk_t b0 = chunk_from_chars(0x02, 0x01, 0x00); + chunk_t b1 = chunk_from_chars(0x02, 0x01, 0x7f); + chunk_t b2 = chunk_from_chars(0x02, 0x02, 0x00, 0x80); + + chunk_t c0 = chunk_empty; + chunk_t c1 = chunk_from_chars(0x7f); + chunk_t c2 = chunk_from_chars(0x80); + chunk_t c3 = chunk_from_chars(0x00, 0x80); + + testdata_t test[] = { + { b0, c0 }, + { b1, c1 }, + { b2, c2 }, + { b2, c3 } + }; + + chunk_t a = chunk_empty; + int i; + + for (i = 0; i < countof(test); i++) + { + a = asn1_integer("c", test[i].c); + ck_assert(chunk_equals(a, test[i].b)); + chunk_free(&a); + + a = asn1_integer("m", chunk_clone(test[i].c)); + ck_assert(chunk_equals(a, test[i].b)); + chunk_free(&a); + } +} +END_TEST + +/******************************************************************************* + * parse_integer_uint64 + */ + +START_TEST(test_asn1_parse_integer_uint64) +{ + typedef struct { + u_int64_t n; + chunk_t chunk; + } testdata_t; + + + testdata_t test[] = { + { 67305985ULL, chunk_from_chars( + 0x04, 0x03, 0x02, 0x01) }, + { 578437695752307201ULL, chunk_from_chars( + 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01) }, + { 18446744073709551615ULL, chunk_from_chars( + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff) } + }; + + int i; + + for (i = 0; i < countof(test); i++) + { + ck_assert(asn1_parse_integer_uint64(test[i].chunk) == test[i].n); + } +} +END_TEST + +Suite *asn1_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("asn1"); + + tc = tcase_create("algorithmIdentifier"); + tcase_add_test(tc, test_asn1_algorithmIdentifier); + suite_add_tcase(s, tc); + + tc = tcase_create("parse_algorithmIdentifier"); + tcase_add_test(tc, test_asn1_parse_algorithmIdentifier); + suite_add_tcase(s, tc); + + tc = tcase_create("known_oid"); + tcase_add_test(tc, test_asn1_known_oid); + suite_add_tcase(s, tc); + + tc = tcase_create("build_known_oid"); + tcase_add_test(tc, test_asn1_build_known_oid); + suite_add_tcase(s, tc); + + tc = tcase_create("oid_from_string"); + tcase_add_test(tc, test_asn1_oid_from_string); + suite_add_tcase(s, tc); + + tc = tcase_create("oid_to_string"); + tcase_add_test(tc, test_asn1_oid_to_string); + suite_add_tcase(s, tc); + + tc = tcase_create("length"); + tcase_add_test(tc, test_asn1_length); + suite_add_tcase(s, tc); + + tc = tcase_create("unwrap"); + tcase_add_test(tc, test_asn1_unwrap); + suite_add_tcase(s, tc); + + tc = tcase_create("is_asn1"); + tcase_add_test(tc, test_is_asn1); + suite_add_tcase(s, tc); + + tc = tcase_create("is_printablestring"); + tcase_add_test(tc, test_asn1_is_printablestring); + suite_add_tcase(s, tc); + + tc = tcase_create("to_time"); + tcase_add_test(tc, test_asn1_to_time); + suite_add_tcase(s, tc); + + tc = tcase_create("from_time"); + tcase_add_test(tc, test_asn1_from_time); + suite_add_tcase(s, tc); + + tc = tcase_create("parse_time"); + tcase_add_test(tc, test_asn1_parse_time); + suite_add_tcase(s, tc); + + tc = tcase_create("build_object"); + tcase_add_test(tc, test_asn1_build_object); + suite_add_tcase(s, tc); + + tc = tcase_create("simple_object"); + tcase_add_test(tc, test_asn1_simple_object); + suite_add_tcase(s, tc); + + tc = tcase_create("parse_simple_object"); + tcase_add_test(tc, test_asn1_parse_simple_object); + suite_add_tcase(s, tc); + + tc = tcase_create("bitstring"); + tcase_add_test(tc, test_asn1_bitstring); + suite_add_tcase(s, tc); + + tc = tcase_create("integer"); + tcase_add_test(tc, test_asn1_integer); + suite_add_tcase(s, tc); + + tc = tcase_create("parse_integer_uint64"); + tcase_add_test(tc, test_asn1_parse_integer_uint64); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/suites/test_asn1_parser.c b/src/libstrongswan/tests/suites/test_asn1_parser.c new file mode 100644 index 000000000..973562bff --- /dev/null +++ b/src/libstrongswan/tests/suites/test_asn1_parser.c @@ -0,0 +1,291 @@ +/* + * Copyright (C) 2014 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <asn1/asn1_parser.h> +#include <utils/chunk.h> + +/******************************************************************************* + * utilities + */ + +typedef struct { + bool success; + int count; + chunk_t blob; +} asn1_test_t; + +static void run_parser_test(const asn1Object_t *objects, int id, + asn1_test_t *test) +{ + asn1_parser_t *parser; + chunk_t object; + int objectID, count = 0; + bool success; + + parser = asn1_parser_create(objects, test->blob); + while (parser->iterate(parser, &objectID, &object)) + { + if (objectID == id) + { + count++; + } + } + success = parser->success(parser); + parser->destroy(parser); + + ck_assert(success == test->success && count == test->count); +} + +/******************************************************************************* + * length + */ + +static const asn1Object_t octetStringObjects[] = { + { 0, "octetString", ASN1_OCTET_STRING, ASN1_BODY }, /* 0 */ + { 0, "exit", ASN1_EOC, ASN1_EXIT } +}; + +asn1_test_t length_tests[] = { + { FALSE, 0, { NULL, 0 } }, + { FALSE, 0, chunk_from_chars(0x04) }, + { TRUE, 1, chunk_from_chars(0x04, 0x00) }, + { TRUE, 1, chunk_from_chars(0x04, 0x01, 0xaa) }, + { FALSE, 0, chunk_from_chars(0x04, 0x7f) }, + { FALSE, 0, chunk_from_chars(0x04, 0x80) }, + { FALSE, 0, chunk_from_chars(0x04, 0x81) }, + { TRUE, 1, chunk_from_chars(0x04, 0x81, 0x00) }, + { FALSE, 0, chunk_from_chars(0x04, 0x81, 0x01) }, + { TRUE, 1, chunk_from_chars(0x04, 0x81, 0x01, 0xaa) }, + { FALSE, 0, chunk_from_chars(0x04, 0x82, 0x00, 0x01) }, + { TRUE, 1, chunk_from_chars(0x04, 0x82, 0x00, 0x01, 0xaa) }, + { FALSE, 0, chunk_from_chars(0x04, 0x83, 0x00, 0x00, 0x01) }, + { TRUE, 1, chunk_from_chars(0x04, 0x83, 0x00, 0x00, 0x01, 0xaa) }, + { FALSE, 0, chunk_from_chars(0x04, 0x84, 0x00, 0x00, 0x00, 0x01) }, + { TRUE, 1, chunk_from_chars(0x04, 0x84, 0x00, 0x00, 0x00, 0x01, 0xaa) }, +}; + +START_TEST(test_asn1_parser_length) +{ + run_parser_test(octetStringObjects, 0, &length_tests[_i]); +} +END_TEST + +/******************************************************************************* + * loop + */ + +static const asn1Object_t loopObjects[] = { + { 0, "loopObjects", ASN1_SEQUENCE, ASN1_LOOP }, /* 0 */ + { 1, "octetString", ASN1_OCTET_STRING, ASN1_BODY }, /* 1 */ + { 0, "end loop", ASN1_EOC, ASN1_END }, /* 2 */ + { 0, "exit", ASN1_EOC, ASN1_EXIT } +}; + +asn1_test_t loop_tests[] = { + { TRUE, 0, chunk_from_chars(0x30, 0x00) }, + { FALSE, 0, chunk_from_chars(0x30, 0x02, 0x04, 0x01) }, + { TRUE, 1, chunk_from_chars(0x30, 0x03, 0x04, 0x01, 0xaa) }, + { TRUE, 2, chunk_from_chars(0x30, 0x05, 0x04, 0x01, 0xaa, 0x04, 0x00) }, + { FALSE, 1, chunk_from_chars(0x30, 0x05, 0x04, 0x01, 0xaa, 0x05, 0x00) }, + { TRUE, 3, chunk_from_chars(0x30, 0x09, 0x04, 0x01, 0xaa, 0x04, 0x00, + 0x04, 0x02, 0xbb, 0xcc) }, +}; + +START_TEST(test_asn1_parser_loop) +{ + run_parser_test(loopObjects, 1, &loop_tests[_i]); +} +END_TEST + +/******************************************************************************* + * default + */ + +typedef struct { + int i1, i2, i3; + chunk_t blob; +} default_opt_test_t; + +static const asn1Object_t defaultObjects[] = { + { 0, "defaultObjects", ASN1_SEQUENCE, ASN1_OBJ }, /* 0 */ + { 1, "explicit int1", ASN1_CONTEXT_C_1, ASN1_DEF }, /* 1 */ + { 2, "int1", ASN1_INTEGER, ASN1_BODY }, /* 2 */ + { 1, "int2", ASN1_INTEGER, ASN1_DEF|ASN1_BODY }, /* 3 */ + { 1, "implicit int3", ASN1_CONTEXT_S_3, ASN1_DEF|ASN1_BODY }, /* 4 */ + { 0, "exit", ASN1_EOC, ASN1_EXIT } +}; + +default_opt_test_t default_tests[] = { + { -1, -2, -3, chunk_from_chars(0x30, 0x00) }, + { 1, -2, -3, chunk_from_chars(0x30, 0x05, 0xa1, 0x03, 0x02, 0x01, 0x01) }, + { -1, 2, -3, chunk_from_chars(0x30, 0x03, 0x02, 0x01, 0x02) }, + { -1, -2, 3, chunk_from_chars(0x30, 0x03, 0x83, 0x01, 0x03) }, + { 1, 2, -3, chunk_from_chars(0x30, 0x08, 0xa1, 0x03, 0x02, 0x01, 0x01, + 0x02, 0x01, 0x02) }, + { 1, -2, 3, chunk_from_chars(0x30, 0x08, 0xa1, 0x03, 0x02, 0x01, 0x01, + 0x83, 0x01, 0x03) }, + { -1, 2, 3, chunk_from_chars(0x30, 0x06, 0x02, 0x01, 0x02, + 0x83, 0x01, 0x03) }, + { 1, 2, 3, chunk_from_chars(0x30, 0x0b, 0xa1, 0x03, 0x02, 0x01, 0x01, + 0x02, 0x01, 0x02, + 0x83, 0x01, 0x03) }, + { 0, 0, 0, chunk_from_chars(0x30, 0x0b, 0xa1, 0x03, 0x04, 0x01, 0xaa, + 0x02, 0x01, 0x02, + 0x83, 0x01, 0x03) }, + { 1, 0, 0, chunk_from_chars(0x30, 0x0b, 0xa1, 0x03, 0x02, 0x01, 0x01, + 0x02, 0x05, 0x02, + 0x83, 0x01, 0x03) }, + { 1, 2, 0, chunk_from_chars(0x30, 0x0b, 0xa1, 0x03, 0x02, 0x01, 0x01, + 0x02, 0x01, 0x02, + 0x83, 0x02, 0x03) }, +}; + +START_TEST(test_asn1_parser_default) +{ + asn1_parser_t *parser; + chunk_t object; + int objectID, i1 = 0, i2 = 0, i3 = 0; + bool success; + + parser = asn1_parser_create(defaultObjects, default_tests[_i].blob); + while (parser->iterate(parser, &objectID, &object)) + { + switch (objectID) + { + case 2: + i1 = object.len ? *object.ptr : -1; + break; + case 3: + i2 = object.len ? *object.ptr : -2; + break; + case 4: + i3 = object.len ? *object.ptr : -3; + break; + default: + break; + } + } + success = parser->success(parser); + parser->destroy(parser); + + ck_assert(success == (default_tests[_i].i1 && + default_tests[_i].i2 && + default_tests[_i].i3)); + + ck_assert(i1 == default_tests[_i].i1 && + i2 == default_tests[_i].i2 && + i3 == default_tests[_i].i3); +} +END_TEST + +/******************************************************************************* + * option + */ + +static const asn1Object_t optionObjects[] = { + { 0, "optionalObjects", ASN1_SEQUENCE, ASN1_OBJ }, /* 0 */ + { 1, "sequence int1", ASN1_SEQUENCE, ASN1_OPT }, /* 1 */ + { 2, "int1", ASN1_INTEGER, ASN1_OPT|ASN1_BODY }, /* 2 */ + { 2, "end opt", ASN1_EOC, ASN1_END }, /* 3 */ + { 1, "end opt", ASN1_EOC, ASN1_END }, /* 4 */ + { 1, "int2", ASN1_INTEGER, ASN1_OPT|ASN1_BODY }, /* 5 */ + { 1, "end opt", ASN1_EOC, ASN1_END }, /* 6 */ + { 1, "implicit int3", ASN1_CONTEXT_S_3, ASN1_OPT|ASN1_BODY }, /* 7 */ + { 1, "end opt", ASN1_EOC, ASN1_END }, /* 8 */ + { 0, "exit", ASN1_EOC, ASN1_EXIT } +}; + +default_opt_test_t option_tests[] = { + { 0, 0, 0, chunk_from_chars(0x30, 0x00) }, + { 1, 0, 0, chunk_from_chars(0x30, 0x05, 0x30, 0x03, 0x02, 0x01, 0x01) }, + { 0, 2, 0, chunk_from_chars(0x30, 0x03, 0x02, 0x01, 0x02) }, + { 0, 0, 3, chunk_from_chars(0x30, 0x03, 0x83, 0x01, 0x03) }, + { 1, 2, 0, chunk_from_chars(0x30, 0x08, 0x30, 0x03, 0x02, 0x01, 0x01, + 0x02, 0x01, 0x02) }, + { 1, 0, 3, chunk_from_chars(0x30, 0x08, 0x30, 0x03, 0x02, 0x01, 0x01, + 0x83, 0x01, 0x03) }, + { 0, 2, 3, chunk_from_chars(0x30, 0x06, 0x02, 0x01, 0x02, + 0x83, 0x01, 0x03) }, + { 1, 2, 3, chunk_from_chars(0x30, 0x0b, 0x30, 0x03, 0x02, 0x01, 0x01, + 0x02, 0x01, 0x02, + 0x83, 0x01, 0x03) }, + { 0, 2, 3, chunk_from_chars(0x30, 0x08, 0x30, 0x00, + 0x02, 0x01, 0x02, + 0x83, 0x01, 0x03) }, +}; + +START_TEST(test_asn1_parser_option) +{ + asn1_parser_t *parser; + chunk_t object; + int objectID, i1 = 0, i2 = 0, i3 = 0; + bool success; + + parser = asn1_parser_create(optionObjects, option_tests[_i].blob); + while (parser->iterate(parser, &objectID, &object)) + { + switch (objectID) + { + case 2: + i1 = *object.ptr; + break; + case 5: + i2 = *object.ptr; + break; + case 7: + i3 = *object.ptr; + break; + default: + break; + } + } + success = parser->success(parser); + parser->destroy(parser); + + ck_assert(success); + + ck_assert(i1 == option_tests[_i].i1 && + i2 == option_tests[_i].i2 && + i3 == option_tests[_i].i3); +} +END_TEST + +Suite *asn1_parser_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("asn1_parser"); + + tc = tcase_create("length"); + tcase_add_loop_test(tc, test_asn1_parser_length, 0, countof(length_tests)); + suite_add_tcase(s, tc); + + tc = tcase_create("loop"); + tcase_add_loop_test(tc, test_asn1_parser_loop, 0, countof(loop_tests)); + suite_add_tcase(s, tc); + + tc = tcase_create("default"); + tcase_add_loop_test(tc, test_asn1_parser_default, 0, countof(default_tests)); + suite_add_tcase(s, tc); + + tc = tcase_create("option"); + tcase_add_loop_test(tc, test_asn1_parser_option, 0, countof(option_tests)); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/test_bio_reader.c b/src/libstrongswan/tests/suites/test_bio_reader.c index 45b20db00..6a9743d62 100644 --- a/src/libstrongswan/tests/test_bio_reader.c +++ b/src/libstrongswan/tests/suites/test_bio_reader.c @@ -329,7 +329,7 @@ END_TEST */ #define assert_read_data_len(bits) ({ \ - bio_reader_t *reader; \ + bio_reader_t *reader; \ chunk_t read, data; \ int i, len = bits / 8; \ data = chunk_empty; \ diff --git a/src/libstrongswan/tests/test_bio_writer.c b/src/libstrongswan/tests/suites/test_bio_writer.c index 665cd2d7c..e74288eb7 100644 --- a/src/libstrongswan/tests/test_bio_writer.c +++ b/src/libstrongswan/tests/suites/test_bio_writer.c @@ -181,7 +181,7 @@ END_TEST */ #define assert_write_data_len(init, bits) ({ \ - bio_writer_t *writer; \ + bio_writer_t *writer; \ chunk_t buf, data; \ int i, len = bits / 8; \ writer = bio_writer_create(init); \ @@ -240,7 +240,7 @@ END_TEST */ #define assert_wrap_data(init, bits) ({ \ - bio_writer_t *writer; \ + bio_writer_t *writer; \ chunk_t buf, data; \ int i, len = bits / 8; \ writer = bio_writer_create(init); \ diff --git a/src/libstrongswan/tests/test_chunk.c b/src/libstrongswan/tests/suites/test_chunk.c index 8e29971c1..e373fbdb6 100644 --- a/src/libstrongswan/tests/test_chunk.c +++ b/src/libstrongswan/tests/suites/test_chunk.c @@ -14,10 +14,16 @@ * for more details. */ - #include "test_suite.h" +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> + #include <utils/chunk.h> +#include <threading/thread.h> /******************************************************************************* * utilities @@ -672,6 +678,31 @@ static const u_char sip_vectors[64][8] = { 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, } }; +/** + * Our SipHash-2-4 implementation returns the result in host order, which + * doesn't matter for practical purposes and even avoids a byte swap. But + * because the test vectors are in little-endian we have to account for this + * with this custom comparison function. + */ +static inline bool sipeq(const void *a, const void *b, size_t n) +{ + u_char *ap = (u_char*)a, *bp = (u_char*)b; + int i; + + for (i = 0; i < n; i++) + { +#ifdef WORDS_BIGENDIAN + if (ap[i] != bp[n - i - 1]) +#else + if (ap[i] != bp[i]) +#endif + { + return FALSE; + } + } + return TRUE; +} + START_TEST(test_chunk_mac) { chunk_t in; @@ -692,7 +723,7 @@ START_TEST(test_chunk_mac) in.ptr[i] = i; in.len = i; out = chunk_mac(in, key); - fail_unless(memeq(&out, sip_vectors[i], 8), + fail_unless(sipeq(&out, sip_vectors[i], 8), "test vector failed for %d bytes", i); } } @@ -739,7 +770,7 @@ START_TEST(test_chunk_hash_static) in.len = i; /* compared to chunk_mac() we only get half the value back */ out = chunk_hash_static(in); - fail_unless(memeq(&out, sip_vectors[i], 4), + fail_unless(sipeq(&out, sip_vectors[i], 4), "test vector failed for %d bytes", i); } hash_a = chunk_hash_static_inc(in, out); @@ -750,6 +781,116 @@ START_TEST(test_chunk_hash_static) END_TEST /******************************************************************************* + * test for chunk_map and friends + */ + +START_TEST(test_chunk_map) +{ + chunk_t *map, contents = chunk_from_chars(0x01,0x02,0x03,0x04,0x05); + char *path = "/tmp/strongswan-chunk-map-test"; + + ck_assert(chunk_write(contents, path, 022, TRUE)); + + /* read */ + map = chunk_map(path, FALSE); + ck_assert(map != NULL); + ck_assert_msg(chunk_equals(*map, contents), "%B", map); + /* altering mapped chunk should not hurt */ + *map = chunk_empty; + ck_assert(chunk_unmap(map)); + + /* write */ + map = chunk_map(path, TRUE); + ck_assert(map != NULL); + ck_assert_msg(chunk_equals(*map, contents), "%B", map); + map->ptr[0] = 0x06; + ck_assert(chunk_unmap(map)); + + /* verify write */ + contents.ptr[0] = 0x06; + map = chunk_map(path, FALSE); + ck_assert(map != NULL); + ck_assert_msg(chunk_equals(*map, contents), "%B", map); + ck_assert(chunk_unmap(map)); + + unlink(path); +} +END_TEST + +/******************************************************************************* + * test for chunk_from_fd + */ + +START_TEST(test_chunk_from_fd_file) +{ + chunk_t in, contents = chunk_from_chars(0x01,0x02,0x03,0x04,0x05); + char *path = "/tmp/strongswan-chunk-fd-test"; + int fd; + + ck_assert(chunk_write(contents, path, 022, TRUE)); + + fd = open(path, O_RDONLY); + ck_assert(fd != -1); + + ck_assert(chunk_from_fd(fd, &in)); + close(fd); + ck_assert_msg(chunk_equals(in, contents), "%B", &in); + unlink(path); + free(in.ptr); +} +END_TEST + +START_TEST(test_chunk_from_fd_skt) +{ + chunk_t in, contents = chunk_from_chars(0x01,0x02,0x03,0x04,0x05); + int s[2]; + + ck_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, s) == 0); + ck_assert(write(s[1], contents.ptr, contents.len) == contents.len); + close(s[1]); + ck_assert_msg(chunk_from_fd(s[0], &in), "%s", strerror(errno)); + close(s[0]); + ck_assert_msg(chunk_equals(in, contents), "%B", &in); + free(in.ptr); +} +END_TEST + +#define FROM_FD_COUNT 8192 + +void *chunk_from_fd_run(void *data) +{ + int i, fd = (uintptr_t)data; + + for (i = 0; i < FROM_FD_COUNT; i++) + { + ck_assert(write(fd, &i, sizeof(i)) == sizeof(i)); + } + close(fd); + return NULL; +} + +START_TEST(test_chunk_from_fd_huge) +{ + thread_t *thread; + chunk_t in; + int s[2], i; + + ck_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, s) == 0); + + thread = thread_create(chunk_from_fd_run, (void*)(uintptr_t)s[1]); + ck_assert_msg(chunk_from_fd(s[0], &in), "%s", strerror(errno)); + ck_assert_int_eq(in.len, FROM_FD_COUNT * sizeof(i)); + for (i = 0; i < FROM_FD_COUNT; i++) + { + ck_assert_int_eq(((int*)in.ptr)[i], i); + } + thread->join(thread); + close(s[0]); + free(in.ptr); +} +END_TEST + +/******************************************************************************* * printf_hook tests */ @@ -866,6 +1007,16 @@ Suite *chunk_suite_create() tcase_add_test(tc, test_chunk_hash_static); suite_add_tcase(s, tc); + tc = tcase_create("chunk_map"); + tcase_add_test(tc, test_chunk_map); + suite_add_tcase(s, tc); + + tc = tcase_create("chunk_from_fd"); + tcase_add_test(tc, test_chunk_from_fd_file); + tcase_add_test(tc, test_chunk_from_fd_skt); + tcase_add_test(tc, test_chunk_from_fd_huge); + suite_add_tcase(s, tc); + tc = tcase_create("printf_hook"); tcase_add_loop_test(tc, test_printf_hook_hash, 0, countof(printf_hook_data)); tcase_add_loop_test(tc, test_printf_hook_plus, 0, countof(printf_hook_data)); diff --git a/src/libstrongswan/tests/suites/test_crypter.c b/src/libstrongswan/tests/suites/test_crypter.c new file mode 100644 index 000000000..4e7550aee --- /dev/null +++ b/src/libstrongswan/tests/suites/test_crypter.c @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2013 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <crypto/crypters/crypter.h> +#include <asn1/oid.h> +#include <utils/test.h> + +typedef struct { + int oid; + encryption_algorithm_t alg; + size_t key_size; +}crypter_oid_t; + +static crypter_oid_t oids[] = { + { OID_UNKNOWN, ENCR_AES_CBC, 0 }, + { OID_UNKNOWN, ENCR_CAMELLIA_CBC, 0 }, + { OID_UNKNOWN, ENCR_UNDEFINED, 0 }, + { OID_DES_CBC, ENCR_DES, 0 }, + { OID_3DES_EDE_CBC, ENCR_3DES, 0 }, + { OID_AES128_CBC, ENCR_AES_CBC, 128 }, + { OID_AES192_CBC, ENCR_AES_CBC, 192 }, + { OID_AES256_CBC, ENCR_AES_CBC, 256 }, + { OID_CAMELLIA128_CBC, ENCR_CAMELLIA_CBC, 128 }, + { OID_CAMELLIA192_CBC, ENCR_CAMELLIA_CBC, 192 }, + { OID_CAMELLIA256_CBC, ENCR_CAMELLIA_CBC, 256 } +}; + +START_TEST(test_crypter_from_oid) +{ + size_t key_size; + + ck_assert(encryption_algorithm_from_oid(oids[_i].oid, NULL) == + oids[_i].alg); + ck_assert(encryption_algorithm_from_oid(oids[_i].oid, &key_size) == + oids[_i].alg); + ck_assert(key_size == oids[_i].key_size); +} +END_TEST + +START_TEST(test_crypter_to_oid) +{ + ck_assert(encryption_algorithm_to_oid(oids[_i].alg, + oids[_i].key_size) == oids[_i].oid); +} +END_TEST + +typedef struct { + encryption_algorithm_t alg; + bool is_aead; +}crypter_aead_t; + +static crypter_aead_t aead[] = { + { ENCR_AES_CCM_ICV8, TRUE }, + { ENCR_AES_CCM_ICV12, TRUE }, + { ENCR_AES_CCM_ICV16, TRUE }, + { ENCR_AES_GCM_ICV8, TRUE }, + { ENCR_AES_GCM_ICV12, TRUE }, + { ENCR_AES_GCM_ICV16, TRUE }, + { ENCR_NULL_AUTH_AES_GMAC, TRUE }, + { ENCR_CAMELLIA_CCM_ICV8, TRUE }, + { ENCR_CAMELLIA_CCM_ICV12, TRUE }, + { ENCR_CAMELLIA_CCM_ICV16, TRUE }, + { ENCR_AES_CBC, FALSE }, + { ENCR_CAMELLIA_CBC, FALSE } +}; + +START_TEST(test_crypter_is_aead) +{ + ck_assert(encryption_algorithm_is_aead(aead[_i].alg) == aead[_i].is_aead); +} +END_TEST + +Suite *crypter_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("crypter"); + + tc = tcase_create("from_oid"); + tcase_add_loop_test(tc, test_crypter_from_oid, 2, countof(oids)); + suite_add_tcase(s, tc); + + tc = tcase_create("to_oid"); + tcase_add_loop_test(tc, test_crypter_to_oid, 0, countof(oids)); + suite_add_tcase(s, tc); + + tc = tcase_create("is_aead"); + tcase_add_loop_test(tc, test_crypter_is_aead, 0, countof(aead)); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/test_ecdsa.c b/src/libstrongswan/tests/suites/test_ecdsa.c index 2955bae2f..3c842996d 100644 --- a/src/libstrongswan/tests/test_ecdsa.c +++ b/src/libstrongswan/tests/suites/test_ecdsa.c @@ -222,11 +222,17 @@ Suite *ecdsa_suite_create() { Suite *s; TCase *tc; + int gen_count = countof(key_sizes); s = suite_create("ecdsa"); + if (getenv("TESTS_REDUCED_KEYLENGTHS") != NULL) + { + gen_count = min(1, gen_count); + } + tc = tcase_create("generate"); - tcase_add_loop_test(tc, test_gen, 0, countof(key_sizes)); + tcase_add_loop_test(tc, test_gen, 0, gen_count); suite_add_tcase(s, tc); tc = tcase_create("load"); diff --git a/src/libstrongswan/tests/test_enum.c b/src/libstrongswan/tests/suites/test_enum.c index 990d9cfad..990d9cfad 100644 --- a/src/libstrongswan/tests/test_enum.c +++ b/src/libstrongswan/tests/suites/test_enum.c diff --git a/src/libstrongswan/tests/test_enumerator.c b/src/libstrongswan/tests/suites/test_enumerator.c index b5dde4650..b5dde4650 100644 --- a/src/libstrongswan/tests/test_enumerator.c +++ b/src/libstrongswan/tests/suites/test_enumerator.c diff --git a/src/libstrongswan/tests/suites/test_fetch_http.c b/src/libstrongswan/tests/suites/test_fetch_http.c new file mode 100644 index 000000000..8749ff375 --- /dev/null +++ b/src/libstrongswan/tests/suites/test_fetch_http.c @@ -0,0 +1,273 @@ +/* + * Copyright (C) 2014 Martin Willi + * Copyright (C) 2014 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <unistd.h> +#include <time.h> + +/** + * HTTP test definition + */ +typedef struct { + /* HTTP Method */ + char *meth; + /* HTTP 1.x minor version */ + int minor; + /* host to connect to */ + char *host; + /* HTTP service port */ + int port; + /* path on host to fetch from */ + char *path; + /* request Content-Type, if any */ + char *type; + /* request data, if any */ + void *req; + /* length of request data */ + int req_len; + /* response data, if any */ + void *res; + /* length of response data */ + int res_len; +} test_service_t; + +static char large[] = { + 0x88,0x3e,0xa3,0xe3,0x95,0x67,0x53,0x93,0xc8,0xce,0x5c,0xcd,0x8c,0x03,0x0c,0xa8, + 0x94,0xaf,0x49,0xf6,0xc6,0x50,0xad,0xb8,0xea,0xb8,0x85,0x8a,0xde,0x92,0xe1,0xbc, + 0xf3,0x15,0xbb,0x5b,0xb8,0x35,0xd8,0x17,0xad,0xcf,0x6b,0x07,0x63,0x61,0x2e,0x2f, + 0xa5,0xc9,0x1d,0xa7,0xac,0xaa,0x4d,0xde,0x71,0x65,0x95,0x87,0x66,0x50,0xa2,0xa6, + 0x28,0xef,0x49,0x5c,0x53,0xa3,0x87,0xad,0x42,0xc3,0x41,0xd8,0xfa,0x92,0xd8,0x32, + 0xce,0x7c,0xf2,0x72,0x2f,0x51,0x27,0x71,0xe3,0x78,0x59,0xf9,0x46,0x23,0xf3,0xa7, + 0x38,0x12,0x05,0xbb,0x1a,0xb0,0xe0,0x12,0xae,0x97,0xa1,0x0f,0xd4,0x34,0xe0,0x15, + 0xb4,0xa3,0x15,0x08,0xbe,0xff,0x4d,0x31,0x81,0x39,0x62,0x29,0xf0,0x90,0x79,0x02, + 0x4d,0x0c,0xf4,0x9e,0xe5,0xd4,0xdc,0xca,0xea,0xb8,0x85,0x8a,0xde,0x92,0xe1,0xbc, + 0xf3,0x15,0xbb,0x5b,0xb8,0x35,0xd8,0x17,0xad,0xcf,0x6b,0x07,0x63,0x61,0x2e,0x2f, + 0xa5,0xc9,0x1d,0xa7,0xac,0xaa,0x4d,0xde,0x71,0x65,0x95,0x87,0x66,0x50,0xa2,0xa6, + 0x28,0xef,0x49,0x5c,0x53,0xa3,0x87,0xad,0x42,0xc3,0x41,0xd8,0xfa,0x92,0xd8,0x32, + 0xce,0x7c,0xf2,0x72,0x2f,0x51,0x27,0x71,0xe3,0x78,0x59,0xf9,0x46,0x23,0xf3,0xa7, + 0x38,0x12,0x05,0xbb,0x1a,0xb0,0xe0,0x12,0xae,0x97,0xa1,0x0f,0xd4,0x34,0xe0,0x15, + 0xf3,0x15,0xbb,0x5b,0xb8,0x35,0xd8,0x17,0xad,0xcf,0x6b,0x07,0x63,0x61,0x2e,0x2f, + 0xa5,0xc9,0x1d,0xa7,0xac,0xaa,0x4d,0xde,0x71,0x65,0x95,0x87,0x66,0x50,0xa2,0xa6, + 0x28,0xef,0x49,0x5c,0x53,0xa3,0x87,0xad,0x42,0xc3,0x41,0xd8,0xfa,0x92,0xd8,0x32, + 0xce,0x7c,0xf2,0x72,0x2f,0x51,0x27,0x71,0xe3,0x78,0x59,0xf9,0x46,0x23,0xf3,0xa7, + 0x38,0x12,0x05,0xbb,0x1a,0xb0,0xe0,0x12,0xae,0x97,0xa1,0x0f,0xd4,0x34,0xe0,0x15, + 0xb4,0xa3,0x15,0x08,0xbe,0xff,0x4d,0x31,0x81,0x39,0x62,0x29,0xf0,0x90,0x79,0x02, + 0x4d,0x0c,0xf4,0x9e,0xe5,0xd4,0xdc,0xca,0xea,0xb8,0x85,0x8a,0xde,0x92,0xe1,0xbc, + 0xf3,0x15,0xbb,0x5b,0xb8,0x35,0xd8,0x17,0xad,0xcf,0x6b,0x07,0x63,0x61,0x2e,0x2f, + 0xa5,0xc9,0x1d,0xa7,0xac,0xaa,0x4d,0xde,0x71,0x65,0x95,0x87,0x66,0x50,0xa2,0xa6, + 0x28,0xef,0x49,0x5c,0x53,0xa3,0x87,0xad,0x42,0xc3,0x41,0xd8,0xfa,0x92,0xd8,0x32, + 0xce,0x7c,0xf2,0x72,0x2f,0x51,0x27,0x71,0xe3,0x78,0x59,0xf9,0x46,0x23,0xf3,0xa7, + 0x38,0x12,0x05,0xbb,0x1a,0xb0,0xe0,0x12,0xae,0x97,0xa1,0x0f,0xd4,0x34,0xe0,0x15, + 0xb4,0xa3,0x15,0x08,0xbe,0xff,0x4d,0x31,0x81,0x39,0x62,0x29,0xf0,0x90,0x79,0x02, + 0x4d,0x0c,0xf4,0x9e,0xe5,0xd4,0xdc,0xca,0xea,0xb8,0x85,0x8a,0xde,0x92,0xe1,0xbc, +}; + +static bool servicing(void *data, stream_t *stream) +{ + test_service_t *test = (test_service_t*)data; + char buf[1024], hdr[256], *start, *end = NULL, *body = NULL, *type = NULL; + struct tm tm; + time_t t; + ssize_t len, tot = 0; + int nr = 0; + + start = buf; + + /* parse method and headers */ + while (end != start) + { + len = stream->read(stream, buf + tot, sizeof(buf) - tot, TRUE); + ck_assert(len > 0); + tot += len; + + while (TRUE) + { + end = memchr(start, '\n', tot); + if (!end) + { + break; + } + *end = '\0'; + ck_assert(end > buf); + ck_assert(*(--end) == '\r'); + *end = '\0'; + if (end == start) + { + body = end + strlen("\r\n"); + break; + } + switch (nr++) + { + case 0: + snprintf(hdr, sizeof(hdr), "%s %s HTTP/1.%u", + test->meth, test->path, test->minor); + ck_assert_str_eq(hdr, start); + break; + default: + if (strcasepfx(start, "Content-Length: ")) + { + ck_assert_int_eq( + atoi(start + strlen("Content-Length: ")), + test->req_len); + } + if (strcasepfx(start, "Content-Type: ")) + { + type = start + strlen("Content-Type: "); + } + break; + } + start = end + strlen("\r\n"); + } + } + + if (test->type) + { + ck_assert(type); + ck_assert_str_eq(type, test->type); + } + + /* request body */ + if (test->req_len) + { + ck_assert(stream->read_all(stream, buf + tot, + test->req_len - (tot - (body - buf)))); + ck_assert(memeq(body, test->req, test->req_len)); + } + + /* response headers */ + snprintf(buf, sizeof(buf), "HTTP/1.%u 200 OK\r\n", test->minor); + ck_assert(stream->write_all(stream, buf, strlen(buf))); + t = time(NULL); + gmtime_r(&t, &tm); + strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z", &tm); + ck_assert(stream->write_all(stream, buf, strlen(buf))); + snprintf(buf, sizeof(buf), "Server: strongSwan unit test\r\n"); + ck_assert(stream->write_all(stream, buf, strlen(buf))); + + /* rest of response headers */ + snprintf(buf, sizeof(buf), "Content-Type: text/plain\r\n"); + ck_assert(stream->write_all(stream, buf, strlen(buf))); + snprintf(buf, sizeof(buf), "Content-Length: %u\r\n", test->res_len); + ck_assert(stream->write_all(stream, buf, strlen(buf))); + snprintf(buf, sizeof(buf), "Connection: close\r\n"); + ck_assert(stream->write_all(stream, buf, strlen(buf))); + snprintf(buf, sizeof(buf), "\r\n"); + ck_assert(stream->write_all(stream, buf, strlen(buf))); + + /* response body */ + ck_assert(stream->write_all(stream, test->res, test->res_len)); + return FALSE; +} + +static test_service_t gtests[] = { + { "GET", 1, "127.0.0.1", 6543, "/a/test/?b=c", NULL, + NULL, 0, "\x12\x34", 2 }, + { "GET", 0, "localhost", 6543, "/", NULL, + NULL, 0, NULL, 0 }, + { "GET", 0, "127.0.0.1", 6543, "/largefile", NULL, + NULL, 0, large, sizeof(large) }, + { "GET", 1, "[::1]", 6543, "/ipv6-url", NULL, + NULL, 0, "\x00\r\n\r\x00testdatablabla", 20 }, +}; + +START_TEST(test_get) +{ + stream_service_t *service; + status_t status; + chunk_t data, expected; + char uri[256]; + + lib->processor->set_threads(lib->processor, 8); + + snprintf(uri, sizeof(uri), "tcp://%s:%u", gtests[_i].host, gtests[_i].port); + service = lib->streams->create_service(lib->streams, uri, 1); + ck_assert(service != NULL); + service->on_accept(service, servicing, >ests[_i], JOB_PRIO_HIGH, 0); + + snprintf(uri, sizeof(uri), "http://%s:%u%s", + gtests[_i].host, gtests[_i].port, gtests[_i].path); + status = lib->fetcher->fetch(lib->fetcher, uri, &data, + !gtests[_i].minor ? FETCH_HTTP_VERSION_1_0 : FETCH_END, + FETCH_END); + ck_assert_int_eq(status, SUCCESS); + expected = chunk_create(gtests[_i].res, gtests[_i].res_len); + ck_assert_msg(chunk_compare(expected, data) == 0, + "exp %B\ngot %B\n", &expected, &data); + free(data.ptr); + + service->destroy(service); +} +END_TEST + + +static test_service_t ptests[] = { + { "POST", 1, "127.0.0.1", 6543, "/a/test/?b=c", "application/binary", + "\x23\x45", 2, "\x12\x34", 2 }, + { "POST", 0, "localhost", 6543, "/largefile", "application/x-large", + large, sizeof(large), large, sizeof(large) }, + { "POST", 1, "[::1]", 6543, "/ipv6-url", "text/plain", + "\x00\r\n\r\x00testdatablabla", 20, "\x00\r\n\r\x00testdatablabla", 20 }, +}; + +START_TEST(test_post) +{ + stream_service_t *service; + status_t status; + chunk_t data, expected; + char uri[256]; + + lib->processor->set_threads(lib->processor, 8); + + snprintf(uri, sizeof(uri), "tcp://%s:%u", ptests[_i].host, ptests[_i].port); + service = lib->streams->create_service(lib->streams, uri, 1); + ck_assert(service != NULL); + service->on_accept(service, servicing, &ptests[_i], JOB_PRIO_HIGH, 0); + + snprintf(uri, sizeof(uri), "http://%s:%u%s", + ptests[_i].host, ptests[_i].port, ptests[_i].path); + status = lib->fetcher->fetch(lib->fetcher, uri, &data, + FETCH_REQUEST_TYPE, ptests[_i].type, + FETCH_REQUEST_DATA, + chunk_create(ptests[_i].req, ptests[_i].req_len), + !ptests[_i].minor ? FETCH_HTTP_VERSION_1_0 : FETCH_END, + FETCH_END); + ck_assert_int_eq(status, SUCCESS); + expected = chunk_create(ptests[_i].res, ptests[_i].res_len); + ck_assert_msg(chunk_compare(expected, data) == 0, + "exp %B\ngot %B\n", &expected, &data); + free(data.ptr); + + service->destroy(service); +} +END_TEST + +Suite *fetch_http_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("http fetcher"); + + tc = tcase_create("GET"); + tcase_add_loop_test(tc, test_get, 0, countof(gtests)); + suite_add_tcase(s, tc); + + tc = tcase_create("POST"); + tcase_add_loop_test(tc, test_post, 0, countof(ptests)); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/suites/test_hasher.c b/src/libstrongswan/tests/suites/test_hasher.c new file mode 100644 index 000000000..41a9d64ef --- /dev/null +++ b/src/libstrongswan/tests/suites/test_hasher.c @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2013 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <crypto/hashers/hasher.h> +#include <crypto/prfs/prf.h> +#include <crypto/signers/signer.h> +#include <asn1/oid.h> +#include <utils/test.h> + +typedef struct { + int oid; + hash_algorithm_t alg; + key_type_t key; +}hasher_oid_t; + +static hasher_oid_t oids[] = { + { OID_MD2, HASH_MD2, KEY_ANY }, + { OID_MD5, HASH_MD5, KEY_ANY }, + { OID_SHA1, HASH_SHA1, KEY_ANY }, + { OID_SHA224, HASH_SHA224, KEY_ANY }, + { OID_SHA256, HASH_SHA256, KEY_ANY }, + { OID_SHA384, HASH_SHA384, KEY_ANY }, + { OID_SHA512, HASH_SHA512, KEY_ANY }, + { OID_UNKNOWN, HASH_UNKNOWN, KEY_ANY }, + { OID_MD2_WITH_RSA, HASH_MD2, KEY_RSA }, + { OID_MD5_WITH_RSA, HASH_MD5, KEY_RSA }, + { OID_SHA1_WITH_RSA, HASH_SHA1, KEY_RSA }, + { OID_SHA224_WITH_RSA, HASH_SHA224, KEY_RSA }, + { OID_SHA256_WITH_RSA, HASH_SHA256, KEY_RSA }, + { OID_SHA384_WITH_RSA, HASH_SHA384, KEY_RSA }, + { OID_SHA512_WITH_RSA, HASH_SHA512, KEY_RSA }, + { OID_UNKNOWN, HASH_UNKNOWN, KEY_RSA }, + { OID_ECDSA_WITH_SHA1, HASH_SHA1, KEY_ECDSA }, + { OID_ECDSA_WITH_SHA256, HASH_SHA256, KEY_ECDSA }, + { OID_ECDSA_WITH_SHA384, HASH_SHA384, KEY_ECDSA }, + { OID_ECDSA_WITH_SHA512, HASH_SHA512, KEY_ECDSA }, + { OID_UNKNOWN, HASH_UNKNOWN, KEY_ECDSA } +}; + +START_TEST(test_hasher_from_oid) +{ + ck_assert(hasher_algorithm_from_oid(oids[_i].oid) == oids[_i].alg); +} +END_TEST + +START_TEST(test_hasher_to_oid) +{ + ck_assert(hasher_algorithm_to_oid(oids[_i].alg) == oids[_i].oid); +} +END_TEST + +START_TEST(test_hasher_sig_to_oid) +{ + ck_assert(hasher_signature_algorithm_to_oid(oids[_i].alg, + oids[_i].key) == oids[_i].oid); +} +END_TEST + +typedef struct { + pseudo_random_function_t prf; + hash_algorithm_t alg; +}hasher_prf_t; + +static hasher_prf_t prfs[] = { + { PRF_HMAC_MD5, HASH_MD5 }, + { PRF_HMAC_SHA1, HASH_SHA1 }, + { PRF_FIPS_SHA1_160, HASH_SHA1 }, + { PRF_KEYED_SHA1, HASH_SHA1 }, + { PRF_HMAC_SHA2_256, HASH_SHA256 }, + { PRF_HMAC_SHA2_384, HASH_SHA384 }, + { PRF_HMAC_SHA2_512, HASH_SHA512 }, + { PRF_HMAC_TIGER, HASH_UNKNOWN }, + { PRF_AES128_XCBC, HASH_UNKNOWN }, + { PRF_AES128_CMAC, HASH_UNKNOWN }, + { PRF_FIPS_DES, HASH_UNKNOWN }, + { PRF_CAMELLIA128_XCBC, HASH_UNKNOWN }, + { PRF_UNDEFINED, HASH_UNKNOWN }, + { 0, HASH_UNKNOWN } +}; + +START_TEST(test_hasher_from_prf) +{ + ck_assert(hasher_algorithm_from_prf(prfs[_i].prf) == prfs[_i].alg); +} +END_TEST + +typedef struct { + integrity_algorithm_t auth; + hash_algorithm_t alg; + size_t length; +}hasher_auth_t; + +static hasher_auth_t auths[] = { + { AUTH_UNDEFINED, HASH_MD2, 0 }, + { AUTH_UNDEFINED, HASH_MD4, 0 }, + { AUTH_UNDEFINED, HASH_SHA224, 0 }, + { AUTH_UNDEFINED, 9, 0 }, + { AUTH_UNDEFINED, HASH_UNKNOWN, 0 }, + { AUTH_HMAC_MD5_96, HASH_MD5, 12 }, + { AUTH_HMAC_SHA1_96, HASH_SHA1, 12 }, + { AUTH_HMAC_SHA2_256_96, HASH_SHA256, 12 }, + { AUTH_HMAC_MD5_128, HASH_MD5, 16 }, + { AUTH_HMAC_SHA1_128, HASH_SHA1, 16 }, + { AUTH_HMAC_SHA2_256_128, HASH_SHA256, 16 }, + { AUTH_HMAC_SHA1_160, HASH_SHA1, 20 }, + { AUTH_HMAC_SHA2_384_192, HASH_SHA384, 24 }, + { AUTH_HMAC_SHA2_256_256, HASH_SHA256, 32 }, + { AUTH_HMAC_SHA2_512_256, HASH_SHA512, 32 }, + { AUTH_HMAC_SHA2_384_384, HASH_SHA384, 48 }, + { AUTH_HMAC_SHA2_512_512, HASH_SHA512, 64 }, + { AUTH_AES_CMAC_96, HASH_UNKNOWN, 0 }, + { AUTH_AES_128_GMAC, HASH_UNKNOWN, 0 }, + { AUTH_AES_192_GMAC, HASH_UNKNOWN, 0 }, + { AUTH_AES_256_GMAC, HASH_UNKNOWN, 0 }, + { AUTH_AES_XCBC_96, HASH_UNKNOWN, 0 }, + { AUTH_DES_MAC, HASH_UNKNOWN, 0 }, + { AUTH_CAMELLIA_XCBC_96, HASH_UNKNOWN, 0 }, + { 0, HASH_UNKNOWN, 0 } +}; + +START_TEST(test_hasher_from_integrity) +{ + size_t length; + + length = 0; + ck_assert(hasher_algorithm_from_integrity(auths[_i].auth, NULL) == + auths[_i].alg); + ck_assert(hasher_algorithm_from_integrity(auths[_i].auth, &length) == + auths[_i].alg); + ck_assert(length == auths[_i].length); +} +END_TEST + +START_TEST(test_hasher_to_integrity) +{ + ck_assert(hasher_algorithm_to_integrity( + auths[_i].alg, auths[_i].length) == auths[_i].auth); + ck_assert(hasher_algorithm_to_integrity( + auths[_i].alg, 0) == AUTH_UNDEFINED); +} +END_TEST + +Suite *hasher_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("hasher"); + + tc = tcase_create("from_oid"); + tcase_add_loop_test(tc, test_hasher_from_oid, 0, 15); + suite_add_tcase(s, tc); + + tc = tcase_create("to_oid"); + tcase_add_loop_test(tc, test_hasher_to_oid, 0, 8); + suite_add_tcase(s, tc); + + tc = tcase_create("sig_to_oid"); + tcase_add_loop_test(tc, test_hasher_sig_to_oid, 7, countof(oids)); + suite_add_tcase(s, tc); + + tc = tcase_create("from_prf"); + tcase_add_loop_test(tc, test_hasher_from_prf, 0, countof(prfs)); + suite_add_tcase(s, tc); + + tc = tcase_create("from_integrity"); + tcase_add_loop_test(tc, test_hasher_from_integrity, 4, countof(auths)); + suite_add_tcase(s, tc); + + tc = tcase_create("to_integrity"); + tcase_add_loop_test(tc, test_hasher_to_integrity, 0, 17); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/test_hashtable.c b/src/libstrongswan/tests/suites/test_hashtable.c index 8cc7bfe42..8cc7bfe42 100644 --- a/src/libstrongswan/tests/test_hashtable.c +++ b/src/libstrongswan/tests/suites/test_hashtable.c diff --git a/src/libstrongswan/tests/test_host.c b/src/libstrongswan/tests/suites/test_host.c index 30b9eb940..30b9eb940 100644 --- a/src/libstrongswan/tests/test_host.c +++ b/src/libstrongswan/tests/suites/test_host.c diff --git a/src/libstrongswan/tests/test_identification.c b/src/libstrongswan/tests/suites/test_identification.c index 1dc6776d1..edf53f0fd 100644 --- a/src/libstrongswan/tests/test_identification.c +++ b/src/libstrongswan/tests/suites/test_identification.c @@ -179,7 +179,7 @@ static struct { START_TEST(test_from_string) { identification_t *a; - chunk_t encoding, expected; + chunk_t encoding, expected = chunk_empty; char *id; id = string_data[_i].id; diff --git a/src/libstrongswan/tests/test_linked_list.c b/src/libstrongswan/tests/suites/test_linked_list.c index 9e85c58d8..922f954e3 100644 --- a/src/libstrongswan/tests/test_linked_list.c +++ b/src/libstrongswan/tests/suites/test_linked_list.c @@ -246,10 +246,10 @@ struct invoke_t { static void invoke(intptr_t item, void *a, void *b, void *c, void *d, int *sum) { - ck_assert(a == (void*)1); - ck_assert(b == (void*)2); - ck_assert(c == (void*)3); - ck_assert(d == (void*)4); + ck_assert_int_eq((uintptr_t)a, 1); + ck_assert_int_eq((uintptr_t)b, 2); + ck_assert_int_eq((uintptr_t)c, 3); + ck_assert_int_eq((uintptr_t)d, 4); *sum += item; } @@ -267,7 +267,9 @@ START_TEST(test_invoke_function) list->insert_last(list, (void*)3); list->insert_last(list, (void*)4); list->insert_last(list, (void*)5); - list->invoke_function(list, (linked_list_invoke_t)invoke, 1, 2, 3, 4, &sum); + list->invoke_function(list, (linked_list_invoke_t)invoke, + (uintptr_t)1, (uintptr_t)2, + (uintptr_t)3, (uintptr_t)4, &sum); ck_assert_int_eq(sum, 15); } END_TEST @@ -287,7 +289,9 @@ START_TEST(test_invoke_offset) { list->insert_last(list, &items[i]); } - list->invoke_offset(list, offsetof(invoke_t, invoke), 1, 2, 3, 4, &sum); + list->invoke_offset(list, offsetof(invoke_t, invoke), + (uintptr_t)1, (uintptr_t)2, + (uintptr_t)3, (uintptr_t)4, &sum); ck_assert_int_eq(sum, 15); } END_TEST @@ -303,7 +307,7 @@ struct clone_t { void *(*clone)(clone_t *item); }; -static void *clone(clone_t *item) +static void *clonefn(clone_t *item) { return item->val; } @@ -326,11 +330,11 @@ START_TEST(test_clone_offset) { linked_list_t *other; clone_t items[] = { - { .val = (void*)1, .clone = clone, }, - { .val = (void*)2, .clone = clone, }, - { .val = (void*)3, .clone = clone, }, - { .val = (void*)4, .clone = clone, }, - { .val = (void*)5, .clone = clone, }, + { .val = (void*)1, .clone = clonefn, }, + { .val = (void*)2, .clone = clonefn, }, + { .val = (void*)3, .clone = clonefn, }, + { .val = (void*)4, .clone = clonefn, }, + { .val = (void*)5, .clone = clonefn, }, }; int i; diff --git a/src/libstrongswan/tests/test_linked_list_enumerator.c b/src/libstrongswan/tests/suites/test_linked_list_enumerator.c index 48d6f40e6..48d6f40e6 100644 --- a/src/libstrongswan/tests/test_linked_list_enumerator.c +++ b/src/libstrongswan/tests/suites/test_linked_list_enumerator.c diff --git a/src/libstrongswan/tests/suites/test_ntru.c b/src/libstrongswan/tests/suites/test_ntru.c new file mode 100644 index 000000000..a46f5742c --- /dev/null +++ b/src/libstrongswan/tests/suites/test_ntru.c @@ -0,0 +1,1042 @@ +/* + * Copyright (C) 2013-2014 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <tests/utils/test_rng.h> +#include <plugins/ntru/ntru_drbg.h> +#include <plugins/ntru/ntru_mgf1.h> +#include <plugins/ntru/ntru_trits.h> +#include <plugins/ntru/ntru_poly.h> +#include <utils/test.h> + +IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_drbg_create, ntru_drbg_t*, + u_int32_t strength, chunk_t pers_str, rng_t *entropy) + +IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_mgf1_create, ntru_mgf1_t*, + hash_algorithm_t alg, chunk_t seed, bool hash_seed) + +IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_trits_create, ntru_trits_t*, + size_t len, hash_algorithm_t alg, chunk_t seed) + +IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_poly_create_from_seed, ntru_poly_t*, + hash_algorithm_t alg, chunk_t seed, uint8_t c_bits, + uint16_t N, uint16_t q, uint32_t indices_len_p, + uint32_t indices_len_m, bool is_product_form) + +IMPORT_FUNCTION_FOR_TESTS(ntru, ntru_poly_create_from_data, ntru_poly_t*, + u_int16_t *data, uint16_t N, uint16_t q, + uint32_t indices_len_p, uint32_t indices_len_m, + bool is_product_form) + +/** + * NTRU parameter sets to test + */ +static struct { + diffie_hellman_group_t group; + char *group_name; +} params[] = { + { NTRU_112_BIT, "NTRU_112" }, + { NTRU_128_BIT, "NTRU_128" }, + { NTRU_192_BIT, "NTRU_192" }, + { NTRU_256_BIT, "NTRU_256" } +}; + +/** + * NTRU parameter set selection + */ +char *parameter_sets[] = { + "x9_98_speed", "x9_98_bandwidth", "x9_98_balance", "optimum" +}; + +typedef struct { + u_int32_t requested; + u_int32_t standard; +}strength_t; + +strength_t strengths[] = { + { 80, 112 }, + { 112, 112 }, + { 120, 128 }, + { 128, 128 }, + { 150, 192 }, + { 192, 192 }, + { 200, 256 }, + { 256, 256 }, + { 512, 0 } +}; + +START_TEST(test_ntru_drbg_strength) +{ + ntru_drbg_t *drbg; + rng_t *entropy; + + entropy = lib->crypto->create_rng(lib->crypto, RNG_STRONG); + ck_assert(entropy != NULL); + + drbg = ntru_drbg_create(strengths[_i].requested, chunk_empty, entropy); + if (strengths[_i].standard) + { + ck_assert(drbg != NULL); + ck_assert(drbg->get_strength(drbg) == strengths[_i].standard); + drbg->destroy(drbg); + } + else + { + ck_assert(drbg == NULL); + } + entropy->destroy(entropy); +} +END_TEST + +typedef struct { + chunk_t pers_str; + chunk_t entropy; + chunk_t out; +} drbg_test_t; + +/** + * NIST SP 800-90A Deterministic Random Generator Validation System (DRBGVS) + */ +drbg_test_t drbg_tests[] = { + /* SHA-256 test case 1 - count 0 */ + { { NULL, 0 }, + chunk_from_chars(0x06, 0x03, 0x2c, 0xd5, 0xee, 0xd3, 0x3f, 0x39, + 0x26, 0x5f, 0x49, 0xec, 0xb1, 0x42, 0xc5, 0x11, + 0xda, 0x9a, 0xff, 0x2a, 0xf7, 0x12, 0x03, 0xbf, + 0xfa, 0xf3, 0x4a, 0x9c, 0xa5, 0xbd, 0x9c, 0x0d, + 0x0e, 0x66, 0xf7, 0x1e, 0xdc, 0x43, 0xe4, 0x2a, + 0x45, 0xad, 0x3c, 0x6f, 0xc6, 0xcd, 0xc4, 0xdf, + 0x01, 0x92, 0x0a, 0x4e, 0x66, 0x9e, 0xd3, 0xa8, + 0x5a, 0xe8, 0xa3, 0x3b, 0x35, 0xa7, 0x4a, 0xd7, + 0xfb, 0x2a, 0x6b, 0xb4, 0xcf, 0x39, 0x5c, 0xe0, + 0x03, 0x34, 0xa9, 0xc9, 0xa5, 0xa5, 0xd5, 0x52), + chunk_from_chars(0x76, 0xfc, 0x79, 0xfe, 0x9b, 0x50, 0xbe, 0xcc, + 0xc9, 0x91, 0xa1, 0x1b, 0x56, 0x35, 0x78, 0x3a, + 0x83, 0x53, 0x6a, 0xdd, 0x03, 0xc1, 0x57, 0xfb, + 0x30, 0x64, 0x5e, 0x61, 0x1c, 0x28, 0x98, 0xbb, + 0x2b, 0x1b, 0xc2, 0x15, 0x00, 0x02, 0x09, 0x20, + 0x8c, 0xd5, 0x06, 0xcb, 0x28, 0xda, 0x2a, 0x51, + 0xbd, 0xb0, 0x38, 0x26, 0xaa, 0xf2, 0xbd, 0x23, + 0x35, 0xd5, 0x76, 0xd5, 0x19, 0x16, 0x08, 0x42, + 0xe7, 0x15, 0x8a, 0xd0, 0x94, 0x9d, 0x1a, 0x9e, + 0xc3, 0xe6, 0x6e, 0xa1, 0xb1, 0xa0, 0x64, 0xb0, + 0x05, 0xde, 0x91, 0x4e, 0xac, 0x2e, 0x9d, 0x4f, + 0x2d, 0x72, 0xa8, 0x61, 0x6a, 0x80, 0x22, 0x54, + 0x22, 0x91, 0x82, 0x50, 0xff, 0x66, 0xa4, 0x1b, + 0xd2, 0xf8, 0x64, 0xa6, 0xa3, 0x8c, 0xc5, 0xb6, + 0x49, 0x9d, 0xc4, 0x3f, 0x7f, 0x2b, 0xd0, 0x9e, + 0x1e, 0x0f, 0x8f, 0x58, 0x85, 0x93, 0x51, 0x24) + }, + /* SHA-256 test case 3 - count 0 */ + { chunk_from_chars(0xf2, 0xe5, 0x8f, 0xe6, 0x0a, 0x3a, 0xfc, 0x59, + 0xda, 0xd3, 0x75, 0x95, 0x41, 0x5f, 0xfd, 0x31, + 0x8c, 0xcf, 0x69, 0xd6, 0x77, 0x80, 0xf6, 0xfa, + 0x07, 0x97, 0xdc, 0x9a, 0xa4, 0x3e, 0x14, 0x4c), + chunk_from_chars(0xfa, 0x0e, 0xe1, 0xfe, 0x39, 0xc7, 0xc3, 0x90, + 0xaa, 0x94, 0x15, 0x9d, 0x0d, 0xe9, 0x75, 0x64, + 0x34, 0x2b, 0x59, 0x17, 0x77, 0xf3, 0xe5, 0xf6, + 0xa4, 0xba, 0x2a, 0xea, 0x34, 0x2e, 0xc8, 0x40, + 0xdd, 0x08, 0x20, 0x65, 0x5c, 0xb2, 0xff, 0xdb, + 0x0d, 0xa9, 0xe9, 0x31, 0x0a, 0x67, 0xc9, 0xe5, + 0xe0, 0x62, 0x9b, 0x6d, 0x79, 0x75, 0xdd, 0xfa, + 0x96, 0xa3, 0x99, 0x64, 0x87, 0x40, 0xe6, 0x0f, + 0x1f, 0x95, 0x57, 0xdc, 0x58, 0xb3, 0xd7, 0x41, + 0x5f, 0x9b, 0xa9, 0xd4, 0xdb, 0xb5, 0x01, 0xf6), + chunk_from_chars(0xf9, 0x2d, 0x4c, 0xf9, 0x9a, 0x53, 0x5b, 0x20, + 0x22, 0x2a, 0x52, 0xa6, 0x8d, 0xb0, 0x4c, 0x5a, + 0xf6, 0xf5, 0xff, 0xc7, 0xb6, 0x6a, 0x47, 0x3a, + 0x37, 0xa2, 0x56, 0xbd, 0x8d, 0x29, 0x8f, 0x9b, + 0x4a, 0xa4, 0xaf, 0x7e, 0x8d, 0x18, 0x1e, 0x02, + 0x36, 0x79, 0x03, 0xf9, 0x3b, 0xdb, 0x74, 0x4c, + 0x6c, 0x2f, 0x3f, 0x34, 0x72, 0x62, 0x6b, 0x40, + 0xce, 0x9b, 0xd6, 0xa7, 0x0e, 0x7b, 0x8f, 0x93, + 0x99, 0x2a, 0x16, 0xa7, 0x6f, 0xab, 0x6b, 0x5f, + 0x16, 0x25, 0x68, 0xe0, 0x8e, 0xe6, 0xc3, 0xe8, + 0x04, 0xae, 0xfd, 0x95, 0x2d, 0xdd, 0x3a, 0xcb, + 0x79, 0x1c, 0x50, 0xf2, 0xad, 0x69, 0xe9, 0xa0, + 0x40, 0x28, 0xa0, 0x6a, 0x9c, 0x01, 0xd3, 0xa6, + 0x2a, 0xca, 0x2a, 0xaf, 0x6e, 0xfe, 0x69, 0xed, + 0x97, 0xa0, 0x16, 0x21, 0x3a, 0x2d, 0xd6, 0x42, + 0xb4, 0x88, 0x67, 0x64, 0x07, 0x2d, 0x9c, 0xbe) + }, + /* SHA-256 test case 5 - count 0 */ + { { NULL, 0 }, + chunk_from_chars(0xff, 0x0c, 0xdd, 0x55, 0x5c, 0x60, 0x46, 0x47, + 0x60, 0xb2, 0x89, 0xb7, 0xbc, 0x1f, 0x81, 0x1a, + 0x41, 0xff, 0xf7, 0x2d, 0xe5, 0x90, 0x83, 0x85, + 0x8c, 0x02, 0x0a, 0x10, 0x53, 0xbd, 0xc7, 0x4a, + 0x7b, 0xc0, 0x99, 0x28, 0x5a, 0xd5, 0x62, 0x19, + 0x93, 0xb6, 0x39, 0xc4, 0xa9, 0x4c, 0x37, 0x6b, + 0x14, 0xfc, 0x6c, 0x9b, 0x17, 0x8d, 0xb6, 0x44, + 0xa8, 0xcd, 0x71, 0x30, 0xa4, 0xcf, 0x05, 0x16, + 0x78, 0xc8, 0xf4, 0xfa, 0x8f, 0x24, 0xc2, 0x7b, + 0x0a, 0x53, 0x13, 0x38, 0xa5, 0xce, 0x85, 0x89), + chunk_from_chars(0x2f, 0x26, 0x20, 0x34, 0x7b, 0xdd, 0xca, 0xa2, + 0x94, 0x36, 0x85, 0x34, 0x6b, 0xbf, 0x31, 0xc4, + 0x40, 0x81, 0xf8, 0x66, 0x5f, 0x3d, 0xdb, 0x2b, + 0x42, 0xae, 0x14, 0x16, 0xa7, 0x4c, 0x4b, 0x77, + 0xfa, 0xb3, 0xfa, 0x19, 0xae, 0xec, 0xc5, 0x47, + 0xe7, 0x6c, 0x8c, 0xbe, 0x6a, 0xd1, 0xf1, 0x00, + 0xa3, 0xfc, 0x8b, 0x2c, 0xe2, 0xa1, 0xea, 0x3a, + 0x3d, 0xd7, 0xcf, 0xad, 0x46, 0xc1, 0xb2, 0x78, + 0x30, 0xb9, 0x40, 0xba, 0x18, 0xd0, 0x9e, 0x9b, + 0x7f, 0xa9, 0x02, 0xbb, 0x76, 0x06, 0x69, 0xb1, + 0x73, 0x5c, 0xc7, 0xb7, 0xbd, 0x39, 0x05, 0x2d, + 0xa7, 0xf2, 0x62, 0x6f, 0xa8, 0x70, 0x00, 0xcf, + 0xfa, 0xda, 0x41, 0x00, 0x19, 0xd0, 0x53, 0x38, + 0x6a, 0xd8, 0x08, 0xbd, 0x3c, 0x0c, 0xfc, 0xf5, + 0x6b, 0x91, 0x87, 0x9e, 0xb8, 0xd3, 0xf9, 0x32, + 0xee, 0x2d, 0x18, 0x5e, 0x54, 0xf3, 0x1b, 0x74) + }, + /* SHA-256 test case 7 - count 0 */ + { chunk_from_chars(0x40, 0x93, 0x3f, 0xdc, 0xce, 0x41, 0x59, 0xb0, + 0x95, 0x51, 0x11, 0xf8, 0x44, 0x47, 0x1b, 0x0d, + 0xb8, 0x5b, 0x73, 0xbd, 0xd2, 0xb7, 0x8c, 0x46, + 0x8d, 0xd3, 0x9e, 0x2a, 0x9b, 0x29, 0xae, 0xf2), + chunk_from_chars(0x28, 0xba, 0x1a, 0x66, 0x16, 0x32, 0xef, 0xc8, + 0xec, 0xce, 0xd5, 0xf5, 0x1b, 0x79, 0x13, 0x00, + 0xfb, 0x3b, 0x55, 0xb0, 0x5d, 0x04, 0x17, 0x08, + 0x63, 0x8d, 0xe4, 0xbe, 0xb7, 0x57, 0xa9, 0xe5, + 0x76, 0x82, 0x87, 0x96, 0xaf, 0xf0, 0x7f, 0x55, + 0x79, 0x5c, 0xb5, 0x47, 0x13, 0xc7, 0x7e, 0xd4, + 0xa5, 0xf5, 0x42, 0xb0, 0x4a, 0xaa, 0x5d, 0xbc, + 0x93, 0x1e, 0x47, 0x01, 0x9f, 0xeb, 0x38, 0x96, + 0x26, 0x16, 0xc5, 0x7a, 0xf0, 0x9b, 0x7c, 0x1d, + 0xf8, 0x3f, 0x2b, 0x86, 0x0f, 0xf7, 0x65, 0x86), + chunk_from_chars(0x65, 0xe5, 0xaa, 0x47, 0xb3, 0x85, 0xf1, 0xea, + 0x42, 0xb2, 0x31, 0xb9, 0xfe, 0x74, 0x42, 0x53, + 0xb8, 0x59, 0x88, 0x59, 0xd7, 0x01, 0x1e, 0x52, + 0x5f, 0x5a, 0x2a, 0x1a, 0xd3, 0x2a, 0x97, 0x2a, + 0x85, 0x08, 0x02, 0xc6, 0x0a, 0x2b, 0xe1, 0x9b, + 0xe2, 0x70, 0x06, 0x3a, 0x3c, 0xfb, 0xea, 0xae, + 0x95, 0x4f, 0x10, 0xb1, 0x22, 0x35, 0x2d, 0xe6, + 0xa0, 0x8a, 0xc4, 0x10, 0xe0, 0x99, 0x16, 0x53, + 0xaa, 0xb2, 0x71, 0xb3, 0x60, 0xfe, 0x91, 0x91, + 0xcf, 0x5a, 0xdd, 0xcc, 0xcc, 0xed, 0x8c, 0x4a, + 0xcf, 0xb6, 0x14, 0x57, 0x04, 0x99, 0x92, 0x98, + 0x8f, 0xd7, 0xa9, 0xac, 0xca, 0x1f, 0x1b, 0xca, + 0x35, 0xf1, 0x47, 0x58, 0x13, 0x69, 0x4a, 0x39, + 0x98, 0x8e, 0x5f, 0xac, 0x9f, 0x4a, 0xc0, 0x57, + 0x22, 0x86, 0xbc, 0x46, 0x25, 0x82, 0xad, 0x0a, + 0xf7, 0x8a, 0xb3, 0xb8, 0x5e, 0xc1, 0x7a, 0x25) + } +}; + +START_TEST(test_ntru_drbg) +{ + ntru_drbg_t *drbg; + rng_t *entropy; + chunk_t out; + + out = chunk_alloc(128); + entropy = test_rng_create(drbg_tests[_i].entropy); + drbg = ntru_drbg_create(256, drbg_tests[_i].pers_str, entropy); + ck_assert(drbg != NULL); + ck_assert(drbg->reseed(drbg)); + ck_assert(drbg->generate(drbg, 256, 128, out.ptr)); + ck_assert(drbg->generate(drbg, 256, 128, out.ptr)); + ck_assert(chunk_equals(out, drbg_tests[_i].out)); + drbg->destroy(drbg); + entropy->destroy(entropy); + chunk_free(&out); +} +END_TEST + +START_TEST(test_ntru_drbg_reseed) +{ + ntru_drbg_t *drbg; + rng_t *entropy; + chunk_t out; + + lib->settings->set_int(lib->settings, + "libstrongswan.plugins.ntru.max_drbg_requests", 2); + out = chunk_alloc(128); + entropy = test_rng_create(drbg_tests[0].entropy); + drbg = ntru_drbg_create(256, chunk_empty, entropy); + + /* bad output parameters */ + ck_assert(!drbg->generate(drbg, 256, 0, out.ptr)); + ck_assert(!drbg->generate(drbg, 256, 128, NULL)); + + /* no reseeding occurs */ + ck_assert(drbg->generate(drbg, 256, 128, out.ptr)); + ck_assert(drbg->generate(drbg, 256, 128, out.ptr)); + + /* consuming remaining entropy */ + ck_assert(entropy->get_bytes(entropy, 32, out.ptr)); + + /* no entropy available for automatic reseeding */ + ck_assert(!drbg->generate(drbg, 256, 128, out.ptr)); + drbg->destroy(drbg); + + /* no entropy available for DRBG instantiation */ + drbg = ntru_drbg_create(256, chunk_empty, entropy); + ck_assert(drbg == NULL); + entropy->destroy(entropy); + + /* one automatic reseeding occurs */ + entropy = test_rng_create(drbg_tests[0].entropy); + drbg = ntru_drbg_create(256, chunk_empty, entropy); + ck_assert(drbg->generate(drbg, 256, 128, out.ptr)); + ck_assert(drbg->generate(drbg, 256, 128, out.ptr)); + ck_assert(drbg->generate(drbg, 256, 128, out.ptr)); + + /* no entropy left */ + ck_assert(!entropy->get_bytes(entropy, 32, out.ptr)); + + drbg->destroy(drbg); + entropy->destroy(entropy); + chunk_free(&out); + lib->settings->set_int(lib->settings, + "libstrongswan.plugins.ntru.max_drbg_requests", 2000); +} +END_TEST + +typedef struct { + uint8_t c_bits; + uint16_t N; + uint16_t q; + bool is_product_form; + uint32_t indices_len; + uint32_t indices_size; + uint16_t *indices; +} poly_test_t; + +typedef struct { + hash_algorithm_t alg; + size_t hash_size; + size_t ml1, ml2, ml3, seed_len; + chunk_t seed; + chunk_t hashed_seed; + chunk_t mask; + chunk_t trits; + poly_test_t poly_test[2]; +} mgf1_test_t; + +uint16_t indices_ees439ep1[] = { + 367, 413, 16, 214, 114, 128, 42, 268, 346, 329, 119, 303, 208, 287, 150, + 3, 45, 321, 110, 109, 272, 430, 80, 305, 51, 381, 322, 140, 207, 315, + 206, 186, 56, 5, 273, 177, 44, 100, 205, 210, 98, 191, 8, 336 +}; + +uint16_t indices_ees613ep1[] = { + 245, 391, 251, 428, 301, 2, 176, 296, 461, 224, 590, 215, 250, 91, 395, + 363, 58, 537, 278, 291, 247, 33, 140, 447, 172, 514, 424, 412, 95, 94, + 281, 159, 196, 302, 277, 63, 404, 150, 608, 315, 195, 334, 207, 376, 398, + 0, 309, 486, 516, 86, 267, 139, 130, 38, 141, 258, 21, 341, 526, 388, + 194, 116, 138, 524, 547, 383, 542, 406, 270, 438, 240, 445, 527, 168, 320, + 186, 327, 212, 543, 82, 606, 131, 294, 392, 477, 430, 583, 142, 253, 434, + 134, 458, 559, 414, 162, 407, 580, 577, 191, 109, 554, 523, 32, 62, 297, + 283, 268, 54, 539, 5 +}; + +uint16_t indices_ees743ep1[] = { + 285, 62, 136, 655, 460, 35, 450, 208, 340, 212, 61, 234, 454, 52, 520, + 399, 315, 616, 496, 88, 280, 543, 508, 237, 553, 39, 214, 253, 720, 291, + 586, 615, 635, 596, 62, 499, 301, 176, 271, 659, 372, 185, 621, 350, 683, + 180, 717, 509, 641, 738, 666, 171, 639, 606, 353, 706, 237, 358, 410, 423, + 197, 501, 261, 654, 658, 701, 377, 182, 548, 287, 700, 403, 248, 137 +}; + +uint16_t indices_ees1171ep1[] = { + 514, 702, 760, 505, 262, 486, 695, 783, 533, 74, 403, 847, 170,1019, 568, + 676,1057, 277,1021, 238, 203, 884, 124, 87, 65, 93, 131, 881,1102, 133, + 459, 462, 92, 40, 5,1152,1158, 297, 599, 299, 7, 458, 347, 343, 173, + 1044, 264, 871, 819, 679, 328, 438, 990, 982, 308,1135, 423, 470, 254, 295, + 1029, 892, 759, 789, 123, 939, 749, 353,1062, 145, 562, 337, 550, 102, 549, + 821,1098, 823, 96, 365, 135,1110, 334, 391, 638, 963, 962,1002,1069, 993, + 983, 649,1056, 399, 385, 715, 582, 799, 161, 512, 629, 979, 250, 37, 213, + 929, 413, 566, 336, 727, 160, 616,1170, 748, 282,1115, 325, 994, 189, 500, + 913, 332,1118, 753, 946, 775, 59, 809, 782, 612, 909,1090, 223, 777, 940, + 866,1032, 471, 298, 969, 192, 411, 721, 476, 910,1045,1027, 812, 352, 487, + 215, 625, 808, 230, 602, 457, 900, 416, 985, 850, 908, 155, 670, 669,1054, + 400,1126, 733, 647, 786, 195, 148, 362,1094, 389,1086,1166, 231, 436, 210, + 333, 824, 785, 826, 658, 472, 639,1046,1028, 519, 422, 80, 924,1089, 547, + 1157, 579, 2, 508,1040, 998, 902,1058, 600, 220, 805, 945, 140,1117, 179, + 536, 191 +}; + +/** + * MGF1 Mask Generation Function Test Vectors + */ +mgf1_test_t mgf1_tests[] = { + { HASH_SHA1, 20, 60, 20, 15, 24, + chunk_from_chars( + 0xED, 0xA5, 0xC3, 0xBC, 0xAF, 0xB3, 0x20, 0x7D, + 0x14, 0xA1, 0x54, 0xF7, 0x8B, 0x37, 0xF2, 0x8D, + 0x8C, 0x9B, 0xD5, 0x63, 0x57, 0x38, 0x11, 0xC2, + 0xB5, 0xCA, 0xBF, 0x06, 0x43, 0x45, 0x19, 0xD5, + 0xE7, 0x36, 0xD0, 0x29, 0x21, 0xDA, 0x02, 0x20, + 0x45, 0xF6, 0x5F, 0x0F, 0x10, 0x04, 0x2A, 0xE3, + 0x6A, 0x1D, 0xD5, 0x9F, 0x1D, 0x66, 0x44, 0x8F, + 0xFA, 0xC6, 0xCA, 0xA4, 0x6E, 0x3B, 0x00, 0x66, + 0xA6, 0xC9, 0x80, 0x5C, 0xF5, 0x2D, 0xD7, 0x72, + 0xC6, 0xD4, 0x4F, 0x30, 0x72, 0xA2, 0xAD, 0xE0, + 0x33, 0xE8, 0x55, 0xD5, 0xE6, 0xD6, 0x00, 0x1D, + 0xA8, 0x68, 0xFF, 0x97, 0x36, 0x8A, 0xF4, 0xD6, + 0xF1, 0xB6, 0x7E, 0x1F, 0x06, 0xCB, 0x57, 0xCB, + 0x35, 0x38, 0xF2, 0x2D, 0xF6, 0x20), + chunk_from_chars( + 0xF3, 0x9B, 0x0B, 0xB4, 0x97, 0x50, 0xB5, 0xA7, + 0xE6, 0xBD, 0xDA, 0xD0, 0x9A, 0x52, 0xBE, 0xA0, + 0x21, 0xC4, 0x90, 0xB6), + chunk_from_chars( + 0x10, 0x43, 0x76, 0x72, 0x6C, 0xDE, 0xA0, 0x0E, + 0x77, 0x51, 0xFB, 0x58, 0x39, 0x8A, 0x36, 0xE1, + 0x63, 0x2B, 0xC9, 0x17, 0x56, 0x0C, 0x4B, 0x46, + 0xA4, 0x07, 0xA4, 0x3B, 0x8E, 0x33, 0x4D, 0xD1, + 0x65, 0xF1, 0xAC, 0xC8, 0x59, 0x21, 0x32, 0x16, + 0x44, 0x2B, 0x7F, 0xB2, 0xA8, 0xA7, 0x26, 0x5D, + 0xE8, 0x02, 0xBE, 0x8E, 0xDC, 0x34, 0xEB, 0x10, + 0x76, 0x16, 0x8C, 0xDD, 0x90, 0x92, 0x3D, 0x29, + 0x90, 0x98, 0x46, 0x11, 0x73, 0x53, 0x47, 0xB1, + 0x2C, 0xD4, 0x83, 0x78, 0x9B, 0x93, 0x2F, 0x5B, + 0xFC, 0x26, 0xFF, 0x42, 0x08, 0x1F, 0x70, 0x66, + 0x40, 0x4B, 0xE7, 0x22, 0x3A, 0x56, 0x10, 0x6D, + 0x4D, 0x29, 0x0B, 0xCE, 0xA6, 0x21, 0xB5, 0x5C, + 0x71, 0x66, 0x2F, 0x70, 0x35, 0xD8, 0x8A, 0x92, + 0x33, 0xF0, 0x16, 0xD4, 0x0E, 0x43, 0x8A, 0x14), + chunk_from_chars( + 1, 2, 1, 0, 0, 1, 1, 1, 2, 0, 1, 0, 1, 1, 1, 0, 2, 0, 1, 1, + 0, 0, 0, 1, 1, 0, 2, 0, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 0, 0, + 2, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 2, 0, 0, 1, 0, 1, 0, 2, 0, + 0, 1, 0, 2, 1, 0, 0, 0, 2, 0, 0, 0, 1, 2, 2, 0, 0, 2, 0, 1, + 1, 2, 1, 1, 0, 0, 1, 1, 1, 2, 2, 1, 2, 0, 0, 2, 1, 0, 0, 1, + 0, 1, 1, 0, 0, 0, 1, 2, 2, 0, 1, 2, 1, 2, 0, 2, 0, 0, 0, 2, + 1, 2, 0, 0, 0, 2, 0, 0, 0, 2, 2, 1, 0, 2, 0, 1, 2, 0, 2, 1, + 0, 2, 2, 1, 0, 2, 1, 2, 2, 0, 2, 0, 2, 1, 2, 2, 0, 2, 0, 1, + 1, 2, 2, 2, 2, 1, 0, 1, 0, 2, 2, 0, 1, 1, 2, 2, 2, 0, 0, 1, + 0, 2, 0, 1, 0, 2, 1, 2, 1, 0, 1, 1, 2, 0, 0, 2, 1, 1, 2, 0, + 1, 2, 1, 1, 0, 1, 0, 2, 1, 1, 1, 2, 1, 0, 2, 0, 2, 0, 0, 2, + 2, 1, 0, 0, 2, 2, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 2, 1, 2, 2, + 2, 0, 0, 0, 0, 1, 0, 0, 1, 2, 1, 2, 0, 2, 1, 1, 1, 0, 2, 2, + 1, 2, 2, 1, 0, 1, 0, 2, 2, 2, 1, 2, 1, 0, 0, 1, 0, 1, 1, 1, + 1, 1, 2, 0, 0, 2, 1, 0, 2, 1, 2, 1, 0, 2, 2, 0, 0, 1, 2, 1, + 2, 0, 1, 2, 1, 1, 2, 0, 2, 0, 2, 1, 1, 1, 0, 0, 0, 1, 2, 1, + 2, 2, 1, 2, 1, 1, 2, 1, 2, 0, 2, 2, 1, 0, 0, 1, 2, 0, 1, 1, + 2, 0, 0, 0, 1, 2, 2, 1, 2, 0, 0, 2, 1, 0, 2, 2, 2, 1, 1, 0, + 2, 1, 2, 1, 2, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 0, 2, 2, 1, + 0, 1, 1, 2, 1, 2, 0, 2, 1, 0, 1, 0, 1, 0, 1, 2, 0, 1, 1, 0, + 0, 1, 1, 2, 0, 2, 2, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, + 0, 1, 2, 0, 1, 1, 0, 1, 2, 0, 0, 1, 2, 2, 0, 0, 2, 1, 2), + { + { 9, 439, 2048, TRUE, 9 + (8 << 8) + (5 << 16), + countof(indices_ees439ep1), indices_ees439ep1 + }, + { 11, 613, 2048, FALSE, 55, + countof(indices_ees613ep1), indices_ees613ep1 + } + } + }, + { HASH_SHA256, 32, 64, 32, 33, 40, + chunk_from_chars( + 0x52, 0xC5, 0xDD, 0x1E, 0xEF, 0x76, 0x1B, 0x53, + 0x08, 0xE4, 0x86, 0x3F, 0x91, 0x12, 0x98, 0x69, + 0xC5, 0x9D, 0xDE, 0xF6, 0xFC, 0xFA, 0x93, 0xCE, + 0x32, 0x52, 0x66, 0xF9, 0xC9, 0x97, 0xF6, 0x42, + 0x00, 0x2C, 0x64, 0xED, 0x1A, 0x6B, 0x14, 0x0A, + 0x4B, 0x04, 0xCF, 0x6D, 0x2D, 0x82, 0x0A, 0x07, + 0xA2, 0x3B, 0xDE, 0xCE, 0x19, 0x8A, 0x39, 0x43, + 0x16, 0x61, 0x29, 0x98, 0x68, 0xEA, 0xE5, 0xCC, + 0x0A, 0xF8, 0xE9, 0x71, 0x26, 0xF1, 0x07, 0x36, + 0x2C, 0x07, 0x1E, 0xEB, 0xE4, 0x28, 0xA2, 0xF4, + 0xA8, 0x12, 0xC0, 0xC8, 0x20, 0x37, 0xF8, 0xF2, + 0x6C, 0xAF, 0xDC, 0x6F, 0x2E, 0xD0, 0x62, 0x58, + 0xD2, 0x37, 0x03, 0x6D, 0xFA, 0x6E, 0x1A, 0xAC, + 0x9F, 0xCA, 0x56, 0xC6, 0xA4, 0x52, 0x41, 0xE8, + 0x0F, 0x1B, 0x0C, 0xB9, 0xE6, 0xBA, 0xDE, 0xE1, + 0x03, 0x5E, 0xC2, 0xE5, 0xF8, 0xF4, 0xF3, 0x46, + 0x3A, 0x12, 0xC0, 0x1F, 0x3A, 0x00, 0xD0, 0x91, + 0x18, 0xDD, 0x53, 0xE4, 0x22, 0xF5, 0x26, 0xA4, + 0x54, 0xEE, 0x20, 0xF0, 0x80), + chunk_from_chars( + 0x76, 0x89, 0x8B, 0x1B, 0x60, 0xEC, 0x10, 0x9D, + 0x8F, 0x13, 0xF2, 0xFE, 0xD9, 0x85, 0xC1, 0xAB, + 0x7E, 0xEE, 0xB1, 0x31, 0xDD, 0xF7, 0x7F, 0x0C, + 0x7D, 0xF9, 0x6B, 0x7B, 0x19, 0x80, 0xBD, 0x28), + chunk_from_chars( + 0xF1, 0x19, 0x02, 0x4F, 0xDA, 0x58, 0x05, 0x9A, + 0x07, 0xDF, 0x61, 0x81, 0x22, 0x0E, 0x15, 0x46, + 0xCB, 0x35, 0x3C, 0xDC, 0xAD, 0x20, 0xD9, 0x3F, + 0x0D, 0xD1, 0xAA, 0x64, 0x66, 0x5C, 0xFA, 0x4A, + 0xFE, 0xD6, 0x8F, 0x55, 0x57, 0x15, 0xB2, 0xA6, + 0xA0, 0xE6, 0xA8, 0xC6, 0xBD, 0x28, 0xB4, 0xD5, + 0x6E, 0x5B, 0x4B, 0xB0, 0x97, 0x09, 0xF5, 0xAC, + 0x57, 0x65, 0x13, 0x97, 0x71, 0x2C, 0x45, 0x13, + 0x3D, 0xEE, 0xFB, 0xBF, 0xFE, 0xAF, 0xBB, 0x4B, + 0x0D, 0x5C, 0x45, 0xD4, 0x2F, 0x17, 0x92, 0x07, + 0x66, 0x11, 0xF5, 0x46, 0xF8, 0x0C, 0x03, 0x92, + 0xF5, 0xF5, 0xFF, 0xA4, 0xF3, 0x52, 0xF4, 0x08, + 0x2C, 0x49, 0x32, 0x1A, 0x93, 0x51, 0x98, 0xB6, + 0x94, 0x83, 0x39, 0xCF, 0x6B, 0x1F, 0x2F, 0xFC, + 0x2B, 0xFF, 0x10, 0x71, 0x7D, 0x35, 0x6C, 0xEA, + 0xC5, 0x66, 0xC7, 0x26, 0x7D, 0x9E, 0xAC, 0xDD, + 0x35, 0xD7, 0x06, 0x3F, 0x40, 0x82, 0xDA, 0xC3, + 0x2B, 0x3C, 0x91, 0x3A, 0x32, 0xF8, 0xB2, 0xC6, + 0x44, 0x4D, 0xCD, 0xB6, 0x54, 0x5F, 0x81, 0x95, + 0x59, 0xA1, 0xE5, 0x4E, 0xA5, 0x0A, 0x4A, 0x42), + chunk_from_chars( + 1, 2, 2, 2, 2, 1, 2, 2, 0, 0, 2, 0, 0, 0, 0, 1, 2, 2, 2, 0, + 2, 0, 0, 2, 2, 1, 2, 0, 0, 1, 2, 1, 0, 0, 0, 1, 0, 2, 2, 1, + 1, 2, 0, 0, 0, 1, 2, 0, 2, 2, 1, 2, 1, 0, 1, 0, 1, 2, 1, 1, + 1, 2, 0, 1, 0, 2, 1, 1, 0, 0, 0, 1, 2, 0, 0, 1, 2, 1, 2, 0, + 2, 1, 1, 1, 2, 2, 2, 2, 1, 0, 0, 2, 0, 2, 0, 1, 1, 0, 2, 2, + 2, 0, 1, 0, 2, 2, 1, 0, 1, 0, 1, 0, 0, 2, 2, 0, 0, 1, 2, 0, + 1, 1, 1, 0, 0, 2, 0, 2, 1, 2, 2, 2, 0, 0, 2, 1, 0, 2, 0, 1, + 0, 1, 2, 0, 1, 2, 0, 1, 0, 1, 2, 0, 2, 2, 0, 1, 2, 2, 1, 2, + 2, 2, 0, 2, 1, 1, 1, 0, 0, 1, 0, 2, 0, 0, 1, 0, 1, 2, 0, 0, + 1, 2, 1, 0, 2, 1, 1, 0, 0, 2, 1, 2, 2, 2, 1, 2, 1, 1, 2, 2, + 0, 2, 0, 0, 2, 0, 0, 1, 1, 2, 0, 0, 0, 1, 2, 1, 1, 1, 1, 0, + 0, 0, 2, 0, 2, 0, 2, 2, 1, 2, 2, 0, 0, 1, 1, 1, 0, 1, 0, 1, + 0, 1, 2, 2, 0, 2, 1, 1, 0, 2, 1, 2, 1, 2, 1, 0, 0, 1, 0, 0, + 1, 0, 1, 0, 2, 0, 2, 0, 0, 1, 2, 0, 2, 0, 1, 1, 0, 2, 0, 0, + 1, 2, 1, 2, 1, 2, 1, 0, 1, 1, 2, 2, 1, 1, 0, 0, 2, 1, 2, 0, + 1, 0, 2, 0, 0, 1, 2, 0, 2, 0, 1, 1, 2, 2, 2, 2, 0, 0, 1, 2, + 1, 1, 1, 0, 2, 1, 2, 2, 0, 2, 0, 1, 2, 2, 0, 1, 1, 1, 0, 0, + 2, 0, 1, 0, 1, 0, 2, 1, 2, 0, 2, 1, 2, 1, 2, 2, 0, 2, 1, 0, + 2, 1, 2, 0, 0, 2, 0, 1, 2, 1, 1, 2, 0, 0, 0, 0, 1, 2, 0, 1, + 2, 2, 1, 0, 0, 1, 2, 1, 2, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, + 2, 0, 1, 2, 1, 2, 0, 0, 0, 2, 1, 0, 0, 0, 1, 2, 2, 0, 0, 0, + 2, 2, 1, 1, 0, 1, 0, 2, 2, 0, 2, 1, 2, 1, 0, 2, 2, 2, 0, 0, + 0, 1, 1, 2, 1, 0, 0, 0, 0, 1, 2, 2, 1, 2, 1, 2, 0, 2, 0, 2, + 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 0, 2, 0, 0, 0, 2, 1, 2, + 2, 2, 2, 0, 1, 1, 1, 0, 1, 0, 2, 0, 2, 1, 0, 1, 2, 1, 1, 0, + 1, 2, 1, 0, 0, 2, 1, 0, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0, + 0, 0, 0, 1, 1, 0, 0, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1, + 1, 0, 1, 1, 2, 2, 0, 1, 1, 0, 2, 2, 1, 1, 1, 2, 1, 2, 2, 1, + 1, 0, 1, 0, 2, 2, 1, 0, 2, 2, 2, 2, 2, 1, 0, 2, 2, 2, 1, 2, + 0, 2, 0, 0, 0, 0, 0, 1, 2, 0, 1, 0, 1), + { + { 13, 743, 2048, TRUE, 11 + (11 << 8) + (15 << 16), + countof(indices_ees743ep1), indices_ees743ep1 + }, + { 12, 1171, 2048, FALSE, 106, + countof(indices_ees1171ep1), indices_ees1171ep1 + } + } + } +}; + +START_TEST(test_ntru_mgf1) +{ + ntru_mgf1_t *mgf1; + chunk_t mask, mask1, mask2, mask3; + + mask1 = mgf1_tests[_i].mask; + mask2 = chunk_skip(mask1, mgf1_tests[_i].ml1); + mask3 = chunk_skip(mask2, mgf1_tests[_i].ml2); + mask1.len = mgf1_tests[_i].ml1; + mask2.len = mgf1_tests[_i].ml2; + mask3.len = mgf1_tests[_i].ml3; + + mgf1 = ntru_mgf1_create(HASH_UNKNOWN, mgf1_tests[_i].seed, TRUE); + ck_assert(mgf1 == NULL); + + mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, chunk_empty, TRUE); + ck_assert(mgf1 == NULL); + + /* return mask in allocated chunk */ + mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].seed, TRUE); + ck_assert(mgf1); + + /* check hash size */ + ck_assert(mgf1->get_hash_size(mgf1) == mgf1_tests[_i].hash_size); + + /* get zero number of octets */ + ck_assert(mgf1->allocate_mask(mgf1, 0, &mask)); + ck_assert(mask.len == 0 && mask.ptr == NULL); + + /* get non-zero number of octets */ + ck_assert(mgf1->allocate_mask(mgf1, mgf1_tests[_i].mask.len, &mask)); + ck_assert(chunk_equals(mask, mgf1_tests[_i].mask)); + mgf1->destroy(mgf1); + + /* copy mask to pre-allocated buffer */ + mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].seed, TRUE); + ck_assert(mgf1); + ck_assert(mgf1->get_mask(mgf1, mgf1_tests[_i].mask.len, mask.ptr)); + ck_assert(chunk_equals(mask, mgf1_tests[_i].mask)); + mgf1->destroy(mgf1); + + /* get mask in batches without hashing the seed */ + mgf1 = ntru_mgf1_create(mgf1_tests[_i].alg, mgf1_tests[_i].hashed_seed, FALSE); + ck_assert(mgf1); + + /* first batch */ + ck_assert(mgf1->get_mask(mgf1, mask1.len, mask.ptr)); + mask.len = mask1.len; + ck_assert(chunk_equals(mask, mask1)); + + /* second batch */ + ck_assert(mgf1->get_mask(mgf1, mask2.len, mask.ptr)); + mask.len = mask2.len; + ck_assert(chunk_equals(mask, mask2)); + + /* third batch */ + ck_assert(mgf1->get_mask(mgf1, mask3.len, mask.ptr)); + mask.len = mask3.len; + ck_assert(chunk_equals(mask, mask3)); + + mgf1->destroy(mgf1); + chunk_free(&mask); +} +END_TEST + +START_TEST(test_ntru_trits) +{ + ntru_trits_t *mask; + chunk_t trits; + + mask = ntru_trits_create(mgf1_tests[_i].trits.len, HASH_UNKNOWN, + mgf1_tests[_i].seed); + ck_assert(mask == NULL); + + mask = ntru_trits_create(mgf1_tests[_i].trits.len, mgf1_tests[_i].alg, + chunk_empty); + ck_assert(mask == NULL); + + mask = ntru_trits_create(mgf1_tests[_i].trits.len, mgf1_tests[_i].alg, + mgf1_tests[_i].seed); + ck_assert(mask); + + trits = chunk_create(mask->get_trits(mask), mask->get_size(mask)); + ck_assert(chunk_equals(trits, mgf1_tests[_i].trits)); + mask->destroy(mask); + + /* generate a multiple of 5 trits */ + mask = ntru_trits_create(10, mgf1_tests[_i].alg, mgf1_tests[_i].seed); + ck_assert(mask); + + trits = chunk_create(mask->get_trits(mask), mask->get_size(mask)); + ck_assert(chunk_equals(trits, chunk_create(mgf1_tests[_i].trits.ptr, 10))); + mask->destroy(mask); +} +END_TEST + +START_TEST(test_ntru_poly) +{ + ntru_poly_t *poly; + uint16_t *indices; + chunk_t seed; + poly_test_t *p; + int j, n; + + seed = mgf1_tests[_i].seed; + seed.len = mgf1_tests[_i].seed_len; + + p = &mgf1_tests[_i].poly_test[0]; + poly = ntru_poly_create_from_seed(HASH_UNKNOWN, seed, p->c_bits, p->N, p->q, + p->indices_len, p->indices_len, + p->is_product_form); + ck_assert(poly == NULL); + + for (n = 0; n < 2; n++) + { + p = &mgf1_tests[_i].poly_test[n]; + poly = ntru_poly_create_from_seed(mgf1_tests[_i].alg, seed, p->c_bits, + p->N, p->q, p->indices_len, + p->indices_len, p->is_product_form); + ck_assert(poly != NULL && poly->get_size(poly) == p->indices_size); + + indices = poly->get_indices(poly); + for (j = 0; j < p->indices_size; j++) + { + ck_assert(indices[j] == p->indices[j]); + } + poly->destroy(poly); + } +} +END_TEST + +typedef struct { + uint16_t N; + uint16_t q; + bool is_product_form; + uint32_t indices_len_p; + uint32_t indices_len_m; + uint16_t *indices; + uint16_t *a; + uint16_t *c; +} ring_mult_test_t; + +uint16_t t1_indices[] = { 1, 6, 5, 3 }; + +uint16_t t1_a[] = { 1, 0, 0, 0, 0, 0, 0 }; +uint16_t t1_c[] = { 0, 1, 0, 7, 0, 7, 1 }; + +uint16_t t2_a[] = { 5, 0, 0, 0, 0, 0, 0 }; +uint16_t t2_c[] = { 0, 5, 0, 3, 0, 3, 5 }; + +uint16_t t3_a[] = { 4, 0, 0, 0, 0, 0, 0 }; +uint16_t t3_c[] = { 0, 4, 0, 4, 0, 4, 4 }; + +uint16_t t4_a[] = { 0, 6, 0, 0, 0, 0, 0 }; +uint16_t t4_c[] = { 6, 0, 6, 0, 2, 0, 2 }; + +uint16_t t5_a[] = { 4, 6, 0, 0, 0, 0, 0 }; +uint16_t t5_c[] = { 6, 4, 6, 4, 2, 4, 6 }; + +uint16_t t6_a[] = { 0, 0, 3, 0, 0, 0, 0 }; +uint16_t t6_c[] = { 5, 3, 0, 3, 0, 5, 0 }; + +uint16_t t7_a[] = { 4, 6, 3, 0, 0, 0, 0 }; +uint16_t t7_c[] = { 3, 7, 6, 7, 2, 1, 6 }; + +uint16_t t8_a[] = { 0, 0, 0, 7, 0, 0, 0 }; +uint16_t t8_c[] = { 0, 1, 7, 0, 7, 0, 1 }; + +uint16_t t9_a[] = { 4, 6, 3, 7, 0, 0, 0 }; +uint16_t t9_c[] = { 3, 0, 5, 7, 1, 1, 7 }; + +uint16_t t10_a[] = { 0, 0, 0, 0, 0, 1, 0 }; +uint16_t t10_c[] = { 0, 7, 0, 7, 1, 0, 1 }; + +uint16_t t11_a[] = { 4, 6, 3, 7, 0, 1, 0 }; +uint16_t t11_c[] = { 3, 7, 5, 6, 2, 1, 0 }; + +uint16_t t2_indices[] = { 1, 6, 5, 2, 3 }; + +uint16_t t12_c[] = { 0, 1, 7, 7, 0, 1, 1 }; +uint16_t t13_c[] = { 0, 1, 7, 7, 0, 7, 1 }; +uint16_t t14_c[] = { 0, 1, 0, 31, 0, 31, 1 }; +uint16_t t15_c[] = { 0, 5, 0, 2043, 0, 2043, 5 }; +uint16_t t16_c[] = { 0, 5, 0, 32763, 0, 32763, 5 }; + +uint16_t t3_indices[] = { 7, 2, 3, 5, 0, 2, 3, 10, 7, 0, 8, 2 }; + +uint16_t t17_a[] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +uint16_t t17_c[] = { 7, 1, 0, 1, 1, 7, 0, 7, 7, 7, 2 }; + +ring_mult_test_t ring_mult_tests[] = { + { 7, 8, FALSE, 2, 2, t1_indices, t1_a, t1_c }, + { 7, 8, FALSE, 2, 2, t1_indices, t2_a, t2_c }, + { 7, 8, FALSE, 2, 2, t1_indices, t3_a, t3_c }, + { 7, 8, FALSE, 2, 2, t1_indices, t4_a, t4_c }, + { 7, 8, FALSE, 2, 2, t1_indices, t5_a, t5_c }, + { 7, 8, FALSE, 2, 2, t1_indices, t6_a, t6_c }, + { 7, 8, FALSE, 2, 2, t1_indices, t7_a, t7_c }, + { 7, 8, FALSE, 2, 2, t1_indices, t8_a, t8_c }, + { 7, 8, FALSE, 2, 2, t1_indices, t9_a, t9_c }, + { 7, 8, FALSE, 2, 2, t1_indices, t10_a, t10_c }, + { 7, 8, FALSE, 2, 2, t1_indices, t11_a, t11_c }, + { 7, 8, FALSE, 3, 2, t2_indices, t1_a, t12_c }, + { 7, 8, FALSE, 2, 3, t2_indices, t1_a, t13_c }, + { 7, 32, FALSE, 2, 2, t1_indices, t1_a, t14_c }, + { 7, 2048, FALSE, 2, 2, t1_indices, t2_a, t15_c }, + { 7, 32768, FALSE, 2, 2, t1_indices, t2_a, t16_c }, + { 11, 8, TRUE, 197121, 197121, t3_indices, t17_a, t17_c }, +}; + +START_TEST(test_ntru_ring_mult) +{ + ntru_poly_t *poly; + ring_mult_test_t *t; + uint16_t *c; + int i; + + t = &ring_mult_tests[_i]; + poly = ntru_poly_create_from_data(t->indices, t->N, t->q, t->indices_len_p, + t->indices_len_m, t->is_product_form); + ck_assert(poly != NULL); + + c = malloc(t->N * sizeof(uint16_t)); + poly->ring_mult(poly, t->a, c); + + for (i = 0; i < t->N; i++) + { + ck_assert(c[i] == t->c[i]); + } + + free(c); + poly->destroy(poly); +} +END_TEST + +int array_tests[] = { 0, 11, 12, 16 }; + +START_TEST(test_ntru_array) +{ + ntru_poly_t *poly; + ring_mult_test_t *t; + uint16_t *c; + int i; + + t = &ring_mult_tests[array_tests[_i]]; + + poly = ntru_poly_create_from_data(t->indices, t->N, t->q, t->indices_len_p, + t->indices_len_m, t->is_product_form); + ck_assert(poly != NULL); + + c = malloc(t->N * sizeof(uint16_t)); + poly->get_array(poly, c); + + for (i = 0; i < t->N; i++) + { + ck_assert(c[i] == t->c[i]); + } + + free(c); + poly->destroy(poly); +} +END_TEST + +START_TEST(test_ntru_ke) +{ + chunk_t pub_key, cipher_text, i_shared_secret, r_shared_secret; + diffie_hellman_t *i_ntru, *r_ntru; + char buf[10]; + int n, len; + status_t status; + + len = snprintf(buf, sizeof(buf), "%N", diffie_hellman_group_names, + params[_i].group); + ck_assert(len == 8); + ck_assert(streq(buf, params[_i].group_name)); + + for (n = 0; n < countof(parameter_sets); n++) + { + lib->settings->set_str(lib->settings, + "libstrongswan.plugins.ntru.parameter_set", + parameter_sets[n]); + + i_ntru = lib->crypto->create_dh(lib->crypto, params[_i].group); + ck_assert(i_ntru != NULL); + ck_assert(i_ntru->get_dh_group(i_ntru) == params[_i].group); + + i_ntru->get_my_public_value(i_ntru, &pub_key); + ck_assert(pub_key.len > 0); + + r_ntru = lib->crypto->create_dh(lib->crypto, params[_i].group); + ck_assert(r_ntru != NULL); + + r_ntru->set_other_public_value(r_ntru, pub_key); + r_ntru->get_my_public_value(r_ntru, &cipher_text); + ck_assert(cipher_text.len > 0); + + status = r_ntru->get_shared_secret(r_ntru, &r_shared_secret); + ck_assert(status == SUCCESS); + ck_assert(r_shared_secret.len > 0); + + i_ntru->set_other_public_value(i_ntru, cipher_text); + status = i_ntru->get_shared_secret(i_ntru, &i_shared_secret); + + if (status == SUCCESS) + { + ck_assert(chunk_equals(i_shared_secret, r_shared_secret)); + } + else + { + ck_assert(i_shared_secret.len == 0); + } + + chunk_clear(&i_shared_secret); + chunk_clear(&r_shared_secret); + chunk_free(&pub_key); + chunk_free(&cipher_text); + i_ntru->destroy(i_ntru); + r_ntru->destroy(r_ntru); + } +} +END_TEST + +START_TEST(test_ntru_retransmission) +{ + diffie_hellman_t *i_ntru; + chunk_t pub_key1, pub_key2; + + i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_256_BIT); + i_ntru->get_my_public_value(i_ntru, &pub_key1); + i_ntru->get_my_public_value(i_ntru, &pub_key2); + ck_assert(chunk_equals(pub_key1, pub_key2)); + + chunk_free(&pub_key1); + chunk_free(&pub_key2); + i_ntru->destroy(i_ntru); +} +END_TEST + +chunk_t oid_tests[] = { + { NULL, 0 }, + chunk_from_chars(0x00), + chunk_from_chars(0x01), + chunk_from_chars(0x02), + chunk_from_chars(0x02, 0x03, 0x00, 0x03, 0x10), + chunk_from_chars(0x01, 0x04, 0x00, 0x03, 0x10), + chunk_from_chars(0x01, 0x03, 0x00, 0x03, 0x10), + chunk_from_chars(0x01, 0x03, 0xff, 0x03, 0x10), +}; + +START_TEST(test_ntru_pubkey_oid) +{ + diffie_hellman_t *r_ntru; + chunk_t cipher_text; + + r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT); + r_ntru->set_other_public_value(r_ntru, oid_tests[_i]); + r_ntru->get_my_public_value(r_ntru, &cipher_text); + ck_assert(cipher_text.len == 0); + r_ntru->destroy(r_ntru); +} +END_TEST + +START_TEST(test_ntru_wrong_set) +{ + diffie_hellman_t *i_ntru, *r_ntru; + chunk_t pub_key, cipher_text; + + lib->settings->set_str(lib->settings, + "libstrongswan.plugins.ntru.parameter_set", + "x9_98_bandwidth"); + i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_112_BIT); + i_ntru->get_my_public_value(i_ntru, &pub_key); + + lib->settings->set_str(lib->settings, + "libstrongswan.plugins.ntru.parameter_set", + "optimum"); + r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_112_BIT); + r_ntru->set_other_public_value(r_ntru, pub_key); + r_ntru->get_my_public_value(r_ntru, &cipher_text); + ck_assert(cipher_text.len == 0); + + chunk_free(&pub_key); + chunk_free(&cipher_text); + i_ntru->destroy(i_ntru); + r_ntru->destroy(r_ntru); +} +END_TEST + +START_TEST(test_ntru_ciphertext) +{ + char buf_00[604], buf_ff[604]; + + chunk_t test[] = { + chunk_empty, + chunk_from_chars(0x00), + chunk_create(buf_00, sizeof(buf_00)), + chunk_create(buf_ff, sizeof(buf_ff)), + }; + + diffie_hellman_t *i_ntru; + chunk_t pub_key, shared_secret; + int i; + + memset(buf_00, 0x00, sizeof(buf_00)); + memset(buf_ff, 0xff, sizeof(buf_ff)); + + for (i = 0; i < countof(test); i++) + { + i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT); + i_ntru->get_my_public_value(i_ntru, &pub_key); + i_ntru->set_other_public_value(i_ntru, test[i]); + ck_assert(i_ntru->get_shared_secret(i_ntru, &shared_secret) != SUCCESS); + ck_assert(shared_secret.len == 0); + + chunk_free(&pub_key); + i_ntru->destroy(i_ntru); + } +} +END_TEST + +START_TEST(test_ntru_wrong_ciphertext) +{ + diffie_hellman_t *i_ntru, *r_ntru, *m_ntru; + chunk_t pub_key_i, pub_key_m, cipher_text, shared_secret; + + i_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT); + r_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT); + m_ntru = lib->crypto->create_dh(lib->crypto, NTRU_128_BIT); + + i_ntru->get_my_public_value(i_ntru, &pub_key_i); + m_ntru->get_my_public_value(m_ntru, &pub_key_m); + r_ntru->set_other_public_value(r_ntru, pub_key_m); + r_ntru->get_my_public_value(r_ntru, &cipher_text); + i_ntru->set_other_public_value(i_ntru, cipher_text); + ck_assert(i_ntru->get_shared_secret(i_ntru, &shared_secret) != SUCCESS); + ck_assert(shared_secret.len == 0); + + chunk_free(&pub_key_i); + chunk_free(&pub_key_m); + chunk_free(&cipher_text); + i_ntru->destroy(i_ntru); + m_ntru->destroy(m_ntru); + r_ntru->destroy(r_ntru); +} +END_TEST + +Suite *ntru_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("ntru"); + + tc = tcase_create("drbg_strength"); + tcase_add_loop_test(tc, test_ntru_drbg_strength, 0, countof(strengths)); + suite_add_tcase(s, tc); + + tc = tcase_create("drbg"); + tcase_add_loop_test(tc, test_ntru_drbg, 0, countof(drbg_tests)); + suite_add_tcase(s, tc); + + tc = tcase_create("drgb_reseed"); + tcase_add_test(tc, test_ntru_drbg_reseed); + suite_add_tcase(s, tc); + + tc = tcase_create("mgf1"); + tcase_add_loop_test(tc, test_ntru_mgf1, 0, countof(mgf1_tests)); + suite_add_tcase(s, tc); + + tc = tcase_create("trits"); + tcase_add_loop_test(tc, test_ntru_trits, 0, countof(mgf1_tests)); + suite_add_tcase(s, tc); + + tc = tcase_create("poly"); + tcase_add_loop_test(tc, test_ntru_poly, 0, countof(mgf1_tests)); + suite_add_tcase(s, tc); + + tc = tcase_create("ring_mult"); + tcase_add_loop_test(tc, test_ntru_ring_mult, 0, countof(ring_mult_tests)); + suite_add_tcase(s, tc); + + tc = tcase_create("array"); + tcase_add_loop_test(tc, test_ntru_array, 0, countof(array_tests)); + suite_add_tcase(s, tc); + + tc = tcase_create("ke"); + tcase_add_loop_test(tc, test_ntru_ke, 0, countof(params)); + suite_add_tcase(s, tc); + + tc = tcase_create("retransmission"); + tcase_add_test(tc, test_ntru_retransmission); + suite_add_tcase(s, tc); + + tc = tcase_create("pubkey_oid"); + tcase_add_loop_test(tc, test_ntru_pubkey_oid, 0, countof(oid_tests)); + suite_add_tcase(s, tc); + + tc = tcase_create("wrong_set"); + tcase_add_test(tc, test_ntru_wrong_set); + suite_add_tcase(s, tc); + + tc = tcase_create("ciphertext"); + tcase_add_test(tc, test_ntru_ciphertext); + suite_add_tcase(s, tc); + + tc = tcase_create("wrong_ciphertext"); + tcase_add_test(tc, test_ntru_wrong_ciphertext); + suite_add_tcase(s, tc); + return s; +} diff --git a/src/libstrongswan/tests/suites/test_pen.c b/src/libstrongswan/tests/suites/test_pen.c new file mode 100644 index 000000000..a6cbc9aa1 --- /dev/null +++ b/src/libstrongswan/tests/suites/test_pen.c @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2013 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + + +#include "test_suite.h" + +#include <pen/pen.h> + +/******************************************************************************* + * create + */ + +START_TEST(test_pen_type_create) +{ + pen_type_t ita_1 = pen_type_create(PEN_ITA, 100); + + ck_assert(ita_1.vendor_id == PEN_ITA); + ck_assert(ita_1.type == 100); +} +END_TEST + +/******************************************************************************* + * equals + */ + +START_TEST(test_pen_type_equals) +{ + pen_type_t ita_1 = pen_type_create(PEN_ITA, 100); + pen_type_t ita_2 = pen_type_create(PEN_ITA, 200); + pen_type_t fhh_1 = pen_type_create(PEN_FHH, 100); + pen_type_t fhh_2 = pen_type_create(PEN_FHH, 200); + + ck_assert( pen_type_equals(ita_1, ita_1)); + ck_assert(!pen_type_equals(ita_1, ita_2)); + ck_assert(!pen_type_equals(ita_1, fhh_1)); + ck_assert(!pen_type_equals(ita_1, fhh_2)); +} +END_TEST + +/******************************************************************************* + * is + */ + +START_TEST(test_pen_type_is) +{ + pen_type_t ita_1 = pen_type_create(PEN_ITA, 100); + + ck_assert( pen_type_is(ita_1, PEN_ITA, 100)); + ck_assert(!pen_type_is(ita_1, PEN_ITA, 200)); + ck_assert(!pen_type_is(ita_1, PEN_FHH, 100)); + ck_assert(!pen_type_is(ita_1, PEN_FHH, 200)); +} +END_TEST + +Suite *pen_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("pen"); + + tc = tcase_create("create"); + tcase_add_test(tc, test_pen_type_create); + suite_add_tcase(s, tc); + + tc = tcase_create("equals"); + tcase_add_test(tc, test_pen_type_equals); + suite_add_tcase(s, tc); + + tc = tcase_create("is"); + tcase_add_test(tc, test_pen_type_is); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/test_printf.c b/src/libstrongswan/tests/suites/test_printf.c index 6c15fbea1..9e40d1fc0 100644 --- a/src/libstrongswan/tests/test_printf.c +++ b/src/libstrongswan/tests/suites/test_printf.c @@ -17,10 +17,10 @@ #include <errno.h> #include <math.h> +#include <inttypes.h> static void verify(char *expected, char *format, ...) { - FILE *mem; char buf[128]; va_list args; @@ -29,17 +29,35 @@ static void verify(char *expected, char *format, ...) ck_assert_str_eq(expected, buf); va_end(args); - mem = fmemopen(buf, sizeof(buf), "w"); - va_start(args, format); - vfprintf(mem, format, args); - va_end(args); - fclose(mem); - ck_assert_str_eq(expected, buf); +#ifdef HAVE_FMEMOPEN + { + FILE *mem; + + mem = fmemopen(buf, sizeof(buf), "w"); + va_start(args, format); + vfprintf(mem, format, args); + va_end(args); + fclose(mem); + ck_assert_str_eq(expected, buf); + } +#endif /* HAVE_FMEMOPEN */ } +START_TEST(test_printf_null) +{ + char buf[16]; + + /* on FreeBSD "(null)" gets printed even when a precision of 0 is used. + * because printing of "(null)" for NULL is not standardized we don't verify + * the output and just make sure there is no crash */ + snprintf(buf, sizeof(buf), "%s", NULL); +} +END_TEST + START_TEST(test_printf_strings) { verify("a bc def", "%s %s %s", "a", "bc", "def"); + verify("", "%.0s", "asdfg"); verify("asd", "%.3s", "asdfg"); verify("asdf", "%.*s", (int)4, "asdfg"); verify(" asdf", "%6s", "asdf"); @@ -150,6 +168,26 @@ START_TEST(test_printf_float) } END_TEST +START_TEST(test_printf_pri) +{ + verify("255", "%" PRIu8, (u_int8_t)0xFF); + verify("65535", "%" PRIu16, (u_int16_t)0xFFFF); + verify("4294967295", "%" PRIu32, (u_int32_t)0x1FFFFFFFFll); + verify("18446744073709551615", "%" PRIu64, (u_int64_t)0xFFFFFFFFFFFFFFFFll); + + verify("-1", "%" PRId8, (int8_t)-1); + verify("-1", "%" PRId16, (int16_t)-1); + verify("-1", "%" PRId32, (int32_t)-1); + verify("-1", "%" PRId64, (int64_t)-1); + + verify("1", "%" PRIuMAX, (uintmax_t)1); + verify("1", "%" PRIuPTR, (uintptr_t)1); + + verify("-1", "%" PRIdMAX, (intmax_t)-1); + verify("-1", "%" PRIdPTR, (intptr_t)-1); +} +END_TEST + Suite *printf_suite_create() { Suite *s; @@ -158,6 +196,7 @@ Suite *printf_suite_create() s = suite_create("printf"); tc = tcase_create("strings"); + tcase_add_test(tc, test_printf_null); tcase_add_test(tc, test_printf_strings); suite_add_tcase(s, tc); @@ -181,5 +220,9 @@ Suite *printf_suite_create() tcase_add_test(tc, test_printf_float); suite_add_tcase(s, tc); + tc = tcase_create("PRI*"); + tcase_add_test(tc, test_printf_pri); + suite_add_tcase(s, tc); + return s; } diff --git a/src/libstrongswan/tests/test_rsa.c b/src/libstrongswan/tests/suites/test_rsa.c index 4c75c34bc..2c1c6fb8d 100644 --- a/src/libstrongswan/tests/test_rsa.c +++ b/src/libstrongswan/tests/suites/test_rsa.c @@ -117,7 +117,7 @@ static void test_bad_sigs(public_key_t *pubkey) * RSA key sizes to test */ static int key_sizes[] = { - 786, 1024, 1536, 2048, 3072, 4096, + 768, 1024, 1536, 2048, 3072, 4096, }; START_TEST(test_gen) @@ -377,11 +377,17 @@ Suite *rsa_suite_create() { Suite *s; TCase *tc; + int gen_count = countof(key_sizes); s = suite_create("rsa"); + if (getenv("TESTS_REDUCED_KEYLENGTHS") != NULL) + { + gen_count = min(1, gen_count); + } + tc = tcase_create("generate"); - tcase_add_loop_test(tc, test_gen, 0, countof(key_sizes)); + tcase_add_loop_test(tc, test_gen, 0, gen_count); tcase_set_timeout(tc, 8); suite_add_tcase(s, tc); diff --git a/src/libstrongswan/tests/suites/test_settings.c b/src/libstrongswan/tests/suites/test_settings.c new file mode 100644 index 000000000..096465191 --- /dev/null +++ b/src/libstrongswan/tests/suites/test_settings.c @@ -0,0 +1,920 @@ +/* + * Copyright (C) 2014 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <unistd.h> + +#include <utils/settings.h> +#include <utils/chunk.h> +#include <utils/utils.h> +#include <collections/linked_list.h> + +static char *path = "/tmp/strongswan-settings-test"; +static settings_t *settings; + +static void create_settings(chunk_t contents) +{ + ck_assert(chunk_write(contents, path, 0022, TRUE)); + settings = settings_create(path); +} + +START_SETUP(setup_base_config) +{ + create_settings(chunk_from_str( + "main {\n" + " key1 = val1\n" + " # this gets overridden below\n" + " key2 = val2\n" + " none = \n" + " sub1 {\n" + " key = value\n" + " key2 = value2\n" + " subsub {\n" + " foo = bar\n" + " }\n" + " # subsub is a section and a value\n" + " subsub = section value\n" + " }\n" + " sub% {\n" + " id = %any\n" + " }\n" + " key2 = with spaces\n" + "}\n" + "out = side\n" + "other {\n" + " key1 = other val\n" + " empty {\n" + " }\n" + "}")); +} +END_SETUP + +START_TEARDOWN(teardown_config) +{ + settings->destroy(settings); + unlink(path); +} +END_TEARDOWN + +#define verify_string(expected, key, ...) \ + ck_assert_str_eq(expected, settings->get_str(settings, key, NULL, ##__VA_ARGS__)) +#define verify_null(key, ...) \ + ck_assert(!settings->get_str(settings, key, NULL, ##__VA_ARGS__)) + +START_TEST(test_get_str) +{ + verify_string("val1", "main.key1"); + verify_string("val1", "main..key1"); + verify_string("val1", ".main.key1"); + verify_string("with spaces", "main.key2"); + verify_string("value", "main.sub1.key"); + verify_string("value2", "main.sub1.key2"); + verify_string("bar", "main.sub1.subsub.foo"); + verify_string("section value", "main.sub1.subsub"); + verify_string("%any", "main.sub%%.id"); + verify_string("side", "out"); + verify_string("other val", "other.key1"); + + /* FIXME: should this rather be undefined i.e. return the default value? */ + verify_string("", "main.none"); + + verify_null("main.key3"); + verify_null("other.sub"); +} +END_TEST + +enum { + KEY1, + SUB1 +} settings_test_enum; + +enum_name_t *test_settings_test_names; + +ENUM_BEGIN(test_settings_test_names, KEY1, SUB1, + "key1", "sub1"); +ENUM_END(test_settings_test_names, SUB1); + +START_TEST(test_get_str_printf) +{ + verify_string("val1", "%s.key1", "main"); + verify_string("val1", "%s.%s", "main", "key1"); + verify_string("val1", "%s.%N", "main", test_settings_test_names, KEY1); + verify_string("val1", "%s.%s%d", "main", "key", 1); + verify_string("bar", "%s.sub1.%s.foo", "main", "subsub"); + verify_string("bar", "%s.%N.%s.foo", "main", test_settings_test_names, SUB1, "subsub"); + verify_string("bar", "%s.sub%d.%s.foo", "main", 1, "subsub"); + verify_string("%any", "%s.sub%%.id", "main"); + + /* FIXME: this is a bit inconsistent, while this works */ + verify_string("value2", "main.%s%u.key2", "sub", 1); + /* this won't because no argument is consumed for %u so key1 will be tried + * granted, we never actually used any other specifiers, but we should + * probably document it at least */ + verify_null("main.%s%u.key%d", "sub", 1, 2); + + verify_null("%s.%s%d", "main", "key", 3); +} +END_TEST + +START_TEST(test_set_str) +{ + settings->set_str(settings, "main.key1", "val"); + verify_string("val", "main.key1"); + settings->set_str(settings, "main.key1", "longer value"); + verify_string("longer value", "main.key1"); + settings->set_str(settings, "main", "main val"); + verify_string("main val", "main"); + settings->set_str(settings, "main.sub1.new", "added"); + verify_string("added", "main.sub1.new"); + settings->set_str(settings, "main.sub2.newsub.foo", "bar"); + verify_string("bar", "main.sub2.newsub.foo"); + settings->set_str(settings, "new.newsub.foo", "bar"); + verify_string("bar", "new.newsub.foo"); + settings->set_str(settings, "main.key1", NULL); + verify_null("main.key1"); +} +END_TEST + +START_TEST(test_set_str_printf) +{ + settings->set_str(settings, "%s.key1", "val", "main"); + verify_string("val", "main.key1"); + settings->set_str(settings, "main.%N.new", "added", test_settings_test_names, SUB1); + verify_string("added", "main.sub1.new"); + settings->set_str(settings, "main.%s%d.newsub.%s", "bar", "sub", 2, "foo"); + verify_string("bar", "main.sub2.newsub.foo"); +} +END_TEST + +START_TEST(test_set_default_str) +{ + settings->set_default_str(settings, "main.key1", "default"); + verify_string("val1", "main.key1"); + settings->set_default_str(settings, "main.sub1.new", "added"); + verify_string("added", "main.sub1.new"); + settings->set_str(settings, "main.sub1.new", "changed"); + verify_string("changed", "main.sub1.new"); +} +END_TEST + +START_SETUP(setup_bool_config) +{ + create_settings(chunk_from_str( + "main {\n" + " key1 = yes\n" + " key2 = true\n" + " key3 = Enabled\n" + " key4 = 1\n" + " key5 = no\n" + " key6 = FALSE\n" + " key7 = disabled\n" + " key8 = 0\n" + " key9 = 5\n" + " none = \n" + " foo = bar\n" + "}")); +} +END_SETUP + +#define verify_bool(expected, def, key, ...) \ + ck_assert(expected == settings->get_bool(settings, key, def, ##__VA_ARGS__)) + +START_TEST(test_get_bool) +{ + verify_bool(TRUE, FALSE, "main.key1"); + verify_bool(TRUE, FALSE, "main.key2"); + verify_bool(TRUE, FALSE, "main.key3"); + verify_bool(TRUE, FALSE, "main.key4"); + verify_bool(FALSE, TRUE, "main.key5"); + verify_bool(FALSE, TRUE, "main.key6"); + verify_bool(FALSE, TRUE, "main.key7"); + verify_bool(FALSE, TRUE, "main.key8"); + + verify_bool(FALSE, FALSE, "main.none"); + verify_bool(TRUE, TRUE, "main.none"); + verify_bool(FALSE, FALSE, "main.foo"); + verify_bool(TRUE, TRUE, "main.foo"); + + verify_bool(FALSE, FALSE, "main.key9"); + verify_bool(TRUE, TRUE, "main.key9"); + verify_bool(FALSE, FALSE, "main"); + verify_bool(TRUE, TRUE, "main"); + +} +END_TEST + +START_TEST(test_set_bool) +{ + settings->set_str(settings, "main.key1", "no"); + verify_bool(FALSE, TRUE, "main.key1"); + settings->set_bool(settings, "main.key2", FALSE); + verify_bool(FALSE, TRUE, "main.key2"); + settings->set_str(settings, "main.key3", NULL); + verify_bool(FALSE, FALSE, "main.key3"); + verify_bool(TRUE, TRUE, "main.key3"); + settings->set_bool(settings, "main.key5", TRUE); + verify_bool(TRUE, FALSE, "main.key5"); + settings->set_bool(settings, "main.new", TRUE); + verify_bool(TRUE, FALSE, "main.new"); +} +END_TEST + +START_SETUP(setup_int_config) +{ + create_settings(chunk_from_str( + "main {\n" + " key1 = 5\n" + " # gets cut off\n" + " key2 = 5.5\n" + " key3 = -42\n" + " none = \n" + " foo1 = bar\n" + " foo2 = bar13\n" + " foo3 = 13bar\n" + "}")); +} +END_SETUP + +#define verify_int(expected, def, key, ...) \ + ck_assert_int_eq(expected, settings->get_int(settings, key, def, ##__VA_ARGS__)) + +START_TEST(test_get_int) +{ + verify_int(5, 0, "main.key1"); + verify_int(5, 0, "main.key2"); + verify_int(-42, 0, "main.key3"); + + /* FIXME: do we want this behavior? */ + verify_int(0, 11, "main.none"); + verify_int(0, 11, "main.foo1"); + verify_int(0, 11, "main.foo2"); + verify_int(13, 11, "main.foo3"); + + verify_int(13, 13, "main.key4"); + verify_int(-13, -13, "main"); +} +END_TEST + +START_TEST(test_set_int) +{ + settings->set_str(settings, "main.key1", "13"); + verify_int(13, 0, "main.key1"); + settings->set_int(settings, "main.key2", 6); + verify_int(6, 0, "main.key2"); + settings->set_int(settings, "main.key3", -6); + verify_int(-6, 0, "main.key3"); + settings->set_str(settings, "main.key3", NULL); + verify_int(15, 15, "main.key3"); + settings->set_int(settings, "main.new", 314); + verify_int(314, 0, "main.new"); +} +END_TEST + +START_SETUP(setup_double_config) +{ + create_settings(chunk_from_str( + "main {\n" + " key1 = 5\n" + " key2 = 5.5\n" + " key3 = -42\n" + " key4 = -42.5\n" + " none = \n" + " foo1 = bar\n" + " foo2 = bar13.5\n" + " foo3 = 13.5bar\n" + "}")); +} +END_SETUP + +#define verify_double(expected, def, key, ...) \ + ck_assert(expected == settings->get_double(settings, key, def, ##__VA_ARGS__)) + +START_TEST(test_get_double) +{ + verify_double(5, 0, "main.key1"); + verify_double(5.5, 0, "main.key2"); + verify_double(-42, 0, "main.key3"); + verify_double(-42.5, 0, "main.key4"); + + /* FIXME: do we want this behavior? */ + verify_double(0, 11.5, "main.none"); + verify_double(0, 11.5, "main.foo1"); + verify_double(0, 11.5, "main.foo2"); + verify_double(13.5, 11.5, "main.foo3"); + + verify_double(11.5, 11.5, "main.key5"); + verify_double(-11.5, -11.5, "main"); +} +END_TEST + +START_TEST(test_set_double) +{ + settings->set_str(settings, "main.key1", "5.5"); + verify_double(5.5, 0, "main.key1"); + settings->set_double(settings, "main.key2", 13); + verify_double(13, 0, "main.key2"); + settings->set_double(settings, "main.key3", -13.5); + verify_double(-13.5, 0, "main.key3"); + settings->set_double(settings, "main.key4", 11.5); + verify_double(11.5, 0, "main.key4"); + settings->set_str(settings, "main.key4", NULL); + verify_double(42.5, 42.5, "main.key4"); + settings->set_double(settings, "main.new", 3.14); + verify_double(3.14, 0, "main.new"); +} +END_TEST + +START_SETUP(setup_time_config) +{ + create_settings(chunk_from_str( + "main {\n" + " key1 = 5s\n" + " key2 = 5m\n" + " key3 = 5h\n" + " key4 = 5d\n" + " none = \n" + " foo1 = bar\n" + " foo2 = bar13\n" + " foo3 = 13bar\n" + "}")); +} +END_SETUP + +#define verify_time(expected, def, key, ...) \ + ck_assert_int_eq(expected, settings->get_time(settings, key, def, ##__VA_ARGS__)) + +START_TEST(test_get_time) +{ + verify_time(5, 0, "main.key1"); + verify_time(300, 0, "main.key2"); + verify_time(18000, 0, "main.key3"); + verify_time(432000, 0, "main.key4"); + + /* FIXME: do we want this behavior? */ + verify_time(0, 11, "main.none"); + verify_time(0, 11, "main.foo1"); + verify_time(0, 11, "main.foo2"); + verify_time(13, 11, "main.foo3"); + + verify_time(11, 11, "main.key5"); + verify_time(11, 11, "main"); +} +END_TEST + +START_TEST(test_set_time) +{ + settings->set_str(settings, "main.key1", "15m"); + verify_time(900, 0, "main.key1"); + settings->set_time(settings, "main.key2", 15); + verify_time(15, 0, "main.key2"); + settings->set_str(settings, "main.key3", NULL); + verify_time(300, 300, "main.key3"); + settings->set_time(settings, "main.new", 314); + verify_time(314, 0, "main.new"); +} +END_TEST + +static bool verify_section(linked_list_t *verifier, char *section) +{ + enumerator_t *enumerator; + char *current; + bool result = FALSE; + + enumerator = verifier->create_enumerator(verifier); + while (enumerator->enumerate(enumerator, ¤t)) + { + if (streq(current, section)) + { + verifier->remove_at(verifier, enumerator); + result = TRUE; + break; + } + } + enumerator->destroy(enumerator); + return result; +} + +static void verify_sections(linked_list_t *verifier, char *parent) +{ + enumerator_t *enumerator; + char *section; + + enumerator = settings->create_section_enumerator(settings, parent); + while (enumerator->enumerate(enumerator, §ion)) + { + ck_assert(verify_section(verifier, section)); + } + enumerator->destroy(enumerator); + ck_assert_int_eq(0, verifier->get_count(verifier)); + verifier->destroy(verifier); +} + +START_TEST(test_section_enumerator) +{ + linked_list_t *verifier; + + verifier = linked_list_create_with_items("sub1", "sub%", NULL); + verify_sections(verifier, "main"); + + settings->set_str(settings, "main.sub2.new", "added"); + verifier = linked_list_create_with_items("sub1", "sub%", "sub2", NULL); + verify_sections(verifier, "main"); + + verifier = linked_list_create_with_items("subsub", NULL); + verify_sections(verifier, "main.sub1"); + + verifier = linked_list_create_with_items(NULL); + verify_sections(verifier, "main.sub%%"); + + verifier = linked_list_create_with_items(NULL); + verify_sections(verifier, "main.key1"); + + verifier = linked_list_create_with_items(NULL); + verify_sections(verifier, "main.unknown"); +} +END_TEST + +static bool verify_key_value(linked_list_t *keys, linked_list_t *values, + char *key, char *value) +{ + enumerator_t *enum_keys, *enum_values; + char *current_key, *current_value; + bool result = FALSE; + + enum_keys = keys->create_enumerator(keys); + enum_values = values->create_enumerator(values); + while (enum_keys->enumerate(enum_keys, ¤t_key) && + enum_values->enumerate(enum_values, ¤t_value)) + { + if (streq(current_key, key)) + { + ck_assert_str_eq(current_value, value); + keys->remove_at(keys, enum_keys); + values->remove_at(values, enum_values); + result = TRUE; + break; + } + } + enum_keys->destroy(enum_keys); + enum_values->destroy(enum_values); + return result; +} + +static void verify_key_values(linked_list_t *keys, linked_list_t *values, + char *parent) +{ + enumerator_t *enumerator; + char *key, *value; + + enumerator = settings->create_key_value_enumerator(settings, parent); + while (enumerator->enumerate(enumerator, &key, &value)) + { + ck_assert(verify_key_value(keys, values, key, value)); + } + enumerator->destroy(enumerator); + ck_assert_int_eq(0, keys->get_count(keys)); + keys->destroy(keys); + values->destroy(values); +} + +START_TEST(test_key_value_enumerator) +{ + linked_list_t *keys, *values; + + keys = linked_list_create_with_items("key1", "key2", "none", NULL); + values = linked_list_create_with_items("val1", "with spaces", "", NULL); + verify_key_values(keys, values, "main"); + + keys = linked_list_create_with_items("key", "key2", "subsub", NULL); + values = linked_list_create_with_items("value", "value2", "section value", NULL); + verify_key_values(keys, values, "main.sub1"); + + settings->set_str(settings, "main.sub2.new", "added"); + keys = linked_list_create_with_items("new", NULL); + values = linked_list_create_with_items("added", NULL); + verify_key_values(keys, values, "main.sub2"); + + keys = linked_list_create_with_items(NULL); + values = linked_list_create_with_items(NULL); + verify_key_values(keys, values, "other.empty"); + + settings->set_str(settings, "other.empty.new", "added"); + keys = linked_list_create_with_items("new", NULL); + values = linked_list_create_with_items("added", NULL); + verify_key_values(keys, values, "other.empty"); + + keys = linked_list_create_with_items(NULL); + values = linked_list_create_with_items(NULL); + verify_key_values(keys, values, "main.unknown"); +} +END_TEST + +#define include1 "/tmp/strongswan-settings-test-include1" +#define include2 "/tmp/strongswan-settings-test-include2" + +START_SETUP(setup_include_config) +{ + chunk_t inc1 = chunk_from_str( + "main {\n" + " key1 = n1\n" + " key2 = n2\n" + " none = \n" + " sub1 {\n" + " key3 = value\n" + " }\n" + " sub2 {\n" + " sub3 = val3\n" + " }\n" + " include " include2 "\n" + "}"); + chunk_t inc2 = chunk_from_str( + "key2 = v2\n" + "sub1 {\n" + " key = val\n" + "}"); + ck_assert(chunk_write(inc1, include1, 0022, TRUE)); + ck_assert(chunk_write(inc2, include2, 0022, TRUE)); +} +END_SETUP + +START_TEARDOWN(teardown_include_config) +{ + settings->destroy(settings); + unlink(include2); + unlink(include1); + unlink(path); +} +END_TEARDOWN + +static void verify_include() +{ + verify_string("n1", "main.key1"); + verify_string("v2", "main.key2"); + verify_string("", "main.none"); + verify_string("val", "main.sub1.key"); + verify_string("v2", "main.sub1.key2"); + verify_string("val", "main.sub1.sub1.key"); + verify_string("value", "main.sub1.key3"); + verify_string("value", "main.sub1.include"); + verify_string("val3", "main.sub2.sub3"); +} + +START_TEST(test_include) +{ + chunk_t contents = chunk_from_str( + "main {\n" + " key1 = val1\n" + " key2 = val2\n" + " none = x\n" + " sub1 {\n" + " include = value\n" + " key2 = value2\n" + " include " include2 "\n" + " }\n" + "}\n" + "# currently there must be a newline after include statements\n" + "include " include1 "\n"); + + create_settings(contents); + verify_include(); +} +END_TEST + +START_TEST(test_load_files) +{ + chunk_t contents = chunk_from_str( + "main {\n" + " key1 = val1\n" + " key2 = val2\n" + " none = x\n" + " sub1 {\n" + " include = value\n" + " key2 = v2\n" + " sub1 {\n" + " key = val\n" + " }\n" + " }\n" + "}"); + + create_settings(contents); + + ck_assert(settings->load_files(settings, include1, TRUE)); + verify_include(); + + ck_assert(settings->load_files(settings, include2, FALSE)); + verify_null("main.key1"); + verify_string("v2", "key2"); + verify_string("val", "sub1.key"); + verify_null("main.sub1.key3"); +} +END_TEST + +START_TEST(test_load_files_section) +{ + chunk_t contents = chunk_from_str( + "main {\n" + " key1 = val1\n" + " key2 = val2\n" + " none = x\n" + " sub1 {\n" + " include = value\n" + " key2 = value2\n" + " }\n" + "}"); + + create_settings(contents); + + ck_assert(settings->load_files_section(settings, include1, TRUE, "")); + ck_assert(settings->load_files_section(settings, include2, TRUE, "main.sub1")); + verify_include(); + + /* non existing files are no failure */ + ck_assert(settings->load_files_section(settings, include1".conf", TRUE, "")); + verify_include(); + + /* unreadable files are */ + ck_assert(chunk_write(contents, include1".no", 0444, TRUE)); + ck_assert(!settings->load_files_section(settings, include1".no", TRUE, "")); + unlink(include1".no"); + verify_include(); + + ck_assert(settings->load_files_section(settings, include2, FALSE, "main")); + verify_null("main.key1"); + verify_string("v2", "main.key2"); + verify_string("val", "main.sub1.key"); + verify_null("main.sub1.key3"); + verify_null("main.sub2.sub3"); + + ck_assert(settings->load_files_section(settings, include2, TRUE, "main.sub2")); + verify_string("v2", "main.sub2.key2"); + verify_string("val", "main.sub2.sub1.key"); +} +END_TEST + +START_SETUP(setup_fallback_config) +{ + create_settings(chunk_from_str( + "main {\n" + " key1 = val1\n" + " sub1 {\n" + " key1 = val1\n" + " }\n" + "}\n" + "sub {\n" + " key1 = subval1\n" + " key2 = subval2\n" + " subsub {\n" + " subkey1 = subsubval1\n" + " }\n" + "}\n" + "base {\n" + " key1 = baseval1\n" + " key2 = baseval2\n" + " sub1 {\n" + " key1 = subbase1\n" + " key2 = subbase2\n" + " key3 = subbase3\n" + " subsub {\n" + " subkey1 = subsubbaseval1\n" + " subkey2 = subsubbaseval2\n" + " }\n" + " }\n" + " sub2 {\n" + " key4 = subbase4\n" + " }\n" + "}")); +} +END_SETUP + +START_TEST(test_add_fallback) +{ + linked_list_t *keys, *values; + + settings->add_fallback(settings, "main.sub1", "sub"); + verify_string("val1", "main.sub1.key1"); + verify_string("subval2", "main.sub1.key2"); + verify_string("subsubval1", "main.sub1.subsub.subkey1"); + + /* fallbacks are preserved even if the complete config is replaced */ + settings->load_files(settings, path, FALSE); + verify_string("val1", "main.sub1.key1"); + verify_string("subval2", "main.sub1.key2"); + verify_string("subsubval1", "main.sub1.subsub.subkey1"); + + keys = linked_list_create_with_items("sub1", NULL); + verify_sections(keys, "main"); + keys = linked_list_create_with_items("subsub", NULL); + verify_sections(keys, "main.sub1"); + + keys = linked_list_create_with_items("key1", NULL); + values = linked_list_create_with_items("val1", NULL); + verify_key_values(keys, values, "main"); + + keys = linked_list_create_with_items("key1", "key2", NULL); + values = linked_list_create_with_items("val1", "subval2", NULL); + verify_key_values(keys, values, "main.sub1"); + + keys = linked_list_create_with_items("subkey1", NULL); + values = linked_list_create_with_items("subsubval1", NULL); + verify_key_values(keys, values, "main.sub1.subsub"); + + settings->add_fallback(settings, "main", "base"); + verify_string("val1", "main.key1"); + verify_string("baseval2", "main.key2"); + verify_string("val1", "main.sub1.key1"); + verify_string("subval2", "main.sub1.key2"); + verify_string("subsubval1", "main.sub1.subsub.subkey1"); + verify_string("subsubbaseval2", "main.sub1.subsub.subkey2"); + verify_string("subbase3", "main.sub1.key3"); + verify_string("subbase4", "main.sub2.key4"); + + + keys = linked_list_create_with_items("sub1", "sub2", NULL); + verify_sections(keys, "main"); + keys = linked_list_create_with_items("subsub", NULL); + verify_sections(keys, "main.sub1"); + + keys = linked_list_create_with_items("key1", "key2", NULL); + values = linked_list_create_with_items("val1", "baseval2", NULL); + verify_key_values(keys, values, "main"); + + keys = linked_list_create_with_items("key1", "key2", "key3", NULL); + values = linked_list_create_with_items("val1", "subval2", "subbase3", NULL); + verify_key_values(keys, values, "main.sub1"); + + keys = linked_list_create_with_items("subkey1", "subkey2", NULL); + values = linked_list_create_with_items("subsubval1", "subsubbaseval2", NULL); + verify_key_values(keys, values, "main.sub1.subsub"); + + settings->set_str(settings, "main.sub1.key2", "val2"); + verify_string("val2", "main.sub1.key2"); + settings->set_str(settings, "main.sub1.subsub.subkey2", "val2"); + verify_string("val2", "main.sub1.subsub.subkey2"); + verify_string("subsubval1", "main.sub1.subsub.subkey1"); +} +END_TEST + +START_TEST(test_add_fallback_printf) +{ + settings->add_fallback(settings, "%s.sub1", "sub", "main"); + verify_string("val1", "main.sub1.key1"); + verify_string("subval2", "main.sub1.key2"); + verify_string("subsubval1", "main.sub1.subsub.subkey1"); + + settings->add_fallback(settings, "%s.%s2", "%s.%s1", "main", "sub"); + verify_string("val1", "main.sub2.key1"); + verify_string("subval2", "main.sub2.key2"); + verify_string("subsubval1", "main.sub2.subsub.subkey1"); +} +END_TEST + +START_SETUP(setup_invalid_config) +{ + create_settings(chunk_from_str( + "# section without name\n" + "{\n" + " key1 = val1\n" + "}\n" + "main {\n" + " key2 = val2\n" + " # value without key\n" + " = val3\n" + " key4 = val4\n" + " # key without value does not change it\n" + " key4\n" + " # subsection without name\n" + " {\n" + " key5 = val5\n" + " }\n" + " # empty include pattern\n" + " include\n" + " key6 = val6\n" + "}")); +} +END_SETUP + +START_TEST(test_invalid) +{ + linked_list_t *keys, *values; + chunk_t contents; + + verify_null("key1"); + verify_null(".key1"); + verify_null("%s.key1", ""); + verify_string("val2", "main.key2"); + verify_string("val4", "main.key4"); + verify_null("main..key5"); + verify_string("val6", "main.key6"); + + keys = linked_list_create_with_items("main", NULL); + verify_sections(keys, ""); + + keys = linked_list_create_with_items(NULL); + verify_sections(keys, "main"); + + keys = linked_list_create_with_items("key2", "key4", "key6", NULL); + values = linked_list_create_with_items("val2", "val4", "val6", NULL); + verify_key_values(keys, values, "main"); + + /* FIXME: we should probably fix this */ + contents = chunk_from_str( + "requires = newline"); + ck_assert(chunk_write(contents, path, 0022, TRUE)); + ck_assert(!settings->load_files(settings, path, FALSE)); + + contents = chunk_from_str( + "unterminated {\n" + " not = valid\n"); + ck_assert(chunk_write(contents, path, 0022, TRUE)); + ck_assert(!settings->load_files(settings, path, FALSE)); + + contents = chunk_from_str( + "singleline { not = valid }\n"); + ck_assert(chunk_write(contents, path, 0022, TRUE)); + ck_assert(!settings->load_files(settings, path, FALSE)); +} +END_TEST + +Suite *settings_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("settings"); + + tc = tcase_create("get/set_str (basic behavior)"); + tcase_add_checked_fixture(tc, setup_base_config, teardown_config); + tcase_add_test(tc, test_get_str); + tcase_add_test(tc, test_get_str_printf); + tcase_add_test(tc, test_set_str); + tcase_add_test(tc, test_set_str_printf); + tcase_add_test(tc, test_set_default_str); + suite_add_tcase(s, tc); + + tc = tcase_create("get/set_bool"); + tcase_add_checked_fixture(tc, setup_bool_config, teardown_config); + tcase_add_test(tc, test_get_bool); + tcase_add_test(tc, test_set_bool); + suite_add_tcase(s, tc); + + tc = tcase_create("get/set_int"); + tcase_add_checked_fixture(tc, setup_int_config, teardown_config); + tcase_add_test(tc, test_get_int); + tcase_add_test(tc, test_set_int); + suite_add_tcase(s, tc); + + tc = tcase_create("get/set_double"); + tcase_add_checked_fixture(tc, setup_double_config, teardown_config); + tcase_add_test(tc, test_get_double); + tcase_add_test(tc, test_set_double); + suite_add_tcase(s, tc); + + tc = tcase_create("get/set_time"); + tcase_add_checked_fixture(tc, setup_time_config, teardown_config); + tcase_add_test(tc, test_get_time); + tcase_add_test(tc, test_set_time); + suite_add_tcase(s, tc); + + tc = tcase_create("section enumerator"); + tcase_add_checked_fixture(tc, setup_base_config, teardown_config); + tcase_add_test(tc, test_section_enumerator); + suite_add_tcase(s, tc); + + tc = tcase_create("key/value enumerator"); + tcase_add_checked_fixture(tc, setup_base_config, teardown_config); + tcase_add_test(tc, test_key_value_enumerator); + suite_add_tcase(s, tc); + + tc = tcase_create("include/load_files[_section]"); + tcase_add_checked_fixture(tc, setup_include_config, teardown_include_config); + tcase_add_test(tc, test_include); + tcase_add_test(tc, test_load_files); + tcase_add_test(tc, test_load_files_section); + suite_add_tcase(s, tc); + + tc = tcase_create("fallback"); + tcase_add_checked_fixture(tc, setup_fallback_config, teardown_config); + tcase_add_test(tc, test_add_fallback); + tcase_add_test(tc, test_add_fallback_printf); + suite_add_tcase(s, tc); + + tc = tcase_create("invalid data"); + tcase_add_checked_fixture(tc, setup_invalid_config, teardown_config); + tcase_add_test(tc, test_invalid); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/suites/test_stream.c b/src/libstrongswan/tests/suites/test_stream.c new file mode 100644 index 000000000..2d3173d46 --- /dev/null +++ b/src/libstrongswan/tests/suites/test_stream.c @@ -0,0 +1,267 @@ +/* + * Copyright (C) 2013 Martin Willi + * Copyright (C) 2013 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <unistd.h> + +static char* services[] = { + "unix:///tmp/strongswan-test-service.sck", + "tcp://127.0.0.1:7766", + "tcp://[::1]:7766", +}; + +static char msg[] = "testmessage"; +static int msglen = 12; + +static bool servicing(void *data, stream_t *stream) +{ + char buf[64]; + ssize_t len, total; + + ck_assert(streq((char*)data, "test")); + + for (total = 0; total < msglen;) + { + len = stream->read(stream, buf, sizeof(buf), TRUE); + ck_assert(len > 0); + total += len; + } + for (total = 0; total < msglen;) + { + len = stream->write(stream, buf, len, TRUE); + ck_assert(len > 0); + total += len; + } + + return FALSE; +} + +START_TEST(test_sync) +{ + char buf[64]; + stream_service_t *service; + stream_t *stream; + ssize_t len, total; + + lib->processor->set_threads(lib->processor, 8); + + service = lib->streams->create_service(lib->streams, services[_i], 1); + ck_assert(service != NULL); + service->on_accept(service, servicing, "test", JOB_PRIO_HIGH, 1); + + stream = lib->streams->connect(lib->streams, services[_i]); + ck_assert(stream != NULL); + for (total = 0; total < msglen;) + { + len = stream->write(stream, msg, msglen, TRUE); + ck_assert(len > 0); + total += len; + } + for (total = 0; total < msglen;) + { + len = stream->read(stream, buf, sizeof(buf), TRUE); + ck_assert(len > 0); + total += len; + } + ck_assert(streq(buf, msg)); + stream->destroy(stream); + + service->destroy(service); +} +END_TEST + +static bool on_write(void *data, stream_t *stream) +{ + ssize_t len, total; + + ck_assert(streq((char*)data, "test-write")); + for (total = 0; total < msglen;) + { + len = stream->write(stream, msg, msglen, TRUE); + ck_assert(len > 0); + total += len; + } + return FALSE; +} + +static bool read_done = FALSE; + +static bool on_read(void *data, stream_t *stream) +{ + ssize_t len, total; + char buf[64]; + + ck_assert(streq((char*)data, "test-read")); + for (total = 0; total < msglen;) + { + len = stream->read(stream, buf, sizeof(buf), TRUE); + ck_assert(len > 0); + total += len; + } + ck_assert(streq(buf, msg)); + read_done = TRUE; + return FALSE; +} + +START_TEST(test_async) +{ + stream_service_t *service; + stream_t *stream; + + + lib->processor->set_threads(lib->processor, 8); + + service = lib->streams->create_service(lib->streams, services[_i], 1); + ck_assert(service != NULL); + service->on_accept(service, servicing, "test", JOB_PRIO_HIGH, 0); + + stream = lib->streams->connect(lib->streams, services[_i]); + ck_assert(stream != NULL); + read_done = FALSE; + stream->on_write(stream, (stream_cb_t)on_write, "test-write"); + stream->on_read(stream, (stream_cb_t)on_read, "test-read"); + + while (!read_done) + { + usleep(1000); + } + stream->destroy(stream); + + service->destroy(service); +} +END_TEST + +static bool all(void *data, stream_t *stream) +{ + char buf[64], *pos; + ssize_t len; + int i; + + pos = buf; + for (i = 0; i < msglen; i++) + { + len = stream->read(stream, pos, 1, TRUE); + ck_assert_int_eq(len, 1); + pos += len; + } + pos = buf; + for (i = 0; i < msglen; i++) + { + len = stream->write(stream, pos, 1, TRUE); + ck_assert_int_eq(len, 1); + pos += len; + } + + return FALSE; +} + +START_TEST(test_all) +{ + char buf[64]; + stream_service_t *service; + stream_t *stream; + + lib->processor->set_threads(lib->processor, 8); + + service = lib->streams->create_service(lib->streams, services[_i], 1); + ck_assert(service != NULL); + service->on_accept(service, all, NULL, JOB_PRIO_HIGH, 1); + + stream = lib->streams->connect(lib->streams, services[_i]); + ck_assert(stream != NULL); + ck_assert(stream->write_all(stream, msg, msglen)); + ck_assert(stream->read_all(stream, buf, msglen)); + ck_assert(streq(buf, msg)); + stream->destroy(stream); + + service->destroy(service); +} +END_TEST + +static bool concurrency(void *data, stream_t *stream) +{ + static refcount_t refs = 0; + u_int current; + ssize_t len; + + current = ref_get(&refs); + ck_assert(current <= 3); + len = stream->write(stream, "x", 1, TRUE); + ck_assert_int_eq(len, 1); + usleep(1000); + ignore_result(ref_put(&refs)); + + return FALSE; +} + +START_TEST(test_concurrency) +{ + stream_service_t *service; + stream_t *streams[10]; + ssize_t len; + char x; + int i; + + lib->processor->set_threads(lib->processor, 8); + + service = lib->streams->create_service(lib->streams, services[_i], 10); + ck_assert(service != NULL); + service->on_accept(service, concurrency, NULL, JOB_PRIO_HIGH, 3); + + for (i = 0; i < countof(streams); i++) + { + streams[i] = lib->streams->connect(lib->streams, services[_i]); + ck_assert(streams[i] != NULL); + } + for (i = 0; i < countof(streams); i++) + { + len = streams[i]->read(streams[i], &x, 1, TRUE); + ck_assert_int_eq(len, 1); + ck_assert_int_eq(x, 'x'); + } + for (i = 0; i < countof(streams); i++) + { + streams[i]->destroy(streams[i]); + } + service->destroy(service); +} +END_TEST + +Suite *stream_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("stream"); + + tc = tcase_create("sync"); + tcase_add_loop_test(tc, test_sync, 0, countof(services)); + suite_add_tcase(s, tc); + + tc = tcase_create("async"); + tcase_add_loop_test(tc, test_async, 0, countof(services)); + suite_add_tcase(s, tc); + + tc = tcase_create("all"); + tcase_add_loop_test(tc, test_all, 0, countof(services)); + suite_add_tcase(s, tc); + + tc = tcase_create("concurrency"); + tcase_add_loop_test(tc, test_concurrency, 0, countof(services)); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/suites/test_test_rng.c b/src/libstrongswan/tests/suites/test_test_rng.c new file mode 100644 index 000000000..9a983b677 --- /dev/null +++ b/src/libstrongswan/tests/suites/test_test_rng.c @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2013 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <tests/utils/test_rng.h> +#include <utils/test.h> + +START_TEST(test_test_rng) +{ + rng_t *entropy; + chunk_t in, in1, in2, out; + + in1 = chunk_from_chars(0x01, 0x02, 0x03, 0x04, 0x05, 0x06); + in2 = chunk_from_chars(0x07, 0x08); + in = chunk_cat("cc", in1, in2); + + entropy = test_rng_create(in); + ck_assert(entropy->allocate_bytes(entropy, 6, &out)); + ck_assert(chunk_equals(in1, out)); + ck_assert(entropy->get_bytes(entropy, 2, out.ptr)); + ck_assert(memeq(in2.ptr, out.ptr, in2.len)); + ck_assert(!entropy->get_bytes(entropy, 4, out.ptr)); + chunk_free(&out); + ck_assert(!entropy->allocate_bytes(entropy, 4, &out)); + entropy->destroy(entropy); + chunk_free(&in); +} +END_TEST + + +Suite *test_rng_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("test_rng"); + + tc = tcase_create("test_rng"); + tcase_add_test(tc, test_test_rng); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/suites/test_threading.c b/src/libstrongswan/tests/suites/test_threading.c new file mode 100644 index 000000000..844959e46 --- /dev/null +++ b/src/libstrongswan/tests/suites/test_threading.c @@ -0,0 +1,1466 @@ +/* + * Copyright (C) 2013 Tobias Brunner + * Copyright (C) 2008 Martin Willi + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <sched.h> +#include <unistd.h> + +#include <threading/thread.h> +#include <threading/mutex.h> +#include <threading/condvar.h> +#include <threading/rwlock.h> +#include <threading/rwlock_condvar.h> +#include <threading/spinlock.h> +#include <threading/semaphore.h> +#include <threading/thread_value.h> + +/******************************************************************************* + * recursive mutex test + */ + +#define THREADS 20 + +/** + * Thread barrier data + */ +typedef struct { + mutex_t *mutex; + condvar_t *cond; + int count; + int current; + bool active; +} barrier_t; + +/** + * Create a thread barrier for count threads + */ +static barrier_t* barrier_create(int count) +{ + barrier_t *this; + + INIT(this, + .mutex = mutex_create(MUTEX_TYPE_DEFAULT), + .cond = condvar_create(CONDVAR_TYPE_DEFAULT), + .count = count, + ); + + return this; +} + +/** + * Destroy a thread barrier + */ +static void barrier_destroy(barrier_t *this) +{ + this->mutex->destroy(this->mutex); + this->cond->destroy(this->cond); + free(this); +} + +/** + * Wait to have configured number of threads in barrier + */ +static bool barrier_wait(barrier_t *this) +{ + bool winner = FALSE; + + this->mutex->lock(this->mutex); + if (!this->active) + { /* first, reset */ + this->active = TRUE; + this->current = 0; + } + + this->current++; + while (this->current < this->count) + { + this->cond->wait(this->cond, this->mutex); + } + if (this->active) + { /* first, win */ + winner = TRUE; + this->active = FALSE; + } + this->mutex->unlock(this->mutex); + this->cond->broadcast(this->cond); + sched_yield(); + + return winner; +} + +/** + * Barrier for some tests + */ +static barrier_t *barrier; + +/** + * A mutex for tests requiring one + */ +static mutex_t *mutex; + +/** + * A condvar for tests requiring one + */ +static condvar_t *condvar; + +/** + * A counter for signaling + */ +static int sigcount; + +static void *mutex_run(void *data) +{ + int locked = 0; + int i; + + /* wait for all threads before getting in action */ + barrier_wait(barrier); + + for (i = 0; i < 100; i++) + { + mutex->lock(mutex); + mutex->lock(mutex); + mutex->lock(mutex); + locked++; + sched_yield(); + if (locked > 1) + { + fail("two threads locked the mutex concurrently"); + } + locked--; + mutex->unlock(mutex); + mutex->unlock(mutex); + mutex->unlock(mutex); + } + return NULL; +} + +START_TEST(test_mutex) +{ + thread_t *threads[THREADS]; + int i; + + barrier = barrier_create(THREADS); + mutex = mutex_create(MUTEX_TYPE_RECURSIVE); + + for (i = 0; i < 10; i++) + { + mutex->lock(mutex); + mutex->unlock(mutex); + } + for (i = 0; i < 10; i++) + { + mutex->lock(mutex); + } + for (i = 0; i < 10; i++) + { + mutex->unlock(mutex); + } + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(mutex_run, NULL); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + mutex->destroy(mutex); + barrier_destroy(barrier); +} +END_TEST + +/** + * Spinlock for testing + */ +static spinlock_t *spinlock; + +static void *spinlock_run(void *data) +{ + int i, *locked = (int*)data; + + barrier_wait(barrier); + + for (i = 0; i < 1000; i++) + { + spinlock->lock(spinlock); + (*locked)++; + ck_assert_int_eq(*locked, 1); + (*locked)--; + spinlock->unlock(spinlock); + } + return NULL; +} + +START_TEST(test_spinlock) +{ + thread_t *threads[THREADS]; + int i, locked = 0; + + barrier = barrier_create(THREADS); + spinlock = spinlock_create(); + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(spinlock_run, &locked); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + spinlock->destroy(spinlock); + barrier_destroy(barrier); +} +END_TEST + +static void *condvar_run(void *data) +{ + mutex->lock(mutex); + sigcount++; + condvar->signal(condvar); + mutex->unlock(mutex); + return NULL; +} + +START_TEST(test_condvar) +{ + thread_t *threads[THREADS]; + int i; + + mutex = mutex_create(MUTEX_TYPE_DEFAULT); + condvar = condvar_create(CONDVAR_TYPE_DEFAULT); + sigcount = 0; + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(condvar_run, NULL); + } + + mutex->lock(mutex); + while (sigcount < THREADS) + { + condvar->wait(condvar, mutex); + } + mutex->unlock(mutex); + + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + mutex->destroy(mutex); + condvar->destroy(condvar); +} +END_TEST + +static void *condvar_recursive_run(void *data) +{ + mutex->lock(mutex); + mutex->lock(mutex); + mutex->lock(mutex); + sigcount++; + condvar->signal(condvar); + mutex->unlock(mutex); + mutex->unlock(mutex); + mutex->unlock(mutex); + return NULL; +} + +START_TEST(test_condvar_recursive) +{ + thread_t *threads[THREADS]; + int i; + + mutex = mutex_create(MUTEX_TYPE_RECURSIVE); + condvar = condvar_create(CONDVAR_TYPE_DEFAULT); + sigcount = 0; + + mutex->lock(mutex); + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(condvar_recursive_run, NULL); + } + + mutex->lock(mutex); + mutex->lock(mutex); + while (sigcount < THREADS) + { + condvar->wait(condvar, mutex); + } + mutex->unlock(mutex); + mutex->unlock(mutex); + mutex->unlock(mutex); + + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + mutex->destroy(mutex); + condvar->destroy(condvar); +} +END_TEST + +static void *condvar_run_broad(void *data) +{ + mutex->lock(mutex); + while (sigcount < 0) + { + condvar->wait(condvar, mutex); + } + mutex->unlock(mutex); + return NULL; +} + +START_TEST(test_condvar_broad) +{ + thread_t *threads[THREADS]; + int i; + + mutex = mutex_create(MUTEX_TYPE_DEFAULT); + condvar = condvar_create(CONDVAR_TYPE_DEFAULT); + sigcount = 0; + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(condvar_run_broad, NULL); + } + + sched_yield(); + + mutex->lock(mutex); + sigcount = 1; + condvar->broadcast(condvar); + mutex->unlock(mutex); + + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + mutex->destroy(mutex); + condvar->destroy(condvar); +} +END_TEST + +START_TEST(test_condvar_timed) +{ + thread_t *thread; + timeval_t start, end, diff = { .tv_usec = 50000 }; + + mutex = mutex_create(MUTEX_TYPE_DEFAULT); + condvar = condvar_create(CONDVAR_TYPE_DEFAULT); + sigcount = 0; + + mutex->lock(mutex); + while (TRUE) + { + time_monotonic(&start); + if (condvar->timed_wait(condvar, mutex, diff.tv_usec / 1000)) + { + break; + } + } + time_monotonic(&end); + mutex->unlock(mutex); + timersub(&end, &start, &end); + ck_assert_msg(timercmp(&end, &diff, >), "end: %u.%u, diff: %u.%u", + end.tv_sec, end.tv_usec, diff.tv_sec, diff.tv_usec); + + thread = thread_create(condvar_run, NULL); + + mutex->lock(mutex); + while (sigcount == 0) + { + ck_assert(!condvar->timed_wait(condvar, mutex, 1000)); + } + mutex->unlock(mutex); + + thread->join(thread); + mutex->destroy(mutex); + condvar->destroy(condvar); +} +END_TEST + +START_TEST(test_condvar_timed_abs) +{ + thread_t *thread; + timeval_t start, end, abso, diff = { .tv_usec = 50000 }; + + mutex = mutex_create(MUTEX_TYPE_DEFAULT); + condvar = condvar_create(CONDVAR_TYPE_DEFAULT); + sigcount = 0; + + mutex->lock(mutex); + while (TRUE) + { + time_monotonic(&start); + timeradd(&start, &diff, &abso); + if (condvar->timed_wait_abs(condvar, mutex, abso)) + { + break; + } + } + time_monotonic(&end); + mutex->unlock(mutex); + ck_assert_msg(timercmp(&end, &diff, >), "end: %u.%u, diff: %u.%u", + end.tv_sec, end.tv_usec, abso.tv_sec, abso.tv_usec); + + thread = thread_create(condvar_run, NULL); + + time_monotonic(&start); + diff.tv_sec = 1; + timeradd(&start, &diff, &abso); + mutex->lock(mutex); + while (sigcount == 0) + { + ck_assert(!condvar->timed_wait_abs(condvar, mutex, abso)); + } + mutex->unlock(mutex); + + thread->join(thread); + mutex->destroy(mutex); + condvar->destroy(condvar); +} +END_TEST + +static void *condvar_cancel_run(void *data) +{ + thread_cancelability(FALSE); + + mutex->lock(mutex); + + sigcount++; + condvar->broadcast(condvar); + + thread_cleanup_push((void*)mutex->unlock, mutex); + thread_cancelability(TRUE); + while (TRUE) + { + condvar->wait(condvar, mutex); + } + thread_cleanup_pop(TRUE); + + return NULL; +} + +START_TEST(test_condvar_cancel) +{ + thread_t *threads[THREADS]; + int i; + + mutex = mutex_create(MUTEX_TYPE_DEFAULT); + condvar = condvar_create(CONDVAR_TYPE_DEFAULT); + sigcount = 0; + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(condvar_cancel_run, NULL); + } + + /* wait for all threads */ + mutex->lock(mutex); + while (sigcount < THREADS) + { + condvar->wait(condvar, mutex); + } + mutex->unlock(mutex); + + for (i = 0; i < THREADS; i++) + { + threads[i]->cancel(threads[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + mutex->destroy(mutex); + condvar->destroy(condvar); +} +END_TEST + +/** + * RWlock for different tests + */ +static rwlock_t *rwlock; + +static void *rwlock_run(refcount_t *refs) +{ + rwlock->read_lock(rwlock); + ref_get(refs); + sched_yield(); + ignore_result(ref_put(refs)); + rwlock->unlock(rwlock); + + if (rwlock->try_write_lock(rwlock)) + { + ck_assert_int_eq(*refs, 0); + sched_yield(); + rwlock->unlock(rwlock); + } + + rwlock->write_lock(rwlock); + ck_assert_int_eq(*refs, 0); + sched_yield(); + rwlock->unlock(rwlock); + + rwlock->read_lock(rwlock); + rwlock->read_lock(rwlock); + ref_get(refs); + sched_yield(); + ignore_result(ref_put(refs)); + rwlock->unlock(rwlock); + rwlock->unlock(rwlock); + + return NULL; +} + +START_TEST(test_rwlock) +{ + thread_t *threads[THREADS]; + refcount_t refs = 0; + int i; + + rwlock = rwlock_create(RWLOCK_TYPE_DEFAULT); + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create((void*)rwlock_run, &refs); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + rwlock->destroy(rwlock); +} +END_TEST + +/** + * Rwlock condvar + */ +static rwlock_condvar_t *rwcond; + +static void *rwlock_condvar_run(void *data) +{ + rwlock->write_lock(rwlock); + sigcount++; + rwcond->signal(rwcond); + rwlock->unlock(rwlock); + return NULL; +} + +START_TEST(test_rwlock_condvar) +{ + thread_t *threads[THREADS]; + int i; + + rwlock = rwlock_create(RWLOCK_TYPE_DEFAULT); + rwcond = rwlock_condvar_create(); + sigcount = 0; + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(rwlock_condvar_run, NULL); + } + + rwlock->write_lock(rwlock); + while (sigcount < THREADS) + { + rwcond->wait(rwcond, rwlock); + } + rwlock->unlock(rwlock); + + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + rwlock->destroy(rwlock); + rwcond->destroy(rwcond); +} +END_TEST + +static void *rwlock_condvar_run_broad(void *data) +{ + rwlock->write_lock(rwlock); + while (sigcount < 0) + { + rwcond->wait(rwcond, rwlock); + } + rwlock->unlock(rwlock); + return NULL; +} + +START_TEST(test_rwlock_condvar_broad) +{ + thread_t *threads[THREADS]; + int i; + + rwlock = rwlock_create(RWLOCK_TYPE_DEFAULT); + rwcond = rwlock_condvar_create(); + sigcount = 0; + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(rwlock_condvar_run_broad, NULL); + } + + sched_yield(); + + rwlock->write_lock(rwlock); + sigcount = 1; + rwcond->broadcast(rwcond); + rwlock->unlock(rwlock); + + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + rwlock->destroy(rwlock); + rwcond->destroy(rwcond); +} +END_TEST + +START_TEST(test_rwlock_condvar_timed) +{ + thread_t *thread; + timeval_t start, end, diff = { .tv_usec = 50000 }; + + rwlock = rwlock_create(RWLOCK_TYPE_DEFAULT); + rwcond = rwlock_condvar_create(); + sigcount = 0; + + rwlock->write_lock(rwlock); + while (TRUE) + { + time_monotonic(&start); + if (rwcond->timed_wait(rwcond, rwlock, diff.tv_usec / 1000)) + { + break; + } + } + rwlock->unlock(rwlock); + time_monotonic(&end); + timersub(&end, &start, &end); + ck_assert_msg(timercmp(&end, &diff, >), "end: %u.%u, diff: %u.%u", + end.tv_sec, end.tv_usec, diff.tv_sec, diff.tv_usec); + + thread = thread_create(rwlock_condvar_run, NULL); + + rwlock->write_lock(rwlock); + while (sigcount == 0) + { + ck_assert(!rwcond->timed_wait(rwcond, rwlock, 1000)); + } + rwlock->unlock(rwlock); + + thread->join(thread); + rwlock->destroy(rwlock); + rwcond->destroy(rwcond); +} +END_TEST + +START_TEST(test_rwlock_condvar_timed_abs) +{ + thread_t *thread; + timeval_t start, end, abso, diff = { .tv_usec = 50000 }; + + rwlock = rwlock_create(RWLOCK_TYPE_DEFAULT); + rwcond = rwlock_condvar_create(); + sigcount = 0; + + rwlock->write_lock(rwlock); + while (TRUE) + { + time_monotonic(&start); + timeradd(&start, &diff, &abso); + if (rwcond->timed_wait_abs(rwcond, rwlock, abso)) + { + break; + } + } + rwlock->unlock(rwlock); + time_monotonic(&end); + ck_assert_msg(timercmp(&end, &abso, >), "end: %u.%u, abso: %u.%u", + end.tv_sec, end.tv_usec, abso.tv_sec, abso.tv_usec); + + thread = thread_create(rwlock_condvar_run, NULL); + + time_monotonic(&start); + diff.tv_sec = 1; + timeradd(&start, &diff, &abso); + rwlock->write_lock(rwlock); + while (sigcount == 0) + { + ck_assert(!rwcond->timed_wait_abs(rwcond, rwlock, abso)); + } + rwlock->unlock(rwlock); + + thread->join(thread); + rwlock->destroy(rwlock); + rwcond->destroy(rwcond); +} +END_TEST + +static void *rwlock_condvar_cancel_run(void *data) +{ + thread_cancelability(FALSE); + + rwlock->write_lock(rwlock); + + sigcount++; + rwcond->broadcast(rwcond); + + thread_cleanup_push((void*)rwlock->unlock, rwlock); + thread_cancelability(TRUE); + while (TRUE) + { + rwcond->wait(rwcond, rwlock); + } + thread_cleanup_pop(TRUE); + + return NULL; +} + +START_TEST(test_rwlock_condvar_cancel) +{ + thread_t *threads[THREADS]; + int i; + + rwlock = rwlock_create(RWLOCK_TYPE_DEFAULT); + rwcond = rwlock_condvar_create(); + sigcount = 0; + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(rwlock_condvar_cancel_run, NULL); + } + + /* wait for all threads */ + rwlock->write_lock(rwlock); + while (sigcount < THREADS) + { + rwcond->wait(rwcond, rwlock); + } + rwlock->unlock(rwlock); + + for (i = 0; i < THREADS; i++) + { + threads[i]->cancel(threads[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + rwlock->destroy(rwlock); + rwcond->destroy(rwcond); +} +END_TEST + +/** + * Semaphore for different tests + */ +static semaphore_t *semaphore; + +static void *semaphore_run(void *data) +{ + semaphore->post(semaphore); + return NULL; +} + +START_TEST(test_semaphore) +{ + thread_t *threads[THREADS]; + int i, initial = 5; + + semaphore = semaphore_create(initial); + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(semaphore_run, NULL); + } + for (i = 0; i < THREADS + initial; i++) + { + semaphore->wait(semaphore); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + semaphore->destroy(semaphore); +} +END_TEST + +START_TEST(test_semaphore_timed) +{ + thread_t *thread; + timeval_t start, end, diff = { .tv_usec = 50000 }; + + semaphore = semaphore_create(0); + + time_monotonic(&start); + ck_assert(semaphore->timed_wait(semaphore, diff.tv_usec / 1000)); + time_monotonic(&end); + timersub(&end, &start, &end); + ck_assert_msg(timercmp(&end, &diff, >), "end: %u.%u, diff: %u.%u", + end.tv_sec, end.tv_usec, diff.tv_sec, diff.tv_usec); + + thread = thread_create(semaphore_run, NULL); + + ck_assert(!semaphore->timed_wait(semaphore, 1000)); + + thread->join(thread); + semaphore->destroy(semaphore); +} +END_TEST + +START_TEST(test_semaphore_timed_abs) +{ + thread_t *thread; + timeval_t start, end, abso, diff = { .tv_usec = 50000 }; + + semaphore = semaphore_create(0); + + time_monotonic(&start); + timeradd(&start, &diff, &abso); + ck_assert(semaphore->timed_wait_abs(semaphore, abso)); + time_monotonic(&end); + ck_assert_msg(timercmp(&end, &abso, >), "end: %u.%u, abso: %u.%u", + end.tv_sec, end.tv_usec, abso.tv_sec, abso.tv_usec); + + thread = thread_create(semaphore_run, NULL); + + time_monotonic(&start); + diff.tv_sec = 1; + timeradd(&start, &diff, &abso); + ck_assert(!semaphore->timed_wait_abs(semaphore, abso)); + + thread->join(thread); + semaphore->destroy(semaphore); +} +END_TEST + +static void *semaphore_cancel_run(void *data) +{ + refcount_t *ready = (refcount_t*)data; + + thread_cancelability(FALSE); + ref_get(ready); + + thread_cancelability(TRUE); + semaphore->wait(semaphore); + + ck_assert(FALSE); + return NULL; +} + +START_TEST(test_semaphore_cancel) +{ + thread_t *threads[THREADS]; + refcount_t ready = 0; + int i; + + semaphore = semaphore_create(0); + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(semaphore_cancel_run, &ready); + } + while (ready < THREADS) + { + sched_yield(); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->cancel(threads[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } + + semaphore->destroy(semaphore); +} +END_TEST + +static void *join_run(void *data) +{ + /* force some context switches */ + sched_yield(); + return (void*)((uintptr_t)data + THREADS); +} + +START_TEST(test_join) +{ + thread_t *threads[THREADS]; + int i; + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(join_run, (void*)(uintptr_t)i); + } + for (i = 0; i < THREADS; i++) + { + ck_assert_int_eq((uintptr_t)threads[i]->join(threads[i]), i + THREADS); + } +} +END_TEST + +static void *exit_join_run(void *data) +{ + sched_yield(); + thread_exit((void*)((uintptr_t)data + THREADS)); + /* not reached */ + ck_assert(FALSE); + return NULL; +} + +START_TEST(test_join_exit) +{ + thread_t *threads[THREADS]; + int i; + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(exit_join_run, (void*)(uintptr_t)i); + } + for (i = 0; i < THREADS; i++) + { + ck_assert_int_eq((uintptr_t)threads[i]->join(threads[i]), i + THREADS); + } +} +END_TEST + +static void *detach_run(void *data) +{ + refcount_t *running = (refcount_t*)data; + + ignore_result(ref_put(running)); + return NULL; +} + +START_TEST(test_detach) +{ + thread_t *threads[THREADS]; + int i; + refcount_t running = 0; + + for (i = 0; i < THREADS; i++) + { + ref_get(&running); + threads[i] = thread_create(detach_run, &running); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->detach(threads[i]); + } + while (running > 0) + { + sched_yield(); + } + /* no checks done here, but we check that thread state gets cleaned + * up with leak detective. */ +} +END_TEST + +static void *detach_exit_run(void *data) +{ + refcount_t *running = (refcount_t*)data; + + ignore_result(ref_put(running)); + thread_exit(NULL); + /* not reached */ + ck_assert(FALSE); + return NULL; +} + +START_TEST(test_detach_exit) +{ + thread_t *threads[THREADS]; + int i; + refcount_t running = 0; + + for (i = 0; i < THREADS; i++) + { + ref_get(&running); + threads[i] = thread_create(detach_exit_run, &running); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->detach(threads[i]); + } + while (running > 0) + { + sched_yield(); + } + /* no checks done here, but we check that thread state gets cleaned + * up with leak detective. */ +} +END_TEST + +static void *cancel_run(void *data) +{ + /* default cancellability should be TRUE, so don't change it */ + while (TRUE) + { + sleep(10); + } + return NULL; +} + +START_TEST(test_cancel) +{ + thread_t *threads[THREADS]; + int i; + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(cancel_run, NULL); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->cancel(threads[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } +} +END_TEST + +static void *cancel_onoff_run(void *data) +{ + bool *cancellable = (bool*)data; + + thread_cancelability(FALSE); + *cancellable = FALSE; + + /* we should not get cancelled here */ + usleep(50000); + + *cancellable = TRUE; + thread_cancelability(TRUE); + + /* but here */ + while (TRUE) + { + sleep(10); + } + return NULL; +} + +START_TEST(test_cancel_onoff) +{ + thread_t *threads[THREADS]; + bool cancellable[THREADS]; + int i; + + for (i = 0; i < THREADS; i++) + { + cancellable[i] = TRUE; + threads[i] = thread_create(cancel_onoff_run, &cancellable[i]); + } + for (i = 0; i < THREADS; i++) + { + /* wait until thread has cleared its cancellability */ + while (cancellable[i]) + { + sched_yield(); + } + threads[i]->cancel(threads[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + ck_assert(cancellable[i]); + } +} +END_TEST + +static void *cancel_point_run(void *data) +{ + thread_cancelability(FALSE); + while (TRUE) + { + /* implicitly enables cancellability */ + thread_cancellation_point(); + } + return NULL; +} + +START_TEST(test_cancel_point) +{ + thread_t *threads[THREADS]; + int i; + + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(cancel_point_run, NULL); + } + sched_yield(); + for (i = 0; i < THREADS; i++) + { + threads[i]->cancel(threads[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + } +} +END_TEST + +static void cleanup1(void *data) +{ + uintptr_t *value = (uintptr_t*)data; + + ck_assert_int_eq(*value, 1); + (*value)++; +} + +static void cleanup2(void *data) +{ + uintptr_t *value = (uintptr_t*)data; + + ck_assert_int_eq(*value, 2); + (*value)++; +} + +static void cleanup3(void *data) +{ + uintptr_t *value = (uintptr_t*)data; + + ck_assert_int_eq(*value, 3); + (*value)++; +} + +static void *cleanup_run(void *data) +{ + thread_cleanup_push(cleanup3, data); + thread_cleanup_push(cleanup2, data); + thread_cleanup_push(cleanup1, data); + return NULL; +} + +START_TEST(test_cleanup) +{ + thread_t *threads[THREADS]; + uintptr_t values[THREADS]; + int i; + + for (i = 0; i < THREADS; i++) + { + values[i] = 1; + threads[i] = thread_create(cleanup_run, &values[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + ck_assert_int_eq(values[i], 4); + } +} +END_TEST + +static void *cleanup_exit_run(void *data) +{ + thread_cleanup_push(cleanup3, data); + thread_cleanup_push(cleanup2, data); + thread_cleanup_push(cleanup1, data); + thread_exit(NULL); + ck_assert(FALSE); + return NULL; +} + +START_TEST(test_cleanup_exit) +{ + thread_t *threads[THREADS]; + uintptr_t values[THREADS]; + int i; + + for (i = 0; i < THREADS; i++) + { + values[i] = 1; + threads[i] = thread_create(cleanup_exit_run, &values[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + ck_assert_int_eq(values[i], 4); + } +} +END_TEST + +static void *cleanup_cancel_run(void *data) +{ + thread_cancelability(FALSE); + + thread_cleanup_push(cleanup3, data); + thread_cleanup_push(cleanup2, data); + thread_cleanup_push(cleanup1, data); + + thread_cancelability(TRUE); + + while (TRUE) + { + sleep(1); + } + return NULL; +} + +START_TEST(test_cleanup_cancel) +{ + thread_t *threads[THREADS]; + uintptr_t values[THREADS]; + int i; + + for (i = 0; i < THREADS; i++) + { + values[i] = 1; + threads[i] = thread_create(cleanup_cancel_run, &values[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->cancel(threads[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + ck_assert_int_eq(values[i], 4); + } +} +END_TEST + +static void *cleanup_pop_run(void *data) +{ + thread_cleanup_push(cleanup3, data); + thread_cleanup_push(cleanup2, data); + thread_cleanup_push(cleanup1, data); + + thread_cleanup_push(cleanup2, data); + thread_cleanup_pop(FALSE); + + thread_cleanup_pop(TRUE); + return NULL; +} + +START_TEST(test_cleanup_pop) +{ + thread_t *threads[THREADS]; + uintptr_t values[THREADS]; + int i; + + for (i = 0; i < THREADS; i++) + { + values[i] = 1; + threads[i] = thread_create(cleanup_pop_run, &values[i]); + } + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + ck_assert_int_eq(values[i], 4); + } +} +END_TEST + +static thread_value_t *tls[10]; + +static void *tls_run(void *data) +{ + uintptr_t value = (uintptr_t)data; + int i, j; + + for (i = 0; i < countof(tls); i++) + { + ck_assert(tls[i]->get(tls[i]) == NULL); + } + for (i = 0; i < countof(tls); i++) + { + tls[i]->set(tls[i], (void*)(value * i)); + } + for (j = 0; j < 1000; j++) + { + for (i = 0; i < countof(tls); i++) + { + tls[i]->set(tls[i], (void*)(value * i)); + ck_assert(tls[i]->get(tls[i]) == (void*)(value * i)); + } + sched_yield(); + } + for (i = 0; i < countof(tls); i++) + { + ck_assert(tls[i]->get(tls[i]) == (void*)(value * i)); + } + return (void*)(value + 1); +} + +START_TEST(test_tls) +{ + thread_t *threads[THREADS]; + int i; + + for (i = 0; i < countof(tls); i++) + { + tls[i] = thread_value_create(NULL); + } + for (i = 0; i < THREADS; i++) + { + threads[i] = thread_create(tls_run, (void*)(uintptr_t)i); + } + + ck_assert_int_eq((uintptr_t)tls_run((void*)(uintptr_t)(THREADS + 1)), + THREADS + 2); + + for (i = 0; i < THREADS; i++) + { + ck_assert_int_eq((uintptr_t)threads[i]->join(threads[i]), i + 1); + } + for (i = 0; i < countof(tls); i++) + { + tls[i]->destroy(tls[i]); + } +} +END_TEST + +static void tls_cleanup(void *data) +{ + uintptr_t *value = (uintptr_t*)data; + + (*value)--; +} + +static void *tls_cleanup_run(void *data) +{ + int i; + + for (i = 0; i < countof(tls); i++) + { + tls[i]->set(tls[i], data); + } + return NULL; +} + +START_TEST(test_tls_cleanup) +{ + thread_t *threads[THREADS]; + uintptr_t values[THREADS], main_value = countof(tls); + int i; + + for (i = 0; i < countof(tls); i++) + { + tls[i] = thread_value_create(tls_cleanup); + } + for (i = 0; i < THREADS; i++) + { + values[i] = countof(tls); + threads[i] = thread_create(tls_cleanup_run, &values[i]); + } + + tls_cleanup_run(&main_value); + + for (i = 0; i < THREADS; i++) + { + threads[i]->join(threads[i]); + ck_assert_int_eq(values[i], 0); + } + for (i = 0; i < countof(tls); i++) + { + tls[i]->destroy(tls[i]); + } + ck_assert_int_eq(main_value, 0); +} +END_TEST + +Suite *threading_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("threading"); + + tc = tcase_create("recursive mutex"); + tcase_add_test(tc, test_mutex); + suite_add_tcase(s, tc); + + tc = tcase_create("spinlock"); + tcase_add_test(tc, test_spinlock); + suite_add_tcase(s, tc); + + tc = tcase_create("condvar"); + tcase_add_test(tc, test_condvar); + tcase_add_test(tc, test_condvar_recursive); + tcase_add_test(tc, test_condvar_broad); + tcase_add_test(tc, test_condvar_timed); + tcase_add_test(tc, test_condvar_timed_abs); + tcase_add_test(tc, test_condvar_cancel); + suite_add_tcase(s, tc); + + tc = tcase_create("rwlock"); + tcase_add_test(tc, test_rwlock); + suite_add_tcase(s, tc); + + tc = tcase_create("rwlock condvar"); + tcase_add_test(tc, test_rwlock_condvar); + tcase_add_test(tc, test_rwlock_condvar_broad); + tcase_add_test(tc, test_rwlock_condvar_timed); + tcase_add_test(tc, test_rwlock_condvar_timed_abs); + tcase_add_test(tc, test_rwlock_condvar_cancel); + suite_add_tcase(s, tc); + + tc = tcase_create("semaphore"); + tcase_add_test(tc, test_semaphore); + tcase_add_test(tc, test_semaphore_timed); + tcase_add_test(tc, test_semaphore_timed_abs); + tcase_add_test(tc, test_semaphore_cancel); + suite_add_tcase(s, tc); + + tc = tcase_create("thread joining"); + tcase_add_test(tc, test_join); + tcase_add_test(tc, test_join_exit); + suite_add_tcase(s, tc); + + tc = tcase_create("thread detaching"); + tcase_add_test(tc, test_detach); + tcase_add_test(tc, test_detach_exit); + suite_add_tcase(s, tc); + + tc = tcase_create("thread cancellation"); + tcase_add_test(tc, test_cancel); + tcase_add_test(tc, test_cancel_onoff); + tcase_add_test(tc, test_cancel_point); + suite_add_tcase(s, tc); + + tc = tcase_create("thread cleanup"); + tcase_add_test(tc, test_cleanup); + tcase_add_test(tc, test_cleanup_exit); + tcase_add_test(tc, test_cleanup_cancel); + tcase_add_test(tc, test_cleanup_pop); + suite_add_tcase(s, tc); + + tc = tcase_create("thread local storage"); + tcase_add_test(tc, test_tls); + tcase_add_test(tc, test_tls_cleanup); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/test_utils.c b/src/libstrongswan/tests/suites/test_utils.c index 3ca0412b4..0260726b2 100644 --- a/src/libstrongswan/tests/test_utils.c +++ b/src/libstrongswan/tests/suites/test_utils.c @@ -346,6 +346,46 @@ START_TEST(test_memstr) END_TEST /******************************************************************************* + * utils_memrchr + */ + +static struct { + char *s; + int c; + size_t n; + int offset; +} memrchr_data[] = { + {NULL, 'f', 0, -1}, + {NULL, 'f', 3, -1}, + {"", 'f', 0, -1}, + {"", '\0', 1, 0}, + {"foo", '\0', 3, -1}, + {"foo", '\0', 4, 3}, + {"foo", 'f', 3, 0}, + {"foo", 'o', 3, 2}, + {"foo", 'o', 2, 1}, + {"foo", 'o', 1, -1}, + {"foo", 'o', 0, -1}, + {"foo", 'x', 3, -1}, +}; + +START_TEST(test_utils_memrchr) +{ + void *ret; + + ret = utils_memrchr(memrchr_data[_i].s, memrchr_data[_i].c, memrchr_data[_i].n); + if (memrchr_data[_i].offset >= 0) + { + ck_assert(ret == memrchr_data[_i].s + memrchr_data[_i].offset); + } + else + { + ck_assert(ret == NULL); + } +} +END_TEST + +/******************************************************************************* * translate */ @@ -385,6 +425,140 @@ START_TEST(test_translate) END_TEST /******************************************************************************* + * strreplace + */ + +static struct { + char *in; + char *out; + char *search; + char *replace; + bool allocated; +} strreplace_data[] = { + /* invalid arguments */ + {NULL, NULL, NULL, NULL, FALSE}, + {"", "", NULL, NULL, FALSE}, + {"", "", "", NULL, FALSE}, + {"", "", NULL, "", FALSE}, + {"", "", "", "", FALSE}, + {"", "", "", "asdf", FALSE}, + {"", "", "asdf", "", FALSE}, + {"asdf", "asdf", NULL, NULL, FALSE}, + {"asdf", "asdf", "", NULL, FALSE}, + {"asdf", "asdf", NULL, "", FALSE}, + {"asdf", "asdf", "", "", FALSE}, + {"asdf", "asdf", "", "asdf", FALSE}, + {"asdf", "asdf", "asdf", NULL, FALSE}, + {"qwer", "qwer", "", "asdf", FALSE}, + /* replacement shorter */ + {"asdf", "", "asdf", "", TRUE}, + {"asdfasdf", "", "asdf", "", TRUE}, + {"asasdfdf", "asdf", "asdf", "", TRUE}, + {"asdf", "df", "as", "", TRUE}, + {"asdf", "as", "df", "", TRUE}, + {"qwer", "qwer", "asdf", "", FALSE}, + /* replacement same length */ + {"a", "b", "a", "b", TRUE}, + {"aaa", "bbb", "a", "b", TRUE}, + {"aaa", "bbb", "aaa", "bbb", TRUE}, + {"asdf", "asdf", "asdf", "asdf", TRUE}, + {"qwer", "qwer", "asdf", "asdf", FALSE}, + /* replacement longer */ + {"asdf", "asdf", "", "asdf", FALSE}, + {"asdf", "asdfasdf", "asdf", "asdfasdf", TRUE}, + {"asdf", "asdfsdf", "a", "asdf", TRUE}, + {"asdf", "asdasdf", "f", "asdf", TRUE}, + {"aaa", "asdfasdfasdf", "a", "asdf", TRUE}, + {"qwer", "qwer", "asdf", "asdfasdf", FALSE}, + /* real examples */ + {"http://x.org/no/spaces", "http://x.org/no/spaces", " ", "%20", FALSE}, + {"http://x.org/end ", "http://x.org/end%20", " ", "%20", TRUE}, + {" http://x.org/start", "%20http://x.org/start", " ", "%20", TRUE}, + {" http://x.org/both ", "%20http://x.org/both%20", " ", "%20", TRUE}, + {"http://x.org/ /slash", "http://x.org/%20/slash", " ", "%20", TRUE}, + {"http://x.org/ /three", "http://x.org/%20%20%20/three", " ", "%20", TRUE}, + {"http://x.org/ ", "http://x.org/%20%20%20%20%20%20", " ", "%20", TRUE}, + {"http://x.org/%20/encoded", "http://x.org/%20/encoded", " ", "%20", FALSE}, +}; + +START_TEST(test_strreplace) +{ + char *ret; + + ret = strreplace(strreplace_data[_i].in, strreplace_data[_i].search, + strreplace_data[_i].replace); + if (ret && strreplace_data[_i].out) + { + ck_assert_str_eq(ret, strreplace_data[_i].out); + } + else + { + ck_assert(ret == strreplace_data[_i].out); + } + if (strreplace_data[_i].allocated) + { + ck_assert(ret != strreplace_data[_i].in); + free(ret); + } + else + { + ck_assert(ret == strreplace_data[_i].in); + } +} +END_TEST + +/******************************************************************************* + * path_dirname/basename + */ + +static struct { + char *path; + char *dir; + char *base; +} path_data[] = { + {NULL, ".", "."}, + {"", ".", "."}, + {".", ".", "."}, + {"..", ".", ".."}, + {"/", "/", "/"}, + {"//", "/", "/"}, + {"foo", ".", "foo"}, + {"f/", ".", "f"}, + {"foo/", ".", "foo"}, + {"foo//", ".", "foo"}, + {"/f", "/", "f"}, + {"/f/", "/", "f"}, + {"/foo", "/", "foo"}, + {"/foo/", "/", "foo"}, + {"//foo/", "/", "foo"}, + {"foo/bar", "foo", "bar"}, + {"foo//bar", "foo", "bar"}, + {"/foo/bar", "/foo", "bar"}, + {"/foo/bar/", "/foo", "bar"}, + {"/foo/bar/baz", "/foo/bar", "baz"}, +}; + +START_TEST(test_path_dirname) +{ + char *dir; + + dir = path_dirname(path_data[_i].path); + ck_assert_str_eq(path_data[_i].dir, dir); + free(dir); +} +END_TEST + +START_TEST(test_path_basename) +{ + char *base; + + base = path_basename(path_data[_i].path); + ck_assert_str_eq(path_data[_i].base, base); + free(base); +} +END_TEST + +/******************************************************************************* * time_printf_hook */ @@ -539,10 +713,23 @@ Suite *utils_suite_create() tcase_add_loop_test(tc, test_memstr, 0, countof(memstr_data)); suite_add_tcase(s, tc); + tc = tcase_create("utils_memrchr"); + tcase_add_loop_test(tc, test_utils_memrchr, 0, countof(memrchr_data)); + suite_add_tcase(s, tc); + tc = tcase_create("translate"); tcase_add_loop_test(tc, test_translate, 0, countof(translate_data)); suite_add_tcase(s, tc); + tc = tcase_create("strreplace"); + tcase_add_loop_test(tc, test_strreplace, 0, countof(strreplace_data)); + suite_add_tcase(s, tc); + + tc = tcase_create("path_dirname/basename"); + tcase_add_loop_test(tc, test_path_dirname, 0, countof(path_data)); + tcase_add_loop_test(tc, test_path_basename, 0, countof(path_data)); + suite_add_tcase(s, tc); + tc = tcase_create("printf_hooks"); tcase_add_loop_test(tc, test_time_printf_hook, 0, countof(time_data)); tcase_add_loop_test(tc, test_time_delta_printf_hook, 0, countof(time_delta_data)); diff --git a/src/libstrongswan/tests/test_vectors.c b/src/libstrongswan/tests/suites/test_vectors.c index f2817d314..242ac9d09 100644 --- a/src/libstrongswan/tests/test_vectors.c +++ b/src/libstrongswan/tests/suites/test_vectors.c @@ -21,7 +21,8 @@ START_TEST(test_vectors) { - fail_if(lib->crypto->get_test_vector_failures(lib->crypto)); + u_int failed = lib->crypto->get_test_vector_failures(lib->crypto); + fail_if(failed > 0, "%u test vectors failed", failed); } END_TEST diff --git a/src/libstrongswan/tests/suites/test_watcher.c b/src/libstrongswan/tests/suites/test_watcher.c new file mode 100644 index 000000000..9415bead9 --- /dev/null +++ b/src/libstrongswan/tests/suites/test_watcher.c @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2013 Martin Willi + * Copyright (C) 2013 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <library.h> + +#include <sched.h> +#include <unistd.h> +#include <errno.h> + +static char testbuf[1] = ""; + +static bool readcb(void *data, int fd, watcher_event_t event) +{ + ck_assert_int_eq(*(int*)data, fd); + ck_assert_int_eq(event, WATCHER_READ); + + if (recv(fd, testbuf, 1, MSG_DONTWAIT) != 1) + { + ck_assert(errno == EAGAIN || errno == EWOULDBLOCK); + } + return TRUE; +} + +START_TEST(test_read) +{ + int fd[2]; + char c; + + lib->processor->set_threads(lib->processor, 8); + + ck_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1); + + lib->watcher->add(lib->watcher, fd[0], WATCHER_READ, readcb, &fd[0]); + + for (c = 'a'; c <= 'z'; c++) + { + ck_assert_int_eq(write(fd[1], &c, 1), 1); + while (testbuf[0] != c) + { + sched_yield(); + } + } + + lib->watcher->remove(lib->watcher, fd[0]); + close(fd[0]); + close(fd[1]); + + lib->processor->cancel(lib->processor); +} +END_TEST + +static bool writecb(void *data, int fd, watcher_event_t event) +{ + ck_assert_int_eq(event, WATCHER_WRITE); + if (send(fd, data, 1, MSG_DONTWAIT) != 1) + { + ck_assert(errno == EAGAIN || errno == EWOULDBLOCK); + } + return TRUE; +} + +START_TEST(test_write) +{ + int fd[2]; + char in = 'x', out; + + lib->processor->set_threads(lib->processor, 8); + + ck_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1); + + lib->watcher->add(lib->watcher, fd[1], WATCHER_WRITE, writecb, &in); + + ck_assert_int_eq(read(fd[0], &out, 1), 1); + ck_assert_int_eq(out, in); + + lib->watcher->remove(lib->watcher, fd[1]); + close(fd[1]); + close(fd[0]); + + lib->processor->cancel(lib->processor); +} +END_TEST + +static bool multiread(void *data, int fd, watcher_event_t event) +{ + ck_assert_int_eq(event, WATCHER_READ); + if (recv(fd, data, 1, MSG_DONTWAIT) != 1) + { + ck_assert(errno == EAGAIN || errno == EWOULDBLOCK); + } + return TRUE; +} + +START_TEST(test_multiread) +{ + int fd[10][2], i; + char in, out[countof(fd)]; + + lib->processor->set_threads(lib->processor, 8); + + for (i = 0; i < countof(fd); i++) + { + ck_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, fd[i]) != -1); + lib->watcher->add(lib->watcher, fd[i][0], + WATCHER_READ, multiread, &out[i]); + } + + for (i = 0; i < countof(fd); i++) + { + for (in = 'a'; in <= 'z'; in++) + { + ck_assert_int_eq(write(fd[i][1], &in, 1), 1); + while (out[i] != in) + { + sched_yield(); + } + } + } + + for (i = 0; i < countof(fd); i++) + { + lib->watcher->remove(lib->watcher, fd[i][0]); + close(fd[i][1]); + close(fd[i][0]); + } + + lib->processor->cancel(lib->processor); +} +END_TEST + +static bool multiwrite(void *data, int fd, watcher_event_t event) +{ + ck_assert_int_eq(event, WATCHER_WRITE); + if (send(fd, data, 1, MSG_DONTWAIT) != 1) + { + ck_assert(errno == EAGAIN || errno == EWOULDBLOCK); + } + return TRUE; +} + +START_TEST(test_multiwrite) +{ + int fd[10][2], i, j; + u_char out, in[countof(fd)]; + + lib->processor->set_threads(lib->processor, 8); + + for (i = 0; i < countof(fd); i++) + { + ck_assert(socketpair(AF_UNIX, SOCK_STREAM, 0, fd[i]) != -1); + in[i] = i; + lib->watcher->add(lib->watcher, fd[i][1], + WATCHER_WRITE, multiwrite, &in[i]); + } + + for (j = 0; j < 10; j++) + { + for (i = 0; i < countof(fd); i++) + { + ck_assert_int_eq(read(fd[i][0], &out, 1), 1); + ck_assert_int_eq(out, i); + } + } + + for (i = 0; i < countof(fd); i++) + { + lib->watcher->remove(lib->watcher, fd[i][1]); + close(fd[i][1]); + close(fd[i][0]); + } + + lib->processor->cancel(lib->processor); +} +END_TEST + +Suite *watcher_suite_create() +{ + Suite *s; + TCase *tc; + + s = suite_create("watcher"); + + tc = tcase_create("read"); + tcase_add_test(tc, test_read); + suite_add_tcase(s, tc); + + tc = tcase_create("write"); + tcase_add_test(tc, test_write); + suite_add_tcase(s, tc); + + tc = tcase_create("multiread"); + tcase_add_test(tc, test_multiread); + suite_add_tcase(s, tc); + + tc = tcase_create("multiwrite"); + tcase_add_test(tc, test_multiwrite); + suite_add_tcase(s, tc); + + return s; +} diff --git a/src/libstrongswan/tests/test_runner.c b/src/libstrongswan/tests/test_runner.c index f85858504..0b26ee128 100644 --- a/src/libstrongswan/tests/test_runner.c +++ b/src/libstrongswan/tests/test_runner.c @@ -1,6 +1,8 @@ /* * Copyright (C) 2013 Tobias Brunner * Hochschule fuer Technik Rapperswil + * Copyright (C) 2013 Martin Willi + * Copyright (C) 2013 revosec AG * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -13,48 +15,170 @@ * for more details. */ -#include <unistd.h> - #include "test_runner.h" #include <library.h> #include <plugins/plugin_feature.h> +#include <collections/array.h> +#include <utils/test.h> #include <dirent.h> +#include <unistd.h> +#include <limits.h> + +/** + * Get a tty color escape character for stderr + */ +#define TTY(color) tty_escape_get(2, TTY_FG_##color) /** - * Load plugins from builddir + * Initialize the lookup table for testable functions (defined in libstrongswan) */ -static bool load_plugins() +static void testable_functions_create() __attribute__ ((constructor(1000))); +static void testable_functions_create() { - enumerator_t *enumerator; - char *name, path[PATH_MAX], dir[64]; + testable_functions = hashtable_create(hashtable_hash_str, + hashtable_equals_str, 8); +} + +/** + * Destroy the lookup table for testable functions + */ +static void testable_functions_destroy() __attribute__ ((destructor(1000))); +static void testable_functions_destroy() +{ + testable_functions->destroy(testable_functions); + /* if leak detective is enabled plugins are not actually unloaded, which + * means their destructor is called AFTER this one when the process + * terminates, even though the priority says differently, make sure this + * does not crash */ + testable_functions = NULL; +} + +/** + * Load all available test suites + */ +static array_t *load_suites(test_configuration_t configs[], + test_runner_init_t init) +{ + array_t *suites; + bool old = FALSE; + int i; - enumerator = enumerator_create_token(PLUGINS, " ", ""); - while (enumerator->enumerate(enumerator, &name)) + library_init(NULL, "test-runner"); + + test_setup_handler(); + + if (init && !init(TRUE)) { - snprintf(dir, sizeof(dir), "%s", name); - translate(dir, "-", "_"); - snprintf(path, sizeof(path), "%s/%s/.libs", PLUGINDIR, dir); - lib->plugins->add_path(lib->plugins, path); + library_deinit(); + return NULL; } - enumerator->destroy(enumerator); + lib->plugins->status(lib->plugins, LEVEL_CTRL); - return lib->plugins->load(lib->plugins, PLUGINS); + if (lib->leak_detective) + { + old = lib->leak_detective->set_state(lib->leak_detective, FALSE); + } + + suites = array_create(0, 0); + + for (i = 0; configs[i].suite; i++) + { + if (configs[i].feature.type == 0 || + lib->plugins->has_feature(lib->plugins, configs[i].feature)) + { + array_insert(suites, -1, configs[i].suite()); + } + } + + if (lib->leak_detective) + { + lib->leak_detective->set_state(lib->leak_detective, old); + } + + if (init) + { + init(FALSE); + } + library_deinit(); + + return suites; } -int main() +/** + * Unload and destroy test suites and associated data + */ +static void unload_suites(array_t *suites) { - SRunner *sr; - int nf; + test_suite_t *suite; + test_case_t *tcase; - /* test cases are forked and there is no cleanup, so disable leak detective. - * if test_suite.h is included leak detective is enabled in test cases */ - setenv("LEAK_DETECTIVE_DISABLE", "1", 1); - /* redirect all output to stderr (to redirect make's stdout to /dev/null) */ - dup2(2, 1); + while (array_remove(suites, 0, &suite)) + { + while (array_remove(suite->tcases, 0, &tcase)) + { + array_destroy(tcase->functions); + array_destroy(tcase->fixtures); + } + free(suite); + } + array_destroy(suites); +} - library_init(NULL); +/** + * Run a single test function, return FALSE on failure + */ +static bool run_test(test_function_t *tfun, int i) +{ + if (test_restore_point()) + { + tfun->cb(i); + return TRUE; + } + return FALSE; +} + +/** + * Invoke fixture setup/teardown + */ +static bool call_fixture(test_case_t *tcase, bool up) +{ + enumerator_t *enumerator; + test_fixture_t *fixture; + bool failure = FALSE; + + enumerator = array_create_enumerator(tcase->fixtures); + while (enumerator->enumerate(enumerator, &fixture)) + { + if (test_restore_point()) + { + if (up) + { + fixture->setup(); + } + else + { + fixture->teardown(); + } + } + else + { + failure = TRUE; + break; + } + } + enumerator->destroy(enumerator); + + return !failure; +} + +/** + * Test initialization, initializes libstrongswan for the next run + */ +static bool pre_test(test_runner_init_t init) +{ + library_init(NULL, "test-runner"); /* use non-blocking RNG to generate keys fast */ lib->settings->set_default_str(lib->settings, @@ -62,45 +186,305 @@ int main() lib->settings->get_str(lib->settings, "libstrongswan.plugins.random.urandom", "/dev/urandom")); - if (!load_plugins()) + if (lib->leak_detective) + { + /* disable leak reports during testing */ + lib->leak_detective->set_report_cb(lib->leak_detective, + NULL, NULL, NULL); + } + if (init && !init(TRUE)) { library_deinit(); - return EXIT_FAILURE; + return FALSE; } - lib->plugins->status(lib->plugins, LEVEL_CTRL); + dbg_default_set_level(LEVEL_SILENT); + return TRUE; +} + +/** + * Failure description + */ +typedef struct { + char *name; + char msg[512 - sizeof(char*) - 2 * sizeof(int)]; + const char *file; + int line; + int i; + backtrace_t *bt; +} failure_t; + +/** + * Data passed to leak report callbacks + */ +typedef struct { + array_t *failures; + char *name; + int i; + int leaks; +} report_data_t; + +/** + * Leak report callback, build failures from leaks + */ +static void report_leaks(report_data_t *data, int count, size_t bytes, + backtrace_t *bt, bool detailed) +{ + failure_t failure = { + .name = data->name, + .i = data->i, + .bt = bt->clone(bt), + }; + + snprintf(failure.msg, sizeof(failure.msg), + "Leak detected: %d allocations using %zu bytes", count, bytes); + + array_insert(data->failures, -1, &failure); +} + +/** + * Leak summary callback, check if any leaks found + */ +static void sum_leaks(report_data_t *data, int count, size_t bytes, + int whitelisted) +{ + data->leaks = count; +} + +/** + * Do library cleanup and optionally check for memory leaks + */ +static bool post_test(test_runner_init_t init, bool check_leaks, + array_t *failures, char *name, int i) +{ + report_data_t data = { + .failures = failures, + .name = name, + .i = i, + }; - sr = srunner_create(NULL); - srunner_add_suite(sr, bio_reader_suite_create()); - srunner_add_suite(sr, bio_writer_suite_create()); - srunner_add_suite(sr, chunk_suite_create()); - srunner_add_suite(sr, enum_suite_create()); - srunner_add_suite(sr, enumerator_suite_create()); - srunner_add_suite(sr, linked_list_suite_create()); - srunner_add_suite(sr, linked_list_enumerator_suite_create()); - srunner_add_suite(sr, hashtable_suite_create()); - srunner_add_suite(sr, array_suite_create()); - srunner_add_suite(sr, identification_suite_create()); - srunner_add_suite(sr, threading_suite_create()); - srunner_add_suite(sr, utils_suite_create()); - srunner_add_suite(sr, host_suite_create()); - srunner_add_suite(sr, vectors_suite_create()); - srunner_add_suite(sr, printf_suite_create()); - if (lib->plugins->has_feature(lib->plugins, - PLUGIN_DEPENDS(PRIVKEY_GEN, KEY_RSA))) - { - srunner_add_suite(sr, rsa_suite_create()); - } - if (lib->plugins->has_feature(lib->plugins, - PLUGIN_DEPENDS(PRIVKEY_GEN, KEY_ECDSA))) - { - srunner_add_suite(sr, ecdsa_suite_create()); - } - - srunner_run_all(sr, CK_NORMAL); - nf = srunner_ntests_failed(sr); - - srunner_free(sr); + if (init) + { + init(FALSE); + } + if (check_leaks && lib->leak_detective) + { + lib->leak_detective->set_report_cb(lib->leak_detective, + (leak_detective_report_cb_t)report_leaks, + (leak_detective_summary_cb_t)sum_leaks, &data); + } library_deinit(); - return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; + return data.leaks != 0; +} + +/** + * Collect failure information, add failure_t to array + */ +static void collect_failure_info(array_t *failures, char *name, int i) +{ + failure_t failure = { + .name = name, + .i = i, + .bt = test_failure_backtrace(), + }; + + failure.line = test_failure_get(failure.msg, sizeof(failure.msg), + &failure.file); + + array_insert(failures, -1, &failure); +} + +/** + * Print array of collected failure_t to stderr + */ +static void print_failures(array_t *failures) +{ + failure_t failure; + + backtrace_init(); + + while (array_remove(failures, 0, &failure)) + { + fprintf(stderr, " %sFailure in '%s': %s (", + TTY(RED), failure.name, failure.msg); + if (failure.line) + { + fprintf(stderr, "%s:%d, ", failure.file, failure.line); + } + fprintf(stderr, "i = %d)%s\n", failure.i, TTY(DEF)); + if (failure.bt) + { + failure.bt->log(failure.bt, stderr, TRUE); + failure.bt->destroy(failure.bt); + } + } + + backtrace_deinit(); +} + +/** + * Run a single test case with fixtures + */ +static bool run_case(test_case_t *tcase, test_runner_init_t init) +{ + enumerator_t *enumerator; + test_function_t *tfun; + int passed = 0; + array_t *failures; + + failures = array_create(sizeof(failure_t), 0); + + fprintf(stderr, " Running case '%s': ", tcase->name); + fflush(stderr); + + enumerator = array_create_enumerator(tcase->functions); + while (enumerator->enumerate(enumerator, &tfun)) + { + int i, rounds = 0; + + for (i = tfun->start; i < tfun->end; i++) + { + if (pre_test(init)) + { + bool ok = FALSE, leaks = FALSE; + + test_setup_timeout(tcase->timeout); + + if (call_fixture(tcase, TRUE)) + { + if (run_test(tfun, i)) + { + if (call_fixture(tcase, FALSE)) + { + ok = TRUE; + } + } + else + { + call_fixture(tcase, FALSE); + } + + } + leaks = post_test(init, ok, failures, tfun->name, i); + + test_setup_timeout(0); + + if (ok) + { + if (!leaks) + { + rounds++; + fprintf(stderr, "%s+%s", TTY(GREEN), TTY(DEF)); + } + } + else + { + collect_failure_info(failures, tfun->name, i); + } + if (!ok || leaks) + { + fprintf(stderr, "%s-%s", TTY(RED), TTY(DEF)); + } + } + else + { + fprintf(stderr, "!"); + } + } + fflush(stderr); + if (rounds == tfun->end - tfun->start) + { + passed++; + } + } + enumerator->destroy(enumerator); + + fprintf(stderr, "\n"); + + print_failures(failures); + array_destroy(failures); + + return passed == array_count(tcase->functions); +} + +/** + * Run a single test suite + */ +static bool run_suite(test_suite_t *suite, test_runner_init_t init) +{ + enumerator_t *enumerator; + test_case_t *tcase; + int passed = 0; + + fprintf(stderr, " Running suite '%s':\n", suite->name); + + enumerator = array_create_enumerator(suite->tcases); + while (enumerator->enumerate(enumerator, &tcase)) + { + if (run_case(tcase, init)) + { + passed++; + } + } + enumerator->destroy(enumerator); + + if (passed == array_count(suite->tcases)) + { + fprintf(stderr, " %sPassed all %u '%s' test cases%s\n", + TTY(GREEN), array_count(suite->tcases), suite->name, TTY(DEF)); + return TRUE; + } + fprintf(stderr, " %sPassed %u/%u '%s' test cases%s\n", + TTY(RED), passed, array_count(suite->tcases), suite->name, TTY(DEF)); + return FALSE; +} + +/** + * See header. + */ +int test_runner_run(const char *name, test_configuration_t configs[], + test_runner_init_t init) +{ + array_t *suites; + test_suite_t *suite; + enumerator_t *enumerator; + int passed = 0, result; + + /* redirect all output to stderr (to redirect make's stdout to /dev/null) */ + dup2(2, 1); + + suites = load_suites(configs, init); + if (!suites) + { + return EXIT_FAILURE; + } + + fprintf(stderr, "Running %u '%s' test suites:\n", array_count(suites), name); + + enumerator = array_create_enumerator(suites); + while (enumerator->enumerate(enumerator, &suite)) + { + if (run_suite(suite, init)) + { + passed++; + } + } + enumerator->destroy(enumerator); + + if (passed == array_count(suites)) + { + fprintf(stderr, "%sPassed all %u '%s' suites%s\n", + TTY(GREEN), array_count(suites), name, TTY(DEF)); + result = EXIT_SUCCESS; + } + else + { + fprintf(stderr, "%sPassed %u of %u '%s' suites%s\n", + TTY(RED), passed, array_count(suites), name, TTY(DEF)); + result = EXIT_FAILURE; + } + + unload_suites(suites); + + return result; } diff --git a/src/libstrongswan/tests/test_runner.h b/src/libstrongswan/tests/test_runner.h index 6315abba7..643b622e5 100644 --- a/src/libstrongswan/tests/test_runner.h +++ b/src/libstrongswan/tests/test_runner.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2013 Tobias Brunner - * Hochschule fuer Technik Rapperswil + * Copyright (C) 2013 Martin Willi + * Copyright (C) 2013 revosec AG * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -13,27 +13,65 @@ * for more details. */ +/** + * @defgroup libtest libtest + * + * @defgroup test_utils test_utils + * @ingroup libtest + * + * @defgroup test_runner test_runner + * @{ @ingroup libtest + */ + #ifndef TEST_RUNNER_H_ #define TEST_RUNNER_H_ -#include <check.h> - -Suite *bio_reader_suite_create(); -Suite *bio_writer_suite_create(); -Suite *chunk_suite_create(); -Suite *enum_suite_create(); -Suite *enumerator_suite_create(); -Suite *linked_list_suite_create(); -Suite *linked_list_enumerator_suite_create(); -Suite *hashtable_suite_create(); -Suite *array_suite_create(); -Suite *identification_suite_create(); -Suite *threading_suite_create(); -Suite *utils_suite_create(); -Suite *vectors_suite_create(); -Suite *ecdsa_suite_create(); -Suite *rsa_suite_create(); -Suite *host_suite_create(); -Suite *printf_suite_create(); - -#endif /** TEST_RUNNER_H_ */ +#include "test_suite.h" + +#include <plugins/plugin_feature.h> + +typedef struct test_configuration_t test_configuration_t; + +/** + * Callback called before and after each test case to de-/initialize the + * environment (e.g. to load plugins). It is also called before and after the + * test suites are loaded. + * + * It is called after libstrongswan has been initialized and likewise before it + * gets deinitialized. + * + * @param init TRUE during initialization + * @return FALSE if de-/init failed + */ +typedef bool (*test_runner_init_t)(bool init); + +/** + * Test configuration, suite constructor with plugin dependency + */ +struct test_configuration_t { + + /** + * Constructor function to create suite. + */ + test_suite_t *(*suite)(); + + /** + * Plugin feature this test suite depends on + */ + plugin_feature_t feature; +}; + +/** + * Run test configuration. + * + * The configs array must be terminated with a NULL element. + * + * @param name name of test runner + * @param config test suite constructors with dependencies + * @param init_cb init/deinit callback + * @return test result, EXIT_SUCCESS if all tests passed + */ +int test_runner_run(const char *name, test_configuration_t config[], + test_runner_init_t init_cb); + +#endif /** TEST_RUNNER_H_ @}*/ diff --git a/src/libstrongswan/tests/test_suite.c b/src/libstrongswan/tests/test_suite.c new file mode 100644 index 000000000..0f2e74b7c --- /dev/null +++ b/src/libstrongswan/tests/test_suite.c @@ -0,0 +1,277 @@ +/* + * Copyright (C) 2013 Martin Willi + * Copyright (C) 2013 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_suite.h" + +#include <signal.h> +#include <unistd.h> + +#include <pthread.h> + +/** + * Failure message buf + */ +static char failure_buf[512]; + +/** + * Source file failure occurred + */ +static const char *failure_file; + +/** + * Line of source file failure occurred + */ +static int failure_line; + +/** + * Backtrace of failure, if any + */ +static backtrace_t *failure_backtrace; + +/** + * Longjump restore point when failing + */ +sigjmp_buf test_restore_point_env; + +/** + * See header. + */ +test_suite_t* test_suite_create(const char *name) +{ + test_suite_t *suite; + + INIT(suite, + .name = name, + .tcases = array_create(0, 0), + ); + return suite; +} + +/** + * See header. + */ +test_case_t* test_case_create(const char *name) +{ + test_case_t *tcase; + + INIT(tcase, + .name = name, + .functions = array_create(sizeof(test_function_t), 0), + .fixtures = array_create(sizeof(test_fixture_t), 0), + .timeout = TEST_FUNCTION_DEFAULT_TIMEOUT, + ); + return tcase; +} + +/** + * See header. + */ +void test_case_add_checked_fixture(test_case_t *tcase, test_fixture_cb_t setup, + test_fixture_cb_t teardown) +{ + test_fixture_t fixture = { + .setup = setup, + .teardown = teardown, + }; + array_insert(tcase->fixtures, -1, &fixture); +} + +/** + * See header. + */ +void test_case_add_test_name(test_case_t *tcase, char *name, + test_function_cb_t cb, int start, int end) +{ + test_function_t fun = { + .name = name, + .cb = cb, + .start = start, + .end = end, + }; + array_insert(tcase->functions, -1, &fun); +} + +/** + * See header. + */ +void test_case_set_timeout(test_case_t *tcase, int s) +{ + tcase->timeout = s; +} + +/** + * See header. + */ +void test_suite_add_case(test_suite_t *suite, test_case_t *tcase) +{ + array_insert(suite->tcases, -1, tcase); +} + +/** + * Main thread performing tests + */ +static pthread_t main_thread; + +/** + * Let test case fail + */ +static inline void test_failure() +{ + if (pthread_self() == main_thread) + { + siglongjmp(test_restore_point_env, 1); + } + else + { + pthread_kill(main_thread, SIGUSR1); + /* how can we stop just the thread? longjmp to a restore point? */ + } +} + +/** + * See header. + */ +void test_fail_vmsg(const char *file, int line, char *fmt, va_list args) +{ + vsnprintf(failure_buf, sizeof(failure_buf), fmt, args); + failure_line = line; + failure_file = file; + + test_failure(); +} + +/** + * See header. + */ +void test_fail_msg(const char *file, int line, char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vsnprintf(failure_buf, sizeof(failure_buf), fmt, args); + failure_line = line; + failure_file = file; + va_end(args); + + test_failure(); +} + +/** + * Signal handler catching critical and alarm signals + */ +static void test_sighandler(int signal) +{ + char *signame; + bool old = FALSE; + + switch (signal) + { + case SIGUSR1: + /* a different thread failed, abort test */ + return test_failure(); + case SIGSEGV: + signame = "SIGSEGV"; + break; + case SIGILL: + signame = "SIGILL"; + break; + case SIGBUS: + signame = "SIGBUS"; + break; + case SIGALRM: + signame = "timeout"; + break; + default: + signame = "SIG"; + break; + } + if (lib->leak_detective) + { + old = lib->leak_detective->set_state(lib->leak_detective, FALSE); + } + failure_backtrace = backtrace_create(3); + if (lib->leak_detective) + { + lib->leak_detective->set_state(lib->leak_detective, old); + } + test_fail_msg(NULL, 0, "%s(%d)", signame, signal); + /* unable to restore a valid context for that thread, terminate */ + fprintf(stderr, "\n%s(%d) outside of main thread:\n", signame, signal); + failure_backtrace->log(failure_backtrace, stderr, TRUE); + fprintf(stderr, "terminating...\n"); + abort(); +} + +/** + * See header. + */ +void test_setup_handler() +{ + struct sigaction action = { + .sa_handler = test_sighandler, + }; + + main_thread = pthread_self(); + + /* signal handler inherited by all threads */ + sigaction(SIGSEGV, &action, NULL); + sigaction(SIGILL, &action, NULL); + sigaction(SIGBUS, &action, NULL); + /* ignore ALRM/USR1, these are catched by main thread only */ + action.sa_handler = SIG_IGN; + sigaction(SIGALRM, &action, NULL); + sigaction(SIGUSR1, &action, NULL); +} + +/** + * See header. + */ +void test_setup_timeout(int s) +{ + struct sigaction action = { + .sa_handler = test_sighandler, + }; + + /* This called by main thread only. Setup handler for timeout and + * failure cross-thread signaling. */ + sigaction(SIGALRM, &action, NULL); + sigaction(SIGUSR1, &action, NULL); + + alarm(s); +} + +/** + * See header. + */ +int test_failure_get(char *msg, int len, const char **file) +{ + strncpy(msg, failure_buf, len - 1); + msg[len - 1] = 0; + *file = failure_file; + return failure_line; +} + +/** + * See header. + */ +backtrace_t *test_failure_backtrace() +{ + backtrace_t *bt; + + bt = failure_backtrace; + failure_backtrace = NULL; + + return bt; +} diff --git a/src/libstrongswan/tests/test_suite.h b/src/libstrongswan/tests/test_suite.h index 2a2861323..c44f149f5 100644 --- a/src/libstrongswan/tests/test_suite.h +++ b/src/libstrongswan/tests/test_suite.h @@ -1,6 +1,8 @@ /* * Copyright (C) 2013 Tobias Brunner * Hochschule fuer Technik Rapperswil + * Copyright (C) 2013 Martin Willi + * Copyright (C) 2013 revosec AG * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -13,98 +15,318 @@ * for more details. */ -#ifndef TEST_UTILS_H_ -#define TEST_UTILS_H_ +/** + * @defgroup test_suite test_suite + * @{ @ingroup libtest + */ + +#ifndef TEST_SUITE_H_ +#define TEST_SUITE_H_ + +#define _GNU_SOURCE +#include <setjmp.h> -#include <check.h> #include <library.h> #include <utils/debug.h> +#include <utils/backtrace.h> +#include <collections/array.h> + +typedef struct test_suite_t test_suite_t; +typedef struct test_case_t test_case_t; +typedef struct test_function_t test_function_t; +typedef struct test_fixture_t test_fixture_t; /** - * Used to mark test cases that use test fixtures. + * Default timeout for a single test function */ -#define UNIT_TEST_FIXTURE_USED "UNIT_TEST_FIXTURE_USED" +#define TEST_FUNCTION_DEFAULT_TIMEOUT 2 /** - * Check for memory leaks and fail if any are encountered. + * Test function implementation */ -#define CHECK_FOR_LEAKS() do \ -{ \ - if (lib->leak_detective) \ - { \ - if (lib->leak_detective->leaks(lib->leak_detective)) { \ - lib->leak_detective->report(lib->leak_detective, TRUE); \ - } \ - ck_assert_int_eq(lib->leak_detective->leaks(lib->leak_detective), 0); \ - } \ -} \ -while(0) +typedef void (*test_function_cb_t)(int); + +/** + * Fixture for a test case. + */ +typedef void (*test_fixture_cb_t)(void); + +/** + * A test suite; a collection of test cases with fixtures + */ +struct test_suite_t { + /** name of the test suite */ + const char *name; + /** test cases registered, as test_case_t* */ + array_t *tcases; +}; /** - * Extended versions of the START|END_TEST macros that use leak detective. + * A test case; multiple test functions using the same fixtures + */ +struct test_case_t { + /** name of the test case */ + const char *name; + /** tests registered, as test_function_t */ + array_t *functions; + /** fixture for tests, as test_fixture_t */ + array_t *fixtures; + /** timeout for each function, in s */ + int timeout; +}; + +/** + * A test function, with optional loop setup + */ +struct test_function_t { + /** name of test function */ + char *name; + /** tests function registered, test_function_t* */ + test_function_cb_t cb; + /** start for loop test */ + int start; + /** end for loop test */ + int end; +}; + +/** + * Registered fixture for a test case + */ +struct test_fixture_t { + test_fixture_cb_t setup; + test_fixture_cb_t teardown; +}; + +/** + * Create a new test suite * - * Since each test case runs in its own fork of the test runner the stuff - * allocated before the test starts is not freed, so leak detective is disabled - * by default to prevent false positives. By enabling it right when the test - * starts we at least capture leaks created by the tested objects/functions and - * the test case itself. This allows writing test cases for cleanup functions. + * @param name name of the test suite + * @return test suite + */ +test_suite_t* test_suite_create(const char *name); + +/** + * Create a new test case * - * To define test fixture with possibly allocated/destroyed memory that is - * allocated/freed in a test case use the START|END_SETUP|TEARDOWN macros. + * @param name name of test case + * @return test case */ -#undef START_TEST -#define START_TEST(name) \ -static void name (int _i CK_ATTRIBUTE_UNUSED) \ -{ \ - tcase_fn_start(""#name, __FILE__, __LINE__); \ - dbg_default_set_level(LEVEL_SILENT); \ - if (lib->leak_detective) \ - { \ - lib->leak_detective->set_state(lib->leak_detective, TRUE); \ - } +test_case_t* test_case_create(const char *name); -#undef END_TEST -#define END_TEST \ - if (!lib->get(lib, UNIT_TEST_FIXTURE_USED)) \ - { \ - CHECK_FOR_LEAKS(); \ - } \ -} +/** + * Add a setup/teardown function to the test case + * + * @param tcase test case to add a fixture to + * @param setup setup function called before each test + * @param teardown cleanup function called after each test + */ +void test_case_add_checked_fixture(test_case_t *tcase, test_fixture_cb_t setup, + test_fixture_cb_t teardown); + +/** + * Add a test function to a test case, with a name, looped several times + * + * @param name name of the test case + * @param tcase test case to add test function to + * @param cb callback function to invoke for test + * @param start start of loop counter + * @param end end of loop counter + */ +void test_case_add_test_name(test_case_t *tcase, char *name, + test_function_cb_t cb, int start, int end); + +/** + * Add a test function to a test case + * + * @param tcase test case to add test function to + * @param cb callback function to invoke for test + */ +#define test_case_add_test(tcase, cb) \ + test_case_add_test_name(tcase, #cb, cb, 0, 1) + +/** + * Add a test function to a test case, looped several times + * + * @param tcase test case to add test function to + * @param cb callback function to invoke for test + * @param start start of loop counter + * @param end end of loop counter + */ +#define test_case_add_loop_test(tcase, cb, start, end) \ + test_case_add_test_name(tcase, #cb, cb, start, end) + +/** + * Set a custom timeout for test functions in a test case + * + * @param tcase test case to set timeout for + * @param s test timeout in s + */ +void test_case_set_timeout(test_case_t *tcase, int s); + +/** + * Add a test function to a test case, looped several times + * + * @param suite test suite to add test case to + * @param tcase test case to add + */ +void test_suite_add_case(test_suite_t *suite, test_case_t *tcase); /** - * Define a function to setup a test fixture that can be used with the above - * macros. + * sigjmp restore point used by test_restore_point + */ +extern sigjmp_buf test_restore_point_env; + +/** + * Set or return from an execution restore point + * + * This call sets a restore execution point and returns TRUE after it has + * been set up. On test failure, the execution is returned to the restore point + * and FALSE is returned to indicate test failure. + * + * @return TRUE if restore point set, FALSE when restored */ -#define START_SETUP(name) \ -static void name() \ -{ \ - lib->set(lib, UNIT_TEST_FIXTURE_USED, (void*)TRUE); \ - if (lib->leak_detective) \ +#define test_restore_point() (sigsetjmp(test_restore_point_env, 1) == 0) + +/** + * Set up signal handlers for test cases + */ +void test_setup_handler(); + +/** + * Set up a timeout to let a test fail + * + * @param s timeout, 0 to disable timeout + */ +void test_setup_timeout(int s); + +/** + * Get info about a test failure + * + * @param msg buffer receiving failure info + * @param len size of msg buffer + * @param file pointer receiving source code file + * @return source code line number + */ +int test_failure_get(char *msg, int len, const char **file); + +/** + * Get a backtrace for a failure. + * + * @return allocated backtrace of test failure, if any + */ +backtrace_t *test_failure_backtrace(); + +/** + * Let a test fail and set a message using vprintf style arguments. + * + * @param file source code file name + * @param line source code line number + * @param fmt printf format string + * @param args argument list for fmt + */ +void test_fail_vmsg(const char *file, int line, char *fmt, va_list args); + +/** + * Let a test fail and set a message using printf style arguments. + * + * @param file source code file name + * @param line source code line number + * @param fmt printf format string + * @param ... arguments for fmt + */ +void test_fail_msg(const char *file, int line, char *fmt, ...); + +/** + * Check if two integers equal, fail test if not + * + * @param a first integer + * @param b second integer + */ +#define test_int_eq(a, b) \ +({ \ + typeof(a) _a = a; \ + typeof(b) _b = b; \ + if (_a != _b) \ { \ - lib->leak_detective->set_state(lib->leak_detective, TRUE); \ - } + test_fail_msg(__FILE__, __LINE__, #a " != " #b " (%d != %d)", _a, _b); \ + } \ +}) /** - * End a setup function + * Check if two strings equal, fail test if not + * + * @param a first string + * @param b second string */ -#define END_SETUP } +#define test_str_eq(a, b) \ +({ \ + char* _a = (char*)a; \ + char* _b = (char*)b; \ + if (!_a || !_b || !streq(_a, _b)) \ + { \ + test_fail_msg(__FILE__, __LINE__, \ + #a " != " #b " (\"%s\" != \"%s\")", _a, _b); \ + } \ +}) /** - * Define a function to teardown a test fixture that can be used with the above - * macros. + * Check if a statement evaluates to TRUE, fail test if not + * + * @param x statement to evaluate */ -#define START_TEARDOWN(name) \ -static void name() \ -{ +#define test_assert(x) \ +({ \ + if (!(x)) \ + { \ + test_fail_msg(__FILE__, __LINE__, #x); \ + } \ +}) /** - * End a teardown function + * Check if a statement evaluates to TRUE, fail and print a message if not + * + * @param x statement to evaluate + * @param fmt message format string + * @param ... fmt printf arguments */ -#define END_TEARDOWN \ - if (lib->get(lib, UNIT_TEST_FIXTURE_USED)) \ +#define test_assert_msg(x, fmt, ...) \ +({ \ + if (!(x)) \ { \ - CHECK_FOR_LEAKS(); \ + test_fail_msg(__FILE__, __LINE__, #x ": " fmt, ##__VA_ARGS__); \ } \ -} +}) + + + +/* "check unit testing" compatibility */ +#define Suite test_suite_t +#define TCase test_case_t +#define ck_assert_int_eq test_int_eq +#define ck_assert test_assert +#define ck_assert_msg test_assert_msg +#define ck_assert_str_eq test_str_eq +#define fail(fmt, ...) test_fail_msg(__FILE__, __LINE__, fmt, ##__VA_ARGS__) +#define fail_if(x, fmt, ...) \ +({ \ + if (x) \ + { \ + test_fail_msg(__FILE__, __LINE__, #x ": " fmt, ##__VA_ARGS__); \ + } \ +}) +#define fail_unless test_assert_msg +#define suite_create test_suite_create +#define tcase_create test_case_create +#define tcase_add_checked_fixture test_case_add_checked_fixture +#define tcase_add_test test_case_add_test +#define tcase_add_loop_test test_case_add_loop_test +#define tcase_set_timeout test_case_set_timeout +#define suite_add_tcase test_suite_add_case +#define START_TEST(name) static void name (int _i) { +#define END_TEST } +#define START_SETUP(name) static void name() { +#define END_SETUP } +#define START_TEARDOWN(name) static void name() { +#define END_TEARDOWN } -#endif /** TEST_UTILS_H_ */ +#endif /** TEST_SUITE_H_ @}*/ diff --git a/src/libstrongswan/tests/test_threading.c b/src/libstrongswan/tests/test_threading.c deleted file mode 100644 index 0c768b3e2..000000000 --- a/src/libstrongswan/tests/test_threading.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2013 Tobias Brunner - * Copyright (C) 2008 Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include <sched.h> -#include <pthread.h> - -#include "test_suite.h" - -#include <threading/mutex.h> - -/******************************************************************************* - * recursive mutex test - */ - -#define THREADS 20 - -static mutex_t *mutex; - -static pthread_barrier_t mutex_barrier; - -static int mutex_locked = 0; - -static void *mutex_run(void *data) -{ - int i; - - /* wait for all threads before getting in action */ - pthread_barrier_wait(&mutex_barrier); - - for (i = 0; i < 100; i++) - { - mutex->lock(mutex); - mutex->lock(mutex); - mutex->lock(mutex); - mutex_locked++; - sched_yield(); - if (mutex_locked > 1) - { - fail("two threads locked the mutex concurrently"); - } - mutex_locked--; - mutex->unlock(mutex); - mutex->unlock(mutex); - mutex->unlock(mutex); - } - return NULL; -} - -START_TEST(test_mutex) -{ - pthread_t threads[THREADS]; - int i; - - mutex = mutex_create(MUTEX_TYPE_RECURSIVE); - - for (i = 0; i < 10; i++) - { - mutex->lock(mutex); - mutex->unlock(mutex); - } - for (i = 0; i < 10; i++) - { - mutex->lock(mutex); - } - for (i = 0; i < 10; i++) - { - mutex->unlock(mutex); - } - - pthread_barrier_init(&mutex_barrier, NULL, THREADS); - for (i = 0; i < THREADS; i++) - { - pthread_create(&threads[i], NULL, mutex_run, NULL); - } - for (i = 0; i < THREADS; i++) - { - pthread_join(threads[i], NULL); - } - pthread_barrier_destroy(&mutex_barrier); - - mutex->destroy(mutex); -} -END_TEST - -Suite *threading_suite_create() -{ - Suite *s; - TCase *tc; - - s = suite_create("threading"); - - tc = tcase_create("recursive mutex"); - tcase_add_test(tc, test_mutex); - suite_add_tcase(s, tc); - - return s; -} diff --git a/src/libstrongswan/tests/tests.c b/src/libstrongswan/tests/tests.c new file mode 100644 index 000000000..9f2adfd15 --- /dev/null +++ b/src/libstrongswan/tests/tests.c @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2013 Martin Willi + * Copyright (C) 2013 revosec AG + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include <test_runner.h> + +/* declare test suite constructors */ +#define TEST_SUITE(x) test_suite_t* x(); +#define TEST_SUITE_DEPEND(x, ...) TEST_SUITE(x) +#include "tests.h" +#undef TEST_SUITE +#undef TEST_SUITE_DEPEND + +static test_configuration_t tests[] = { +#define TEST_SUITE(x) \ + { .suite = x, }, +#define TEST_SUITE_DEPEND(x, type, args) \ + { .suite = x, .feature = PLUGIN_DEPENDS(type, args) }, +#include "tests.h" + { .suite = NULL, } +}; + +static bool test_runner_init(bool init) +{ + if (init) + { + plugin_loader_add_plugindirs(PLUGINDIR, PLUGINS); + if (!lib->plugins->load(lib->plugins, PLUGINS)) + { + return FALSE; + } + } + else + { + lib->processor->set_threads(lib->processor, 0); + lib->processor->cancel(lib->processor); + lib->plugins->unload(lib->plugins); + } + return TRUE; +} + +int main(int argc, char *argv[]) +{ + return test_runner_run("libstrongswan", tests, test_runner_init); +} diff --git a/src/libstrongswan/tests/tests.h b/src/libstrongswan/tests/tests.h new file mode 100644 index 000000000..82a5137c1 --- /dev/null +++ b/src/libstrongswan/tests/tests.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2013 Tobias Brunner + * Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +TEST_SUITE(bio_reader_suite_create) +TEST_SUITE(bio_writer_suite_create) +TEST_SUITE(chunk_suite_create) +TEST_SUITE(enum_suite_create) +TEST_SUITE(enumerator_suite_create) +TEST_SUITE(linked_list_suite_create) +TEST_SUITE(linked_list_enumerator_suite_create) +TEST_SUITE(hashtable_suite_create) +TEST_SUITE(array_suite_create) +TEST_SUITE(identification_suite_create) +TEST_SUITE(threading_suite_create) +TEST_SUITE(watcher_suite_create) +TEST_SUITE(stream_suite_create) +TEST_SUITE(utils_suite_create) +TEST_SUITE(settings_suite_create) +TEST_SUITE(vectors_suite_create) +TEST_SUITE_DEPEND(ecdsa_suite_create, PRIVKEY_GEN, KEY_ECDSA) +TEST_SUITE_DEPEND(rsa_suite_create, PRIVKEY_GEN, KEY_RSA) +TEST_SUITE(host_suite_create) +TEST_SUITE(printf_suite_create) +TEST_SUITE(hasher_suite_create) +TEST_SUITE(crypter_suite_create) +TEST_SUITE(pen_suite_create) +TEST_SUITE(asn1_suite_create) +TEST_SUITE(asn1_parser_suite_create) +TEST_SUITE(test_rng_suite_create) +TEST_SUITE_DEPEND(ntru_suite_create, DH, NTRU_112_BIT) +TEST_SUITE_DEPEND(fetch_http_suite_create, FETCHER, "http://") diff --git a/src/libstrongswan/tests/utils/test_rng.c b/src/libstrongswan/tests/utils/test_rng.c new file mode 100644 index 000000000..01569509b --- /dev/null +++ b/src/libstrongswan/tests/utils/test_rng.c @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2013 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "test_rng.h" + +typedef struct private_rng_t private_rng_t; + +/** + * Private data. + */ +struct private_rng_t { + + /** + * Public interface. + */ + rng_t public; + + /** + * Entropy string. + */ + chunk_t entropy; +}; + +METHOD(rng_t, get_bytes, bool, + private_rng_t *this, size_t bytes, u_int8_t *buffer) +{ + if (bytes > this->entropy.len) + { + return FALSE; + } + memcpy(buffer, this->entropy.ptr, bytes); + this->entropy = chunk_skip(this->entropy, bytes); + return TRUE; +} + +METHOD(rng_t, allocate_bytes, bool, + private_rng_t *this, size_t bytes, chunk_t *chunk) +{ + if (bytes > this->entropy.len) + { + *chunk = chunk_empty; + return FALSE; + } + + *chunk = chunk_alloc(bytes); + memcpy(chunk->ptr, this->entropy.ptr, bytes); + this->entropy = chunk_skip(this->entropy, bytes); + return TRUE; +} + +METHOD(rng_t, destroy, void, + private_rng_t *this) +{ + free(this); +} + +/* + * Described in header. + */ +rng_t *test_rng_create(chunk_t entropy) +{ + private_rng_t *this; + + INIT(this, + .public = { + .get_bytes = _get_bytes, + .allocate_bytes = _allocate_bytes, + .destroy = _destroy, + }, + .entropy = entropy, + ); + + return &this->public; +} diff --git a/src/libstrongswan/tests/utils/test_rng.h b/src/libstrongswan/tests/utils/test_rng.h new file mode 100644 index 000000000..e588f3be7 --- /dev/null +++ b/src/libstrongswan/tests/utils/test_rng.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2013 Andreas Steffen + * HSR Hochschule fuer Technik Rapperswil + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +/** + * rng_t providing NIST SP 800-90A entropy test vectors + * + * @defgroup test_rng test_rng + * @{ @ingroup test_utils + */ + +#ifndef TEST_RNG_H_ +#define TEST_RNG_H_ + +#include <library.h> + +/** + * Creates a test_rng_t instance. + * + * @param entropy entropy test vector + * @return created test_rng_t + */ +rng_t *test_rng_create(chunk_t entropy); + +#endif /** TEST_RNG_H_ @} */ |