2 * Copyright (C) 2007 Martin Willi
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 "unit_tester.h"
22 typedef struct private_unit_tester_t private_unit_tester_t
;
23 typedef struct unit_test_t unit_test_t
;
24 typedef enum test_status_t test_status_t
;
27 * private data of unit_tester
29 struct private_unit_tester_t
{
56 #define DEFINE_TEST(name, function, enabled) bool function();
57 #include <plugins/unit_tester/tests.h>
59 #define DEFINE_TEST(name, function, enabled) {name, function, enabled},
60 static unit_test_t tests
[] = {
61 #include <plugins/unit_tester/tests.h>
64 static void run_tests(private_unit_tester_t
*this)
66 int i
, run
= 0, failed
= 0, success
= 0, skipped
= 0;
68 DBG1(DBG_CFG
, "running unit tests, %d tests registered",
69 sizeof(tests
)/sizeof(unit_test_t
));
71 for (i
= 0; i
< sizeof(tests
)/sizeof(unit_test_t
); i
++)
78 DBG1(DBG_CFG
, "test '%s' successful", tests
[i
].name
);
83 DBG1(DBG_CFG
, "test '%s' failed", tests
[i
].name
);
89 DBG1(DBG_CFG
, "test '%s' disabled", tests
[i
].name
);
93 DBG1(DBG_CFG
, "%d/%d tests successful (%d failed, %d disabled)",
94 success
, run
, failed
, skipped
);
98 * Implementation of 2007_t.destroy
100 static void destroy(private_unit_tester_t
*this)
108 plugin_t
*plugin_create()
110 private_unit_tester_t
*this = malloc_thing(private_unit_tester_t
);
112 this->public.plugin
.destroy
= (void(*)(plugin_t
*))destroy
;
116 return &this->public.plugin
;