diff --git a/src/charon-tkm/Makefile.am b/src/charon-tkm/Makefile.am index 4939c074a..03694e3f7 100644 --- a/src/charon-tkm/Makefile.am +++ b/src/charon-tkm/Makefile.am @@ -39,14 +39,15 @@ build_charon: build_charon.gpr src/charon-tkm.c build_tests: build_tests.gpr @$(GPRBUILD) -p $< $(BUILD_OPTS) $(TEST_OPTS) -check-tkm: build_tests +check: build_tests + if test -z "${TESTS_TKM}"; then \ + echo -e >&2 \ + "\nSome TKM tests are not enabled, by deafult, because they have" \ + "\nto be run as root and require a running TKM daemon. They may" \ + "\nbe enabled by defining the TESTS_TKM environment variable.\n"; \ + fi @LD_LIBRARY_PATH=$(LIBPT) obj/tests -check: - @echo "TKM tests are not run automatically because they have to be run as root" >&2 - @echo "and require a properly configured TKM daemon to be running." >&2 - @echo "They can be run from '$(abs_builddir)' with 'make check-tkm'" >&2 - install: build_charon $(INSTALL) -m 755 obj/charon-tkm $(DESTDIR)$(ipsecdir) diff --git a/src/charon-tkm/tests/keymat_tests.c b/src/charon-tkm/tests/keymat_tests.c index eea589c09..ff6a6c8c7 100644 --- a/src/charon-tkm/tests/keymat_tests.c +++ b/src/charon-tkm/tests/keymat_tests.c @@ -62,7 +62,7 @@ START_TEST(test_derive_ike_keys) aead_t * const aead = keymat->keymat_v2.keymat.get_aead(&keymat->keymat_v2.keymat, TRUE); fail_if(!aead, "AEAD is NULL"); - fail_if(aead->get_key_size(aead) != 96, "Key size mismatch %d", + fail_if(aead->get_key_size(aead) != 1, "Key size mismatch %d", aead->get_key_size(aead)); fail_if(aead->get_block_size(aead) != 16, "Block size mismatch %d", aead->get_block_size(aead)); diff --git a/src/charon-tkm/tests/tests.c b/src/charon-tkm/tests/tests.c index 150a6d437..c09936a37 100644 --- a/src/charon-tkm/tests/tests.c +++ b/src/charon-tkm/tests/tests.c @@ -41,21 +41,31 @@ static test_configuration_t tests[] = { { .suite = NULL, } }; -static bool tkm_initialized = false; +static bool tkm_initialized, use_tkm; static bool test_runner_init(bool init) { bool result = TRUE; - if (init) + if (init && use_tkm) { + int level = LEVEL_SILENT; + char *verbosity; + libcharon_init(); - lib->settings->set_int(lib->settings, - "test-runner.filelog.stdout.default", 0); + verbosity = getenv("TESTS_VERBOSITY"); + if (verbosity) + { + level = atoi(verbosity); + } + lib->settings->set_int(lib->settings, "%s.filelog.stderr.default", + lib->settings->get_int(lib->settings, "%s.filelog.stderr.default", + level, lib->ns), lib->ns); charon->load_loggers(charon); /* Register TKM specific plugins */ static plugin_feature_t features[] = { + PLUGIN_PROVIDE(CUSTOM, "tkm"), PLUGIN_REGISTER(NONCE_GEN, tkm_nonceg_create), PLUGIN_PROVIDE(NONCE_GEN), PLUGIN_CALLBACK(kernel_ipsec_register, tkm_kernel_ipsec_create), @@ -98,6 +108,8 @@ int main(int argc, char *argv[]) { bool result; + use_tkm = getenv("TESTS_TKM") != NULL; + /* disable leak detective because of how tkm_init/deinit is called, which * does not work otherwise due to limitations of the external libraries */ setenv("LEAK_DETECTIVE_DISABLE", "1", 1); diff --git a/src/charon-tkm/tests/tests.h b/src/charon-tkm/tests/tests.h index 0214a413e..a93837c7c 100644 --- a/src/charon-tkm/tests/tests.h +++ b/src/charon-tkm/tests/tests.h @@ -17,7 +17,7 @@ TEST_SUITE(make_id_manager_tests) TEST_SUITE(make_chunk_map_tests) TEST_SUITE(make_utility_tests) -TEST_SUITE(make_nonceg_tests) -TEST_SUITE(make_diffie_hellman_tests) -TEST_SUITE(make_keymat_tests) +TEST_SUITE_DEPEND(make_nonceg_tests, CUSTOM, "tkm") +TEST_SUITE_DEPEND(make_diffie_hellman_tests, CUSTOM, "tkm") +TEST_SUITE_DEPEND(make_keymat_tests, CUSTOM, "tkm") TEST_SUITE(make_kernel_sad_tests)