. "$BST_LIB" # BST-TIMEOUT: 300 # measured elapsed=22s (38 cases) on the local build host, # # 2026-08-19; 300 keeps ~13x headroom, which this suite # # wants because the scan entry point is held at -O0 (see # # below). The ==BST-SUITE== line # # reports what it actually spent -- take the number off a # # run, not from here. # zbar 0.23.1+git (meta-oe recipes-support/zbar, SRCREV 89e7900d) -- the ZBar # bar-code reader: a scanner and decoder for EAN-13/UPC-A, UPC-E, EAN-8, # Code 128/93/39, Codabar, Interleaved 2 of 5, QR and SQ Code. # # WHAT SHIPS, AND WHY THAT DICTATES A PROBE. This port installs libzbar.a, # zbar.h and zbar.pc and NO EXECUTABLE. zbarimg reads every image through # ImageMagick's MagickWand and has no other loader, so upstream builds it only # `if HAVE_MAGICK'; ImageMagick is not on this image, and with video off too, # bin_PROGRAMS stays empty. Without a cross-linked consumer this suite could # assert only that three files exist -- which passes just as happily against an # archive whose every decoder answers WRONGLY, and answering wrongly, not # crashing, is exactly how a bar-code reader fails. /usr/libexec/zbar-tests/ # zbar-probe is recipes-support/zbar/zbar/zbar_probe.c linked in-recipe against # the very libzbar.a that ships. # # THE ORACLE IS A NATIVE x86-64 BUILD OF THE IDENTICAL SRCREV, and unlike its # neighbours in the 57- range this port had no reason to hesitate about that. # 57-libvorbis.test and 57-speexdsp.test refuse a stored cross-machine digest # and 57-libopus.test pins one observed on target, because all three decode # through floating-point synthesis whose last ulp moves with the FPU. Bar-code # decoding is not that: the scanner thresholds integer sample runs and the # decoders are table lookups over run-length ratios, so there is no accumulation # for an FMA or a libm difference to move. The QR and SQ readers do use floats # for the perspective transform, which is why those two fixtures are in the # byte-exact comparison rather than exempted from it -- if anything here is # going to drift it is them, and the suite should be what says so. # # THE COMPARISON IS LAYERED, so a red says WHICH WAY it moved: # # zbar/native-identical the whole transcript byte for byte -- the bar the # ticket asks for, and what this port achieves # zbar/native-structural the decoded symbols alone (type and payload), with # image geometry and the version line dropped. A red # HERE is a real decode defect and cannot be blamed # on a fixture regeneration # zbar/sym- one case per symbology, with the expected payload # written out HERE rather than read from the # reference, so a regenerated reference cannot move # the meaning of the test in silence # # READING A RED. native-structural red => the decoder is wrong on this arm and # nothing excuses it. native-identical red with structural green => the geometry # or version line moved, which is a recipe or fixture change, not a decode # defect. A single sym-* red with the rest green localises the failure to one # decoder, which is the whole reason they are enumerated. # # TWO CASES ARE EXPECTED RED, AND THEY ARE ATTRIBUTED RATHER THAN SKIPPED. # zbar/qr-binary-len and zbar/qr-binary-head fail on this arm because # zbar_scan_image finds NO symbol in upstream's examples/qr-code-binary.png -- # silently, nsym=0, no trap -- while x86-64 (at -O2 AND -O0, byte-identical # transcripts) and i386 both decode its 298-byte payload. That is # https://brintos.io/brintos/hwjs-cc/issues/75. zbar/native-identical and # zbar/native-structural go red with them, since the missing line is part of the # transcript they compare. The plain QR fixture decodes correctly, so the QR # locator and decoder work in general; the two fixtures differ in BOTH payload # mode and symbol version, and which of those matters is not established. # # They are left FAILING on purpose. A skip would make the suite green and throw # away the regression signal: these four flip green on their own the day #75 # lands, which is the whole reason the suite exists. # # SEPARATELY, img_scanner.c ALONE IS HELD AT -O0 by a source pragma the bbappend # patches in (BRINTOS-WORKAROUND: hwjs-cc#74); the rest of the library builds at # the distro's -O2. Optimised, _zbar_scan_image traps on every image and this # entire suite is red below zbar/probe-rc. If that is what you are looking at, # the workaround has been dropped rather than the port having regressed. # # THE FIXTURES ARE MOSTLY UPSTREAM'S OWN. examples/*.png, converted to binary # PGM (P5 -- Y800 with a text header) on x86-64 by src/zbar_mkfixtures.py, # because this port builds no PNG reader. Three are not upstream's, and each # exists because the corpus could not otherwise cover something: # # zbar-upc-e.pgm upstream ships no UPC-E sample at all # zbar-ean-13p.pgm upstream's ean-13.png carries a 978 prefix, so zbar's ISBN # add-on claims it and reports ISBN-13 -- correct, and it # leaves the EAN-13 type name asserted by nothing # zbar-blank.pgm a uniform white field: the negative control. A corpus of # readable barcodes cannot pin the not-found path, and # not-found is a result this library has to get right # # and zbar-ean-13.jpg is the same EAN-13 raster as JPEG, driving zbar/jpeg.c -- # the --with-jpeg arm. The ticket asked for that option so zbarimg could read # samples; that is not what it does (zbarimg does not exist here and never read # JPEG itself), but the option is still load-bearing for the library's own # zbar_image_convert() path, and this is the fixture that proves it. R=${BST_ZBAR_ROOT:-} tmp=${TMPDIR:-/tmp} TESTDIR=${BST_ZBAR_TESTDIR:-$R/usr/libexec/zbar-tests} LIBDIR=$R/usr/lib INCDIR=$R/usr/include PROBE=$TESTDIR/zbar-probe NATIVE=$BST_DATA/zbar-native.txt # --- what ships ------------------------------------------------------------- if [ -f "$LIBDIR/libzbar.a" ]; then bst_ok zbar/staticlib else bst_notok zbar/staticlib "no $LIBDIR/libzbar.a" fi if [ -f "$INCDIR/zbar.h" ]; then bst_ok zbar/header else bst_notok zbar/header "no $INCDIR/zbar.h" fi if [ -f "$LIBDIR/pkgconfig/zbar.pc" ]; then bst_ok zbar/pkgconfig else bst_notok zbar/pkgconfig "no $LIBDIR/pkgconfig/zbar.pc" fi # Shape, not absence: this arm converts to shared libraries per recipe # (BRINTOS-1740), so a .so here is a conversion, not a policy breach. bst_lib_shape zbar/no-shared "$LIBDIR/libzbar.so*" # THE TWO MUST-NOT-SHIP ABSENCES. These are not tidiness: they are the assertion # that PACKAGECONFIG took. If zbarimg ever appears without imagemagick having # been added deliberately, something has re-enabled Magick autodetection; if # zbarcam appears, the `video' weak default has won again and this image has # grown a v4l dependency for a camera it does not have. if [ ! -e "$R/usr/bin/zbarimg" ]; then bst_ok zbar/no-zbarimg else bst_notok zbar/no-zbarimg "zbarimg shipped -- Magick was enabled without the port being revisited" fi if [ ! -e "$R/usr/bin/zbarcam" ]; then bst_ok zbar/no-zbarcam else bst_notok zbar/no-zbarcam "zbarcam shipped -- the 'video' PACKAGECONFIG default won again" fi if [ -f "$NATIVE" ]; then bst_ok zbar/native-ref-present else bst_notok zbar/native-ref-present "no $NATIVE -- every comparison below would be vacuous" fi # --- stage the probe -------------------------------------------------------- # do_install ships it 0755, but the rootfs is read-only at browser runtime and # the /tmp tmpfs is mounted without noexec, so it is copied and re-marked there. probe=$tmp/bst-zbar-probe.$$ if [ -f "$PROBE" ] && cp "$PROBE" "$probe" 2>/dev/null && chmod +x "$probe" 2>/dev/null; then bst_ok zbar/probe-stage else bst_notok zbar/probe-stage "cannot stage $PROBE" rm -f "$probe" return 0 2>/dev/null || exit 0 fi out=$tmp/bst-zbar-out.$$ err=$tmp/bst-zbar-err.$$ "$probe" "$BST_DATA" > "$out" 2>"$err"; prc=$? # The probe's last `probe-begin' breadcrumb names the fixture it was scanning # when it stopped, which is the one thing a reader of a red run needs and the # one thing a lost stdout buffer cannot supply. if [ "$prc" -eq 0 ]; then bst_ok zbar/probe-rc else bst_notok zbar/probe-rc "probe exited $prc, last: $(_bst_1line "$(tail -n 1 "$err" 2>/dev/null)")" fi rm -f "$err" # A transcript that stopped early would otherwise let every extraction below # compare an empty string to an empty string and report green. if [ -s "$out" ] && grep -q '^ZBAR-PROBE-END$' "$out"; then bst_ok zbar/probe-complete else bst_notok zbar/probe-complete "transcript has no ZBAR-PROBE-END: $(_bst_1line "$(tail -n 2 "$out" 2>/dev/null)")" fi # --- the fixtures and the walk arithmetic, without entering the scanner ------ # These are what separate "the port is miscompiled" from "the payload never # arrived". --dump reads a fixture, walks the raster linearly, and then re-runs # img_scanner.c's OWN movedelta walk -- row and column, character for character # -- in the probe's translation unit. Three sums that agree with each other and # with x86-64 say the fixture shipped intact and the walk arithmetic is right on # this arm, which is exactly the control hwjs-cc#74 rests on. They stay green # while the scan is broken, and that is the point: without them a reader of a # red run cannot tell a codegen fault from a missing data file. d=$("$probe" --dump "$BST_DATA/zbar-ean-13.pgm" 2>/dev/null); drc=$? check_eq zbar/dump-rc 0 "$drc" check_eq zbar/dump-geom "dump geom w=226 h=100 len=22600" \ "$(printf '%s\n' "$d" | grep '^dump geom ')" check_eq zbar/walk-linear "dump linear-sum=3630867" "$(printf '%s\n' "$d" | grep '^dump linear-sum=')" check_eq zbar/walk-row "dump rowwalk-sum=3630867" "$(printf '%s\n' "$d" | grep '^dump rowwalk-sum=')" check_eq zbar/walk-col "dump colwalk-sum=3630867" "$(printf '%s\n' "$d" | grep '^dump colwalk-sum=')" # --- the whole transcript, byte for byte ------------------------------------ if cmp -s "$out" "$NATIVE"; then bst_ok zbar/native-identical else d=$(diff "$out" "$NATIVE" 2>/dev/null | grep -c '^<') bst_notok zbar/native-identical "$d transcript lines differ from the x86-64 control" fi # The decoded symbols alone: geometry and the version line dropped, so this # survives a fixture regenerated at a different size and fails only on a decode # that actually changed. grep '^sym ' "$out" > "$tmp/bst-zbar-s1.$$" 2>/dev/null grep '^sym ' "$NATIVE" > "$tmp/bst-zbar-s2.$$" 2>/dev/null if [ -s "$tmp/bst-zbar-s1.$$" ] && cmp -s "$tmp/bst-zbar-s1.$$" "$tmp/bst-zbar-s2.$$"; then bst_ok zbar/native-structural else bst_notok zbar/native-structural "$(_bst_1line "$(diff "$tmp/bst-zbar-s1.$$" "$tmp/bst-zbar-s2.$$" 2>/dev/null | head -n 4)")" fi rm -f "$tmp/bst-zbar-s1.$$" "$tmp/bst-zbar-s2.$$" # --- one case per symbology ------------------------------------------------- # The expected values are written out here rather than read from the reference, # so regenerating the reference cannot silently change what this suite means. # _zbar_sym prints " " for a fixture's first symbol. _zbar_sym() { awk -v f="$1" '$1=="sym" && $2==f && $3=="0" { t=""; d=""; for (i = 4; i <= NF; i++) { if (substr($i,1,5) == "type=") t = substr($i,6); if (substr($i,1,5) == "data=") { d = substr($0, index($0,"data=") + 5); break } } print t " " d; exit }' "$out" } check_eq zbar/sym-isbn-13 "ISBN-13 9789876543217" "$(_zbar_sym zbar-ean-13.pgm)" check_eq zbar/sym-ean-13 "EAN-13 1234567890128" "$(_zbar_sym zbar-ean-13p.pgm)" check_eq zbar/sym-ean-8 "EAN-8 98765430" "$(_zbar_sym zbar-ean-8.pgm)" check_eq zbar/sym-upc-a "UPC-A 987654321012" "$(_zbar_sym zbar-upc-a.pgm)" check_eq zbar/sym-upc-e "UPC-E 01234565" "$(_zbar_sym zbar-upc-e.pgm)" check_eq zbar/sym-code-128 "CODE-128 https://github.com/mchehab/zbar" "$(_zbar_sym zbar-code-128.pgm)" check_eq zbar/sym-code-93 "CODE-93 ZBAR-9876543210" "$(_zbar_sym zbar-code-93.pgm)" check_eq zbar/sym-code-39 "CODE-39 ZBAR-9876543210" "$(_zbar_sym zbar-code-39.pgm)" check_eq zbar/sym-codabar "Codabar A9876543210B" "$(_zbar_sym zbar-codabar.pgm)" check_eq zbar/sym-i2-5 "I2/5 9876543210" "$(_zbar_sym zbar-i2-5.pgm)" check_eq zbar/sym-qrcode "QR-Code https://github.com/mchehab/zbar" "$(_zbar_sym zbar-qr-code.pgm)" check_eq zbar/sym-databar "DataBar 0198765432109879" "$(_zbar_sym zbar-databar.pgm)" # THE JPEG ARM. Same raster as zbar-ean-13.pgm, so an identical payload here is # the statement that zbar/jpeg.c reproduced the image the decoder needs -- which # is the whole of what --with-jpeg buys this port. check_eq zbar/sym-jpeg "ISBN-13 9789876543217" "$(_zbar_sym zbar-ean-13.jpg)" # The two 2-D payloads are long (298 escaped bytes and 6144) and are covered in # full by native-identical above; here they are pinned by length and head, which # is enough to localise a red to the symbology without a 6 kB literal. _zbar_len() { awk -v f="$1" '$1=="sym" && $2==f {for(i=4;i<=NF;i++) if(substr($i,1,4)=="len=") {print substr($i,5); exit}}' "$out"; } check_eq zbar/qr-binary-len 298 "$(_zbar_len zbar-qr-binary.pgm)" check_eq zbar/sqcode-len 6144 "$(_zbar_len zbar-sqcode.pgm)" check_eq zbar/qr-binary-head "QR-Code \\xc2\\x89PNG" "$(_zbar_sym zbar-qr-binary.pgm | cut -c1-19)" # --- the not-found path ----------------------------------------------------- # A corpus of readable barcodes says nothing about the result this library has # to get right when there is no symbol. --scan-one mirrors zbarimg's own status # convention (zbarimg.c: num_images && notfound -> exit 4). nsym=$(awk '$1=="scan" && $2=="zbar-blank.pgm" {for(i=3;i<=NF;i++) if(substr($i,1,5)=="nsym=") {print substr($i,6); exit}}' "$out") check_eq zbar/blank-nsym 0 "$nsym" "$probe" --scan-one "$BST_DATA/zbar-ean-13.pgm" >/dev/null 2>&1 check_eq zbar/rc-found 0 "$?" "$probe" --scan-one "$BST_DATA/zbar-blank.pgm" >/dev/null 2>&1 check_eq zbar/rc-notfound 4 "$?" # An unreadable fixture must be distinguishable from a clean not-found, or a # missing payload would read as "there was no barcode in it". "$probe" --scan-one "$BST_DATA/zbar-no-such-fixture.pgm" >/dev/null 2>&1 check_eq zbar/rc-unreadable 2 "$?" # --- version ---------------------------------------------------------------- check_eq zbar/version "version 0.23.1" "$(grep '^version ' "$out" | head -n 1)" rm -f "$probe" "$out" "$err"