]>
git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-unicode-file-names.c
8 #include "test-utils.h"
9 #include "disk-image.h"
11 TEST(unicode_file_names
)
13 static disk_image_t
*di
;
15 int run_unicode_file_names(__unused test_ctx_t
*ctx
)
17 di
= disk_image_get();
20 asprintf(&dir
, "%s/unicode-file-names", di
->mount_point
);
23 assert_no_err(posix_spawn(&pid
, "/bin/rm", NULL
, NULL
,
24 (char *[]){ "rm", "-rf", dir
, NULL
}, NULL
));
26 assert_with_errno(waitpid(pid
, &stat
, 0) == pid
);
28 assert_no_err(mkdir(dir
, 0777));
31 asprintf(&path
, "%s/file-\xcd\x80\xcd\x81\xcd\x82\xcd\x83\xcd\x84\xcd\x85\xcd\x86\xcd\x87\xcd\x88\xcd\x89\xcd\x90", dir
);
34 assert_with_errno((fd
= open(path
, O_RDWR
| O_CREAT
, 0666)) >= 0);
36 assert_no_err(close(fd
));
39 * Create a hard link (so that we can force the cache to
43 asprintf(&path2
, "%s/hard-link", dir
);
44 assert_no_err(link(path
, path2
));
48 assert_no_err(chdir(dir
));
50 assert_no_err(glob("*", 0, NULL
, &gl
));
53 for (i
= 0; i
< gl
.gl_matchc
; ++i
) {
54 if (!strncmp(gl
.gl_pathv
[i
], "file", 4))
58 assert_fail("could not find file!");
62 // Paths should be different: gl_pathv should be normalised
63 assert(strcmp(gl
.gl_pathv
[i
], path
) != 0);
66 asprintf(&path3
, "%s/%s", dir
, gl
.gl_pathv
[i
]);
68 assert((fd
= open(path3
, O_RDONLY
)) >= 0);
70 assert_no_err(unlink(path3
));
71 assert_no_err (close(fd
));