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/test/run_with_tmp.sh b/test/run_with_tmp.sh
new file mode 100755
index 0000000..485d6a3
--- /dev/null
+++ b/test/run_with_tmp.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+TMPDIR="$(mktemp -d --tmpdir "${TMPTMPL-tmp.XXXXXXXXXX}")" || exit
+trap 'rm -rf -- "$TMPDIR"' EXIT
+export TMPDIR
+echo "Exec $* with TMPDIR=$TMPDIR" >&2
+"$@"