# BST-TIMEOUT: 1800 # four autoconf generations and two configure runs, each forking perl and m4
. "$BST_LIB"
# The archive ships no program -- it is 582 m4 macro files under ${datadir}/aclocal
# -- so there is nothing for `require` to look up. What stands in for it is the
# directory the autotools search, which is the one thing a wrong install path
# breaks. BST_ACLOCAL_DIR exists so the suite can be scored against a native
# control on a host that has no archive installed; nothing on the image sets it.
ACDIR=${BST_ACLOCAL_DIR:-/usr/share/aclocal}
# ------------------------------------------ 1. installed where the autotools look
check autoconf-archive/acdir test -d "$ACDIR"
check autoconf-archive/macro-file test -s "$ACDIR/ax_check_compile_flag.m4"
check autoconf-archive/macro-require test -s "$ACDIR/ax_require_defined.m4"
check autoconf-archive/macro-compare test -s "$ACDIR/ax_compare_version.m4"
check autoconf-archive/macro-eval test -s "$ACDIR/ax_recursive_eval.m4"
check autoconf-archive/macro-perlver test -s "$ACDIR/ax_prog_perl_version.m4"
# Bounded from below. The release ships 582 and the count moves with every version
# bump, so an exact figure goes false on the next one while a floor still catches
# the failure that matters -- a handful of files, or none.
#
# BRINTOS-WORKAROUND: linux-in-the-browser#150 remove — counted by filtering
# `ls
` rather than globbing `ls /ax_*.m4`. 582 paths make a ~26 kB argv
# block against this arm's 8192 B __wasm32_args_buf, and an overflow is not E2BIG:
# the exec is abandoned with no error path into the guest, so the shell never comes
# back and the whole suite run is lost rather than this one case going red. Restore
# the glob when #150 closes. This package is the worst-case shape for that defect --
# it installs 582 files into one directory whose entire purpose is to be globbed.
n=$(ls "$ACDIR" 2>/dev/null | grep -c '^ax_.*\.m4$')
if [ "$n" -ge 500 ]; then bst_ok autoconf-archive/macro-count
else bst_notok autoconf-archive/macro-count "want >=500 ax_*.m4 in $ACDIR, got $n"; fi
# A file of the right name that is not the macro is the same failure as no file.
check_out autoconf-archive/macro-defun "AC_DEFUN([AX_CHECK_COMPILE_FLAG]" \
cat "$ACDIR/ax_check_compile_flag.m4"
# aclocal is the tool that actually scans this directory, so where IT looks is the
# authoritative answer. Skipped when the override is in force, because the control
# host's aclocal cannot be expected to agree with a staged directory.
if [ -n "${BST_ACLOCAL_DIR:-}" ]; then
bst_skip autoconf-archive/aclocal-acdir "BST_ACLOCAL_DIR override in force (native control)"
elif command -v aclocal >/dev/null 2>&1; then
# Installed is not the same as runnable: aclocal is perl, so on this arm it
# aborts under #154 like every other autoconf program and answers nothing. An
# empty answer is that defect, not a wrong install path, and is reported as the
# named skip below rather than as a second red saying what the guard already says.
acdir=$(aclocal --print-ac-dir 2>/dev/null)
if [ -n "$acdir" ]; then
check_eq autoconf-archive/aclocal-acdir "$ACDIR" "$acdir"
else
bst_skip autoconf-archive/aclocal-acdir \
"aclocal is installed (BRINTOS-688) but cannot run: linux-in-the-browser#154"
fi
else
bst_skip autoconf-archive/aclocal-acdir "automake/aclocal not on this image (BRINTOS-688)"
fi
require autoconf autoconf-archive/autoconf-present
# ---------------------------------- 1b. can autoconf run here at all? (guard)
# Two platform defects have blocked this port's functional half, and they are not
# the same one. Keep them apart: attributing a red to a closed issue is worse than
# not attributing it, because it reads as tracked.
#
# linux-in-the-browser#154 -- perl aborting in glibc's allocator on module load,
# so no autoconf program started at all -- NO LONGER REPRODUCES on this baseline.
# The probe below is therefore an assertion that it has not come back, not the
# guard it used to be; leave it, because it is the cheapest regression detector
# this suite has for a defect that once cost the whole sweep.
#
# What blocks the chain today is linux-in-the-browser#167: splice(2) is ENOSYS
# (x86_64 nr 275 is unwired in arch/wasm32's syscall table), and GNU grep drains
# its input with splice when stdin is a pipe and stdout is /dev/null, treating any
# negative return as fatal. autom4te's GNU-m4 version check is exactly that idiom,
# m4 --help &1 | grep reload-state >/dev/null
# so every autoconf program aborts with "need GNU m4 1.4 or later" on an image
# whose m4 1.4.19 is installed and working. That diagnostic names the wrong
# component, which is why the guard below probes the syscall defect directly
# rather than parsing autoconf's complaint.
probe=$(autoconf --version 2>&1); prc=$?
# The abort message is not the first line of the capture: perl emits a six-line
# locale warning ahead of it on this image, so reporting the head of the probe
# names the locale as the failure and loses the signature #154 asks for. Pick the
# allocator line; fall back to the first line that is not part of that preamble.
sig=$(printf '%s\n' "$probe" \
| grep -E 'mremap_chunk|corrupted size|realloc\(\)|double free|Aborted' | head -1)
[ -n "$sig" ] || sig=$(printf '%s\n' "$probe" \
| grep -vE '^perl: warning:|^[[:space:]]*(LANGUAGE|LC_ALL|LANG)[[:space:]]*=|^[[:space:]]*are supported|^[[:space:]]*$' \
| head -1)
[ -n "$sig" ] || sig=$probe
case "$probe" in
*"GNU Autoconf"*)
bst_ok autoconf-archive/autoconf-runs ;;
*)
bst_notok autoconf-archive/autoconf-runs \
"linux-in-the-browser#154: autoconf aborts before parsing an argument (rc=$prc $(_bst_1line "$sig"))"
bst_skip autoconf-archive/macro-expansion \
"blocked by linux-in-the-browser#154 -- the archive is installed and asserted above, but no AX_ macro can be expanded while autoconf cannot start"
exit 0 ;;
esac
# BRINTOS-WORKAROUND: linux-in-the-browser#167 remove -- the functional half below
# cannot run while splice(2) is ENOSYS. Delete this block when #167 closes; the
# cases it guards need no edit and the suite returns to its full count on its own.
#
# Run the one-line reproducer rather than inferring the defect from autoconf's
# output, so the red names the syscall instead of m4. Two details matter and both
# are load-bearing: stdout must be /dev/null (with the output anywhere else grep
# never reaches its splice path), and the pattern must MATCH (grep only drains,
# and so only splices, once it has decided it can stop reading). `2>&1 >/dev/null`
# in that order captures grep's stderr while leaving its stdout on /dev/null,
# which is the combination under test.
sperr=$(echo bst-splice-probe | grep bst-splice-probe 2>&1 >/dev/null); sr="$?"
if [ "$sr" = "0" ]; then
bst_ok autoconf-archive/autom4te-usable
else
bst_notok autoconf-archive/autom4te-usable \
"linux-in-the-browser#167: splice(2) is ENOSYS, so 'cmd | grep P >/dev/null' fails (rc=$sr $(_bst_1line "$sperr")) and autom4te rejects a working m4 -- no autoconf program can run"
bst_skip autoconf-archive/macro-expansion \
"blocked by linux-in-the-browser#167 -- the archive is installed and asserted above, but no AX_ macro can be expanded while autom4te's m4 version check cannot pass"
exit 0
fi
tmp=${TMPDIR:-/tmp}/bst-aca.$$
mkdir -p "$tmp" || { bst_notok autoconf-archive/tmpdir "cannot create $tmp"; exit 0; }
cd "$tmp" || { bst_notok autoconf-archive/chdir "cannot cd $tmp"; exit 0; }
# ------------------------------------------------------------ 2. the fixture
# AX_CHECK_COMPILE_FLAG is the macro the ticket names. It is asserted on
# GENERATION only: its body compiles a probe, and this image has no target C
# compiler, so running it would fail for a reason that says nothing about the
# archive. Section 3 covers the run with macros that need no compiler.
cat > configure.ac <<'ACEOF'
AC_INIT([bst-aca], [1.0], [bst@example.invalid])
AC_CONFIG_SRCDIR([fixture.txt])
AX_CHECK_COMPILE_FLAG([-Wall], [ax_bst_wall=yes], [ax_bst_wall=no])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
ACEOF
: > fixture.txt
printf 'WALL = @ax_bst_wall@\n' > Makefile.in
# ------------------------------------ 3. the negative control, run FIRST on target
# With the macro unresolvable, autoconf exits 0, warns about nothing, and copies
# the CALL through into ./configure verbatim -- an AX_ name is not one of the
# prefixes it traces. That silence is the failure this package exists to prevent,
# and it is why every assertion below is written against residue and effect rather
# than against exit status. Asserting it here, on the target, is what makes the
# no-residue case downstream evidence rather than a tautology.
rm -f aclocal.m4
autoconf -o configure.noarchive configure.ac 2>/dev/null
n=$(grep -c 'AX_CHECK_COMPILE_FLAG(' configure.noarchive 2>/dev/null || true)
if [ "$n" -ge 1 ]; then bst_ok autoconf-archive/control-unresolved
else bst_notok autoconf-archive/control-unresolved \
"no residue without the archive (got $n) -- the residue assertions below prove nothing"; fi
# --------------------------- 4. the pass criterion: the macro expands, by effect
# aclocal.m4 is assembled from the installed directory by hand rather than by
# running aclocal. automake has landed (BRINTOS-688) so aclocal is on the image,
# but it is perl and cannot run here (#154); assembling by hand is precisely what
# aclocal itself does -- copy the matching macro files out of ${datadir}/aclocal --
# so the path under test is the same one and only the copier differs. Section 7
# below runs the real aclocal wherever it works.
cat "$ACDIR/ax_check_compile_flag.m4" "$ACDIR/ax_require_defined.m4" > aclocal.m4
rm -f configure
check autoconf-archive/generate autoconf -o configure configure.ac
check autoconf-archive/configure-exists test -s configure
n=$(grep -c 'AX_CHECK_COMPILE_FLAG(' configure 2>/dev/null || true)
check_eq autoconf-archive/no-residue 0 "$n"
# The macro's own footprint: its cache variable and its checking line. A configure
# that merely dropped the call would have neither, so these separate "expanded" from
# "silently discarded" -- which no residue count can do on its own.
check_out autoconf-archive/expanded-cachevar "ax_cv_check_cflags___Wall" cat configure
check_out autoconf-archive/expanded-checking "checking whether C compiler accepts" cat configure
# ------------------------------- 5. compiler-free macros GENERATE and then RUN
# The archive is data, so "it expands" is only half the claim: the expansion has to
# be shell that works on this substrate. These four need no compiler, so their
# effect is observable in the substituted Makefile of a real configure run.
d2=$tmp/run; rm -rf "$d2"; mkdir -p "$d2"
if cd "$d2" 2>/dev/null; then
cat > configure.ac <<'ACEOF'
AC_INIT([bst-aca-run], [2.0], [bst@example.invalid])
AC_CONFIG_SRCDIR([fixture.txt])
AX_COMPARE_VERSION([2.72], [ge], [2.60], [ax_bst_cmp=yes], [ax_bst_cmp=no])
AX_COMPARE_VERSION([1.0], [gt], [9.9], [ax_bst_cmp2=yes], [ax_bst_cmp2=no])
AC_SUBST([ax_bst_cmp])
AC_SUBST([ax_bst_cmp2])
ax_bst_pfx='${prefix}/lib'
AX_RECURSIVE_EVAL([$ax_bst_pfx], [ax_bst_eval])
AC_SUBST([ax_bst_eval])
AX_PRINT_TO_FILE([bst-printed.txt], [BST-PRINT-OK])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
ACEOF
: > fixture.txt
cat > Makefile.in <<'MKEOF'
CMP = @ax_bst_cmp@
CMP2 = @ax_bst_cmp2@
EVAL = @ax_bst_eval@
MKEOF
cat "$ACDIR/ax_compare_version.m4" "$ACDIR/ax_recursive_eval.m4" \
"$ACDIR/ax_print_to_file.m4" "$ACDIR/ax_file_escapes.m4" > aclocal.m4
check autoconf-archive/generate-run autoconf -o configure configure.ac
# Residue is grepped by macro NAME here, not by a leading AX_: AX_FILE_ESCAPES
# legitimately emits shell assignments (AX_DOLLAR=, AX_DQ=) at the head of a
# line, so a `^AX_` count would report four false positives on a correct run.
n=$(grep -cE 'AX_(COMPARE_VERSION|RECURSIVE_EVAL|PRINT_TO_FILE)\(' configure 2>/dev/null || true)
check_eq autoconf-archive/no-residue-run 0 "$n"
# A scratch subdirectory, so this is also a VPATH run.
rm -rf sc && mkdir -p sc
if cd sc 2>/dev/null; then
out=$(sh ../configure --prefix=/usr 2>&1); rc=$?
if [ "$rc" -eq 0 ]; then bst_ok autoconf-archive/configure-run
elif bst_execfail "$out"; then bst_unrun autoconf-archive/configure-run "$out"
else bst_notok autoconf-archive/configure-run "rc=$rc $(_bst_1line "$out")"; fi
check autoconf-archive/config-status test -x config.status
check autoconf-archive/makefile test -s Makefile
# each macro asserted by the VALUE it produced, not by having been mentioned
check_out autoconf-archive/cmp-true "CMP = yes" cat Makefile
check_out autoconf-archive/cmp-false "CMP2 = no" cat Makefile
check_out autoconf-archive/eval-prefix "EVAL = /usr/lib" cat Makefile
check autoconf-archive/print-file test -s bst-printed.txt
check_out autoconf-archive/print-body "BST-PRINT-OK" cat bst-printed.txt
n=$(grep -c '@[A-Za-z_][A-Za-z0-9_]*@' Makefile 2>/dev/null || true)
check_eq autoconf-archive/subst-complete 0 "$n"
cd "$d2" || true
else
bst_notok autoconf-archive/configure-run "cannot cd $d2/sc"
fi
cd "$tmp" || true
else
bst_notok autoconf-archive/generate-run "cannot cd $tmp/run"
fi
# ---------------------------------- 6. a macro that drives perl, end to end
# AX_PROG_PERL_VERSION forks perl and parses its version, so it exercises the one
# runtime dependency an m4-only package still has on this substrate.
d3=$tmp/perlver; rm -rf "$d3"; mkdir -p "$d3"
if cd "$d3" 2>/dev/null; then
cat > configure.ac <<'ACEOF'
AC_INIT([bst-aca-perl], [3.0], [bst@example.invalid])
AC_CONFIG_SRCDIR([fixture.txt])
AC_PROG_SED
AC_PROG_GREP
AC_PATH_PROG([PERL], [perl])
AX_PROG_PERL_VERSION([5.6.0], [ax_bst_perl=ok], [ax_bst_perl=too-old])
AC_SUBST([ax_bst_perl])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
ACEOF
: > fixture.txt
# PERL_VERSION is substituted by the macro itself, so asserting it non-empty
# catches the case where the branch was taken for the wrong reason: $PERL unset
# sends the macro straight to ACTION-IF-FALSE without ever running perl.
printf 'PERL = @ax_bst_perl@\nPERLVER = @PERL_VERSION@\n' > Makefile.in
# AX_PROG_PERL_VERSION's body calls AX_COMPARE_VERSION, so the archive's own
# inter-macro dependency has to be satisfied too -- omitting it produces a
# ./configure that autoconf generates happily and the shell then dies parsing.
cat "$ACDIR/ax_prog_perl_version.m4" "$ACDIR/ax_compare_version.m4" > aclocal.m4
check autoconf-archive/generate-perlver autoconf -o configure configure.ac
out=$(sh ./configure 2>&1); rc=$?
if [ "$rc" -eq 0 ]; then bst_ok autoconf-archive/configure-perlver
elif bst_execfail "$out"; then bst_unrun autoconf-archive/configure-perlver "$out"
else bst_notok autoconf-archive/configure-perlver "rc=$rc $(_bst_1line "$out")"; fi
check_out autoconf-archive/perlver-value "PERL = ok" cat Makefile
v=$(sed -n 's/^PERLVER = //p' Makefile 2>/dev/null)
if [ -n "$v" ]; then bst_ok autoconf-archive/perlver-substituted
else bst_notok autoconf-archive/perlver-substituted "PERL_VERSION came back empty -- the macro never ran perl"; fi
cd "$tmp" || true
else
bst_notok autoconf-archive/generate-perlver "cannot cd $tmp/perlver"
fi
# ------------------------------------------ 7. the aclocal path, when it exists
# The whole reason the archive lands in ${datadir}/aclocal is that aclocal finds it
# there with no -I. Once automake is on the image (BRINTOS-688) this is the
# criterion in its native form; until then it is a named skip rather than a silent
# gap, so the report says which half of the claim is covered.
d4=$tmp/aclocal; rm -rf "$d4"; mkdir -p "$d4"
if command -v aclocal >/dev/null 2>&1 && cd "$d4" 2>/dev/null; then
cat > configure.ac <<'ACEOF'
AC_INIT([bst-aca-aclocal], [4.0], [bst@example.invalid])
AC_CONFIG_SRCDIR([fixture.txt])
AX_COMPARE_VERSION([2.72], [ge], [2.60], [ax_bst_cmp=yes], [ax_bst_cmp=no])
AC_SUBST([ax_bst_cmp])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
ACEOF
: > fixture.txt
printf 'CMP = @ax_bst_cmp@\n' > Makefile.in
# Under the native control aclocal must be pointed at the staged directory too,
# or it searches the control host's own (archive-less) one and reds for a reason
# that is about the control rather than about the port. Empty on target.
ACLOCAL_SYSDIR=""
[ -n "${BST_ACLOCAL_DIR:-}" ] && ACLOCAL_SYSDIR="--system-acdir=$ACDIR"
check autoconf-archive/aclocal-run aclocal $ACLOCAL_SYSDIR
check autoconf-archive/aclocal-out test -s aclocal.m4
check_out autoconf-archive/aclocal-picked "AX_COMPARE_VERSION" cat aclocal.m4
check autoconf-archive/aclocal-autoconf autoconf -o configure configure.ac
n=$(grep -c 'AX_COMPARE_VERSION(' configure 2>/dev/null || true)
check_eq autoconf-archive/aclocal-no-residue 0 "$n"
cd "$tmp" || true
else
bst_skip autoconf-archive/aclocal-run "automake/aclocal not on this image (BRINTOS-688)"
fi
cd /
rm -rf "$tmp"