scanner tester
[henge/webcc.git] / src / bin / tools / testscanner.c
1 /*!@file
2 \brief IR Driver
3 \details This is a testing driver for the IR system of APC.
4 \author Jordan Lavatai
5 \date Aug 2016
6 ----------------------------------------------------------------------------*/
7 /* Standard */
8 #include <stdio.h> //print
9 #include <stdlib.h>
10 #include <errno.h> //lib errors
11 /* Internal */
12 extern //scanner.c
13 int scanner_init(void);
14 extern
15 void scanner_quit(void);
16
17 /* Ansi Term Colors */
18 #define RED "\x1b[31m"
19 #define GREEN "\x1b[32m"
20 #define YELLOW "\x1b[33m"
21 #define BLUE "\x1b[34m"
22 #define MAGENTA "\x1b[35m"
23 #define CYAN "\x1b[36m"
24 #define CLRC "\x1b[0m" //clear current color
25
26 int main(void);
27 int test_init(void);
28
29 int main
30 #define $($)#$
31 #define PRINTFAIL(U) printf(RED $(U) " FAILED\n" CLRC)
32 #define PRINTPASS(U) printf(GREEN $(U) " PASSED\n" CLRC)
33 #define PRINTINFO(S) printf(YELLOW S CLRC)
34 #define RUN_UNIT(U,T) \
35 do { \
36 PRINTINFO(T); \
37 if (U()) \
38 PRINTFAIL(U); \
39 PRINTPASS(U); \
40 } while (0)
41 ()
42 { RUN_UNIT(test_init,"Initializing\n");
43 return 0;
44 }
45
46 int test_init
47 #define TESTS 50
48 ()
49 { static int n = 0;
50 printf("Init Run %-2i\n",n+1);
51 if (scanner_init())
52 { perror("scanner init");
53 return -1;
54 }
55 scanner_quit();
56 return (++n < TESTS) ? test_init() : scanner_init();
57 }
58