Skip to content
suit Artifact [19219679c5]
Login

Artifact [19219679c5]

Artifact 19219679c52cbc3ae3c6c4ccd915a327bc4ee735572ee6a4a51f856abcdc7820:


#!/bin/sh
# The whole local gate, one run after another, stopping at the first failure:
#   rm -rf build/dev; make check CC=gcc-16        -> build/check-gcc.log
#   rm -rf build/dev; make all                    -> build/all.log
#   env -u USER -u LOGNAME make check             -> build/check-nouser.log
#   (umask 027; make check)                       -> build/check-umask.log
# The last two reuse the dev build that `make all` just made: same compiler,
# same flags, so make finds nothing to rebuild. Then, for each run that
# started, its exit status, its seconds and its summary lines.
# usage: gate.sh   (env: GATE_GCC, the second compiler; default gcc-16)
set -u
gcc=${GATE_GCC:-gcc-16}
if ! command -v "$gcc" >/dev/null 2>&1; then
    echo "gate: $gcc is not installed; the first run needs it" >&2
    exit 1
fi
mkdir -p build
done_runs=

report() {
    for n in $done_runs; do
        printf '%s: exit %s, %ss\n' "$n" "$(cat "build/$n.rc")" "$(cat "build/$n.sec")"
        grep -E '^(unit: [0-9]+ checks|[a-z]+\.sh: [0-9]+ cases), [0-9]+ failed$' "build/$n.log" | head -8
        grep '^skip ' "build/$n.log" | sort -u | head -5
    done
}

# run NAME COMMAND...: output to build/NAME.log, status to build/NAME.rc
run() {
    n=$1; shift
    echo "gate: $n"
    start=$(date +%s)
    "$@" >"build/$n.log" 2>&1
    echo $? >"build/$n.rc"
    echo $(($(date +%s) - start)) >"build/$n.sec"
    done_runs="$done_runs $n"
    [ "$(cat "build/$n.rc")" = 0 ]
}

run check-gcc sh -c "rm -rf build/dev; make check CC=$gcc" &&
run all sh -c 'rm -rf build/dev; make all' &&
run check-nouser env -u USER -u LOGNAME make check &&
run check-umask sh -c 'umask 027; make check'
rc=$?
report
[ $rc = 0 ] && echo "gate: passed" || echo "gate: FAILED" >&2
exit $rc