2 * Copyright (C) 2013 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 #include "test_runner.h"
21 #include <plugins/plugin_feature.h>
26 * Load plugins from builddir
28 static bool load_plugins()
30 enumerator_t
*enumerator
;
31 char *name
, path
[PATH_MAX
], dir
[64];
33 enumerator
= enumerator_create_token(PLUGINS
, " ", "");
34 while (enumerator
->enumerate(enumerator
, &name
))
36 snprintf(dir
, sizeof(dir
), "%s", name
);
37 translate(dir
, "-", "_");
38 snprintf(path
, sizeof(path
), "%s/%s/.libs", PLUGINDIR
, dir
);
39 lib
->plugins
->add_path(lib
->plugins
, path
);
41 enumerator
->destroy(enumerator
);
43 return lib
->plugins
->load(lib
->plugins
, NULL
, PLUGINS
);
51 /* test cases are forked and there is no cleanup, so disable leak detective.
52 * if test_suite.h is included leak detective is enabled in test cases */
53 setenv("LEAK_DETECTIVE_DISABLE", "1", 1);
54 /* redirect all output to stderr (to redirect make's stdout to /dev/null) */
59 /* use non-blocking RNG to generate keys fast */
60 lib
->settings
->set_default_str(lib
->settings
,
61 "libstrongswan.plugins.random.random",
62 lib
->settings
->get_str(lib
->settings
,
63 "libstrongswan.plugins.random.urandom", "/dev/urandom"));
71 sr
= srunner_create(NULL
);
72 srunner_add_suite(sr
, bio_reader_suite_create());
73 srunner_add_suite(sr
, bio_writer_suite_create());
74 srunner_add_suite(sr
, chunk_suite_create());
75 srunner_add_suite(sr
, enum_suite_create());
76 srunner_add_suite(sr
, enumerator_suite_create());
77 srunner_add_suite(sr
, linked_list_suite_create());
78 srunner_add_suite(sr
, linked_list_enumerator_suite_create());
79 srunner_add_suite(sr
, hashtable_suite_create());
80 srunner_add_suite(sr
, identification_suite_create());
81 srunner_add_suite(sr
, threading_suite_create());
82 srunner_add_suite(sr
, utils_suite_create());
83 srunner_add_suite(sr
, vectors_suite_create());
84 if (lib
->plugins
->has_feature(lib
->plugins
,
85 PLUGIN_DEPENDS(PRIVKEY_GEN
, KEY_RSA
)))
87 srunner_add_suite(sr
, rsa_suite_create());
89 if (lib
->plugins
->has_feature(lib
->plugins
,
90 PLUGIN_DEPENDS(PRIVKEY_GEN
, KEY_ECDSA
)))
92 srunner_add_suite(sr
, ecdsa_suite_create());
95 srunner_run_all(sr
, CK_NORMAL
);
96 nf
= srunner_ntests_failed(sr
);
101 return (nf
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;