Fix running tests/benchmarks on the host.

This was broken by all the mainline modules stuff. It's quite a bit
hairier to set up now, given that we don't have an apexd on the host.
An alternative might be to actually set up a fake /apex that points to
the bootstrap directories?

Test: ./benchmarks/run-on-host.sh 64
Test: ./tests/run-on-host.sh 64
Change-Id: If2c277ba492c7c443cdf51526ea42f56568e2ea6
diff --git a/benchmarks/run-on-host.sh b/benchmarks/run-on-host.sh
index af96b27..0f2aefb 100755
--- a/benchmarks/run-on-host.sh
+++ b/benchmarks/run-on-host.sh
@@ -25,7 +25,7 @@
             cd ${ANDROID_BUILD_TOP}
             export ANDROID_DATA=${TARGET_OUT_DATA}
             export ANDROID_ROOT=${TARGET_OUT}
-            ${NATIVETEST}/bionic-benchmarks/bionic-benchmarks $@
+            ${BENCHMARKS}/bionic-benchmarks/bionic-benchmarks $@
         )
     else
         echo "$0 not supported on TARGET_ARCH=$TARGET_ARCH"
diff --git a/build/run-on-host.sh b/build/run-on-host.sh
index c3a2751..85539e2 100644
--- a/build/run-on-host.sh
+++ b/build/run-on-host.sh
@@ -15,33 +15,36 @@
     BITS=$1
     shift
 
+    BENCHMARKS=${TARGET_OUT_DATA}/benchmarktest
     NATIVETEST=${TARGET_OUT_DATA}/nativetest
     if [ "${BITS}" = 64 ]; then
+        BENCHMARKS=${BENCHMARKS}64
         NATIVETEST=${NATIVETEST}64
     fi
 
-    if [ ${TARGET_ARCH} = arm -o ${TARGET_ARCH} = mips -o ${TARGET_ARCH} = x86 ]; then
-        LINKER=${TARGET_OUT_EXECUTABLES}/linker
-    else
-        LINKER="${TARGET_OUT_EXECUTABLES}/linker64 ${TARGET_OUT_EXECUTABLES}/linker"
-    fi
-
     if [ ${TARGET_ARCH} = x86 -o ${TARGET_ARCH} = x86_64 ]; then
-        m -j ${LINKER} ${TARGET_OUT}/etc/hosts ${TARGET_OUT_EXECUTABLES}/sh $@
+        m -j MODULES-IN-bionic MODULES-IN-external-icu MODULES-IN-external-mksh ${TARGET_OUT}/etc/hosts $@
 
         if [ ! -d /system ]; then
             echo "Attempting to create /system";
             sudo mkdir -p -m 0777 /system;
+            mkdir -p -m 0777 /system/bin;
+            mkdir -p -m 0777 /system/lib;
+            mkdir -p -m 0777 /system/lib64;
         fi
         (
             cd ${ANDROID_BUILD_TOP}
             mkdir -p ${TARGET_OUT_DATA}/local/tmp
-            ln -fs `realpath ${TARGET_OUT}/bin` /system/
+            for i in ${TARGET_OUT}/bin/bootstrap/* ${TARGET_OUT}/bin/*; do
+              ln -fs `realpath ${i}` /system/bin/
+            done
             ln -fs `realpath ${TARGET_OUT}/etc` /system/
-            ln -fs `realpath ${TARGET_OUT}/lib` /system/
-            if [ -d "${TARGET_OUT}/lib64" ]; then
-                ln -fs `realpath ${TARGET_OUT}/lib64` /system/;
-            fi
+            for i in ${TARGET_OUT}/lib/bootstrap/* ${TARGET_OUT}/lib/*; do
+              ln -fs `realpath ${i}` /system/lib/
+            done
+            for i in ${TARGET_OUT}/lib64/bootstrap/* ${TARGET_OUT}/lib64/*; do
+              ln -fs `realpath ${i}` /system/lib64/
+            done
         )
     fi
 }
diff --git a/tests/run-on-host.sh b/tests/run-on-host.sh
index c8a30f5..fe2c25a 100755
--- a/tests/run-on-host.sh
+++ b/tests/run-on-host.sh
@@ -20,6 +20,7 @@
 if [ ${HOST_OS}-${HOST_ARCH} = linux-x86 -o ${HOST_OS}-${HOST_ARCH} = linux-x86_64 ]; then
 
   prepare $1 bionic-unit-tests
+  shift
 
   if [ ${TARGET_ARCH} = x86 -o ${TARGET_ARCH} = x86_64 ]; then
     (