. "$BST_LIB" require mbuffer mbuffer/present # mbuffer 20140310 (meta-oe recipes-support) -- a buffered stream copy with rate # and progress reporting, built for the wasm32-hwjs glibc arm by BRINTOS-249. # # Everything past `present` is RED on this platform, and for a reason that is # reached before mbuffer parses a single option: main() calls # sysconf(_SC_AVPHYS_PAGES) and asserts the result is positive # (mbuffer.c:1872), while sysinfo(2) is ENOSYS here and glibc's # __get_avphys_pages ignores the failure and returns 0 (brintos/linux#26). So # EVERY mode aborts, including --version. The cases below are left failing on # purpose: each is a distinct user-visible capability that flips green on its # own the day #26 closes. # # There is a SECOND, independent blocker behind it, which is why fixing #26 # alone will not produce a working mbuffer: the tool is a reader thread plus a # writer thread around a ring buffer, and pthread_create returns 0 here for a # thread that never runs, with pthread_join dying in glibc's futex fatal # (brintos/linux-in-the-browser#85). That one cannot be asserted from this # suite -- mbuffer never gets far enough to spawn a thread -- so it is measured # in the ticket with a standalone probe and recorded here in prose only. t=${TMPDIR:-/tmp}/bst-mbuffer.$$ mkdir -p "$t" && cd "$t" || exit 0 # --- what does hold on this image --------------------------------------------- check mbuffer/path test -x /usr/bin/mbuffer # The control that makes every red below mean "sysinfo, not memory": the kernel # accounts memory correctly and publishes it -- only the syscall glibc uses to # read it is missing. Without this case a reader could reasonably conclude the # guest simply has no free memory to report. mt=$(awk '/^MemTotal:/{print $2}' /proc/meminfo 2>/dev/null) if [ -n "$mt" ] && [ "$mt" -gt 0 ] 2>/dev/null; then bst_ok mbuffer/meminfo-control else bst_notok mbuffer/meminfo-control "MemTotal unreadable or 0: '$mt'"; fi # --- the abort itself, pinned to its cause ------------------------------------ # Asserted separately from the capability cases below so that a future change of # behaviour is attributable: if this one flips green while the rest stay red, # the assert is gone but the tool still does not work. mbuffer --version > v.out 2> v.err; vrc=$? if grep -q "Assertion \`NumP > 0' failed" v.err 2>/dev/null; then bst_notok mbuffer/no-sysconf-abort "sysconf(_SC_AVPHYS_PAGES)=0 -> assert NumP>0 (brintos/linux#26)" else bst_ok mbuffer/no-sysconf-abort fi # --- capabilities, each red until #26 closes ----------------------------------- # Upstream prints "mbuffer version 20140302" (the tarball is dated 20140310 but # VERSION is 20140302) -- asserted against the string a working build emits. check_out mbuffer/version "mbuffer version 20140302" mbuffer --version # usage text, which upstream prints on --help with rc 0 check_out mbuffer/usage "usage: mbuffer" mbuffer --help # the core function: a byte-exact stream copy through the buffer printf 'hello-mbuffer' > small.in mbuffer -q < small.in > small.out 2>/dev/null if cmp -s small.in small.out 2>/dev/null; then bst_ok mbuffer/copy-stdin else bst_notok mbuffer/copy-stdin "stdin->stdout copy not byte-identical (brintos/linux#26)"; fi # a copy large enough to cycle the ring buffer rather than fit in one block dd if=/dev/urandom of=big.in bs=1k count=64 2>/dev/null mbuffer -q -s 4k -m 2M < big.in > big.out 2>/dev/null if cmp -s big.in big.out 2>/dev/null; then bst_ok mbuffer/copy-64k else bst_notok mbuffer/copy-64k "64k copy with -s 4k -m 2M not byte-identical (brintos/linux#26)"; fi # file arguments rather than redirection mbuffer -q -i big.in -o file.out 2>/dev/null if cmp -s big.in file.out 2>/dev/null; then bst_ok mbuffer/file-io else bst_notok mbuffer/file-io "-i/-o file copy not byte-identical (brintos/linux#26)"; fi # the summary mbuffer writes to stderr when not quiet mbuffer < small.in > /dev/null 2> sum.err if grep -q '^summary:' sum.err 2>/dev/null; then bst_ok mbuffer/summary else bst_notok mbuffer/summary "no summary: line on stderr (brintos/linux#26)"; fi # error paths: exit 1 with upstream's message, both measured against a native # x86_64 build of the same source mbuffer --no-such-option < /dev/null > /dev/null 2> bad.err; brc=$? if [ "$brc" = 1 ] && grep -q 'unknown option' bad.err 2>/dev/null; then bst_ok mbuffer/bad-option else bst_notok mbuffer/bad-option "rc=$brc want 1 with 'unknown option' (brintos/linux#26)"; fi mbuffer -q -i /no/such/file > /dev/null 2> noin.err; nrc=$? if [ "$nrc" = 1 ] && grep -q 'could not open input file' noin.err 2>/dev/null; then bst_ok mbuffer/missing-input else bst_notok mbuffer/missing-input "rc=$nrc want 1 with 'could not open input file' (brintos/linux#26)"; fi # --- the platform gap, witnessed without mbuffer ------------------------------- # busybox free reads sysinfo(2); procps free reads /proc/meminfo. Asserting the # disagreement directly means this suite still reports the root cause even if # mbuffer is one day removed from the image. bt=$(busybox free 2>/dev/null | awk '/^Mem:/{print $2}') if [ -n "$bt" ] && [ "$bt" -gt 0 ] 2>/dev/null; then bst_ok mbuffer/sysinfo-memtotal else bst_notok mbuffer/sysinfo-memtotal "busybox free (sysinfo(2)) reports total=$bt while /proc/meminfo reports $mt kB (brintos/linux#26)"; fi cd /; rm -rf "$t"