#!/bin/sh # Drive the whole resolvconf interface under a temporary root and print a # deterministic transcript. # # Run identically on both sides: natively at build time to produce the expected # transcript, and on target to produce the actual one. Everything that could # differ for a reason that is not the port -- the root path, a pid, the host name # -- is normalised out, so a difference in the transcript is a difference in what # the ported bash, sed, coreutils, run-parts and flock did with the same scripts. # # Usage: resolvconf-scenarios.sh ROOT NORMALIZE_CORPUS [GROUP] # # ROOT is a tree already materialised by resolvconf-temproot.sh. # # GROUP is "a", "d", "b", "c" or a run of them ("abcd" is the default), selecting # a contiguous run of phases. The letters are in the order the groups were split # out, not alphabetical: the phase order is a, d, c, b. # It exists because the whole matrix does not fit in ONE guest: the run costs # ~600 process spawns, and this platform does not return memory on process exit # (brintos/linux#21, brintos/hardwarejs#20), so a single-guest run peaked at # 12.4 GiB and was killed by brintos_local_verify's RSS-rate bound -- reporting # ZERO cases, which is worse than any red. Split across two guests each half is # comfortably inside both the memory and the wall-clock bound. The halves are # contiguous rather than interleaved so that each is a coherent story and each # starts from its own reset_state. set -u R=${1:?ROOT} CORPUS=${2:?normalize corpus} GROUP=${3:-abcd} case "$GROUP" in a|b|c|d|ad|bc|abcd) ;; *) echo "resolvconf-scenarios: GROUP must be a, b, c, d or a run of them (got '$GROUP')" >&2 ; exit 2 ;; esac in_group() { case "$GROUP" in *"$1"*) return 0 ;; *) return 1 ;; esac ; } RC="$R/sbin/resolvconf" LR="$R/lib/resolvconf/list-records" NORM="$R/lib/resolvconf/normalize-resolvconf" IFDIR="$R/run/resolvconf/interface" DYN="$R/run/resolvconf/resolv.conf" RCD="$R/etc/resolvconf/resolv.conf.d" # Everything below runs with the C locale and a fixed umask: sed's character # classes, sort order and the mode of every file resolvconf creates are all # locale- or umask-derived, and a transcript that silently depends on the # ambient value of either is not a comparison between two platforms. LC_ALL=C LANG=C export LC_ALL LANG umask 022 # The transcript's only escape hatch. $R differs between the two sides by # construction, and it reaches the output through $0 in resolvconf's own warning # text and through readlink, so it is mapped to a constant rather than kept out. scrub() { sed -e "s|$R|@ROOT@|g" ; } case_begin() { printf '==CASE %s==\n' "$1" ; } case_end() { printf '==END %s==\n' "$1" ; } # run