9baad463e0f48a07a809696de024b471c4f581ce
[strongswan.git] / src / libstrongswan / tests / test_runner.c
1 /*
2 * Copyright (C) 2013 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 #include <unistd.h>
17
18 #include "test_runner.h"
19
20 #include <library.h>
21
22 int main()
23 {
24 SRunner *sr;
25 int nf;
26
27 /* if a test fails there is no cleanup, so disable leak detective */
28 setenv("LEAK_DETECTIVE_DISABLE", "1", 1);
29 /* redirect all output to stderr (to redirect make's stdout to /dev/null) */
30 dup2(2, 1);
31
32 library_init(NULL);
33
34 sr = srunner_create(NULL);
35 srunner_add_suite(sr, enumerator_suite_create());
36 srunner_add_suite(sr, linked_list_suite_create());
37
38 srunner_run_all(sr, CK_NORMAL);
39 nf = srunner_ntests_failed(sr);
40
41 srunner_free(sr);
42 library_deinit();
43
44 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
45 }