if (rump_sys_mkdir("/kern", 0777) == -1)
atf_tc_fail_errno("mkdir /kern");
if (rump_sys_mount(MOUNT_KERNFS, "/kern", 0, NULL, 0) == -1)
atf_tc_fail_errno("could not mount kernfs");
}
ATF_TC_BODY(getdents, tc)
{
struct dirent *dent;
char buf[8192];
int dfd;
mountkernfs();
if ((dfd = rump_sys_open("/kern", O_RDONLY)) == -1)
atf_tc_fail_errno("can't open directory");
if (rump_sys_getdents(dfd, buf, sizeof(buf)) == -1)
atf_tc_fail_errno("getdents");
/*
* Check that we get the first three values (., .., boottime).
* Make more complete by autogenerating list from kernfs_vnops.c?
*/
dent = (void *)buf;
ATF_REQUIRE_STREQ(dent->d_name, ".");
dent = _DIRENT_NEXT(dent);
ATF_REQUIRE_STREQ(dent->d_name, "..");
dent = _DIRENT_NEXT(dent);
ATF_REQUIRE_STREQ(dent->d_name, "boottime");