]> rtime.felk.cvut.cz Git - arc.git/blob - system/kernel/testsystem/test_framework.c
4327970c64be0dce68bf9cd48ba6262cbc4b939f
[arc.git] / system / kernel / testsystem / test_framework.c
1 /* -------------------------------- Arctic Core ------------------------------
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com
3  *
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
5  *
6  * This source code is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 as published by the
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.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  * -------------------------------- Arctic Core ------------------------------*/
15
16 #include <stdint.h>
17 #include <stdio.h>\r
18 #include "Platform_Types.h"
19 \r
20 int test_suite = 1;\r
21 int test_nr = 1;\r
22 int _test_ok = 0;\r
23 int _test_failed = 0;\r
24
25 int testCnt = 0;
26 struct test {
27         uint8_t testSuite;
28         uint8_t testNr;
29         uint16_t status;
30 };
31 \r
32 struct test testTable[50] = { {0} };
33
34 \r
35 void test_done( void ) {\r
36         printf( "\nTest summary\n"\r
37                                 "Total: %d\n"\r
38                                 "OK   : %d\n"\r
39                                 "FAIL : %d\n", _test_ok + _test_failed, _test_ok, _test_failed);\r
40 \r
41 }\r
42 \r
43 void test_fail( const char *text,char *file,  int line, const char *function ) {\r
44         printf("%02d %02d FAILED, %s , %d, %s\n",test_suite, test_nr, file, line, function);\r
45         testTable[testCnt].testSuite = test_suite;
46         testTable[testCnt].testNr = test_nr;
47         testTable[testCnt].status = 0;
48         testCnt++;
49         _test_failed++;\r
50 }\r
51 \r
52 \r
53 void test_ok( void ) {\r
54         printf("%02d %02d OK\n",test_suite, test_nr);
55         testTable[testCnt].testSuite = test_suite;
56         testTable[testCnt].testNr = test_nr;
57         testTable[testCnt].status = 1;
58         testCnt++;\r
59         _test_ok++;\r
60 }\r