main/postmarketos-mkinitfs-hook-ci: Print markers many times

This helps ensure the logs are actually flushed.

The numbers chosen are relatively arbitrary, and it might be that using
a longer delay, maybe with more messages too, is desirable.

Right now, it's printing 20 times over a span of 2 seconds.

The whole `precision` schtick is how we can approximate float division,
when using only integer division. Then, the important trick is to shove
the given number back into the correct representation for `sleep`, and
careful `printf` application gives us exactly what we need.

Signed-off-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6335
[ci:skip-build]: already built successfully in CI
This commit is contained in:
Samuel Dionne-Riel 2025-03-14 22:47:42 -04:00 committed by Pablo Correa Gómez
parent a3155b8985
commit be29aa00d7
No known key found for this signature in database
GPG key ID: 7A342565FF635F79
2 changed files with 20 additions and 7 deletions

View file

@ -6,6 +6,20 @@
# shellcheck source=../devicepkg-utils/source_deviceinfo
. /usr/share/misc/source_deviceinfo
# Prints a given string a couple of times, over a span of time
# This helps paper over weirdness where the output may not flush
# as eagerly as expected, and the CI may miss the messages.
# This also helps if any messages would end-up interleaved.
_report_ci() {
local precision=1000
local duration=2
local count=20
while [ "$((count = count - 1))" -gt 0 ]; do
printf '%s\n' "$@"
sleep "$(printf '0.%03d' "$(( precision * duration / count ))")"
done
}
DID_FAIL=0
echo "==> Running postmarketos-mkinitfs-hook-ci"
@ -27,14 +41,13 @@ echo "==> re-enabling dmesg on console at loglevel 8"
dmesg -n 8
if [ $DID_FAIL -ne 0 ]; then
echo "==> PMOS-CI-FAIL"
_report_ci "==> PMOS-CI-FAIL"
else
echo "==> PMOS-CI-OK"
_report_ci "==> PMOS-CI-OK"
fi
# We're done, kill it
# CDBA will exit if it sees 20 '~' characters
# in a row, send a whole bunch just to be sure
# In the worst case it will timeout.
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
_report_ci "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

View file

@ -1,7 +1,7 @@
# Maintainer: Caleb Connolly <caleb@connolly.tech>
pkgname=postmarketos-mkinitfs-hook-ci
pkgver=0.1.0
pkgrel=2
pkgver=0.1.1
pkgrel=0
pkgdesc="Hook for doing automated CI tests in the initramfs"
url="https://postmarketos.org"
source="
@ -20,6 +20,6 @@ package() {
}
sha512sums="
43f9d9a35a57845eb36893a3f20d8ff5f20b93b1c22c7c6e3959b07a41b3c5fe2f9941612620cf006a0018b53edae5fdc7ed3006befc6908c19a5617f322dea3 05-ci.sh
3dfc0024370a43765081f34ae86e5289a6bd3f30daea81d8ed87e03e66e1001bb5ee02bdbabea7491c9f560cf2099968419c66090384b52890669a629246139e 05-ci.sh
26d665b817a4978dca44e0c697d98e12c58fa7941da86b9e3bfef6ecb0791d55859c0b671c00d7f88cfca688acf0dcc3e593ca5d8dd3cc094f582b49dabea645 05-ci.files
"