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>
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 @@
 
         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;