gtest: Add a testcase wrapper for handling tmpdirs

This makes it trivial to have a pristine temp directory on every test
case execution. Just derive from the provided class.

Change-Id: I5355914cdedc482eddd0749a9ccc10fc93de6571
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include-gtest/meson.build b/include-gtest/meson.build
new file mode 100644
index 0000000..dfba348
--- /dev/null
+++ b/include-gtest/meson.build
@@ -0,0 +1,5 @@
+stdplus_gtest_headers = include_directories('.')
+
+install_headers(
+  'stdplus/gtest/tmp.hpp',
+  subdir: 'stdplus')
diff --git a/include-gtest/stdplus/gtest/tmp.hpp b/include-gtest/stdplus/gtest/tmp.hpp
new file mode 100644
index 0000000..9f88084
--- /dev/null
+++ b/include-gtest/stdplus/gtest/tmp.hpp
@@ -0,0 +1,35 @@
+#include <string>
+
+#include <gtest/gtest.h>
+
+namespace stdplus
+{
+namespace gtest
+{
+
+/**
+ * @brief Provides googletest users with automatic temp directory
+ *        handling per test case. You will still want to wrap your
+ *        unit test execution in a `TMPDIR` RAII script in case the
+ *        unit test binary ends up crashing.
+ */
+class TestWithTmp : public ::testing::Test
+{
+  protected:
+    TestWithTmp();
+    ~TestWithTmp();
+    static void SetUpTestSuite();
+    static void TearDownTestSuite();
+
+    static std::string SuiteTmpDir();
+    inline const std::string& CaseTmpDir() const
+    {
+        return casedir;
+    }
+
+  private:
+    std::string casedir;
+};
+
+} // namespace gtest
+} // namespace stdplus