]>
git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-renamex.c
1 #include <TargetConditionals.h>
9 #include "test-utils.h"
10 #include "disk-image.h"
14 static disk_image_t
*di
;
17 int run_renamex_test (__unused test_ctx_t
*ctx
) {
19 di
= disk_image_get();
24 asprintf (&dst_file
, "%s/renamex_dst", di
->mount_point
);
25 asprintf (&src_file
, "%s/renamex_src", di
->mount_point
);
27 /* create the files */
29 src_file_fd
= open (src_file
, O_RDWR
| O_CREAT
| O_TRUNC
, 0666);
30 assert (src_file_fd
>= 0);
32 dst_file_fd
= open (dst_file
, O_RDWR
| O_CREAT
| O_TRUNC
, 0666);
33 assert (src_file_fd
>= 0);
35 /* attempt the renamex calls...*/
37 //first verify non-supported flags error out
38 int error
= renamex_np (src_file
, dst_file
, (RENAME_SWAP
));
42 error
= renamex_np (src_file
, dst_file
, (RENAME_SWAP
| RENAME_EXCL
));
45 //now verify it errors out because destination exists.
46 error
= renamex_np (src_file
, dst_file
, (RENAME_EXCL
));
47 assert ((error
!= 0) && (errno
== EEXIST
));
49 /* now delete dst and try again */
50 error
= unlink (dst_file
);
53 error
= renamex_np (src_file
, dst_file
, (RENAME_EXCL
));
56 error
= unlink(dst_file
);
59 assert_no_err(close(src_file_fd
));
60 assert_no_err(close(dst_file_fd
));