/*!@file \brief IR Driver \details This is a testing driver for the IR system of APC. \author Jordan Lavatai \date Aug 2016 ----------------------------------------------------------------------------*/ /* Standard */ #include //print #include //itoa #include //lib errors /* Internal */ #include extern //irmem.c void ir_quit(void); extern int ir_init(void); struct irmem; /* Ansi Term Colors */ #define RED "\x1b[31m" #define GREEN "\x1b[32m" #define YELLOW "\x1b[33m" #define BLUE "\x1b[34m" #define MAGENTA "\x1b[35m" #define CYAN "\x1b[36m" #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 () #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 () #define TESTS 50 { static int n = 0; printf("Init Run %-2i\n",n+1); if (ir_init()) { perror("ir init"); return -1; } ir_quit(); 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; }