diff options
Diffstat (limited to 'pintos-progos/tests/userprog/close-twice.c')
| -rw-r--r-- | pintos-progos/tests/userprog/close-twice.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pintos-progos/tests/userprog/close-twice.c b/pintos-progos/tests/userprog/close-twice.c new file mode 100644 index 0000000..830bccf --- /dev/null +++ b/pintos-progos/tests/userprog/close-twice.c | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | /* Opens a file and then tries to close it twice. The second | ||
| 2 | close must either fail silently or terminate with exit code | ||
| 3 | -1. */ | ||
| 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 handle; | ||
| 13 | CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\""); | ||
| 14 | msg ("close \"sample.txt\""); | ||
| 15 | close (handle); | ||
| 16 | msg ("close \"sample.txt\" again"); | ||
| 17 | close (handle); | ||
| 18 | } | ||
