test: tmpd: Replace createVpnorRoot() with VpnorRoot class

The VpnorRoot class prepares a temporary directory for use as a VPNOR
backing store. Implementing it as a class allows us to use RAII to get
it to clean up after itself.

Change-Id: Ia5a839e751f8dc2126a4c0b474e9a7b8593cfd57
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/test/vpnor/tmpd.cpp b/test/vpnor/tmpd.cpp
new file mode 100644
index 0000000..16a4c2b
--- /dev/null
+++ b/test/vpnor/tmpd.cpp
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: Apache-2.0
+// Copyright (C) 2018 IBM Corp.
+
+#include "test/vpnor/tmpd.hpp"
+
+namespace openpower
+{
+namespace virtual_pnor
+{
+namespace test
+{
+
+namespace fs = std::experimental::filesystem;
+
+size_t VpnorRoot::write(const std::string &name, const void *data, size_t len)
+{
+    fs::path path{root};
+    path /= name;
+
+    if (!fs::exists(path))
+        /* It's not in the ToC */
+        throw std::invalid_argument(name);
+
+    std::ofstream partitionFile(path.c_str());
+    partitionFile.write((const char *)data, len);
+    partitionFile.close();
+
+    return len;
+}
+
+} // test
+} // virtual_pnor
+} // openpower