c1f6da5f6a1cb0a1ca010b7f47054812bf9d441c
[pintos-anon] / src / tests / filesys / extended / dir-open.c
1 /* Tries to open a directory.
2    This is allowed to succeed or fail,
3    but if it succeeds then attempts to write to it must fail. */
4
5 #include <syscall.h>
6 #include "tests/lib.h"
7 #include "tests/main.h"
8
9 void
10 test_main (void) 
11 {
12   int fd;
13   
14   CHECK (mkdir ("xyzzy"), "mkdir \"xyzzy\"");
15   msg ("open \"xyzzy\"");
16   fd = open ("xyzzy");
17   if (fd == -1) 
18     msg ("open returned -1 -- ok");
19   else 
20     {
21       int retval = write (fd, "foobar", 6);
22       CHECK (retval == -1, "write \"xyzzy\" (must return -1, actually %d)",
23              retval);
24     }
25 }