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
diff --git a/tests/membarrier_test.cpp b/tests/membarrier_test.cpp
index 74c8ed2..9e871c7 100644
--- a/tests/membarrier_test.cpp
+++ b/tests/membarrier_test.cpp
@@ -30,8 +30,8 @@
 
 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,14 +49,7 @@
     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));
-  }
+  ASSERT_EQ(0, syscall(__NR_membarrier, MEMBARRIER_CMD_GLOBAL, 0));
 }
 
 static const char* MembarrierCommandToName(int membarrier_cmd) {