Add more tests.
[pintos-anon] / grading / userprog / write-normal.c
diff --git a/grading/userprog/write-normal.c b/grading/userprog/write-normal.c
new file mode 100644 (file)
index 0000000..b2e96e8
--- /dev/null
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <string.h>
+#include <syscall.h>
+#include "sample.inc"
+
+int
+main (void) 
+{
+  int handle, byte_cnt;
+  printf ("(write-normal) begin\n");
+
+  if (!create ("test.txt", sizeof sample - 1))
+    printf ("(write-normal) create() failed\n");
+
+  handle = open ("test.txt");
+  if (handle < 2)
+    printf ("(write-normal) fail: open() returned %d\n", handle);
+
+  byte_cnt = write (handle, sample, sizeof sample - 1);
+  if (byte_cnt != sizeof sample - 1)
+    printf ("(write-normal) fail: write() returned %d instead of %d\n",
+            byte_cnt, sizeof sample - 1);
+  
+  printf ("(write-normal) end\n");
+  return 0;
+}