aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorReto Buerki <reet@codelabs.ch>2012-12-18 15:06:07 +0100
committerTobias Brunner <tobias@strongswan.org>2013-03-19 15:23:50 +0100
commitec169572a0092cbcd43c4f712f9b99d52f0326da (patch)
tree25ac9322e0a919d260dbb52cebb93611336a35aa /src
parent9099d2ba0b9dfcde773ec9ae577d95a6bcfb48d3 (diff)
downloadstrongswan-ec169572a0092cbcd43c4f712f9b99d52f0326da.tar.bz2
strongswan-ec169572a0092cbcd43c4f712f9b99d52f0326da.tar.xz
Initialize libstrongswan in test_runner main()
Diffstat (limited to 'src')
-rw-r--r--src/charon-tkm/tests/keymat_tests.c54
-rw-r--r--src/charon-tkm/tests/test_runner.c41
2 files changed, 41 insertions, 54 deletions
diff --git a/src/charon-tkm/tests/keymat_tests.c b/src/charon-tkm/tests/keymat_tests.c
index e4c59fa64..2a7525d4e 100644
--- a/src/charon-tkm/tests/keymat_tests.c
+++ b/src/charon-tkm/tests/keymat_tests.c
@@ -19,40 +19,16 @@
#include <hydra.h>
#include <config/proposal.h>
#include <encoding/payloads/ike_header.h>
-#include <plugins/kernel_netlink/kernel_netlink_net.h>
#include <tkm/client.h>
#include "tkm.h"
#include "tkm_nonceg.h"
#include "tkm_diffie_hellman.h"
#include "tkm_keymat.h"
-#include "tkm_kernel_ipsec.h"
#include "tkm_types.h"
START_TEST(test_derive_ike_keys)
{
- fail_if(!library_init(NULL), "Unable to init library");
- fail_if(!libhydra_init("tkm-tests"), "Unable to init libhydra");
- fail_if(!libcharon_init("tkm-tests"), "Unable to init libcharon");
-
- /* Register TKM specific plugins */
- static plugin_feature_t features[] = {
- PLUGIN_REGISTER(NONCE_GEN, tkm_nonceg_create),
- PLUGIN_PROVIDE(NONCE_GEN),
- PLUGIN_REGISTER(DH, tkm_diffie_hellman_create),
- PLUGIN_PROVIDE(DH, MODP_3072_BIT),
- PLUGIN_PROVIDE(DH, MODP_4096_BIT),
- PLUGIN_CALLBACK(kernel_ipsec_register, tkm_kernel_ipsec_create),
- PLUGIN_PROVIDE(CUSTOM, "kernel-ipsec"),
- PLUGIN_DEPENDS(RNG, RNG_WEAK),
- PLUGIN_CALLBACK(kernel_net_register, kernel_netlink_net_create),
- PLUGIN_PROVIDE(CUSTOM, "kernel-net"),
- };
- lib->plugins->add_static_features(lib->plugins, "tkm-tests", features,
- countof(features), TRUE);
-
- fail_if(!charon->initialize(charon, PLUGINS), "Unable to init charon");
-
proposal_t *proposal = proposal_create_from_string(PROTO_IKE,
"aes256-sha512-modp4096");
fail_if(!proposal, "Unable to create proposal");
@@ -97,37 +73,11 @@ START_TEST(test_derive_ike_keys)
ike_sa_id->destroy(ike_sa_id);
keymat->keymat_v2.keymat.destroy(&keymat->keymat_v2.keymat);
chunk_free(&pubvalue);
-
- libcharon_deinit();
- libhydra_deinit();
- library_deinit();
}
END_TEST
START_TEST(test_derive_child_keys)
{
- fail_if(!library_init(NULL), "Unable to init library");
- fail_if(!libhydra_init("tkm-tests"), "Unable to init libhydra");
- fail_if(!libcharon_init("tkm-tests"), "Unable to init libcharon");
-
- /* Register TKM specific plugins */
- static plugin_feature_t features[] = {
- PLUGIN_REGISTER(NONCE_GEN, tkm_nonceg_create),
- PLUGIN_PROVIDE(NONCE_GEN),
- PLUGIN_REGISTER(DH, tkm_diffie_hellman_create),
- PLUGIN_PROVIDE(DH, MODP_3072_BIT),
- PLUGIN_PROVIDE(DH, MODP_4096_BIT),
- PLUGIN_CALLBACK(kernel_ipsec_register, tkm_kernel_ipsec_create),
- PLUGIN_PROVIDE(CUSTOM, "kernel-ipsec"),
- PLUGIN_DEPENDS(RNG, RNG_WEAK),
- PLUGIN_CALLBACK(kernel_net_register, kernel_netlink_net_create),
- PLUGIN_PROVIDE(CUSTOM, "kernel-net"),
- };
- lib->plugins->add_static_features(lib->plugins, "tkm-tests", features,
- countof(features), TRUE);
-
- fail_if(!charon->initialize(charon, PLUGINS), "Unable to init charon");
-
tkm_diffie_hellman_t *dh = tkm_diffie_hellman_create(MODP_4096_BIT);
fail_if(!dh, "Unable to create DH object");
proposal_t *proposal = proposal_create_from_string(PROTO_ESP,
@@ -186,10 +136,6 @@ START_TEST(test_derive_child_keys)
keymat->keymat_v2.keymat.destroy(&keymat->keymat_v2.keymat);
chunk_free(&encr_i);
chunk_free(&encr_r);
-
- libcharon_deinit();
- libhydra_deinit();
- library_deinit();
}
END_TEST
diff --git a/src/charon-tkm/tests/test_runner.c b/src/charon-tkm/tests/test_runner.c
index b716dc633..b22f1ff20 100644
--- a/src/charon-tkm/tests/test_runner.c
+++ b/src/charon-tkm/tests/test_runner.c
@@ -14,11 +14,49 @@
* for more details.
*/
+#include <library.h>
+#include <hydra.h>
+#include <daemon.h>
+#include <plugins/kernel_netlink/kernel_netlink_net.h>
+
#include "tkm.h"
+#include "tkm_nonceg.h"
+#include "tkm_diffie_hellman.h"
+#include "tkm_kernel_ipsec.h"
#include "test_runner.h"
int main(void)
{
+ library_init(NULL);
+ libhydra_init("test_runner");
+ libcharon_init("test_runner");
+
+ lib->settings->set_int(lib->settings, "test_runner.filelog.stdout.default",
+ 1);
+ charon->load_loggers(charon, NULL, FALSE);
+
+ /* Register TKM specific plugins */
+ static plugin_feature_t features[] = {
+ PLUGIN_REGISTER(NONCE_GEN, tkm_nonceg_create),
+ PLUGIN_PROVIDE(NONCE_GEN),
+ PLUGIN_REGISTER(DH, tkm_diffie_hellman_create),
+ PLUGIN_PROVIDE(DH, MODP_3072_BIT),
+ PLUGIN_PROVIDE(DH, MODP_4096_BIT),
+ PLUGIN_CALLBACK(kernel_ipsec_register, tkm_kernel_ipsec_create),
+ PLUGIN_PROVIDE(CUSTOM, "kernel-ipsec"),
+ PLUGIN_DEPENDS(RNG, RNG_WEAK),
+ PLUGIN_CALLBACK(kernel_net_register, kernel_netlink_net_create),
+ PLUGIN_PROVIDE(CUSTOM, "kernel-net"),
+ };
+ lib->plugins->add_static_features(lib->plugins, "tkm-tests", features,
+ countof(features), TRUE);
+
+ if (!charon->initialize(charon, PLUGINS))
+ {
+ fprintf(stderr, "Unable to init charon");
+ return EXIT_FAILURE;
+ }
+
if (!tkm_init())
{
fprintf(stderr, "Could not connect to TKM, aborting tests\n");
@@ -41,6 +79,9 @@ int main(void)
number_failed = srunner_ntests_failed(sr);
tkm_deinit();
+ libcharon_deinit();
+ libhydra_deinit();
+ library_deinit();
srunner_free(sr);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;