-
Notifications
You must be signed in to change notification settings - Fork 47
/
rmdir.c
34 lines (27 loc) · 857 Bytes
/
rmdir.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <fs/fs.h>
#include "unit_test.h"
#include "../fs/mock/mock.h"
#include <assert.h>
void test_rmdir_file_should_fail(){
int ret;
ret = sys_creat(curr_scheduling_proc, "/test", 0755);
assert(ret == 0);
ret = sys_rmdir(curr_scheduling_proc, "/test");
assert(ret == -ENOTDIR);
}
void test_rmdir_empty_directory_should_succeed(){
int ret;
ret = sys_mkdir(curr_scheduling_proc, "/test", 0755);
assert(ret == 0);
ret = sys_rmdir(curr_scheduling_proc, "/test");
assert(ret == 0);
}
void test_rmdir_non_emtpy_directory_should_fail_with_enotempty(){
int ret;
ret = sys_mkdir(curr_scheduling_proc, "/test", 0755);
assert(ret == 0);
ret = sys_creat(curr_scheduling_proc, "/test/test", 0755);
assert(ret == 0);
ret = sys_rmdir(curr_scheduling_proc, "/test");
assert(ret == -ENOTEMPTY);
}