Support a relative OUT_DIR

OUT_DIR may be a relative path to the top of the build tree.

Bug: 35984597
Test: OUT_DIR=out art/test/testrunner/testrunner.py --host -t 115-native-bridge
Test: OUT_DIR=$PWD/out art/test/testrunner/testrunner.py --host -t 115-native-bridge
Change-Id: I654ce26dbd45f0e2d54a0a0d5438c231372fe8f9
diff --git a/test/run-test b/test/run-test
index 1ac2857..464acb3 100755
--- a/test/run-test
+++ b/test/run-test
@@ -78,9 +78,16 @@
     export ANDROID_BUILD_TOP=$oldwd
 fi
 
+# OUT_DIR defaults to out, and may be relative to $ANDROID_BUILD_TOP.
+# Convert it to an absolute path, since we cd into the tmp_dir to run the tests.
+export OUT_DIR=${OUT_DIR:-out}
+if [[ "$OUT_DIR" != /* ]]; then
+    export OUT_DIR=$ANDROID_BUILD_TOP/$OUT_DIR
+fi
+
 # ANDROID_HOST_OUT is not set in a build environment.
 if [ -z "$ANDROID_HOST_OUT" ]; then
-    export ANDROID_HOST_OUT=${OUT_DIR:-$ANDROID_BUILD_TOP/out}/host/linux-x86
+    export ANDROID_HOST_OUT=${OUT_DIR}/host/linux-x86
 fi
 
 # If JACK_CLASSPATH is not set, assume it only contains core-libart.