fuse(4): use GTEST_SKIP in the tests
Now the entire fuse test suite can "pass", or at least not fail. Skipped tests are reported to Kyua as passes, because googletest is still using Kyua's plain test adapter. Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
e433e105ba
commit
4f1543f359
@ -46,11 +46,12 @@ using namespace testing;
|
||||
class DefaultPermissions: public FuseTest {
|
||||
|
||||
virtual void SetUp() {
|
||||
FuseTest::SetUp();
|
||||
|
||||
if (geteuid() == 0) {
|
||||
FAIL() << "This test requires an unprivileged user";
|
||||
GTEST_SKIP() << "This test requires an unprivileged user";
|
||||
}
|
||||
m_default_permissions = true;
|
||||
FuseTest::SetUp();
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -42,11 +42,11 @@ class Mknod: public FuseTest {
|
||||
public:
|
||||
|
||||
virtual void SetUp() {
|
||||
if (geteuid() != 0) {
|
||||
// TODO: With GoogleTest 1.8.2, use SKIP instead
|
||||
FAIL() << "Only root may use most mknod(2) variations";
|
||||
}
|
||||
FuseTest::SetUp();
|
||||
|
||||
if (geteuid() != 0) {
|
||||
GTEST_SKIP() << "Only root may use most mknod(2) variations";
|
||||
}
|
||||
}
|
||||
|
||||
/* Test an OK creation of a file with the given mode and device number */
|
||||
|
@ -61,12 +61,13 @@ virtual void SetUp() {
|
||||
int val = 0;
|
||||
size_t size = sizeof(val);
|
||||
|
||||
FuseTest::SetUp();
|
||||
|
||||
ASSERT_EQ(0, sysctlbyname(node, &val, &size, NULL, 0))
|
||||
<< strerror(errno);
|
||||
// TODO: With GoogleTest 1.8.2, use SKIP instead
|
||||
if (!val)
|
||||
FAIL() << "vfs.aio.enable_unsafe must be set for this test";
|
||||
FuseTest::SetUp();
|
||||
GTEST_SKIP() <<
|
||||
"vfs.aio.enable_unsafe must be set for this test";
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -40,31 +40,36 @@
|
||||
|
||||
using namespace testing;
|
||||
|
||||
/* Check that fuse(4) is accessible and the current user can mount(2) */
|
||||
void check_environment()
|
||||
{
|
||||
const char *mod_name = "fuse";
|
||||
const char *devnode = "/dev/fuse";
|
||||
const char *usermount_node = "vfs.usermount";
|
||||
int usermount_val = 0;
|
||||
size_t usermount_size = sizeof(usermount_val);
|
||||
if (modfind(mod_name) == -1) {
|
||||
GTEST_SKIP() << "Module " << mod_name <<
|
||||
" could not be resolved";
|
||||
}
|
||||
if (eaccess(devnode, R_OK | W_OK)) {
|
||||
if (errno == ENOENT) {
|
||||
GTEST_SKIP() << devnode << " does not exist";
|
||||
} else if (errno == EACCES) {
|
||||
GTEST_SKIP() << devnode <<
|
||||
" is not accessible by the current user";
|
||||
} else {
|
||||
GTEST_SKIP() << strerror(errno);
|
||||
}
|
||||
}
|
||||
sysctlbyname(usermount_node, &usermount_val, &usermount_size,
|
||||
NULL, 0);
|
||||
if (geteuid() != 0 && !usermount_val)
|
||||
GTEST_SKIP() << "current user is not allowed to mount";
|
||||
}
|
||||
|
||||
class FuseEnv: public Environment {
|
||||
virtual void SetUp() {
|
||||
const char *mod_name = "fuse";
|
||||
const char *devnode = "/dev/fuse";
|
||||
const char *usermount_node = "vfs.usermount";
|
||||
int usermount_val = 0;
|
||||
size_t usermount_size = sizeof(usermount_val);
|
||||
if (modfind(mod_name) == -1) {
|
||||
FAIL() << "Module " << mod_name <<
|
||||
" could not be resolved";
|
||||
}
|
||||
if (eaccess(devnode, R_OK | W_OK)) {
|
||||
if (errno == ENOENT) {
|
||||
FAIL() << devnode << " does not exist";
|
||||
} else if (errno == EACCES) {
|
||||
FAIL() << devnode <<
|
||||
" is not accessible by the current user";
|
||||
} else {
|
||||
FAIL() << strerror(errno);
|
||||
}
|
||||
}
|
||||
sysctlbyname(usermount_node, &usermount_val, &usermount_size,
|
||||
NULL, 0);
|
||||
if (geteuid() != 0 && !usermount_val)
|
||||
FAIL() << "current user is not allowed to mount";
|
||||
}
|
||||
};
|
||||
|
||||
@ -73,6 +78,14 @@ void FuseTest::SetUp() {
|
||||
int val = 0;
|
||||
size_t size = sizeof(val);
|
||||
|
||||
/*
|
||||
* XXX check_environment should be called from FuseEnv::SetUp, but
|
||||
* can't due to https://github.com/google/googletest/issues/2189
|
||||
*/
|
||||
check_environment();
|
||||
if (IsSkipped())
|
||||
return;
|
||||
|
||||
ASSERT_EQ(0, sysctlbyname(node, &val, &size, NULL, 0))
|
||||
<< strerror(errno);
|
||||
m_maxbcachebuf = val;
|
||||
|
@ -73,7 +73,8 @@ void require_sync_resize_0() {
|
||||
ASSERT_EQ(0, sysctlbyname(sync_resize_node, &val, &size, NULL, 0))
|
||||
<< strerror(errno);
|
||||
if (val != 0)
|
||||
FAIL() << "vfs.fuse.sync_resize must be set to 0 for this test."
|
||||
GTEST_SKIP() <<
|
||||
"vfs.fuse.sync_resize must be set to 0 for this test."
|
||||
" That sysctl will probably be removed soon.";
|
||||
}
|
||||
|
||||
@ -85,12 +86,13 @@ virtual void SetUp() {
|
||||
int val = 0;
|
||||
size_t size = sizeof(val);
|
||||
|
||||
FuseTest::SetUp();
|
||||
|
||||
ASSERT_EQ(0, sysctlbyname(node, &val, &size, NULL, 0))
|
||||
<< strerror(errno);
|
||||
// TODO: With GoogleTest 1.8.2, use SKIP instead
|
||||
if (!val)
|
||||
FAIL() << "vfs.aio.enable_unsafe must be set for this test";
|
||||
FuseTest::SetUp();
|
||||
GTEST_SKIP() <<
|
||||
"vfs.aio.enable_unsafe must be set for this test";
|
||||
}
|
||||
};
|
||||
|
||||
@ -102,14 +104,15 @@ virtual void SetUp() {
|
||||
int val = 0;
|
||||
size_t size = sizeof(val);
|
||||
|
||||
FuseTest::SetUp();
|
||||
if (IsSkipped())
|
||||
return;
|
||||
|
||||
ASSERT_EQ(0, sysctlbyname(cache_mode_node, &val, &size, NULL, 0))
|
||||
<< strerror(errno);
|
||||
// TODO: With GoogleTest 1.8.2, use SKIP instead
|
||||
if (val != 1)
|
||||
FAIL() << "vfs.fuse.data_cache_mode must be set to 1 "
|
||||
GTEST_SKIP() << "vfs.fuse.data_cache_mode must be set to 1 "
|
||||
"(writethrough) for this test";
|
||||
|
||||
FuseTest::SetUp();
|
||||
}
|
||||
|
||||
};
|
||||
@ -122,13 +125,15 @@ virtual void SetUp() {
|
||||
int val = 0;
|
||||
size_t size = sizeof(val);
|
||||
|
||||
FuseTest::SetUp();
|
||||
if (IsSkipped())
|
||||
return;
|
||||
|
||||
ASSERT_EQ(0, sysctlbyname(node, &val, &size, NULL, 0))
|
||||
<< strerror(errno);
|
||||
// TODO: With GoogleTest 1.8.2, use SKIP instead
|
||||
if (val != 2)
|
||||
FAIL() << "vfs.fuse.data_cache_mode must be set to 2 "
|
||||
GTEST_SKIP() << "vfs.fuse.data_cache_mode must be set to 2 "
|
||||
"(writeback) for this test";
|
||||
FuseTest::SetUp();
|
||||
}
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user