]>
git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-symlinks.c
2 * Copyright (c) 2020 Apple Inc. All rights reserved.
4 * <rdar://problem/65693863> UNIX Conformance | hfs_vnop_symlink should not validate empty path.
10 #include "hfs-tests.h"
11 #include "test-utils.h"
12 #include "disk-image.h"
14 #define SYMPLINK_TEST_DIR "symlink.testdir"
15 #define SYMLINK_EMPTYSTR "symlink.emptystr"
18 int run_symlinks(__unused test_ctx_t
*ctx
)
22 char *parent_dir
, *slink
;
25 di
= disk_image_get();
28 // Create a parent directory to host our test.
30 asprintf(&parent_dir
, "%s/"SYMPLINK_TEST_DIR
, di
->mount_point
);
31 assert(!mkdir(parent_dir
, 0777) || errno
== EEXIST
);
34 // Now check to make sure we support creating a symlink with an empty
35 // target required for UNIX Conformance.
37 asprintf(&slink
, "%s/"SYMLINK_EMPTYSTR
, parent_dir
);
38 assert_no_err(symlink("", slink
));
41 // Test that symlink has "l" as the S_ISLNK flag using lstat
43 memset(&statb
, 0, sizeof(statb
));
44 assert(!(lstat(slink
, &statb
) < 0 ));
45 assert(S_ISLNK(statb
.st_mode
));
48 // Test that readlink returns zero.
50 assert(!readlink(slink
, &buf
, 1));
53 // Delete test symlink, test directory and release all resources.