----------------------------------------------------------------------------*/
/* Standard */
#include <stdio.h> //print
+#include <stdlib.h> //itoa
+#include <errno.h> //lib errors
/* Internal */
-#include <apc/ir.h> //link to IR
+#include <apc/ir.h>
+extern //irmem.c
+void ir_quit(void);
+extern
+int ir_init(void);
+
+struct irmem;
/* Ansi Term Colors */
#define RED "\x1b[31m"
#define BLUE "\x1b[34m"
#define MAGENTA "\x1b[35m"
#define CYAN "\x1b[36m"
-#define CLRX "\x1b[0m" //clear current color
-
-extern //ir.c
-void ir_quit(void);
-extern
-int ir_init(void);
-extern
-
+#define CLRC "\x1b[0m" //clear current color
int main(void);
int test_init(void);
+int test_mem(void);
+int test_ir(void);
+int test_ir_densedir(void);
int
main
()
-{ test_init();
+#define $($)#$
+#define PRINTFAIL(U) printf(RED $(U) "FAILED\n" CLRC)
+#define PRINTPASS(U) printf(GREEN $(U) "PASS\n" CLRC)
+#define PRINTINFO(S) printf(YELLOW S CLRC)
+#define RUN_UNIT(U,T) \
+ do { \
+ PRINTINFO(T); \
+ if (U()) \
+ PRINTFAIL(U); \
+ PRINTPASS(U); \
+ } while (0)
+{ RUN_UNIT(test_init,"Initializing\n");
+ RUN_UNIT(test_mem,"Memtest\n");
+ RUN_UNIT(test_ir,"Testing IR API\n");
return 0;
}
int
test_init
()
-{ /* Test Init */
- printf("YELLOW Initializing\n");
+#define TESTS 50
+{ static int n = 0;
+ printf("Init Run %-2i\n",n+1);
if (ir_init())
- { printf("RED FAILED CLRX");
- perror("ir init");
- return 1;
+ { perror("ir init");
+ return -1;
}
- printf("Quitting CLRX\n");
ir_quit();
- printf("GREEN PASS");
+ return (++n < TESTS) ? test_init() : ir_init();
+}
+
+int
+test_mem
+()
+{ return 0;
+}
+
+int
+test_ir
+()
+{
+}
+
+/* Test for 64*64 dense directories */
+int
+test_ir_densedir
+()
+#define DISTANCE 64
+#define SSTRLEN(S) (sizeof(S)/sizeof(S[0]))
+#define PUSHDIR() \
+ do {\
+
+ } while (0)
+{ static char dbuf[256] = "DEEP";
+ static char wbuf[256] = "WIDE";
+ static int depth = -1;
+ static int width = -1;
+ static char *dnum = dbuf + SSTRLEN(dbuf) - 1;
+ static char *wnum = wbuf + SSTRLEN(wbuf) - 1;
+
+ while (++depth < DISTANCE)
+ { itoa(depth,dnum,10);
+ push_cdat(dbuf);
+ while (++width < DISTANCE)
+ { itoa(width,wnum,10);
+ push_cdat(wbuf);
+ pop_cdat();
+ }
+ pop_cdat();
+ width = -1;
+ }
return 0;
}
+
+