summaryrefslogtreecommitdiffhomepage
path: root/test/util/test_util.h
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2020-01-27 22:27:57 -0800
committergVisor bot <gvisor-bot@google.com>2020-01-27 22:28:43 -0800
commit5d569408ef94c753b7aae9392b5e4ebf7e5ea50d (patch)
treeb34260f2e94e62b4ee3f4bff45644c39fdf0fecd /test/util/test_util.h
parent2a2da5be31ea3c32e66f0c0ff61ef189848f5258 (diff)
Create platform_util for tests.
PiperOrigin-RevId: 291869423
Diffstat (limited to 'test/util/test_util.h')
-rw-r--r--test/util/test_util.h27
1 files changed, 13 insertions, 14 deletions
diff --git a/test/util/test_util.h b/test/util/test_util.h
index b3235c7e3..2d22b0eb8 100644
--- a/test/util/test_util.h
+++ b/test/util/test_util.h
@@ -26,16 +26,13 @@
// IsRunningOnGvisor returns true if the test is known to be running on gVisor.
// GvisorPlatform can be used to get more detail:
//
-// switch (GvisorPlatform()) {
-// case Platform::kNative:
-// case Platform::kGvisor:
-// EXPECT_THAT(mmap(...), SyscallSucceeds());
-// break;
-// case Platform::kPtrace:
-// EXPECT_THAT(mmap(...), SyscallFailsWithErrno(ENOSYS));
-// break;
+// if (GvisorPlatform() == Platform::kPtrace) {
+// ...
// }
//
+// SetupGvisorDeathTest ensures that signal handling does not interfere with
+/// tests that rely on fatal signals.
+//
// Matchers
// ========
//
@@ -213,13 +210,15 @@ void TestInit(int* argc, char*** argv);
if (expr) GTEST_SKIP() << #expr; \
} while (0)
-enum class Platform {
- kNative,
- kKVM,
- kPtrace,
-};
+// Platform contains platform names.
+namespace Platform {
+constexpr char kNative[] = "native";
+constexpr char kPtrace[] = "ptrace";
+constexpr char kKVM[] = "kvm";
+} // namespace Platform
+
bool IsRunningOnGvisor();
-Platform GvisorPlatform();
+const std::string GvisorPlatform();
bool IsRunningWithHostinet();
#ifdef __linux__