summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJay Zhuang <jayzhuang@google.com>2020-07-01 09:28:20 -0700
committergVisor bot <gvisor-bot@google.com>2020-07-01 09:36:07 -0700
commit68e1c870d3ef5db71226927aee703f2fba61cab7 (patch)
treed82b98a82dfac8ba210539ebb12316523bceaa33
parent068716ddf36f4dcb3d88e92b90774dcba2fe4db8 (diff)
Add test env variable "fuchsia"
... so that Fuchsia gets the same special cases applied to gVisor in tests when this envrionment variable is set. PiperOrigin-RevId: 319239064
-rw-r--r--test/util/test_util.cc11
-rw-r--r--test/util/test_util.h3
2 files changed, 8 insertions, 6 deletions
diff --git a/test/util/test_util.cc b/test/util/test_util.cc
index b20758626..8a037f45f 100644
--- a/test/util/test_util.cc
+++ b/test/util/test_util.cc
@@ -40,15 +40,14 @@
namespace gvisor {
namespace testing {
-#define TEST_ON_GVISOR "TEST_ON_GVISOR"
-#define GVISOR_NETWORK "GVISOR_NETWORK"
-#define GVISOR_VFS "GVISOR_VFS"
+constexpr char kGvisorNetwork[] = "GVISOR_NETWORK";
+constexpr char kGvisorVfs[] = "GVISOR_VFS";
bool IsRunningOnGvisor() { return GvisorPlatform() != Platform::kNative; }
const std::string GvisorPlatform() {
// Set by runner.go.
- const char* env = getenv(TEST_ON_GVISOR);
+ const char* env = getenv(kTestOnGvisor);
if (!env) {
return Platform::kNative;
}
@@ -56,12 +55,12 @@ const std::string GvisorPlatform() {
}
bool IsRunningWithHostinet() {
- const char* env = getenv(GVISOR_NETWORK);
+ const char* env = getenv(kGvisorNetwork);
return env && strcmp(env, "host") == 0;
}
bool IsRunningWithVFS1() {
- const char* env = getenv(GVISOR_VFS);
+ const char* env = getenv(kGvisorVfs);
if (env == nullptr) {
// If not set, it's running on Linux.
return false;
diff --git a/test/util/test_util.h b/test/util/test_util.h
index e635827e6..109078fc7 100644
--- a/test/util/test_util.h
+++ b/test/util/test_util.h
@@ -195,6 +195,8 @@
namespace gvisor {
namespace testing {
+constexpr char kTestOnGvisor[] = "TEST_ON_GVISOR";
+
// TestInit must be called prior to RUN_ALL_TESTS.
//
// This parses all arguments and adjusts argc and argv appropriately.
@@ -215,6 +217,7 @@ namespace Platform {
constexpr char kNative[] = "native";
constexpr char kPtrace[] = "ptrace";
constexpr char kKVM[] = "kvm";
+constexpr char kFuchsia[] = "fuchsia";
} // namespace Platform
bool IsRunningOnGvisor();