OSDN Git Service

Make run-test fail if output-path is too long
authorWojciech Staszkiewicz <staszkiewicz@google.com>
Fri, 23 Sep 2016 17:59:55 +0000 (10:59 -0700)
committerWojciech Staszkiewicz <staszkiewicz@google.com>
Wed, 28 Sep 2016 20:34:46 +0000 (13:34 -0700)
Long output-path in no prebuild mode leads to silent fallback to
interpreter in dalvikvm.

This change ensures that we handle this situation by failing the
test.

Bug: 31597671
Test: m test-art-run-test -j
Change-Id: I19a7cee788760a81c9395be1252b2edab0db39f7

test/etc/run-test-jar

index c51cb0d..d8f42a2 100755 (executable)
@@ -404,6 +404,24 @@ if [ "$HOST" = "n" ]; then
   fi
 fi
 
+# Prevent test from silently falling back to interpreter in no-prebuild mode. This happens
+# when DEX_LOCATION path is too long, because vdex/odex filename is constructed by taking
+# full path to dex, stripping leading '/', appending '@classes.vdex' and changing every
+# remaining '/' into '@'.
+if [ "$HOST" = "y" ]; then
+  max_filename_size=$(getconf NAME_MAX $DEX_LOCATION)
+else
+  # There is no getconf on device, fallback to standard value. See NAME_MAX in kernel <linux/limits.h>
+  max_filename_size=255
+fi
+# Compute VDEX_NAME.
+DEX_LOCATION_STRIPPED="${DEX_LOCATION#/}"
+VDEX_NAME="${DEX_LOCATION_STRIPPED//\//@}@$TEST_NAME.jar@classes.vdex"
+if [ ${#VDEX_NAME} -gt $max_filename_size ]; then
+    echo  "Dex location path too long."
+    exit 1
+fi
+
 dex2oat_cmdline="true"
 mkdir_locations="${DEX_LOCATION}/dalvik-cache/$ISA"
 strip_cmdline="true"