1#!/bin/bash 2# shellcheck disable=SC1091 # The relative paths in this file only become valid at runtime. 3# shellcheck disable=SC2034 4# shellcheck disable=SC2086 # we want word splitting 5 6. "$SCRIPTS_DIR"/setup-test-env.sh 7 8BM=$CI_PROJECT_DIR/install/bare-metal 9CI_COMMON=$CI_PROJECT_DIR/install/common 10 11if [ -z "$BM_SERIAL" ] && [ -z "$BM_SERIAL_SCRIPT" ]; then 12 echo "Must set BM_SERIAL OR BM_SERIAL_SCRIPT in your gitlab-runner config.toml [[runners]] environment" 13 echo "BM_SERIAL:" 14 echo " This is the serial device to talk to for waiting for fastboot to be ready and logging from the kernel." 15 echo "BM_SERIAL_SCRIPT:" 16 echo " This is a shell script to talk to for waiting for fastboot to be ready and logging from the kernel." 17 exit 1 18fi 19 20if [ -z "$BM_POWERUP" ]; then 21 echo "Must set BM_POWERUP in your gitlab-runner config.toml [[runners]] environment" 22 echo "This is a shell script that should reset the device and begin its boot sequence" 23 echo "such that it pauses at fastboot." 24 exit 1 25fi 26 27if [ -z "$BM_POWERDOWN" ]; then 28 echo "Must set BM_POWERDOWN in your gitlab-runner config.toml [[runners]] environment" 29 echo "This is a shell script that should power off the device." 30 exit 1 31fi 32 33if [ -z "$BM_FASTBOOT_SERIAL" ]; then 34 echo "Must set BM_FASTBOOT_SERIAL in your gitlab-runner config.toml [[runners]] environment" 35 echo "This must be the a stable-across-resets fastboot serial number." 36 exit 1 37fi 38 39if [ -z "$BM_KERNEL" ]; then 40 echo "Must set BM_KERNEL to your board's kernel vmlinuz or Image.gz in the job's variables:" 41 exit 1 42fi 43 44if [ -z "$BM_DTB" ]; then 45 echo "Must set BM_DTB to your board's DTB file in the job's variables:" 46 exit 1 47fi 48 49if [ -z "$BM_ROOTFS" ]; then 50 echo "Must set BM_ROOTFS to your board's rootfs directory in the job's variables:" 51 exit 1 52fi 53 54if echo $BM_CMDLINE | grep -q "root=/dev/nfs"; then 55 BM_FASTBOOT_NFSROOT=1 56fi 57 58section_start prepare_rootfs "Preparing rootfs components" 59 60set -ex 61 62# Clear out any previous run's artifacts. 63rm -rf results/ 64mkdir -p results/ 65 66if [ -n "$BM_FASTBOOT_NFSROOT" ]; then 67 # Create the rootfs in the NFS directory. rm to make sure it's in a pristine 68 # state, since it's volume-mounted on the host. 69 rsync -a --delete $BM_ROOTFS/ /nfs/ 70 mkdir -p /nfs/results 71 . $BM/rootfs-setup.sh /nfs 72 73 # Root on NFS, no need for an inintramfs. 74 rm -f rootfs.cpio.gz 75 touch rootfs.cpio 76 gzip rootfs.cpio 77else 78 # Create the rootfs in a temp dir 79 rsync -a --delete $BM_ROOTFS/ rootfs/ 80 . $BM/rootfs-setup.sh rootfs 81 82 # Finally, pack it up into a cpio rootfs. Skip the vulkan CTS since none of 83 # these devices use it and it would take up space in the initrd. 84 85 if [ -n "$PIGLIT_PROFILES" ]; then 86 EXCLUDE_FILTER="deqp|arb_gpu_shader5|arb_gpu_shader_fp64|arb_gpu_shader_int64|glsl-4.[0123456]0|arb_tessellation_shader" 87 else 88 EXCLUDE_FILTER="piglit|python" 89 fi 90 91 pushd rootfs 92 find -H . | \ 93 grep -E -v "external/(openglcts|vulkancts|amber|glslang|spirv-tools)" | 94 grep -E -v "traces-db|apitrace|renderdoc" | \ 95 grep -E -v $EXCLUDE_FILTER | \ 96 cpio -H newc -o | \ 97 xz --check=crc32 -T4 - > $CI_PROJECT_DIR/rootfs.cpio.gz 98 popd 99fi 100 101if echo "$BM_KERNEL $BM_DTB" | grep -q http; then 102 curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 103 "$BM_KERNEL" -o kernel 104 # FIXME: modules should be supplied too 105 curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 106 "$BM_DTB" -o dtb 107 108 cat kernel dtb > Image.gz-dtb 109 110elif [ -n "${EXTERNAL_KERNEL_TAG}" ]; then 111 curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 112 "${FDO_HTTP_CACHE_URI:-}${KERNEL_IMAGE_BASE}/${DEBIAN_ARCH}/${BM_KERNEL}" -o kernel 113 curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 114 "${FDO_HTTP_CACHE_URI:-}${KERNEL_IMAGE_BASE}/${DEBIAN_ARCH}/modules.tar.zst" -o modules.tar.zst 115 116 if [ -n "$BM_DTB" ]; then 117 curl -L --retry 4 -f --retry-all-errors --retry-delay 60 \ 118 "${FDO_HTTP_CACHE_URI:-}${KERNEL_IMAGE_BASE}/${DEBIAN_ARCH}/${BM_DTB}.dtb" -o dtb 119 fi 120 121 cat kernel dtb > Image.gz-dtb || echo "No DTB available, using pure kernel." 122 rm kernel 123 tar --keep-directory-symlink --zstd -xf modules.tar.zst -C "$BM_ROOTFS/" 124 rm modules.tar.zst & 125else 126 cat /baremetal-files/"$BM_KERNEL" /baremetal-files/"$BM_DTB".dtb > Image.gz-dtb 127 cp /baremetal-files/"$BM_DTB".dtb dtb 128fi 129 130export PATH=$BM:$PATH 131 132mkdir -p artifacts 133mkbootimg.py \ 134 --kernel Image.gz-dtb \ 135 --ramdisk rootfs.cpio.gz \ 136 --dtb dtb \ 137 --cmdline "$BM_CMDLINE" \ 138 $BM_MKBOOT_PARAMS \ 139 --header_version 2 \ 140 -o artifacts/fastboot.img 141 142rm Image.gz-dtb dtb 143 144# Start background command for talking to serial if we have one. 145if [ -n "$BM_SERIAL_SCRIPT" ]; then 146 $BM_SERIAL_SCRIPT > results/serial-output.txt & 147 148 while [ ! -e results/serial-output.txt ]; do 149 sleep 1 150 done 151fi 152 153section_end prepare_rootfs 154 155set +e 156$BM/fastboot_run.py \ 157 --dev="$BM_SERIAL" \ 158 --test-timeout ${TEST_PHASE_TIMEOUT_MINUTES:-20} \ 159 --fbserial="$BM_FASTBOOT_SERIAL" \ 160 --powerup="$BM_POWERUP" \ 161 --powerdown="$BM_POWERDOWN" 162ret=$? 163set -e 164 165if [ -n "$BM_FASTBOOT_NFSROOT" ]; then 166 # Bring artifacts back from the NFS dir to the build dir where gitlab-runner 167 # will look for them. 168 cp -Rp /nfs/results/. results/ 169fi 170 171exit $ret 172