Date: Thu, 05 Feb 2026 15:26:58 +0000 From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 27e73a1802a9 - stable/15 - libc/tests: Clean up *dir() tests Message-ID: <6984b6c2.3fd89.3dc85a5d@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=27e73a1802a98f0d4d509ed3350e8c319ecbb140 commit 27e73a1802a98f0d4d509ed3350e8c319ecbb140 Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2026-02-03 14:39:21 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2026-02-05 14:50:20 +0000 libc/tests: Clean up *dir() tests Mainly, avoid reusing the name of one of the functions we should be testing (but aren't) for local variables. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D55054 (cherry picked from commit d70b9eb74fc4aa430bd2ff4bca37e6a9b6c8004f) --- lib/libc/tests/gen/dir2_test.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/libc/tests/gen/dir2_test.c b/lib/libc/tests/gen/dir2_test.c index 4ec5a1759d06..dac8ccbe472a 100644 --- a/lib/libc/tests/gen/dir2_test.c +++ b/lib/libc/tests/gen/dir2_test.c @@ -41,7 +41,6 @@ ATF_TC(telldir_after_seekdir); ATF_TC_HEAD(telldir_after_seekdir, tc) { - atf_tc_set_md_var(tc, "descr", "Calling telldir(3) after seekdir(3) " "should return the argument passed to seekdir."); } @@ -50,7 +49,7 @@ ATF_TC_BODY(telldir_after_seekdir, tc) const int NUMFILES = 1000; char template[] = "dXXXXXX"; char *tmpdir; - int i, dirfd; + int i, dd; DIR *dirp; struct dirent *de; long beginning, middle, end, td; @@ -58,8 +57,8 @@ ATF_TC_BODY(telldir_after_seekdir, tc) /* Create a temporary directory */ tmpdir = mkdtemp(template); ATF_REQUIRE_MSG(tmpdir != NULL, "mkdtemp failed"); - dirfd = open(tmpdir, O_RDONLY | O_DIRECTORY); - ATF_REQUIRE(dirfd > 0); + dd = open(tmpdir, O_RDONLY | O_DIRECTORY); + ATF_REQUIRE(dd > 0); /* * Fill it with files. Must be > 128 to ensure that the directory @@ -70,14 +69,14 @@ ATF_TC_BODY(telldir_after_seekdir, tc) char filename[16]; snprintf(filename, sizeof(filename), "%d", i); - fd = openat(dirfd, filename, O_WRONLY | O_CREAT, 0600); + fd = openat(dd, filename, O_WRONLY | O_CREAT, 0600); ATF_REQUIRE(fd > 0); close(fd); } /* Get some directory bookmarks in various locations */ - dirp = fdopendir(dirfd); - ATF_REQUIRE_MSG(dirfd >= 0, "fdopendir failed"); + dirp = fdopendir(dd); + ATF_REQUIRE_MSG(dd >= 0, "fdopendir failed"); beginning = telldir(dirp); for (i = 0; i < NUMFILES / 2; i = i+1) { de = readdir(dirp); @@ -126,7 +125,7 @@ ATF_TC_BODY(telldir_at_end_of_block, tc) const int NUMFILES = 129; char template[] = "dXXXXXX"; char *tmpdir; - int i, dirfd; + int i, dd; DIR *dirp; struct dirent *de; long td; @@ -135,8 +134,8 @@ ATF_TC_BODY(telldir_at_end_of_block, tc) /* Create a temporary directory */ tmpdir = mkdtemp(template); ATF_REQUIRE_MSG(tmpdir != NULL, "mkdtemp failed"); - dirfd = open(tmpdir, O_RDONLY | O_DIRECTORY); - ATF_REQUIRE(dirfd > 0); + dd = open(tmpdir, O_RDONLY | O_DIRECTORY); + ATF_REQUIRE(dd > 0); /* * Fill it with files. Must be > 128 to ensure that the directory @@ -147,14 +146,14 @@ ATF_TC_BODY(telldir_at_end_of_block, tc) char filename[16]; snprintf(filename, sizeof(filename), "%d", i); - fd = openat(dirfd, filename, O_WRONLY | O_CREAT, 0600); + fd = openat(dd, filename, O_WRONLY | O_CREAT, 0600); ATF_REQUIRE(fd > 0); close(fd); } /* Read all entries within the first page */ - dirp = fdopendir(dirfd); - ATF_REQUIRE_MSG(dirfd >= 0, "fdopendir failed"); + dirp = fdopendir(dd); + ATF_REQUIRE_MSG(dd >= 0, "fdopendir failed"); for (i = 0; i < NUMFILES - 1; i = i + 1) ATF_REQUIRE_MSG(readdir(dirp) != NULL, "readdir failed"); @@ -178,9 +177,8 @@ ATF_TC_BODY(telldir_at_end_of_block, tc) ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, telldir_after_seekdir); ATF_TP_ADD_TC(tp, telldir_at_end_of_block); - return atf_no_error(); + return (atf_no_error()); }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6984b6c2.3fd89.3dc85a5d>
