AtlatestRepositorycore-channel

core-channel / tree / scriptsgate-concurrency.sh

1#!/bin/sh
2set -eu
3
4sigil_bin=${SIGIL_BIN:?set SIGIL_BIN to the production sigil binary}
5channel=${SIGIL_CHANNEL:-$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)}
6recipe=${1:-zlib}
7gate_root=$(mktemp -d /tmp/sigil-channel-concurrency.XXXXXX)
8store=$gate_root/store
9
10realize_pair() {
11 label=$1
12 "$sigil_bin" external-build realize "$recipe" --channel "$channel" --store "$store" \
13 >"$gate_root/$label.a" 2>"$gate_root/$label.a.err" &
14 pid_a=$!
15 "$sigil_bin" external-build realize "$recipe" --channel "$channel" --store "$store" \
16 >"$gate_root/$label.b" 2>"$gate_root/$label.b.err" &
17 pid_b=$!
18 wait "$pid_a"
19 wait "$pid_b"
20 hash_a=$(tail -n 1 "$gate_root/$label.a")
21 hash_b=$(tail -n 1 "$gate_root/$label.b")
22 test "$hash_a" = "$hash_b"
23 printf '%s statuses=0,0 hash=%s\n' "$label" "$hash_a"
26# The first pair intentionally starts with neither source nor derivation in the
27# fresh store. The second pair retains the original warm-hit race coverage.
28realize_pair cold
29realize_pair warm
30printf 'transcripts=%s\n' "$gate_root"