PKUOS - Pintos
Pintos source browser for PKU Operating System course
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
8void
9test_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}
void test_main(void)
Opens a directory, then tries to write to it, which must fail.
Definition: dir-open.c:9
int open(const char *file)
Definition: syscall.c:103
int write(int fd, const void *buffer, unsigned size)
Definition: syscall.c:121
bool mkdir(const char *dir)
Definition: syscall.c:163
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