summaryrefslogtreecommitdiffhomepage
path: root/test/util
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2019-12-04 23:44:25 -0800
committergVisor bot <gvisor-bot@google.com>2019-12-04 23:45:49 -0800
commit6ae64d793593eaf3c1364354ef01a555f230a0fe (patch)
tree9089db1fde337cadbd8fa44acfb4a6fb0f072ba5 /test/util
parent1eda90d0848658f330e5f37ce18209bd3d069766 (diff)
Allow syscall tests to run with hostinet.
Fixes #1207 PiperOrigin-RevId: 283914438
Diffstat (limited to 'test/util')
-rw-r--r--test/util/test_util.cc6
-rw-r--r--test/util/test_util.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/test/util/test_util.cc b/test/util/test_util.cc
index 9cb050735..848504c88 100644
--- a/test/util/test_util.cc
+++ b/test/util/test_util.cc
@@ -41,6 +41,7 @@ namespace gvisor {
namespace testing {
#define TEST_ON_GVISOR "TEST_ON_GVISOR"
+#define GVISOR_NETWORK "GVISOR_NETWORK"
bool IsRunningOnGvisor() { return GvisorPlatform() != Platform::kNative; }
@@ -60,6 +61,11 @@ Platform GvisorPlatform() {
abort();
}
+bool IsRunningWithHostinet() {
+ char* env = getenv(GVISOR_NETWORK);
+ return env && strcmp(env, "host") == 0;
+}
+
// Inline cpuid instruction. Preserve %ebx/%rbx register. In PIC compilations
// %ebx contains the address of the global offset table. %rbx is occasionally
// used to address stack variables in presence of dynamic allocas.
diff --git a/test/util/test_util.h b/test/util/test_util.h
index ee6c2bf4d..b3235c7e3 100644
--- a/test/util/test_util.h
+++ b/test/util/test_util.h
@@ -220,6 +220,7 @@ enum class Platform {
};
bool IsRunningOnGvisor();
Platform GvisorPlatform();
+bool IsRunningWithHostinet();
#ifdef __linux__
void SetupGvisorDeathTest();