Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/tests/gen/dir2_test.c
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | ATF_TC_BODY(telldir_after_seekdir, tc) | ||||
* Fill it with files. Must be > 128 to ensure that the directory | * Fill it with files. Must be > 128 to ensure that the directory | ||||
* can't fit within a single page | * can't fit within a single page | ||||
*/ | */ | ||||
for (i = 0; i < NUMFILES; i = i+1) { | for (i = 0; i < NUMFILES; i = i+1) { | ||||
int fd; | int fd; | ||||
char filename[16]; | char filename[16]; | ||||
snprintf(filename, sizeof(filename), "%d", i); | snprintf(filename, sizeof(filename), "%d", i); | ||||
fd = openat(dirfd, filename, O_WRONLY | O_CREAT); | fd = openat(dirfd, filename, O_WRONLY | O_CREAT, 0600); | ||||
ATF_REQUIRE(fd > 0); | ATF_REQUIRE(fd > 0); | ||||
close(fd); | close(fd); | ||||
} | } | ||||
/* Get some directory bookmarks in various locations */ | /* Get some directory bookmarks in various locations */ | ||||
dirp = fdopendir(dirfd); | dirp = fdopendir(dirfd); | ||||
ATF_REQUIRE_MSG(dirfd >= 0, "fdopendir failed"); | ATF_REQUIRE_MSG(dirfd >= 0, "fdopendir failed"); | ||||
beginning = telldir(dirp); | beginning = telldir(dirp); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | ATF_TC_BODY(telldir_at_end_of_block, tc) | ||||
* Fill it with files. Must be > 128 to ensure that the directory | * Fill it with files. Must be > 128 to ensure that the directory | ||||
* can't fit within a single page. The "-2" accounts for "." and ".." | * can't fit within a single page. The "-2" accounts for "." and ".." | ||||
*/ | */ | ||||
for (i = 0; i < NUMFILES - 2; i = i+1) { | for (i = 0; i < NUMFILES - 2; i = i+1) { | ||||
int fd; | int fd; | ||||
char filename[16]; | char filename[16]; | ||||
snprintf(filename, sizeof(filename), "%d", i); | snprintf(filename, sizeof(filename), "%d", i); | ||||
fd = openat(dirfd, filename, O_WRONLY | O_CREAT); | fd = openat(dirfd, filename, O_WRONLY | O_CREAT, 0600); | ||||
ATF_REQUIRE(fd > 0); | ATF_REQUIRE(fd > 0); | ||||
close(fd); | close(fd); | ||||
} | } | ||||
/* Read all entries within the first page */ | /* Read all entries within the first page */ | ||||
dirp = fdopendir(dirfd); | dirp = fdopendir(dirfd); | ||||
ATF_REQUIRE_MSG(dirfd >= 0, "fdopendir failed"); | ATF_REQUIRE_MSG(dirfd >= 0, "fdopendir failed"); | ||||
for (i = 0; i < NUMFILES - 1; i = i + 1) | for (i = 0; i < NUMFILES - 1; i = i + 1) | ||||
Show All 28 Lines |