]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
unit-tests: Add option to collect active crypto transforms
authorTobias Brunner <tobias@strongswan.org>
Fri, 8 Aug 2025 09:10:29 +0000 (11:10 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 8 Aug 2025 09:13:29 +0000 (11:13 +0200)
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

index 212a315b42d0cb58d3f9c2e08b19baa5656c15ca..d2713a3a2365133ce88ce5bb0c7feb02f711c58e 100644 (file)
@@ -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);