From: Tobias Brunner Date: Fri, 8 Aug 2025 09:10:29 +0000 (+0200) Subject: unit-tests: Add option to collect active crypto transforms X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=261af4620a03daac6751223e5b7a4d119790a07e;p=thirdparty%2Fstrongswan.git unit-tests: Add option to collect active crypto transforms This will allow us to compare new library versions against previous ones, so we don't suddenly loose some algorithms like it happened with KDFs recently after updating OpenSSL to 3.5.1. --- diff --git a/src/libstrongswan/tests/suites/test_vectors.c b/src/libstrongswan/tests/suites/test_vectors.c index 212a315b42..d2713a3a23 100644 --- a/src/libstrongswan/tests/suites/test_vectors.c +++ b/src/libstrongswan/tests/suites/test_vectors.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 Tobias Brunner + * Copyright (C) 2014-2025 Tobias Brunner * Copyright (C) 2013 Martin Willi * * Copyright (C) secunet Security Networks AG @@ -34,6 +34,29 @@ static transform_type_t tfs[] = { KEY_EXCHANGE_METHOD, }; +static FILE *active_transforms; + +START_SETUP(setup) +{ + char *path; + + path = getenv("TESTS_ACTIVE_TRANSFORMS"); + if (path) + { + active_transforms = fopen(path, "a"); + } +} +END_SETUP + +START_TEARDOWN(teardown) +{ + if (active_transforms) + { + fclose(active_transforms); + } +} +END_TEARDOWN + START_TEST(test_vectors) { enumerator_t *enumerator; @@ -47,12 +70,16 @@ START_TEST(test_vectors) { ck_assert_msg(success, "test vector for %N from '%s' plugin failed", transform_get_enum_names(tfs[_i]), alg, plugin); + if (active_transforms) + { + fprintf(active_transforms, "%N[%s]\n", + transform_get_enum_names(tfs[_i]), alg, plugin); + } } thread_cleanup_pop(TRUE); } END_TEST - Suite *vectors_suite_create() { Suite *s; @@ -61,6 +88,7 @@ Suite *vectors_suite_create() s = suite_create("vectors"); tc = tcase_create("transforms"); + tcase_add_checked_fixture(tc, setup, teardown); tcase_add_loop_test(tc, test_vectors, 0, countof(tfs)); tcase_set_timeout(tc, 30); suite_add_tcase(s, tc);