Update probing in membarrier_test

Updates HasMembarrier(cmd) to probe rather than execute command to fix
unintended test skipping.

Test: manual on OrangePi Zero running 4.17.4.
Change-Id: I33a6684a3662cae20cbedc52463b26ef299caf71
This commit is contained in:
Orion Hodson 2018-09-10 10:21:40 +01:00
parent 2942b6a2c2
commit 0c938550cf
1 changed files with 3 additions and 10 deletions

View File

@ -30,8 +30,8 @@ class ScopedErrnoCleaner {
bool HasMembarrier(int membarrier_cmd) {
ScopedErrnoCleaner errno_cleaner;
bool present = syscall(__NR_membarrier, membarrier_cmd, 0) > 0;
return present;
int supported_cmds = syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
return (supported_cmds > 0) && ((supported_cmds & membarrier_cmd) != 0);
}
TEST(membarrier, query) {
@ -49,15 +49,8 @@ TEST(membarrier, global_barrier) {
GTEST_LOG_(INFO) << "MEMBARRIER_CMD_GLOBAL not supported, skipping test.";
return;
}
ScopedErrnoCleaner errno_cleaner;
int supported = syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
ASSERT_LE(0, supported);
if ((supported & MEMBARRIER_CMD_GLOBAL) != 0) {
ASSERT_EQ(0, syscall(__NR_membarrier, MEMBARRIER_CMD_GLOBAL, 0));
}
}
static const char* MembarrierCommandToName(int membarrier_cmd) {
switch (membarrier_cmd) {