Revert "Revert "runtime: Mmap uncompressed dex files (in zip) as clean memory""

This reverts commit 960b2af8a05f0844e78004e2d0d3ae6ab058d430.

Fix failing 071-dex-file-map-clean on target
which was due to an IO race in the run-test script.

Test: make test-art-target
Bug: 27650033
Original-Change-Id: I18efbd392c5980ffe0d983833b6cc581e0237b92
Change-Id: I6f4ff1e85f8326916c2ae0842a32f53fb7901639
diff --git a/test/run-test b/test/run-test
index 27c700e..4936039 100755
--- a/test/run-test
+++ b/test/run-test
@@ -90,6 +90,22 @@
 
 export JACK="$JACK -g -cp $JACK_CLASSPATH"
 
+# Zipalign is not on the PATH in some configs, auto-detect it.
+if [ -z "$ZIPALIGN" ]; then
+  if which zipalign >/dev/null; then
+    ZIPALIGN="zipalign";
+  else
+    # TODO: Add a dependency for zipalign in Android.run-test.mk
+    # once it doesn't depend on libandroidfw (b/35246701)
+    case "$OSTYPE" in
+      darwin*)  ZIPALIGN="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/darwin/bin/zipalign" ;;
+      linux*)   ZIPALIGN="$ANDROID_BUILD_TOP/prebuilts/sdk/tools/linux/bin/zipalign" ;;
+      *)        echo "Can't find zipalign: unknown: $OSTYPE" >&2;;
+    esac
+  fi
+fi
+export ZIPALIGN
+
 info="info.txt"
 build="build"
 run="run"