12 static int fds[8], fd_cnt;
16 for (i = 0; i < fd_cnt; i++)
18 fail (
"fd returned is not unique");
35 "\"/\" and \"/a\" must have different inumbers");
39 msg (
"try to remove \"/a\"");
42 msg (
"remove successful");
44 CHECK (
open (
"/a") == -1,
"open \"/a\" (must fail)");
45 CHECK (
open (
".") == -1,
"open \".\" (must fail)");
46 CHECK (
open (
"..") == -1,
"open \"..\" (must fail)");
47 CHECK (!
create (
"x", 512),
"create \"x\" (must fail)");
51 int a_fd1, a_fd2, a_fd3;
53 msg (
"remove failed");
55 CHECK (!
remove (
"../a"),
"try to remove \"../a\" (must fail)");
56 CHECK (!
remove (
".././a"),
"try to remove \".././a\" (must fail)");
57 CHECK (!
remove (
"/./a"),
"try to remove \"/./a\" (must fail)");
62 "\"/a\" and \".\" must have same inumber");
64 "\"/\" and \"/a\" must have different inumbers");
69 "\".\" must have same inumber as before");
72 CHECK (!
remove (
"a"),
"try to remove \"a\" (must fail: still open)");
void test_main(void)
tests/main.h
static int wrap_open(const char *name)
Tries to remove the current directory, which may succeed or fail.
bool readdir(int fd, char name[READDIR_MAX_LEN+1])
bool chdir(const char *dir)
Project 4 only.
bool create(const char *file, unsigned initial_size)
int open(const char *file)
bool remove(const char *file)
int inumber(int fd)
lib/user/syscall.h
bool mkdir(const char *dir)
#define READDIR_MAX_LEN
Maximum characters in a filename written by readdir().
void fail(const char *format,...)
void msg(const char *format,...)
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.