veyron/examples/tunnel/tunneld,veyron/services/mounttable/mounttabled: Make tests more portable
Avoid using the --tmpdir flag of mktemp, which doesn't exist on bsd.
Change-Id: I9ed4505e0d6a2c2b81e9c764574dbd9dab1766bf
diff --git a/examples/tunnel/tunneld/test.sh b/examples/tunnel/tunneld/test.sh
index 9800b58..dcf1629 100755
--- a/examples/tunnel/tunneld/test.sh
+++ b/examples/tunnel/tunneld/test.sh
@@ -12,14 +12,15 @@
echo "Test directory: $(dirname $0)"
-builddir=$(mktemp -d --tmpdir=${toplevel}/go)
+workdir=$(mktemp -d ${toplevel}/go/tmp.XXXXXXXXXXX)
+export TMPDIR=$workdir
trap onexit EXIT
onexit() {
cd /
exec 2> /dev/null
kill -9 $(jobs -p)
- rm -rf $builddir
+ rm -rf $workdir
}
FAIL() {
@@ -34,7 +35,7 @@
}
# Build binaries.
-cd $builddir
+cd $workdir
$go build veyron/examples/tunnel/tunneld || FAIL "line $LINENO: failed to build tunneld"
$go build veyron/examples/tunnel/vsh || FAIL "line $LINENO: failed to build vsh"
$go build veyron/services/mounttable/mounttabled || FAIL "line $LINENO: failed to build mounttabled"
@@ -42,7 +43,7 @@
$go build veyron/tools/identity || FAIL "line $LINENO: failed to build identity"
# Start mounttabled and find its endpoint.
-mtlog=$(mktemp --tmpdir=.)
+mtlog=${workdir}/mt.log
./mounttabled --address=localhost:0 > $mtlog 2>&1 &
for i in 1 2 3 4; do
@@ -54,14 +55,14 @@
done
[ -z $ep ] && FAIL "line $LINENO: no mounttable server"
-tmpid=$(mktemp --tmpdir=.)
+tmpid=$workdir/id
./identity generate test > $tmpid
export NAMESPACE_ROOT=$ep
export VEYRON_IDENTITY=$tmpid
# Start tunneld and find its endpoint.
-tunlog=$(mktemp --tmpdir=.)
+tunlog=$workdir/tunnel.log
./tunneld --address=localhost:0 > $tunlog 2>&1 &
for i in 1 2 3 4; do
diff --git a/services/mounttable/mounttabled/test.sh b/services/mounttable/mounttabled/test.sh
index 1f15be1..9e98748 100755
--- a/services/mounttable/mounttabled/test.sh
+++ b/services/mounttable/mounttabled/test.sh
@@ -15,15 +15,15 @@
echo "Test directory: $(dirname $0)"
-builddir=$(mktemp -d --tmpdir=${toplevel}/go)
-tmplog=$(mktemp)
+workdir=$(mktemp -d ${toplevel}/go/tmp.XXXXXXXXXX)
+export TMPDIR=$workdir
trap onexit EXIT
onexit() {
cd /
exec 2> /dev/null
kill -9 $(jobs -p)
- rm -rf $builddir $tmplog
+ rm -rf $workdir
}
FAIL() {
@@ -38,16 +38,17 @@
}
# Build mounttabled and mounttable binaries.
-cd $builddir
+cd $workdir
$go build veyron/services/mounttable/mounttabled || FAIL "line $LINENO: failed to build mounttabled"
$go build veyron/tools/mounttable || FAIL "line $LINENO: failed to build mounttable"
# Start mounttabled and find its endpoint.
nhname=test$$
-./mounttabled --address=localhost:0 --neighborhood_name=$nhname > $tmplog 2>&1 &
+mtlog=$workdir/mt.log
+./mounttabled --address=localhost:0 --neighborhood_name=$nhname > $mtlog 2>&1 &
for i in 1 2 3 4; do
- ep=$(grep "Mount table service at:" $tmplog | sed -re 's/^.*endpoint: ([^ ]*).*/\1/')
+ ep=$(grep "Mount table service at:" $mtlog | sed -re 's/^.*endpoint: ([^ ]*).*/\1/')
if [ -n "$ep" ]; then
break
fi