From 545eb2416aaffe0d99e2139c7e11efd49a88ec3c Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 8 Aug 2025 11:10:29 +0200 Subject: [PATCH] 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. --- src/libstrongswan/tests/suites/test_vectors.c | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) 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); -- 2.47.3