]>
git.proxmox.com Git - libgit2.git/blob - tests-clay/core/rmdir.c
1 #include "clay_libgit2.h"
4 static const char *empty_tmp_dir
= "test_gitfo_rmdir_recurs_test";
6 void test_core_rmdir__initialize(void)
8 char path
[GIT_PATH_MAX
];
10 cl_must_pass(p_mkdir(empty_tmp_dir
, 0777));
12 git_path_join(path
, empty_tmp_dir
, "/one");
13 cl_must_pass(p_mkdir(path
, 0777));
15 git_path_join(path
, empty_tmp_dir
, "/one/two_one");
16 cl_must_pass(p_mkdir(path
, 0777));
18 git_path_join(path
, empty_tmp_dir
, "/one/two_two");
19 cl_must_pass(p_mkdir(path
, 0777));
21 git_path_join(path
, empty_tmp_dir
, "/one/two_two/three");
22 cl_must_pass(p_mkdir(path
, 0777));
24 git_path_join(path
, empty_tmp_dir
, "/two");
25 cl_must_pass(p_mkdir(path
, 0777));
28 /* make sure empty dir can be deleted recusively */
29 void test_core_rmdir__delete_recursive(void)
31 cl_git_pass(git_futils_rmdir_r(empty_tmp_dir
, 0));
34 /* make sure non-empty dir cannot be deleted recusively */
35 void test_core_rmdir__fail_to_delete_non_empty_dir(void)
37 char file
[GIT_PATH_MAX
];
40 git_path_join(file
, empty_tmp_dir
, "/two/file.txt");
42 fd
= p_creat(file
, 0755);
45 cl_must_pass(p_close(fd
));
46 cl_git_fail(git_futils_rmdir_r(empty_tmp_dir
, 0));
48 cl_must_pass(p_unlink(file
));
49 cl_git_pass(git_futils_rmdir_r(empty_tmp_dir
, 0));