X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftests%2Ffilesys%2Fextended%2Fdir-open.c;h=29d18b8580eb5a48fe59d1a77a1758dfb9a8c363;hb=0b01eb8d16b9ff48657aceec17d68522b2a3cfdf;hp=c1f6da5f6a1cb0a1ca010b7f47054812bf9d441c;hpb=3cdb3abe959f205785f0f4fc7101a48bdbc90485;p=pintos-anon diff --git a/src/tests/filesys/extended/dir-open.c b/src/tests/filesys/extended/dir-open.c index c1f6da5..29d18b8 100644 --- a/src/tests/filesys/extended/dir-open.c +++ b/src/tests/filesys/extended/dir-open.c @@ -1,6 +1,5 @@ -/* Tries to open a directory. - This is allowed to succeed or fail, - but if it succeeds then attempts to write to it must fail. */ +/* Opens a directory, then tries to write to it, which must + fail. */ #include #include "tests/lib.h" @@ -10,16 +9,13 @@ void test_main (void) { int fd; + int retval; 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); - } + CHECK ((fd = open ("xyzzy")) > 1, "open \"xyzzy\""); + + msg ("write \"xyzzy\""); + retval = write (fd, "foobar", 6); + CHECK (retval == -1, + "write \"xyzzy\" (must return -1, actually %d)", retval); }