test: Always create unique tmpdirs

This ensures our tests always have clear temporary directories to store
their files.

Change-Id: Ib755c4a9407b1e1925b34ae1537eb234542133b0
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/test_config_parser.cpp b/test/test_config_parser.cpp
index 61432c2..7866f87 100644
--- a/test/test_config_parser.cpp
+++ b/test/test_config_parser.cpp
@@ -2,10 +2,13 @@
 
 #include "config_parser.hpp"
 
+#include <fmt/format.h>
+
 #include <exception>
 #include <fstream>
 #include <phosphor-logging/elog-errors.hpp>
 #include <stdexcept>
+#include <stdplus/gtest/tmp.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 #include <gtest/gtest.h>
@@ -15,19 +18,19 @@
 namespace network
 {
 
-class TestConfigParser : public testing::Test
+class TestConfigParser : public stdplus::gtest::TestWithTmp
 {
   public:
     config::Parser parser;
     TestConfigParser()
     {
-        remove("/tmp/eth0.network");
-        std::ofstream filestream("/tmp/eth0.network");
+        auto filename = fmt::format("{}/eth0.network", CaseTmpDir());
+        std::ofstream filestream(filename);
 
         filestream << "[Match]\nName=eth0\n"
                    << "[Network]\nDHCP=true\n[DHCP]\nClientIdentifier= mac\n";
         filestream.close();
-        parser.setFile("/tmp/eth0.network");
+        parser.setFile(filename);
     }
 
     bool isValueFound(const std::vector<std::string>& values,
@@ -79,7 +82,6 @@
     config::ValueList values;
     std::tie(rc, values) = parser.getValues("Network", "abc");
     EXPECT_EQ(config::ReturnCode::KEY_NOT_FOUND, rc);
-    remove("/tmp/eth0.network");
 }
 
 } // namespace network