aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/tests/test_runner.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2014-04-01 14:53:28 +0200
committerMartin Willi <martin@revosec.ch>2014-04-01 14:53:28 +0200
commitb87f7840bc090de5b76328c4c12dfb7e27e73f7e (patch)
treee50a2bad6ed7edbd0151516ff7220de44c25d6eb /src/libstrongswan/tests/test_runner.c
parent96e3142c39a69cfc99fc808f2df3f9d409b05357 (diff)
parent5ba9f734577321f0445ee38625cdea075d1bb9cf (diff)
downloadstrongswan-b87f7840bc090de5b76328c4c12dfb7e27e73f7e.tar.bz2
strongswan-b87f7840bc090de5b76328c4c12dfb7e27e73f7e.tar.xz
Merge branch 'tls-unit-tests'
Add some initial unit-tests to libtls, testing all supported cipher suites against self, both with and without client authentication, for all supported TLS versions.
Diffstat (limited to 'src/libstrongswan/tests/test_runner.c')
-rw-r--r--src/libstrongswan/tests/test_runner.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/libstrongswan/tests/test_runner.c b/src/libstrongswan/tests/test_runner.c
index 6bb1b290c..5ec4198e7 100644
--- a/src/libstrongswan/tests/test_runner.c
+++ b/src/libstrongswan/tests/test_runner.c
@@ -315,7 +315,7 @@ static void sum_leaks(report_data_t *data, int count, size_t bytes,
* Do library cleanup and optionally check for memory leaks
*/
static bool post_test(test_runner_init_t init, bool check_leaks,
- array_t *failures, char *name, int i)
+ array_t *failures, char *name, int i, int *leaks)
{
report_data_t data = {
.failures = failures,
@@ -325,7 +325,15 @@ static bool post_test(test_runner_init_t init, bool check_leaks,
if (init)
{
- init(FALSE);
+ if (test_restore_point())
+ {
+ init(FALSE);
+ }
+ else
+ {
+ library_deinit();
+ return FALSE;
+ }
}
if (check_leaks && lib->leak_detective)
{
@@ -335,7 +343,8 @@ static bool post_test(test_runner_init_t init, bool check_leaks,
}
library_deinit();
- return data.leaks != 0;
+ *leaks = data.leaks;
+ return TRUE;
}
/**
@@ -407,7 +416,8 @@ static bool run_case(test_case_t *tcase, test_runner_init_t init)
{
if (pre_test(init))
{
- bool ok = FALSE, leaks = FALSE;
+ bool ok = FALSE;
+ int leaks = 0;
test_setup_timeout(tcase->timeout);
@@ -424,9 +434,11 @@ static bool run_case(test_case_t *tcase, test_runner_init_t init)
{
call_fixture(tcase, FALSE);
}
-
}
- leaks = post_test(init, ok, failures, tfun->name, i);
+ if (!post_test(init, ok, failures, tfun->name, i, &leaks))
+ {
+ ok = FALSE;
+ }
test_setup_timeout(0);