Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / filesys / base / syn-remove.c
1 #include <random.h>
2 #include <string.h>
3 #include <syscall.h>
4 #include "tests/lib.h"
5 #include "tests/main.h"
6
7 char buf1[1234];
8 char buf2[1234];
9
10 void
11 test_main (void) 
12 {
13   const char *filename = "deleteme";
14   int fd;
15   
16   CHECK (create (filename, sizeof buf1), "create \"%s\"", filename);
17   CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename);
18   CHECK (remove (filename), "remove \"%s\"", filename);
19   random_bytes (buf1, sizeof buf1);
20   CHECK (write (fd, buf1, sizeof buf1) > 0, "write \"%s\"", filename);
21   msg ("seek \"%s\" to 0", filename);
22   seek (fd, 0);
23   CHECK (read (fd, buf2, sizeof buf2) > 0, "read \"%s\"", filename);
24   compare_bytes (buf2, buf1, sizeof buf1, 0, filename);
25   msg ("close \"%s\"", filename);
26   close (fd);
27 }