--- /dev/null
+/*
+ * Macros for test emission. Compatible with the Test Anything Protocol if
+ * TEST_PREFIX is defined to be the empty string.
+ */
+
+/* Isn't this gross */
+#define TEST_ID_(x) x
+#define TEST_CONCAT_(a,b) a b
+
+#ifndef TEST_NAME
+#error Define TEST_NAME before including test-tapish
+#endif
+#ifndef TEST_PREFIX_PREFIX
+#define TEST_PREFIX_PREFIX "TAPME: "
+#endif
+/* Prefix for test harness aid, since QEMU and other tools output, too */
+#define TEST_PREFIX TEST_CONCAT_(TEST_CONCAT_(TEST_PREFIX_PREFIX, TEST_NAME), " ")
+
+/* Primitives */
+#define TEST_STRT(n) do { printf(2, TEST_PREFIX "1..%d\n" , n ); } while(0);
+#define TEST_FINI(msg, ...) do { printf(2, TEST_PREFIX "ok - " msg "\n", ##__VA_ARGS__); } while(0);
+#define TEST_FAIL(msg, ...) do { printf(2, TEST_PREFIX "not ok - " msg "\n", ##__VA_ARGS__); } while(0);
+#define TEST_EXIT(msg, ...) do { printf(2, TEST_PREFIX "Bail out! " msg "\n", ##__VA_ARGS__); exit(); } while(0);
+#define TEST_DIAG(msg, ...) do { printf(2, TEST_PREFIX "# " msg "\n", ##__VA_ARGS__); } while(0);
+
+/* Conditionals */
+#define TEST_FAIL_IF(cond, msg, ...) if(cond) { TEST_FAIL(msg, ##__VA_ARGS__); }
+#define TEST_EXIT_IF(cond, msg, ...) if(cond) { TEST_EXIT(msg, ##__VA_ARGS__); }
+#define TEST_DIAG_IF(cond, msg, ...) if(cond) { TEST_DIAG(msg, ##__VA_ARGS__); }
+
+#define TEST_FAIL_IF_THEN(cond, then, msg, ...) if(cond) { TEST_FAIL(msg, ##__VA_ARGS__); then; }
+#define TEST_DIAG_IF_THEN(cond, then, msg, ...) if(cond) { TEST_DIAG(msg, ##__VA_ARGS__); then; }
#include "traps.h"
#include "memlayout.h"
+#define TEST_NAME "usertests"
+#include "318_test-tapish.h"
+
char buf[8192];
char name[3];
-char *echoargv[] = { "echo", "ALL", "TESTS", "PASSED", 0 };
+char *echoargv[] = { "echo", "ALL", "TESTS", "PASSED", "\n" TEST_PREFIX "ok -", 0 };
int stdout = 1;
// does chdir() call iput(p->cwd) in a transaction?
main(int argc, char *argv[])
{
printf(1, "usertests starting\n");
+ TEST_STRT(1);
- if(open("usertests.ran", 0) >= 0){
- printf(1, "already ran user tests -- rebuild fs.img\n");
- exit();
- }
+ TEST_EXIT_IF(open("usertests.ran", 0) >= 0, "already ran user tests -- rebuild fs.img");
close(open("usertests.ran", O_CREATE));
createdelete();
concreate();
fourfiles();
sharedfd();
+ TEST_DIAG("group 1");
bigargtest();
bigwrite();
bsstest();
sbrktest();
validatetest();
+ TEST_DIAG("group 2");
opentest();
writetest();
writetest1();
createtest();
+ TEST_DIAG("group 3");
openiputtest();
exitiputtest();
iputtest();
+ TEST_DIAG("group 4");
mem();
pipe1();
preempt();
exitwait();
+ TEST_DIAG("group 5");
rmdot();
fourteen();
forktest();
bigdir(); // slow
exectest();
+ TEST_DIAG("group 6");
exit();
}