# BST-TIMEOUT: 1200 # 74 upstream execs; measured 12.4 s native, and exec here is # # a fresh module instantiation (~1.7 s apiece on faad2's # # measurement), so the spawn budget alone dominates. See below. . "$BST_LIB" # mpc 1.3.1 -- GNU MPC, arbitrary-precision arithmetic on COMPLEX numbers with # correct rounding, layered on mpfr (BRINTOS-526) and gmp (BRINTOS-210). # See libmpc_%.bbappend for what the port adds and why. # # --------------------------------------------------------------------------- # WHAT THIS SUITE IS, AND WHY IT IS NOT A PROBE # # Its neighbour 80-mpfr.test cross-links a probe we wrote (src/mpfr_probe.c), # because mpfr's port predates this Epic and OE packages no ptest for it either. # This ticket is held to a stricter bar: it closes on the PACKAGE'S OWN UPSTREAM # SUITE. mpc ships one -- 74 programmes under tests/, each driving one entry # point against reference vectors held in the source tree -- and the bbappend # stages exactly the set upstream's own tests/Makefile.am declares in # check_PROGRAMS, so what runs here is upstream's suite and not our reading of it. # # That is a materially stronger statement than a probe. A probe asserts the # values its author thought to assert; this asserts every vector upstream # considered worth shipping, including the ones nobody here would have thought # of -- the ternary-value and inexact-flag contracts, the rounding of the two # components INDEPENDENTLY, the underflow/overflow boundaries, and the # double-rounding cases tests/double_rounding.c exists for. # # --------------------------------------------------------------------------- # WHY EVERY ONE OF THESE IS EXPECTED TO PASS, WITH NO ARM-DEPENDENT ROW # # mpc's contract, like mpfr's beneath it, is CORRECT ROUNDING: at a stated # precision and rounding mode the result of each operation is uniquely # determined by the value being approximated. It is not a function of word size, # limb width, compiler or version. So unlike a captured native control -- where # some rows legitimately differ between the arms and have to be asserted # separately (80-mpfr.test's MPV- rows) -- there is no such class here: the # reference vectors are the mathematically correct answers, and a wasm32 build # that disagrees with any of them is wrong, not merely different. # # This is what makes the pass criterion flat: 74 run, 74 pass. A red is a real # defect in the port, the arm, or the arithmetic beneath it -- never a platform # difference to be explained away. # # THE ONE THING THAT IS NOT ARITHMETIC. tio_str drives mpc_inp_str/mpc_out_str # over real FILE* streams and writes a scratch file through a relative path, so # it is the only programme here whose result depends on the filesystem rather # than the numerics. run-ptest gives it a writable working directory for exactly # that reason (measured: with a read-only cwd it fails rc=1, "Could not open file # mpc_test in write mode"), while the vectors stay on the read-only rootfs and # are addressed through srcdir. If this suite ever goes red at t-tio_str alone, # read it as an environment finding, not an arithmetic one. # # --------------------------------------------------------------------------- # SPAWN BUDGET IS THE CONSTRAINT, WHICH IS WHY THE HARNESS RUNS ONCE # # 74 programmes is 74 fresh wasm module instantiations. The whole suite measures # 12.4 s natively; on this arm the instantiations alone dominate that several # times over. So the file runs ptest-runner ONCE, reads back the PASS:/FAIL: # lines it collected, and reports from a shell loop that spawns nothing -- # printf and `test` are ash builtins, and the parse below is a `while read` # rather than a per-case command substitution. ptestdir=/usr/lib/libmpc/ptest runner=/usr/bin/ptest-runner hdr=/usr/include/mpc.h lib=/usr/lib/libmpc.a # Upstream's own counts, from the 1.3.1 tarball the recipe fetches # (sha256 ab642492f5cf...): check_PROGRAMS names 74, EXTRA_DIST ships 44 .dat # data sets and 59 .dsc descriptions. want_progs=74 want_dat=44 want_dsc=59 # Below this file's BST-TIMEOUT on purpose, so an overrun is reported by # ptest-runner in its own voice instead of this whole file being killed around # it -- the arrangement 77-libpcre.test uses. runner_t=1000 tmp=${TMPDIR:-/tmp}/bst-libmpc.$$ mkdir -p "$tmp" 2>/dev/null || tmp=/tmp # ----------------------------------------------------------- what shipped ---- # The -dev/-staticdev half. mpc installs no binary and no shared object: the # distro is static-only, so libmpc.a IS the library, exactly as for gmp and mpfr. check_rc libmpc/hdr 0 test -s "$hdr" check_rc libmpc/ar 0 test -s "$lib" check_rc libmpc/no-so 1 test -e /usr/lib/libmpc.so # NO pkg-config FILE IS ASSERTED, because mpc ships none -- verified against the # upstream install, where gmp.pc and mpfr.pc appear beside it and mpc.pc does # not. Asserting one would be the gmp.h trap in reverse: a red on a perfectly # good port, for a file upstream never had. check_rc libmpc/no-pc 1 test -e /usr/lib/pkgconfig/mpc.pc # The ptest payload the bbappend stages. check_rc libmpc/ptest-dir 0 test -d "$ptestdir" check_rc libmpc/ptest-script 0 test -x "$ptestdir/run-ptest" check_rc libmpc/ptest-progs 0 test -d "$ptestdir/progs" check_rc libmpc/ptest-vectors 0 test -d "$ptestdir/tests" # Counted by glob expansion rather than `ls | wc -l`, which would fork twice per # count. A short count is the failure this asserts against: the bbappend derives # its list from upstream's check_PROGRAMS and bbfatals on a missing binary, so a # disagreement here means something was lost after do_install_ptest. set -- "$ptestdir"/progs/* check_eq libmpc/prog-count "$want_progs" "$#" set -- "$ptestdir"/tests/*.dat check_eq libmpc/dat-count "$want_dat" "$#" set -- "$ptestdir"/tests/*.dsc check_eq libmpc/dsc-count "$want_dsc" "$#" # ------------------------------------------------------- run it, once --------- # The harness is preferred wherever it exists, because this ticket closes on the # suite run UNDER ptest-runner -- its discovery and its tally are part of what is # asserted. The fallback runs the identical script directly and SKIPS only the # cases that are about the harness itself; they have no subject on an image that # ships no ptest-runner. out=$tmp/runner.out if [ -x "$runner" ]; then bst_ok libmpc/ptest-runner-present "$runner" -t "$runner_t" libmpc > "$out" 2>&1 rc=$? check_eq libmpc/ptest-runner-rc 0 "$rc" # ptest-runner's own framing, read back from the same capture. begin=; end=; tally=; rerr= while read -r k v; do case "$k" in BEGIN:) begin=$v ;; END:) end=$v ;; TOTAL:) tally="$k $v" ;; ERROR:) rerr="$v" ;; esac done < "$out" check_eq libmpc/runner-begin "$ptestdir" "$begin" check_eq libmpc/runner-end "$ptestdir" "$end" check_eq libmpc/runner-no-error "" "$rerr" else bst_skip libmpc/ptest-runner-present "this image ships no ptest-runner" bst_skip libmpc/ptest-runner-rc "no ptest-runner to run" for c in runner-begin runner-end runner-no-error; do bst_skip "libmpc/$c" "harness cases have no subject without ptest-runner" done ( cd "$ptestdir" && sh ./run-ptest ) > "$out" 2>&1 fi # ------------------------------------- one case per upstream programme -------- # A single `while read` over the capture: no fork per case, and every programme # upstream declared gets its own BST case so a red names the entry point that # broke rather than just the suite. npass=0 nfail=0 while read -r verdict name _rest; do case "$verdict" in PASS:) bst_ok "libmpc/t-$name"; npass=$((npass + 1)) ;; FAIL:) bst_notok "libmpc/t-$name" "upstream check programme failed"; nfail=$((nfail + 1)) ;; esac done < "$out" # The tally is asserted separately from the individual cases, because the two # fail differently: a red above is one broken entry point, whereas a short total # means programmes never ran at all -- a truncated capture, a harness timeout, or # a scratch directory the run could not create. Without this, a run that produced # three PASS lines and died would read as three green cases and nothing else. check_eq libmpc/suite-total "$want_progs" "$((npass + nfail))" check_eq libmpc/suite-failures 0 "$nfail" rm -rf "$tmp"