More filesys tests.
[pintos-anon] / grading / filesys / dir-open.c
diff --git a/grading/filesys/dir-open.c b/grading/filesys/dir-open.c
new file mode 100644 (file)
index 0000000..40550ee
--- /dev/null
@@ -0,0 +1,22 @@
+#include <syscall.h>
+#include "fslib.h"
+
+const char test_name[] = "dir-open";
+
+void
+test_main (void) 
+{
+  int fd;
+  
+  check (mkdir ("xyzzy"), "mkdir \"xyzzy\"");
+  msg ("open \"xyzzy\"");
+  fd = open ("xyzzy");
+  if (fd == -1) 
+    msg ("open returned -1 -- ok");
+  else 
+    {
+      int retval = write (fd, "foobar", 6);
+      check (retval == -1, "write \"xyzzy\" (must return -1, actually %d)",
+             retval);
+    }
+}