X-Git-Url: https://git.kengrimes.com/?p=henge%2Fwebcc.git;a=blobdiff_plain;f=src%2Fbin%2Ftools%2Ftestir.c;h=e2d423e3deec6d5a585cbd473715db1898d0a4b6;hp=69c9c2897fef6a76ecb345a73a1e67358c794c62;hb=522656e8b68f7189d1c221e19211946ba7774ab5;hpb=92d574d704e54743631464fac3ce739b1077222c diff --git a/src/bin/tools/testir.c b/src/bin/tools/testir.c index 69c9c28..e2d423e 100644 --- a/src/bin/tools/testir.c +++ b/src/bin/tools/testir.c @@ -6,8 +6,16 @@ ----------------------------------------------------------------------------*/ /* Standard */ #include //print +#include //itoa +#include //lib errors /* Internal */ -#include //link to IR +#include +extern //irmem.c +void ir_quit(void); +extern +int ir_init(void); + +struct irmem; /* Ansi Term Colors */ #define RED "\x1b[31m" @@ -16,39 +24,91 @@ #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; } + +