gtest: Install the run_with_tmp script for convenience
This makes it possible for other tests to utilize the script.
Change-Id: I1bb6100e4018bad020817d569294704e267c2776
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/run_with_tmp b/src/run_with_tmp
new file mode 100755
index 0000000..8b8895a
--- /dev/null
+++ b/src/run_with_tmp
@@ -0,0 +1,14 @@
+#!/bin/bash
+TMPDIR="$(mktemp -d --tmpdir "${TMPTMPL-tmp.XXXXXXXXXX}")" || exit
+rmtmp() {
+ if [ -n "${TMP_DEBUG-}" ]; then
+ echo "Removing TMPDIR=$TMPDIR" >&2
+ fi
+ rm -rf -- "$TMPDIR"
+}
+trap rmtmp EXIT
+export TMPDIR
+if [ -n "${TMP_DEBUG-}" ]; then
+ echo "Exec $* with TMPDIR=$TMPDIR" >&2
+fi
+"$@"