scanner tester
authorken <ken@mihrtec.com>
Fri, 7 Oct 2016 01:18:10 +0000 (18:18 -0700)
committerken <ken@mihrtec.com>
Fri, 7 Oct 2016 01:18:10 +0000 (18:18 -0700)
src/bin/tools/testscanner.c [new file with mode: 0644]
src/bin/tools/testscanner.ld [new file with mode: 0644]

diff --git a/src/bin/tools/testscanner.c b/src/bin/tools/testscanner.c
new file mode 100644 (file)
index 0000000..270f1ff
--- /dev/null
@@ -0,0 +1,58 @@
+/*!@file
+  \brief   IR Driver
+  \details This is a testing driver for the IR system of APC.
+  \author  Jordan Lavatai
+  \date    Aug 2016
+  ----------------------------------------------------------------------------*/
+/* Standard */
+#include <stdio.h>  //print
+#include <stdlib.h> 
+#include <errno.h>  //lib errors
+/* Internal */
+extern //scanner.c
+int  scanner_init(void);
+extern
+void scanner_quit(void);
+
+/* 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 main
+#define $($)#$
+#define PRINTFAIL(U) printf(RED $(U) " FAILED\n" CLRC)
+#define PRINTPASS(U) printf(GREEN $(U) " PASSED\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");
+  return 0;
+}
+
+int test_init
+#define TESTS 50
+()
+{ static int n = 0;
+  printf("Init Run %-2i\n",n+1);
+  if (scanner_init())
+    { perror("scanner init");
+      return -1;
+    }
+  scanner_quit();
+  return (++n < TESTS) ? test_init() : scanner_init();
+}
+
diff --git a/src/bin/tools/testscanner.ld b/src/bin/tools/testscanner.ld
new file mode 100644 (file)
index 0000000..05ca7a2
--- /dev/null
@@ -0,0 +1 @@
+apc