ci: Improve the flakes reports on IRC.
[mesa.git] / .gitlab-ci / bare-metal / fastboot.sh
index bdb885bfef9e60000faf45337d64c6e223248258..801cb9a14079ec7950d79ce61c3c7bde12843d58 100755 (executable)
@@ -15,6 +15,12 @@ if [ -z "$BM_POWERUP" ]; then
   exit 1
 fi
 
+if [ -z "$BM_POWERDOWN" ]; then
+  echo "Must set BM_POWERDOWN in your gitlab-runner config.toml [[runners]] environment"
+  echo "This is a shell script that should power off the device."
+  exit 1
+fi
+
 if [ -z "$BM_FASTBOOT_SERIAL" ]; then
   echo "Must set BM_FASTBOOT_SERIAL in your gitlab-runner config.toml [[runners]] environment"
   echo "This must be the a stable-across-resets fastboot serial number."
@@ -22,7 +28,7 @@ if [ -z "$BM_FASTBOOT_SERIAL" ]; then
 fi
 
 if [ -z "$BM_KERNEL" ]; then
-  echo "Must set BM_KERNEL to your board's kernel Image in the job's variables:"
+  echo "Must set BM_KERNEL to your board's kernel vmlinuz or Image.gz in the job's variables:"
   exit 1
 fi
 
@@ -44,10 +50,28 @@ cp -Rp $BM_ROOTFS rootfs
 
 # Set up the init script that brings up the system.
 cp $BM/init.sh rootfs/init
-sed -i "s|DEQP_VER_REPLACE|$DEQP_VER|g" rootfs/init
-sed -i "s|DEQP_PARALLEL_REPLACE|$DEQP_PARALLEL|g" rootfs/init
-sed -i "s|CI_NODE_INDEX_REPLACE|$CI_NODE_INDEX|g" rootfs/init
-sed -i "s|CI_NODE_TOTAL_REPLACE|$CI_NODE_TOTAL|g" rootfs/init
+
+# Pass through relevant env vars from the gitlab job to the baremetal init script
+touch rootfs/set-job-env-vars.sh
+chmod +x rootfs/set-job-env-vars.sh
+for var in \
+    CI_COMMIT_BRANCH \
+    CI_COMMIT_TITLE \
+    CI_JOB_URL \
+    CI_MERGE_REQUEST_SOURCE_BRANCH_NAME \
+    CI_MERGE_REQUEST_TITLE \
+    CI_NODE_INDEX \
+    CI_NODE_TOTAL \
+    CI_PIPELINE_ID \
+    CI_RUNNER_DESCRIPTION \
+    DEQP_EXPECTED_RENDERER \
+    DEQP_PARALLEL \
+    DEQP_VER \
+    FLAKES_CHANNEL \
+    ; do
+  val=`echo ${!var} | sed 's|"||g'`
+  echo "export $var=\"${val}\"" >> rootfs/set-job-env-vars.sh
+done
 
 # Add the Mesa drivers we built, and make a consistent symlink to them.
 mkdir -p rootfs/$CI_PROJECT_DIR
@@ -56,10 +80,9 @@ ln -sf $CI_PROJECT_DIR/install rootfs/install
 
 # Copy the deqp runner script and metadata.
 cp .gitlab-ci/deqp-runner.sh rootfs/deqp/.
-mkdir -p rootfs/artifacts/deqp
-cp .gitlab-ci/$DEQP_SKIPS rootfs/artifacts/deqp-skips.txt
+cp .gitlab-ci/$DEQP_SKIPS rootfs/$CI_PROJECT_DIR/install/deqp-skips.txt
 if [ -n "$DEQP_EXPECTED_FAILS" ]; then
-  cp .gitlab-ci/$DEQP_EXPECTED_FAILS rootfs/artifacts/deqp-expected-fails.txt
+  cp .gitlab-ci/$DEQP_EXPECTED_FAILS rootfs/$CI_PROJECT_DIR/install/deqp-expected-fails.txt
 fi
 
 # Finally, pack it up into a cpio rootfs.
@@ -67,14 +90,14 @@ pushd rootfs
   find -H | cpio -H newc -o | xz --check=crc32 -T4 - > $CI_PROJECT_DIR/rootfs.cpio.gz
 popd
 
-gzip -c $BM_KERNEL > Image.gz
-cat Image.gz $BM_DTB > Image.gz-dtb
+cat $BM_KERNEL $BM_DTB > Image.gz-dtb
+
 abootimg \
   --create artifacts/fastboot.img \
   -k Image.gz-dtb \
   -r rootfs.cpio.gz \
   -c cmdline="$BM_CMDLINE"
-rm Image.gz Image.gz-dtb
+rm Image.gz-dtb
 
 # Start watching serial, and power up the device.
 $BM/serial-buffer.py $BM_SERIAL | tee artifacts/serial-output.txt &
@@ -90,6 +113,9 @@ fastboot boot -s $BM_FASTBOOT_SERIAL artifacts/fastboot.img
 # Wait for the device to complete the deqp run
 $BM/expect-output.sh artifacts/serial-output.txt "DEQP RESULT"
 
+# power down the device
+PATH=$BM:$PATH $BM_POWERDOWN
+
 set +e
 if grep -q "DEQP RESULT: pass" artifacts/serial-output.txt; then
    exit 0