PKUOS - Pintos
Pintos source browser for PKU Operating System course
close-twice.c
Go to the documentation of this file.
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
9void
10test_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}
void test_main(void)
Opens a file and then tries to close it twice.
Definition: close-twice.c:10
void close(int fd)
Definition: syscall.c:139
int open(const char *file)
Definition: syscall.c:103
void msg(const char *format,...)
Definition: lib.c:28
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.
Definition: lib.h:29