. "$BST_LIB" require ls coreutils/present tmp=${TMPDIR:-/tmp}/bst-coreutils.$$ printf 'gamma\nalpha\nbeta\n' > "$tmp" check_out coreutils/cat "alpha" cat "$tmp" check_out coreutils/sort-first "alpha" sh -c "sort '$tmp' | head -1" check_out coreutils/wc-lines "3" sh -c "wc -l < '$tmp' | tr -d ' '" check_out coreutils/ls-root "bin" ls / # checksum determinism: same input hashes identically across two runs if command -v sha256sum >/dev/null 2>&1; then d1=$(sha256sum "$tmp" | cut -d' ' -f1) d2=$(sha256sum "$tmp" | cut -d' ' -f1) check_eq coreutils/sha256-deterministic "$d1" "$d2" else bst_skip coreutils/sha256 "sha256sum not installed on this image" fi rm -f "$tmp" # The GMP-linked tools. factor and expr are the only coreutils binaries that link # libgmp, and multi-limb inputs are what drive its recursive mpn web — the shape # whose escape walk the coroutinize pass could not bound, leaving them unlinkable # and excluded from the image. They are back, so exercise them past one limb: # a bare `factor 91` stays inside a single word on wasm32 and proves nothing. if [ -x /usr/bin/factor ]; then # 2^64+1 = 274177 * 67280421310721 — four limbs at 32-bit, so the Pollard-rho # path runs in mpn rather than the single-word fast path. check_out coreutils/factor-multilimb "18446744073709551617: 274177 67280421310721" \ /usr/bin/factor 18446744073709551617 else bst_skip coreutils/factor-multilimb "factor not installed on this image" fi if [ -x /usr/bin/expr ]; then # Past 2^64, so the addition is arbitrary-precision in GMP, not native. check_out coreutils/expr-bignum "100000000000000000000" \ /usr/bin/expr 99999999999999999999 + 1 else bst_skip coreutils/expr-bignum "expr not installed on this image" fi