2 * \file examples/simple_test/main.c
6 * \author Bjoern Doebel <doebel@os.inf.tu-dresden.de
10 * (c) 2007-2009 Technische Universität Dresden
11 * This file is part of TUD:OS and distributed under the terms of the
12 * GNU General Public License 2.
13 * Please see the COPYING-GPL-2 file for details.
17 #include <l4/log/macros.h>
18 #include <l4/util/util.h>
25 int init_test_suite(void);
26 int cleanup_test_suite(void);
31 int maxi(int i1, int i2)
33 return (i1 > i2) ? i1 : i2;
36 int mini(int i, int j)
43 CU_ASSERT(maxi(0,2) == 2);
44 CU_ASSERT(maxi(0,-2) == 0);
45 CU_ASSERT(maxi(2,2) == 2);
50 CU_ASSERT(mini(0,2) == 0);
51 CU_ASSERT(mini(0,0) == 0);
52 CU_ASSERT(mini(2,-2) == -2);
55 int init_test_suite(void)
57 LOG("test suite initialization.");
61 int cleanup_test_suite(void)
63 LOG("test suite cleanup");
69 CU_pSuite suite = NULL;
71 int error = CU_initialize_registry();
72 if (error == CUE_SUCCESS)
73 LOG("Intialized test registry.");
75 LOG("Registry initialization failed.");
77 suite = CU_add_suite("cunit_simple", init_test_suite, cleanup_test_suite);
79 LOG("Test suite initialized.");
81 CU_ErrorCode e = CU_get_error();
82 LOG("Error initializing test suite.");
83 LOG("Error was: %d", e);
86 CU_ADD_TEST(suite, test_maxi);
87 LOG("added test_maxi to suite.");
88 CU_ADD_TEST(suite, test_mini);
89 LOG("added test_mini to suite.");
91 LOG("Running tests in NORMAL mode.");
92 CU_basic_set_mode(CU_BRM_NORMAL);
95 LOG("Running tests in SILENT mode.");
96 CU_basic_set_mode(CU_BRM_SILENT);
99 LOG("Running tests in VERBOSE mode.");
100 CU_basic_set_mode(CU_BRM_VERBOSE);
101 CU_basic_run_tests();
103 CU_cleanup_registry();
104 LOG("Registry cleaned up.");