Browse Source

[3056] Skip MemorySegmentMappedTest.badAllocate test when run as the root user

Mukund Sivaraman 11 years ago
parent
commit
3c1f096e54
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/lib/util/tests/memory_segment_mapped_unittest.cc

+ 9 - 0
src/lib/util/tests/memory_segment_mapped_unittest.cc

@@ -237,6 +237,15 @@ TEST_F(MemorySegmentMappedTest, allocate) {
 }
 
 TEST_F(MemorySegmentMappedTest, badAllocate) {
+    // If the test is run as the root user, the following allocate()
+    // call will result in a successful MemorySegmentGrown exception,
+    // instead of an abort (due to insufficient permissions during
+    // reopen).
+    if (getuid() == 0) {
+        std::cerr << "Skipping test as it's run as the root user" << std::endl;
+        return;
+    }
+
     // Make the mapped file non-writable; managed_mapped_file::grow() will
     // fail, resulting in abort.
     const int ret = chmod(mapped_file, 0444);