summaryrefslogtreecommitdiff
path: root/.gitlab-ci
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2021-06-11 16:13:01 +0100
committerTomeu Vizoso <tomeu.vizoso@collabora.com>2021-06-15 14:02:44 +0200
commit51395f01ce8c9b427a99e2cd57d724afa0cfe654 (patch)
treebab9e4ecd59057e9385f6819437d76e142e4a458 /.gitlab-ci
parenta941f9bf431a1a12f3b75645216dabc800653c80 (diff)
ci/bare-metal: Split init script into two stages
Whilst we want to reuse the same init and job environment for LAVA and bare-metal, LAVA needs to additionally inject wget and tar jobs, so we can actually get our per-job environment, as the rootfs we run in is just the container-generated base rootfs. Split the init script into two stages, with the first stage doing very base bringup of devices and networking, and the second stage setting the job environment and running the jobs. Signed-off-by: Daniel Stone <daniels@collabora.com> Acked-by: Martin Peres <martin.peres@mupuf.org> Acked-by: Emma Anholt <emma@anholt.net> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11337>
Diffstat (limited to '.gitlab-ci')
-rwxr-xr-x.gitlab-ci/bare-metal/bm-init.sh13
-rw-r--r--.gitlab-ci/bare-metal/rootfs-setup.sh3
-rwxr-xr-x.gitlab-ci/common/init-stage1.sh20
-rwxr-xr-x.gitlab-ci/common/init-stage2.sh (renamed from .gitlab-ci/common/init.sh)23
4 files changed, 39 insertions, 20 deletions
diff --git a/.gitlab-ci/bare-metal/bm-init.sh b/.gitlab-ci/bare-metal/bm-init.sh
new file mode 100755
index 00000000000..6935957b2c6
--- /dev/null
+++ b/.gitlab-ci/bare-metal/bm-init.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Init entrypoint for bare-metal devices; calls common init code.
+
+# First stage: very basic setup to bring up network and /dev etc
+/init-stage1.sh
+
+# Second stage: run jobs
+test $? -eq 0 && /init-stage2.sh
+
+# Wait until the job would have timed out anyway, so we don't spew a "init
+# exited" panic.
+sleep 6000
diff --git a/.gitlab-ci/bare-metal/rootfs-setup.sh b/.gitlab-ci/bare-metal/rootfs-setup.sh
index 4d1cf83c5d0..796b9977f17 100644
--- a/.gitlab-ci/bare-metal/rootfs-setup.sh
+++ b/.gitlab-ci/bare-metal/rootfs-setup.sh
@@ -5,7 +5,8 @@ rootfs_dst=$1
mkdir -p $rootfs_dst/results
# Set up the init script that brings up the system.
-cp $CI_COMMON/init.sh $rootfs_dst/init
+cp $BM/bm-init.sh $rootfs_dst/init
+cp $CI_COMMON/init*.sh $rootfs_dst/
cp $BM/capture-devcoredump.sh $rootfs_dst/
diff --git a/.gitlab-ci/common/init-stage1.sh b/.gitlab-ci/common/init-stage1.sh
new file mode 100755
index 00000000000..60b1e28366e
--- /dev/null
+++ b/.gitlab-ci/common/init-stage1.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Very early init, used to make sure devices and network are set up and
+# reachable.
+
+set -ex
+
+mount -t proc none /proc
+mount -t sysfs none /sys
+mount -t devtmpfs none /dev || echo possibly already mounted
+mkdir -p /dev/pts
+mount -t devpts devpts /dev/pts
+mount -t tmpfs tmpfs /tmp
+
+echo "nameserver 8.8.8.8" > /etc/resolv.conf
+[ -z "$NFS_SERVER_IP" ] || echo "$NFS_SERVER_IP caching-proxy" >> /etc/hosts
+
+# Set the time so we can validate certificates before we fetch anything;
+# however as not all DUTs have network, make this non-fatal.
+for i in 1 2 3; do sntp -sS pool.ntp.org && break || sleep 2; done || true
diff --git a/.gitlab-ci/common/init.sh b/.gitlab-ci/common/init-stage2.sh
index c9938ed91cc..3f5207d0e0a 100755
--- a/.gitlab-ci/common/init.sh
+++ b/.gitlab-ci/common/init-stage2.sh
@@ -1,23 +1,12 @@
#!/bin/sh
-set -ex
-
-mount -t proc none /proc
-mount -t sysfs none /sys
-mount -t devtmpfs none /dev || echo possibly already mounted
-mkdir -p /dev/pts
-mount -t devpts devpts /dev/pts
-mount -t tmpfs tmpfs /tmp
-
-echo "nameserver 8.8.8.8" > /etc/resolv.conf
-[ -z "$NFS_SERVER_IP" ] || echo "$NFS_SERVER_IP caching-proxy" >> /etc/hosts
-
-# Set the time so we can validate certificates before we fetch anything;
-# however as not all DUTs have network, make this non-fatal.
-for i in 1 2 3; do sntp -sS pool.ntp.org && break || sleep 2; done || true
+# Second-stage init, used to set up devices and our job environment before
+# running tests.
. /set-job-env-vars.sh
+set -ex
+
# Set up any devices required by the jobs
[ -z "$HWCI_KERNEL_MODULES" ] || (echo -n $HWCI_KERNEL_MODULES | xargs -d, -n1 /usr/sbin/modprobe)
@@ -73,7 +62,3 @@ if [ $OK -eq 1 ]; then
else
echo "bare-metal result: fail"
fi
-
-# Wait until the job would have timed out anyway, so we don't spew a "init
-# exited" panic.
-sleep 6000