Push vm image on the host
Bug: 375051310
Test: atest TerminalAppTests
Change-Id: If72a0193404f543740877466e707bd612e9143c0
diff --git a/tests/Terminal/Android.bp b/tests/Terminal/Android.bp
index 7ec4e81..cafbe93 100644
--- a/tests/Terminal/Android.bp
+++ b/tests/Terminal/Android.bp
@@ -20,4 +20,5 @@
platform_apis: true,
test_suites: ["general-tests"],
instrumentation_for: "VmTerminalApp",
+ data: ["TerminalAppTests-preparer.sh"],
}
diff --git a/tests/Terminal/AndroidTest.xml b/tests/Terminal/AndroidTest.xml
index e9f549f..eeb7146 100644
--- a/tests/Terminal/AndroidTest.xml
+++ b/tests/Terminal/AndroidTest.xml
@@ -26,6 +26,10 @@
<option name="force-root" value="true"/>
</target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.RunHostScriptTargetPreparer">
+ <option name="script-file" value="TerminalAppTests-preparer.sh" />
+ </target_preparer>
+
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
<option name="throw-if-cmd-fail" value="true" />
<option name="run-command"
diff --git a/tests/Terminal/TerminalAppTests-preparer.sh b/tests/Terminal/TerminalAppTests-preparer.sh
new file mode 100644
index 0000000..de25af3
--- /dev/null
+++ b/tests/Terminal/TerminalAppTests-preparer.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# Copyright 2024 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+serial=${ANDROID_SERIAL}
+
+# Identify file to download
+arch=$(adb -s ${serial} shell getprop ro.bionic.arch)
+if [ ${arch} == "arm64" ]; then
+ src=https://github.com/ikicha/debian_ci/releases/download/release_aarch64/images.tar.gz
+else
+ src=https://github.com/ikicha/debian_ci/releases/download/release_x86_64/images.tar.gz
+fi
+
+# Download
+downloaded=$(tempfile)
+wget ${src} -O ${downloaded}
+
+# Push the file to the device
+user=$(adb -s ${serial} shell am get-current-user)
+dst=/data/media/${user}/linux
+adb -s ${serial} shell mkdir -p ${dst}
+adb -s ${serial} push ${downloaded} ${dst}/images.tar.gz