cgi frontend
[henge/webcc.git] / src / bin / tools / testir.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> //itoa
10 #include <errno.h> //lib errors
11 /* Internal */
12 #include <apc/ir.h>
13 extern //irmem.c
14 void ir_quit(void);
15 extern
16 int ir_init(void);
17
18 struct irmem;
19
20 /* Ansi Term Colors */
21 #define RED "\x1b[31m"
22 #define GREEN "\x1b[32m"
23 #define YELLOW "\x1b[33m"
24 #define BLUE "\x1b[34m"
25 #define MAGENTA "\x1b[35m"
26 #define CYAN "\x1b[36m"
27 #define CLRC "\x1b[0m" //clear current color
28
29 int main(void);
30 int test_init(void);
31 int test_mem(void);
32 int test_ir(void);
33 int test_ir_densedir(void);
34
35 int
36 main
37 ()
38 #define $($)#$
39 #define PRINTFAIL(U) printf(RED $(U) "FAILED\n" CLRC)
40 #define PRINTPASS(U) printf(GREEN $(U) "PASS\n" CLRC)
41 #define PRINTINFO(S) printf(YELLOW S CLRC)
42 #define RUN_UNIT(U,T) \
43 do { \
44 PRINTINFO(T); \
45 if (U()) \
46 PRINTFAIL(U); \
47 PRINTPASS(U); \
48 } while (0)
49 { RUN_UNIT(test_init,"Initializing\n");
50 RUN_UNIT(test_mem,"Memtest\n");
51 RUN_UNIT(test_ir,"Testing IR API\n");
52 return 0;
53 }
54
55 int
56 test_init
57 ()
58 #define TESTS 50
59 { static int n = 0;
60 printf("Init Run %-2i\n",n+1);
61 if (ir_init())
62 { perror("ir init");
63 return -1;
64 }
65 ir_quit();
66 return (++n < TESTS) ? test_init() : ir_init();
67 }
68
69 int
70 test_mem
71 ()
72 { return 0;
73 }
74
75 int
76 test_ir
77 ()
78 {
79 }
80
81 /* Test for 64*64 dense directories */
82 int
83 test_ir_densedir
84 ()
85 #define DISTANCE 64
86 #define SSTRLEN(S) (sizeof(S)/sizeof(S[0]))
87 #define PUSHDIR() \
88 do {\
89
90 } while (0)
91 { static char dbuf[256] = "DEEP";
92 static char wbuf[256] = "WIDE";
93 static int depth = -1;
94 static int width = -1;
95 static char *dnum = dbuf + SSTRLEN(dbuf) - 1;
96 static char *wnum = wbuf + SSTRLEN(wbuf) - 1;
97
98 while (++depth < DISTANCE)
99 { itoa(depth,dnum,10);
100 push_cdat(dbuf);
101 while (++width < DISTANCE)
102 { itoa(width,wnum,10);
103 push_cdat(wbuf);
104 pop_cdat();
105 }
106 pop_cdat();
107 width = -1;
108 }
109 return 0;
110 }
111
112
113
114