]> git.ipfire.org Git - people/ms/strongswan.git/blob - src/libstrongswan/tests/suites/test_vectors.c
unit-tests: Further increase the test vector testing timeout
[people/ms/strongswan.git] / src / libstrongswan / tests / suites / test_vectors.c
1 /*
2 * Copyright (C) 2014 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
5 * Copyright (C) 2013 Martin Willi
6 * Copyright (C) 2013 revosec AG
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 */
18
19 #include "test_suite.h"
20
21 #include <utils/test.h>
22 #include <threading/thread.h>
23 #include <crypto/transform.h>
24
25 static transform_type_t tfs[] = {
26 ENCRYPTION_ALGORITHM,
27 AEAD_ALGORITHM,
28 INTEGRITY_ALGORITHM,
29 HASH_ALGORITHM,
30 PSEUDO_RANDOM_FUNCTION,
31 RANDOM_NUMBER_GENERATOR,
32 DIFFIE_HELLMAN_GROUP,
33 };
34
35 START_TEST(test_vectors)
36 {
37 enumerator_t *enumerator;
38 char *plugin;
39 bool success;
40 u_int alg;
41
42 enumerator = lib->crypto->create_verify_enumerator(lib->crypto, tfs[_i]);
43 thread_cleanup_push((void*)enumerator->destroy, enumerator);
44 while (enumerator->enumerate(enumerator, &alg, &plugin, &success))
45 {
46 ck_assert_msg(success, "test vector for %N from '%s' plugin failed",
47 transform_get_enum_names(tfs[_i]), alg, plugin);
48 }
49 thread_cleanup_pop(TRUE);
50 }
51 END_TEST
52
53
54 Suite *vectors_suite_create()
55 {
56 Suite *s;
57 TCase *tc;
58
59 s = suite_create("vectors");
60
61 tc = tcase_create("transforms");
62 tcase_add_loop_test(tc, test_vectors, 0, countof(tfs));
63 tcase_set_timeout(tc, 20);
64 suite_add_tcase(s, tc);
65
66 return s;
67 }