ci: Fix the nick used in IRC reporting.
[mesa.git] / .gitlab-ci / bare-metal / fastboot.sh
1 #!/bin/bash
2
3 BM=$CI_PROJECT_DIR/.gitlab-ci/bare-metal
4
5 if [ -z "$BM_SERIAL" ]; then
6 echo "Must set BM_SERIAL in your gitlab-runner config.toml [[runners]] environment"
7 echo "This is the serial device to talk to for waiting for fastboot to be ready and logging from the kernel."
8 exit 1
9 fi
10
11 if [ -z "$BM_POWERUP" ]; then
12 echo "Must set BM_POWERUP in your gitlab-runner config.toml [[runners]] environment"
13 echo "This is a shell script that should reset the device and begin its boot sequence"
14 echo "such that it pauses at fastboot."
15 exit 1
16 fi
17
18 if [ -z "$BM_POWERDOWN" ]; then
19 echo "Must set BM_POWERDOWN in your gitlab-runner config.toml [[runners]] environment"
20 echo "This is a shell script that should power off the device."
21 exit 1
22 fi
23
24 if [ -z "$BM_FASTBOOT_SERIAL" ]; then
25 echo "Must set BM_FASTBOOT_SERIAL in your gitlab-runner config.toml [[runners]] environment"
26 echo "This must be the a stable-across-resets fastboot serial number."
27 exit 1
28 fi
29
30 if [ -z "$BM_KERNEL" ]; then
31 echo "Must set BM_KERNEL to your board's kernel vmlinuz or Image.gz in the job's variables:"
32 exit 1
33 fi
34
35 if [ -z "$BM_DTB" ]; then
36 echo "Must set BM_DTB to your board's DTB file in the job's variables:"
37 exit 1
38 fi
39
40 if [ -z "$BM_ROOTFS" ]; then
41 echo "Must set BM_ROOTFS to your board's rootfs directory in the job's variables:"
42 exit 1
43 fi
44
45 set -ex
46
47 # Copy the rootfs to a temporary for our setup, as I believe changes to the
48 # container can end up impacting future runs.
49 cp -Rp $BM_ROOTFS rootfs
50
51 # Set up the init script that brings up the system.
52 cp $BM/init.sh rootfs/init
53
54 # Pass through relevant env vars from the gitlab job to the baremetal init script
55 touch rootfs/set-job-env-vars.sh
56 chmod +x rootfs/set-job-env-vars.sh
57 for var in \
58 CI_COMMIT_BRANCH \
59 CI_COMMIT_TITLE \
60 CI_JOB_ID \
61 CI_JOB_URL \
62 CI_MERGE_REQUEST_SOURCE_BRANCH_NAME \
63 CI_MERGE_REQUEST_TITLE \
64 CI_NODE_INDEX \
65 CI_NODE_TOTAL \
66 CI_PIPELINE_ID \
67 CI_RUNNER_DESCRIPTION \
68 DEQP_EXPECTED_RENDERER \
69 DEQP_PARALLEL \
70 DEQP_VER \
71 FLAKES_CHANNEL \
72 ; do
73 val=`echo ${!var} | sed 's|"||g'`
74 echo "export $var=\"${val}\"" >> rootfs/set-job-env-vars.sh
75 done
76
77 # Add the Mesa drivers we built, and make a consistent symlink to them.
78 mkdir -p rootfs/$CI_PROJECT_DIR
79 tar -C rootfs/$CI_PROJECT_DIR/ -xf $CI_PROJECT_DIR/artifacts/install.tar
80 ln -sf $CI_PROJECT_DIR/install rootfs/install
81
82 # Copy the deqp runner script and metadata.
83 cp .gitlab-ci/deqp-runner.sh rootfs/deqp/.
84 cp .gitlab-ci/$DEQP_SKIPS rootfs/$CI_PROJECT_DIR/install/deqp-skips.txt
85 if [ -n "$DEQP_EXPECTED_FAILS" ]; then
86 cp .gitlab-ci/$DEQP_EXPECTED_FAILS rootfs/$CI_PROJECT_DIR/install/deqp-expected-fails.txt
87 fi
88
89 # Finally, pack it up into a cpio rootfs.
90 pushd rootfs
91 find -H | cpio -H newc -o | xz --check=crc32 -T4 - > $CI_PROJECT_DIR/rootfs.cpio.gz
92 popd
93
94 cat $BM_KERNEL $BM_DTB > Image.gz-dtb
95
96 abootimg \
97 --create artifacts/fastboot.img \
98 -k Image.gz-dtb \
99 -r rootfs.cpio.gz \
100 -c cmdline="$BM_CMDLINE"
101 rm Image.gz-dtb
102
103 # Start watching serial, and power up the device.
104 $BM/serial-buffer.py $BM_SERIAL | tee artifacts/serial-output.txt &
105 while [ ! -e artifacts/serial-output.txt ]; do
106 sleep 1
107 done
108 PATH=$BM:$PATH $BM_POWERUP
109
110 # Once fastboot is ready, boot our image.
111 $BM/expect-output.sh artifacts/serial-output.txt "fastboot: processing commands"
112 fastboot boot -s $BM_FASTBOOT_SERIAL artifacts/fastboot.img
113
114 # Wait for the device to complete the deqp run
115 $BM/expect-output.sh artifacts/serial-output.txt "DEQP RESULT"
116
117 # power down the device
118 PATH=$BM:$PATH $BM_POWERDOWN
119
120 set +e
121 if grep -q "DEQP RESULT: pass" artifacts/serial-output.txt; then
122 exit 0
123 else
124 exit 1
125 fi
126