diff options
author | Michael Davidsaver <mdavidsaver@gmail.com> | 2016-07-08 22:16:19 -0400 |
---|---|---|
committer | Michael Davidsaver <mdavidsaver@gmail.com> | 2016-07-08 22:56:45 -0400 |
commit | 47779efb1de37bb9b564b1fdc3cb6f1d5c662956 (patch) | |
tree | 45a7e4539d5736fb3479ec3a7b3b5b74698339d7 /testme.c | |
parent | 21f36fc59dce0b29239f3efd34700322556e9430 (diff) |
testme for 1 and 9
Diffstat (limited to 'testme.c')
-rw-r--r-- | testme.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/testme.c b/testme.c new file mode 100644 index 0000000..3f6f3da --- /dev/null +++ b/testme.c @@ -0,0 +1,62 @@ + +#include "armv7m.h" +#include "testme.h" + +static +volatile unsigned testcount; + +#define CNT() __atomic_add_fetch(&testcount, 1, __ATOMIC_RELAXED) + +void testInit(unsigned ntests) +{ + unsigned zero=0; + __atomic_store(&testcount, &zero, __ATOMIC_RELAXED); + if(ntests) { + puts("1.."); + putdec(ntests); + } else + puts("# no test spec"); + putc('\n'); +} + +void testOk(int c, const char *msg) +{ + if(!c) + puts("not "); + puts("ok "); + putdec(CNT()); + puts(" - "); + puts(msg); + putc('\n'); +} + +void testPass(const char *msg) +{ + testOk(1, msg); +} + +void testFail(const char *msg) +{ + testOk(0, msg); +} + +void testDiag(const char *msg) +{ + puts("# "); + puts(msg); + putc('\n'); +} + +void testEqI(uint32_t expect, uint32_t actual, const char *msg) +{ + if(expect!=actual) puts("not "); + puts("ok "); + putdec(CNT()); + puts(" - "); + puthex(expect); + puts(" == "); + puthex(actual); + putc(' '); + puts(msg); + putc('\n'); +} |