Merge "ueventd: fixup ueventd_test.cpp" am: 9aaf66b61f
am: 34d4d57b87
Change-Id: I7468e871785ea74e6cd5b070bd6f18153f6304a7
This commit is contained in:
commit
5d256bc555
1 changed files with 14 additions and 4 deletions
|
@ -63,7 +63,10 @@ void WriteFromMultipleThreads(std::vector<std::pair<std::string, T>>& files_and_
|
|||
}
|
||||
|
||||
TEST(ueventd, setegid_IsPerThread) {
|
||||
if (getuid() != 0) return;
|
||||
if (getuid() != 0) {
|
||||
GTEST_LOG_(INFO) << "Skipping test, must be run as root.";
|
||||
return;
|
||||
}
|
||||
|
||||
TemporaryDir dir;
|
||||
|
||||
|
@ -78,13 +81,20 @@ TEST(ueventd, setegid_IsPerThread) {
|
|||
|
||||
for (const auto& [file, expected_gid] : files_and_gids) {
|
||||
struct stat info;
|
||||
EXPECT_EQ(0, stat(file.c_str(), &info));
|
||||
ASSERT_EQ(0, stat(file.c_str(), &info));
|
||||
EXPECT_EQ(expected_gid, info.st_gid);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ueventd, setfscreatecon_IsPerThread) {
|
||||
if (getuid() != 0) return;
|
||||
if (getuid() != 0) {
|
||||
GTEST_LOG_(INFO) << "Skipping test, must be run as root.";
|
||||
return;
|
||||
}
|
||||
if (!is_selinux_enabled() || security_getenforce() == 1) {
|
||||
GTEST_LOG_(INFO) << "Skipping test, SELinux must be enabled and in permissive mode.";
|
||||
return;
|
||||
}
|
||||
|
||||
const char* const contexts[] = {
|
||||
"u:object_r:audio_device:s0",
|
||||
|
@ -105,7 +115,7 @@ TEST(ueventd, setfscreatecon_IsPerThread) {
|
|||
|
||||
for (const auto& [file, expected_context] : files_and_contexts) {
|
||||
char* file_context;
|
||||
EXPECT_GT(getfilecon(file.c_str(), &file_context), 0);
|
||||
ASSERT_GT(getfilecon(file.c_str(), &file_context), 0);
|
||||
EXPECT_EQ(expected_context, file_context);
|
||||
freecon(file_context);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue