• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2# shellcheck disable=SC2086 # we want word splitting
3# shellcheck disable=SC1091 # paths only become valid at runtime
4
5. "${SCRIPTS_DIR}/setup-test-env.sh"
6
7section_start cuttlefish_setup "cuttlefish: setup"
8set -xe
9
10export HOME=/cuttlefish
11export PATH=/cuttlefish/bin:$PATH
12export LD_LIBRARY_PATH=/cuttlefish/lib64:${CI_PROJECT_DIR}/install/lib:$LD_LIBRARY_PATH
13export EGL_PLATFORM=surfaceless
14
15# Pick up a vulkan driver
16#
17# TODO: the vulkan driver should probably be controlled by a variable in the
18# .test-android job or in derived jobs
19export VK_DRIVER_FILES=${CI_PROJECT_DIR}/install/share/vulkan/icd.d/
20
21syslogd
22
23chown root:kvm /dev/kvm
24
25pushd /cuttlefish
26
27# Add a function to perform some tasks when exiting the script
28function my_atexit()
29{
30  # shellcheck disable=SC2317
31  cp /cuttlefish/cuttlefish/instances/cvd-1/logs/logcat $RESULTS_DIR || true
32  # shellcheck disable=SC2317
33  cp /cuttlefish/cuttlefish/instances/cvd-1/kernel.log $RESULTS_DIR || true
34
35  # shellcheck disable=SC2317
36  cp /cuttlefish/cuttlefish/instances/cvd-1/logs/launcher.log $RESULTS_DIR || true
37
38  # shellcheck disable=SC2317
39  /cuttlefish/bin/stop_cvd -wait_for_launcher=10
40}
41
42# stop cuttlefish if the script ends prematurely or is interrupted
43trap 'my_atexit' EXIT
44trap 'exit 2' HUP INT PIPE TERM
45
46ulimit -S -n 32768
47
48# Clean up state of previous run
49rm -rf  /cuttlefish/cuttlefish
50rm -rf  /cuttlefish/.cache
51rm -rf  /cuttlefish/.cuttlefish_config.json
52
53launch_cvd \
54  -daemon \
55  -verbosity=VERBOSE \
56  -file_verbosity=VERBOSE \
57  -use_overlay=false \
58  -enable_bootanimation=false \
59  -enable_minimal_mode=true \
60  -guest_enforce_security=false \
61  -report_anonymous_usage_stats=no \
62  -gpu_mode="$ANDROID_GPU_MODE" \
63  -cpus=${FDO_CI_CONCURRENT:-4} \
64  -memory_mb 8192 \
65  -kernel_path="$HOME/bzImage" \
66  -initramfs_path="$HOME/initramfs.img"
67
68sleep 1
69
70popd
71
72ADB=adb
73
74$ADB wait-for-device root
75sleep 1
76$ADB shell echo Hi from Android
77# shellcheck disable=SC2035
78$ADB logcat dEQP:D *:S &
79
80# overlay vendor
81
82OV_TMPFS="/data/overlay-remount"
83$ADB shell mkdir -p "$OV_TMPFS"
84$ADB shell mount -t tmpfs none "$OV_TMPFS"
85
86$ADB shell mkdir -p "$OV_TMPFS/vendor-upper"
87$ADB shell mkdir -p "$OV_TMPFS/vendor-work"
88
89opts="lowerdir=/vendor,upperdir=$OV_TMPFS/vendor-upper,workdir=$OV_TMPFS/vendor-work"
90$ADB shell mount -t overlay -o "$opts" none /vendor
91
92$ADB shell setenforce 0
93
94# deqp
95
96$ADB shell mkdir -p /data/deqp
97$ADB push /deqp-gles/modules/egl/deqp-egl-android /data/deqp
98$ADB push /deqp-gles/assets/gl_cts/data/mustpass/egl/aosp_mustpass/3.2.6.x/egl-main.txt /data/deqp
99$ADB push /deqp-vk/external/vulkancts/modules/vulkan/* /data/deqp
100$ADB push /deqp-vk/mustpass/vk-main.txt.zst /data/deqp
101$ADB push /deqp-tools/* /data/deqp
102$ADB push /deqp-runner/deqp-runner /data/deqp
103
104# download Android Mesa from S3
105MESA_ANDROID_ARTIFACT_URL=https://${PIPELINE_ARTIFACTS_BASE}/${S3_ANDROID_ARTIFACT_NAME}.tar.zst
106curl -L --retry 4 -f --retry-all-errors --retry-delay 60 -o ${S3_ANDROID_ARTIFACT_NAME}.tar.zst ${MESA_ANDROID_ARTIFACT_URL}
107mkdir /mesa-android
108tar -C /mesa-android -xvf ${S3_ANDROID_ARTIFACT_NAME}.tar.zst
109rm "${S3_ANDROID_ARTIFACT_NAME}.tar.zst" &
110
111$ADB push /mesa-android/install/all-skips.txt /data/deqp
112$ADB push "/mesa-android/install/$GPU_VERSION-flakes.txt" /data/deqp
113$ADB push "/mesa-android/install/deqp-$DEQP_SUITE.toml" /data/deqp
114
115# remove 32 bits libs from /vendor/lib
116
117$ADB shell rm -f /vendor/lib/libglapi.so
118$ADB shell rm -f /vendor/lib/egl/libGLES_mesa.so
119
120$ADB shell rm -f /vendor/lib/egl/libEGL_angle.so
121$ADB shell rm -f /vendor/lib/egl/libEGL_emulation.so
122$ADB shell rm -f /vendor/lib/egl/libGLESv1_CM_angle.so
123$ADB shell rm -f /vendor/lib/egl/libGLESv1_CM_emulation.so
124$ADB shell rm -f /vendor/lib/egl/libGLESv2_angle.so
125$ADB shell rm -f /vendor/lib/egl/libGLESv2_emulation.so
126
127$ADB shell rm -f /vendor/lib/hw/vulkan.*
128
129# replace on /vendor/lib64
130
131$ADB push /mesa-android/install/lib/libgallium_dri.so /vendor/lib64/libgallium_dri.so
132$ADB push /mesa-android/install/lib/libglapi.so /vendor/lib64/libglapi.so
133$ADB push /mesa-android/install/lib/libEGL.so /vendor/lib64/egl/libEGL_mesa.so
134$ADB push /mesa-android/install/lib/libGLESv1_CM.so /vendor/lib64/egl/libGLESv1_CM_mesa.so
135$ADB push /mesa-android/install/lib/libGLESv2.so /vendor/lib64/egl/libGLESv2_mesa.so
136
137$ADB push /mesa-android/install/lib/libvulkan_lvp.so /vendor/lib64/hw/vulkan.lvp.so
138$ADB push /mesa-android/install/lib/libvulkan_virtio.so /vendor/lib64/hw/vulkan.virtio.so
139
140$ADB shell rm -f /vendor/lib64/egl/libEGL_emulation.so
141$ADB shell rm -f /vendor/lib64/egl/libGLESv1_CM_emulation.so
142$ADB shell rm -f /vendor/lib64/egl/libGLESv2_emulation.so
143
144# Check what GLES implementation Surfaceflinger is using before copying the new mesa libraries
145while [ "$($ADB shell dumpsys SurfaceFlinger | grep GLES:)" = "" ] ; do sleep 1; done
146$ADB shell dumpsys SurfaceFlinger | grep GLES
147
148# restart Android shell, so that surfaceflinger uses the new libraries
149$ADB shell stop
150$ADB shell start
151
152# Check what GLES implementation Surfaceflinger is using after copying the new mesa libraries
153while [ "$($ADB shell dumpsys SurfaceFlinger | grep GLES:)" = "" ] ; do sleep 1; done
154MESA_RUNTIME_VERSION="$($ADB shell dumpsys SurfaceFlinger | grep GLES:)"
155MESA_BUILD_VERSION=$(cat /mesa-android/install/VERSION)
156if ! printf "%s" "$MESA_RUNTIME_VERSION" | grep "${MESA_BUILD_VERSION}$"; then
157    echo "Fatal: Android is loading a wrong version of the Mesa3D libs: ${MESA_RUNTIME_VERSION}" 1>&2
158    exit 1
159fi
160
161AOSP_RESULTS=/data/deqp/results
162uncollapsed_section_switch cuttlefish_test "cuttlefish: testing"
163
164set +e
165$ADB shell "mkdir ${AOSP_RESULTS}; cd ${AOSP_RESULTS}/..; \
166  XDG_CACHE_HOME=/data/local/tmp \
167  ./deqp-runner \
168    suite \
169    --suite /data/deqp/deqp-$DEQP_SUITE.toml \
170    --output $AOSP_RESULTS \
171    --skips /data/deqp/all-skips.txt $DEQP_SKIPS \
172    --flakes /data/deqp/$GPU_VERSION-flakes.txt \
173    --testlog-to-xml /data/deqp/testlog-to-xml \
174    --shader-cache-dir /data/local/tmp \
175    --fraction-start ${CI_NODE_INDEX:-1} \
176    --fraction $(( CI_NODE_TOTAL * ${DEQP_FRACTION:-1})) \
177    --jobs ${FDO_CI_CONCURRENT:-4}"
178
179EXIT_CODE=$?
180set -e
181section_switch cuttlefish_results "cuttlefish: gathering the results"
182
183$ADB pull $AOSP_RESULTS $RESULTS_DIR
184
185section_end cuttlefish_results
186exit $EXIT_CODE
187