CS318 - Pintos
Pintos source browser for JHU CS318 course
src
tests
userprog
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
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
}
lib.h
CHECK
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.
Definition:
lib.h:29
test_main
void test_main(void)
Opens a file and then tries to close it twice.
Definition:
close-twice.c:10
open
int open(const char *file)
Definition:
syscall.c:103
main.h
close
void close(int fd)
Definition:
syscall.c:139
msg
void msg(const char *format,...)
Definition:
lib.c:28
Generated on Thu Aug 22 2019 10:19:15 for CS318 - Pintos by
1.8.16