aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Rizwan <omar@omar.website>2020-12-19 15:36:22 -0800
committerOmar Rizwan <omar@omar.website>2020-12-19 15:36:22 -0800
commit375e91bdd75460340b5841d418ad6984ebaa7621 (patch)
treee12ca4cc52e7ac30f22b0eb75e920d77ac3bf35d
parente1e47173b6d432aa6b1a0378fc017291243a74ad (diff)
more tests
-rwxr-xr-xtest.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/test.c b/test.c
index 29de739..15e2c51 100755
--- a/test.c
+++ b/test.c
@@ -1,11 +1,24 @@
//usr/bin/env cc -o test "$0" && ./test; exit
+
+// (run this file directly with `./test.c` in most shells; if that
+// doesn't work, run it with `sh test.c`)
+
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
+int file_contents_equal(char* path, char* contents) {
+ char command[200];
+ snprintf(command, sizeof(command),
+ "[ \"%s\" == \"$(cat %s)\" ]", contents, path);
+ return system(command) == 0;
+}
+
// integration tests
int main() {
assert(system("echo about:blank > fs/mnt/tabs/create") == 0);
+ assert(file_contents_equal("fs/mnt/tabs/last-focused/url", "about:blank"));
+ assert(system("file fs/mnt/tabs/last-focused/screenshot.png") == 0);
assert(1); printf("Done!\n");
}