summaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/host_name
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /vespalib/src/tests/host_name
Publish
Diffstat (limited to 'vespalib/src/tests/host_name')
-rw-r--r--vespalib/src/tests/host_name/.gitignore1
-rw-r--r--vespalib/src/tests/host_name/CMakeLists.txt8
-rw-r--r--vespalib/src/tests/host_name/FILES1
-rw-r--r--vespalib/src/tests/host_name/host_name_test.cpp18
4 files changed, 28 insertions, 0 deletions
diff --git a/vespalib/src/tests/host_name/.gitignore b/vespalib/src/tests/host_name/.gitignore
new file mode 100644
index 00000000000..2a99fbea5e9
--- /dev/null
+++ b/vespalib/src/tests/host_name/.gitignore
@@ -0,0 +1 @@
+vespalib_host_name_test_app
diff --git a/vespalib/src/tests/host_name/CMakeLists.txt b/vespalib/src/tests/host_name/CMakeLists.txt
new file mode 100644
index 00000000000..79c2657b839
--- /dev/null
+++ b/vespalib/src/tests/host_name/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(vespalib_host_name_test_app
+ SOURCES
+ host_name_test.cpp
+ DEPENDS
+ vespalib
+)
+vespa_add_test(NAME vespalib_host_name_test_app COMMAND vespalib_host_name_test_app)
diff --git a/vespalib/src/tests/host_name/FILES b/vespalib/src/tests/host_name/FILES
new file mode 100644
index 00000000000..c50f9ecf0be
--- /dev/null
+++ b/vespalib/src/tests/host_name/FILES
@@ -0,0 +1 @@
+host_name_test.cpp
diff --git a/vespalib/src/tests/host_name/host_name_test.cpp b/vespalib/src/tests/host_name/host_name_test.cpp
new file mode 100644
index 00000000000..7e1a92c17a7
--- /dev/null
+++ b/vespalib/src/tests/host_name/host_name_test.cpp
@@ -0,0 +1,18 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/vespalib/util/host_name.h>
+#include <vespa/vespalib/util/slaveproc.h>
+
+using namespace vespalib;
+
+vespalib::string run_cmd(const vespalib::string &cmd) {
+ std::string out;
+ ASSERT_TRUE(SlaveProc::run(cmd.c_str(), out));
+ return out;
+}
+
+TEST("require that host name can be obtained") {
+ EXPECT_EQUAL(run_cmd("hostname"), HostName::get());
+}
+
+TEST_MAIN_WITH_PROCESS_PROXY() { TEST_RUN_ALL(); }