summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-03-13 22:38:17 +1030
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-03-15 00:21:29 +0000
commit6b371a12a04d45b96514df5b770119ca77584d9a (patch)
tree84611faa284ff80e819436319025cc0938903d86
parentc5ae81e5a7dfa830456dcbfd806b5d11cba51fdb (diff)
downloadphosphor-networkd-6b371a12a04d45b96514df5b770119ca77584d9a.tar.gz
phosphor-networkd-6b371a12a04d45b96514df5b770119ca77584d9a.zip
test: Change tmp file names to fix races
With MAKEFLAGS=-jN for N > 1 we hit race conditions in the test suite. Multiple independent tests use the same absolute path under /tmp for test case IO. This leads to corruption across the tests manifesting as intermittent failures. Make the file-names semi-unique. This solution is poor in that it makes no attempt at ensuring the file names are absolutely unique, but they are at least unique wither respect to the other test file names, which is an improvement. Change-Id: I6b312093a2d9cd52261d02821566b69e874e7770 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--test/test_dns_updater.cpp6
-rw-r--r--test/test_rtnetlink.cpp3
-rw-r--r--test/test_watch.cpp2
3 files changed, 6 insertions, 5 deletions
diff --git a/test/test_dns_updater.cpp b/test/test_dns_updater.cpp
index 5d92cd3..8697d4c 100644
--- a/test/test_dns_updater.cpp
+++ b/test/test_dns_updater.cpp
@@ -5,9 +5,9 @@
#include <fstream>
#include <experimental/filesystem>
-static constexpr auto IN_FILE = "/tmp/netif_state";
-static constexpr auto OUT_FILE = "/tmp/resolv.conf";
-static constexpr auto COMPARE_FILE = "/tmp/resolv_compare.conf";
+static constexpr auto IN_FILE = "/tmp/" __BASE_FILE__ "netif_state";
+static constexpr auto OUT_FILE = "/tmp/" __BASE_FILE__ "resolv.conf";
+static constexpr auto COMPARE_FILE = "/tmp/" __BASE_FILE__ "resolv_compare.conf";
static constexpr auto DNS_ENTRY_1 = "DNS=1.2.3.4\n";
static constexpr auto DNS_ENTRY_2 = "DNS=5.6.7.8\n";
diff --git a/test/test_rtnetlink.cpp b/test/test_rtnetlink.cpp
index 79d9547..203019d 100644
--- a/test/test_rtnetlink.cpp
+++ b/test/test_rtnetlink.cpp
@@ -79,7 +79,8 @@ class TestRtNetlink : public testing::Test
void setConfDir()
{
- confDir = "/tmp/NetworkManager.YYYY";
+ char tmp[] = "/tmp/NetworkManager.XXXXXX";
+ confDir = mkdtemp(tmp);
manager->setConfDir(confDir);
}
diff --git a/test/test_watch.cpp b/test/test_watch.cpp
index dac43b3..3ab3e22 100644
--- a/test/test_watch.cpp
+++ b/test/test_watch.cpp
@@ -6,7 +6,7 @@
#include <fstream>
#include <experimental/filesystem>
-static constexpr auto TRIGGER_FILE = "/tmp/netif_state";
+static constexpr auto TRIGGER_FILE = "/tmp/" __BASE_FILE__ "netif_state";
namespace fs = std::experimental::filesystem;
OpenPOWER on IntegriCloud