Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F170013801
D56016.id174186.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D56016.id174186.diff
View Options
diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile
--- a/lib/libc/tests/gen/Makefile
+++ b/lib/libc/tests/gen/Makefile
@@ -12,6 +12,7 @@
.endif
ATF_TESTS_C+= fts_misc_test
ATF_TESTS_C+= fts_options_test
+ATF_TESTS_C+= fts_symlink_test
ATF_TESTS_C+= ftw_test
ATF_TESTS_C+= getentropy_test
ATF_TESTS_C+= getmntinfo_test
@@ -32,6 +33,7 @@
ATF_TESTS_C+= sigsetops_test
ATF_TESTS_C+= wordexp_test
+
# TODO: t_closefrom, t_fmtcheck, t_randomid,
# TODO: t_siginfo (fixes require further inspection)
# TODO: t_sethostname_test (consistently screws up the hostname)
diff --git a/lib/libc/tests/gen/fts_symlink_test.c b/lib/libc/tests/gen/fts_symlink_test.c
new file mode 100644
--- /dev/null
+++ b/lib/libc/tests/gen/fts_symlink_test.c
@@ -0,0 +1,93 @@
+/*-
+ * Copyright (c) 2026 Iyan Nazarian
+ *
+ * SPDX-License-Identifier
+ */
+
+#include <atf-c.h>
+#include <fts.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "fts_test.h"
+
+/* Test to check if fts_open can count symlinks
+ * correctly
+ */
+ATF_TC(fts_symlink_physical);
+ATF_TC_HEAD(fts_symlink_physical, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "FTS_PHYSICAL reports symlink correctly");
+}
+
+ATF_TC_BODY(fts_symlink_physical, tc)
+{
+ int fd = 0;
+
+ ATF_REQUIRE_EQ_MSG(0, mkdir("dir", 0755), "failed to create dir");
+ ATF_REQUIRE_MSG((fd = open("dir/target", O_CREAT | O_RDONLY, 0644)) >= 0, "%s", strerror(errno));
+ ATF_REQUIRE_EQ_MSG(0, close(fd), "%s", strerror(errno));
+ ATF_REQUIRE_EQ_MSG(0, symlink("target", "dir/link"), "%s", strerror(errno));
+
+ fts_test(tc, &(struct fts_testcase){
+ (char *[]){ "dir", NULL },
+ FTS_PHYSICAL,
+ (struct fts_expect[]){
+ { FTS_D, "dir", "dir" },
+ { FTS_SL, "link", "link" },
+ { FTS_F, "target", "target" },
+ { FTS_DP, "dir", "dir" },
+ { 0 }
+ }
+ });
+
+
+}
+
+ATF_TC(fts_symlink_logical);
+ATF_TC_HEAD(fts_symlink_logical, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "FTS_LOGICAL reports symlink correctly");
+}
+
+ATF_TC_BODY(fts_symlink_logical, tc)
+{
+ int fd = 0;
+
+ ATF_REQUIRE_EQ_MSG(0, mkdir("dir", 0755), "failed to create dir");
+ ATF_REQUIRE_MSG((fd = open("dir/target", O_CREAT | O_RDONLY, 0644)) >= 0, "%s", strerror(errno));
+ ATF_REQUIRE_EQ_MSG(0, close(fd), "%s", strerror(errno));
+ ATF_REQUIRE_EQ_MSG(0, symlink("target", "dir/link"), "%s", strerror(errno));
+
+ fts_test(tc, &(struct fts_testcase){
+ (char *[]){ "dir", NULL },
+ FTS_LOGICAL,
+ (struct fts_expect[]){
+ { FTS_D, "dir", "dir" },
+ { FTS_F, "link", "dir/link" },
+ { FTS_F, "target", "dir/target" },
+ { FTS_DP, "dir", "dir" },
+ { 0 }
+ }
+ });
+
+
+
+}
+
+
+ATF_TP_ADD_TCS(tp)
+{
+ fts_check_debug();
+ ATF_TP_ADD_TC(tp, fts_symlink_physical);
+ ATF_TP_ADD_TC(tp, fts_symlink_logical);
+ return atf_no_error();
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Sep 4, 6:13 AM (20 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38202175
Default Alt Text
D56016.id174186.diff (2 KB)
Attached To
Mode
D56016: lib/libc/tests: add fts symlink traversal tests
Attached
Detach File
Event Timeline
Log In to Comment