aboutsummaryrefslogtreecommitdiff
path: root/src/tests/utests/fs1/test.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-19 19:23:34 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-19 19:23:34 +0100
commit7b27ab493b56f9e77d805c4f44a1717f3a79231e (patch)
treea3037447f4e3d428a61a5c3cfb4e2a98ea5981e4 /src/tests/utests/fs1/test.c
parent62e5a35940198f0f8fbabdf31c80455647420c4e (diff)
downloadkogata-7b27ab493b56f9e77d805c4f44a1717f3a79231e.tar.gz
kogata-7b27ab493b56f9e77d805c4f44a1717f3a79231e.zip
Userland test infrastructure
Diffstat (limited to 'src/tests/utests/fs1/test.c')
-rw-r--r--src/tests/utests/fs1/test.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/tests/utests/fs1/test.c b/src/tests/utests/fs1/test.c
new file mode 100644
index 0000000..e95449d
--- /dev/null
+++ b/src/tests/utests/fs1/test.c
@@ -0,0 +1,40 @@
+#include <string.h>
+
+#include <malloc.h>
+
+#include <syscall.h>
+#include <debug.h>
+
+int main(int argc, char **argv) {
+ dbg_print("Hello, world! from user process.\n");
+
+ fd_t f = open("dev:/", FM_READDIR);
+ dbg_printf("openned /: %d\n", f);
+ dirent_t x;
+ while (readdir(f, &x)) {
+ dbg_printf("- '%s' %p %d\n", x.name, x.st.type, x.st.size);
+ if (x.st.type == FT_REGULAR) {
+ char buf[256];
+ strcpy(buf, "dev:/");
+ strcpy(buf+5, x.name);
+ dbg_printf("trying to open %s...\n", buf);
+ fd_t ff = open(buf, FM_READ);
+ if (ff != 0) {
+ dbg_printf("ok, open as %d\n", ff);
+ char* cont = malloc(x.st.size + 1);
+ ASSERT(read(ff, 0, x.st.size, cont) == x.st.size);
+ cont[x.st.size] = 0;
+ dbg_printf("> '%s'\n", cont);
+ close(ff);
+ } else {
+ dbg_printf("Could not open '%s'\n", buf);
+ }
+ }
+ }
+ close(f);
+
+ dbg_printf("(TEST-OK)\n");
+
+ return 0;
+}
+