CS318 - Pintos
Pintos source browser for JHU CS318 course
src
tests
filesys
extended
dir-open.c
Go to the documentation of this file.
1
/** Opens a directory, then tries to write to it, which must
2
fail. */
3
4
#include <syscall.h>
5
#include "
tests/lib.h
"
6
#include "
tests/main.h
"
7
8
void
9
test_main
(
void
)
10
{
11
int
fd;
12
int
retval;
13
14
CHECK
(
mkdir
(
"xyzzy"
),
"mkdir \"xyzzy\""
);
15
CHECK
((fd =
open
(
"xyzzy"
)) > 1,
"open \"xyzzy\""
);
16
17
msg
(
"write \"xyzzy\""
);
18
retval =
write
(fd,
"foobar"
, 6);
19
CHECK
(retval == -1,
20
"write \"xyzzy\" (must return -1, actually %d)"
, retval);
21
}
lib.h
write
int write(int fd, const void *buffer, unsigned size)
Definition:
syscall.c:121
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 directory, then tries to write to it, which must fail.
Definition:
dir-open.c:9
mkdir
bool mkdir(const char *dir)
Definition:
syscall.c:163
open
int open(const char *file)
Definition:
syscall.c:103
main.h
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