Make zipapex test support multiple-execution
Some run-tests execute run-test-jar multiple times. This could cause
issues with setting up the zipapex due to the already existing symlink
causing a new symlink to be created within the zipapex dir. If two
tests with multiple executions both happened to pick the same
temp-directory name this could cause 'ln' to exit non-zero failing the
test. To fix this we simply detect and continue cases where the
zipapex symlink already exists.
Test: ./test/testrunner/run_build_test_target.py art-linux-bionic-x64-zipapex
Bug: 135507613
Change-Id: Id2f4d5c75ef8d35011eb25e87fd400e6bc3b9eca
diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar
index 75a0f69..fb88c3a 100755
--- a/test/etc/run-test-jar
+++ b/test/etc/run-test-jar
@@ -878,6 +878,7 @@
linkroot_overlay_cmdline="true"
setupapex_cmdline="true"
installapex_cmdline="true"
+installapex_test_cmdline="true"
linkdirs() {
find "$1" -maxdepth 1 -mindepth 1 -type d | xargs -i ln -sf '{}' "$2"
@@ -911,6 +912,8 @@
if [ "$DEV_MODE" = "y" ]; then
ln_options="--verbose"
fi
+ # If the ${RUN} is executed multiple times we don't need to recreate the link
+ installapex_test_cmdline="test -L ${DEX_LOCATION}/zipapex"
installapex_cmdline="ln -s -f ${ln_options} ${EXTRACTED_ZIPAPEX_LOC} ${DEX_LOCATION}/zipapex"
fi
@@ -1334,7 +1337,7 @@
echo EXPORT $var=${!var}
done
echo "$(declare -f linkdirs)"
- echo "mkdir -p ${mkdir_locations} && $setupapex_cmdline && $installapex_cmdline && $linkroot_cmdline && $linkroot_overlay_cmdline && $profman_cmdline && $dex2oat_cmdline && $dm_cmdline && $vdex_cmdline && $strip_cmdline && $sync_cmdline && $cmdline"
+ echo "mkdir -p ${mkdir_locations} && $setupapex_cmdline && ( $installapex_test_cmdline || $installapex_cmdline ) && $linkroot_cmdline && $linkroot_overlay_cmdline && $profman_cmdline && $dex2oat_cmdline && $dm_cmdline && $vdex_cmdline && $strip_cmdline && $sync_cmdline && $cmdline"
fi
cd $ANDROID_BUILD_TOP
@@ -1349,7 +1352,7 @@
mkdir -p ${mkdir_locations} || exit 1
$setupapex_cmdline || { echo "zipapex extraction failed." >&2 ; exit 2; }
- $installapex_cmdline || { echo "zipapex install failed. cmd was: ${installapex_cmdline}." >&2; find ${mkdir_locations} -type f >&2; exit 2; }
+ $installapex_test_cmdline || $installapex_cmdline || { echo "zipapex install failed. cmd was: ${installapex_test_cmdline} || ${installapex_cmdline}." >&2; find ${mkdir_locations} -type f >&2; exit 2; }
$linkroot_cmdline || { echo "create symlink android-root failed." >&2 ; exit 2; }
$linkroot_overlay_cmdline || { echo "overlay android-root failed." >&2 ; exit 2; }
$profman_cmdline || { echo "Profman failed." >&2 ; exit 2; }