# BST-TIMEOUT: 300 # measured 25 s on target 2026-08-12 (52 cases, of which 25 # # are fresh wasm module instantiations). A marker is needed # # even so: the runner's own default is 60 s, and 25 s is an # # idle-host number. 300 is ~12x the measurement and is what # # the ticket gates and the nightly pass anyway, so this # # suite never needs a caller to treat it specially. . "$BST_LIB" # avro-c 1.11.3 -- the Apache Avro C implementation: schema-driven binary # serialisation. A schema is JSON; values are written and read as a compact # binary encoding, either bare or inside an Avro CONTAINER FILE that carries its # own schema in the header and compresses its blocks (deflate here, and lzma; # snappy is not in the image). Four tools come with the library -- avrocat dumps # a container file as JSON, avropipe as a path/value tree, avromod rewrites one # with a different codec or block size, avroappend adds records to one. # See avro-c_%.bbappend for what the port adds and why. # # --------------------------------------------------------------------------- # WHAT THIS SUITE IS, AND WHY IT IS NOT A PROBE # # It closes on the PACKAGE'S OWN UPSTREAM SUITE. avro-c registers 25 entries with # CTest -- 24 from lang/c/tests and quickstop from lang/c/examples -- and the # bbappend stages exactly what the generated CTestTestfile.cmake tree declares, # so what runs here is upstream's suite and not our reading of it. # # The native reference for this configuration (deflate + lzma, no snappy, which # is what the recipe's DEPENDS resolves to) is 25/25 in 0.33 s, taken before any # wasm32 build was spent -- with AND without the shared library, so the # static-only arm is not itself a variable. # # What those 25 cover, in upstream's own grouping: # # test_avro_schema the JSON schema parser against upstream's corpus: # 28 schemas that must parse, 12 that must be # rejected. # test_avro_commons_schema the CROSS-LANGUAGE corpus -- schema.json + data.avro # written by another Avro implementation and read back # here. The only entry that proves interoperability # rather than self-consistency. # test_avro_values the value interface over every type. # test_avro_data the deprecated datum interface, likewise. # test_avro_ fifteen regressions, one per upstream JIRA defect. # test_data_structures the internal st/map/array containers. # test_refcount reference counting on schemas and values. # quickstop the tutorial end to end: write a container file with # the deflate codec, read it back, query it twice. # # --------------------------------------------------------------------------- # THE FOUR TOOLS ARE COVERED HERE AND NOWHERE ELSE # # Upstream registers no test for avrocat, avropipe, avromod or avroappend -- the # suite exercises the library through its own C programmes. They are the part of # this package a user actually types, so this file drives each one over a staged # fixture and asserts what it prints. That is the "drive the tool by hand once" # half of the port, made repeatable. ptestdir=/usr/lib/avro-c/ptest runner=/usr/bin/ptest-runner # Upstream's own counts for this arm, as staged by do_install_ptest out of the # generated CTestTestfile.cmake tree. Asserted rather than assumed: a suite that # is silently shorter than upstream declared reads exactly like a suite that # passed. want_total=25 # CTest entries: 24 from tests/, 1 (quickstop) from examples/ want_pass_schemas=28 # schema_tests/pass -- must parse want_fail_schemas=12 # schema_tests/fail -- must be rejected tmp=${TMPDIR:-/tmp}/bst-avro-c.$$ mkdir -p "$tmp" 2>/dev/null || tmp=/tmp # ----------------------------------------------------------- what shipped ---- # The four tools. Like augeas and unlike the recent library ports, the MAIN # package here is part of the point. check_rc avro-c/avrocat 0 test -x /usr/bin/avrocat check_rc avro-c/avropipe 0 test -x /usr/bin/avropipe check_rc avro-c/avromod 0 test -x /usr/bin/avromod check_rc avro-c/avroappend 0 test -x /usr/bin/avroappend # The library half. Static-only arm: libavro.a IS the library. check_rc avro-c/ar 0 test -s /usr/lib/libavro.a # The standing static-only invariant. It is asserted here for a sharper reason # than usual: upstream builds the shared libavro UNCONDITIONALLY and this port # carries the patch that makes BUILD_SHARED_LIBS switch it off, so this case is # the patch's regression guard as much as the distro's. check_rc avro-c/no-so 1 test -e /usr/lib/libavro.so check_rc avro-c/hdr 0 test -s /usr/include/avro.h check_rc avro-c/hdr-dir 0 test -d /usr/include/avro check_rc avro-c/pc 0 test -s /usr/lib/pkgconfig/avro-c.pc # ------------------------------------------------------- the ptest payload ---- check_rc avro-c/ptest-dir 0 test -d "$ptestdir" check_rc avro-c/ptest-script 0 test -x "$ptestdir/run-ptest" check_rc avro-c/ptest-list 0 test -s "$ptestdir/tests-list" check_rc avro-c/ptest-progs 0 test -d "$ptestdir/progs" # The staged payload mirrors the SOURCE REPOSITORY's shape, because # test_avro_commons_schema resolves its corpus as the literal relative path # ../../../share/test/data/schemas from its working directory. If that tree is # missing the test exits EXIT_FAILURE, so this assertion only makes the cause # legible -- it does not turn a silent pass into a red. check_rc avro-c/ptest-tests-dir 0 test -d "$ptestdir/data/lang/c/tests" check_rc avro-c/ptest-examples 0 test -d "$ptestdir/data/lang/c/examples" check_rc avro-c/ptest-commons 0 test -d "$ptestdir/data/share/test/data/schemas" # The schema corpus, counted by glob expansion rather than `ls | wc -l`, which # would fork twice. A short corpus would leave test_avro_schema passing over # fewer schemas with nothing saying so -- the same silent-shrink failure the # suite-total assertion guards at the other end. set -- "$ptestdir"/data/lang/c/tests/schema_tests/pass/* check_eq avro-c/pass-schema-count "$want_pass_schemas" "$#" set -- "$ptestdir"/data/lang/c/tests/schema_tests/fail/* check_eq avro-c/fail-schema-count "$want_fail_schemas" "$#" set -- "$ptestdir"/progs/* check_eq avro-c/prog-count "$want_total" "$#" if [ -x "$runner" ]; then bst_ok avro-c/ptest-runner-present else bst_skip avro-c/ptest-runner-present "this image ships no ptest-runner" fi # --------------------------------------------------------------- the tools ---- # avrocat dumps a container file as one JSON record per line. The fixture is # upstream's own avro-1237-good.avro: a two-record file whose schema is a union, # so this also says the union discriminant is read correctly. check_out avro-c/avrocat-json '{"int": 100}' avrocat "$ptestdir/data/lang/c/tests/avro-1237-good.avro" # avropipe walks the same file as a path/value tree. Same data, different reader # path through the library -- the value interface rather than the JSON writer. check_out avro-c/avropipe-path '/1/int' avropipe "$ptestdir/data/lang/c/tests/avro-1237-good.avro" # avromod rewrites a container file with a different codec, which is the only # tool that exercises the WRITE path plus a codec. The rootfs is read-only at # browser runtime, so the fixture is copied somewhere writable first. cp "$ptestdir/data/lang/c/tests/avro-1279-no-codec.avro" "$tmp/in.avro" 2>/dev/null if [ -s "$tmp/in.avro" ]; then if avromod --codec=deflate "$tmp/in.avro" "$tmp/out.avro" >/dev/null 2>&1 && [ -s "$tmp/out.avro" ]; then bst_ok avro-c/avromod-deflate else bst_notok avro-c/avromod-deflate "avromod --codec=deflate produced no output file" fi # ...and the rewritten file has to still read back to the same records, which # is what makes the codec claim mean something. check_out avro-c/avromod-roundtrip 'MAX VALUES' avrocat "$tmp/out.avro" else bst_notok avro-c/avromod-deflate "cannot stage the fixture into $tmp" bst_notok avro-c/avromod-roundtrip "cannot stage the fixture into $tmp" fi # --------------------------------------- the one test that can pass vacuously ---- # test_avro_commons_schema walks its corpus with readdir() and selects entries on # `dent->d_type == DT_DIR`. A filesystem that reports DT_UNKNOWN -- which readdir # is permitted to do, and which a guest filesystem is a plausible place to meet -- # would match nothing, walk zero schemas and still `return EXIT_SUCCESS`. It is # the only entry in the suite whose green says nothing when its input is missing, # so its work is counted here rather than assumed: two corpus directories # (simple, withUnion), each announced by upstream's own "Run test for path" line. # # The suite run below discards per-test output, as ptest-runner does, so this # drives the one programme again with its output captured. One extra exec, for # the assertion that a silent green cannot survive. if cp -a "$ptestdir/data/." "$tmp/" 2>/dev/null; then walked=$(cd "$tmp/lang/c/tests" && "$ptestdir/progs/test_avro_commons_schema" 2>&1 \ | grep -c "Run test for path") check_eq avro-c/commons-corpus-walked 2 "$walked" else bst_notok avro-c/commons-corpus-walked "cannot stage the fixtures into $tmp" fi # ------------------------------------------------- run upstream's own suite ---- # One run, one capture, then a `while read` that spawns nothing: printf and test # are ash builtins and the parse below is not a per-case command substitution. out=$tmp/suite.out sh "$ptestdir/run-ptest" > "$out" 2>&1 # THE EXPECTED REDS. There are none, and that is a MEASUREMENT rather than an # assumption: all 25 upstream entries pass on target (2026-08-12), which is # upstream's own native reference for this configuration reproduced exactly. So # the declared set is empty and any red here is a genuine regression -- in the # platform or in the port -- not a known gap that was quietly tolerated. # # It is asserted as a SET rather than a count for the usual reason: a red is # expected to arrive one day, and when it does, a second red appearing while a # first one is fixed must not cancel into a green tally. KNOWN_RED='' red_why() { case "$1" in *) echo "upstream CTest entry failed; no red is expected on this arm (25/25 on 2026-08-12)" ;; esac } npass=0 nfail=0 nskip=0 failed= while read -r verdict name _rest; do case "$verdict" in PASS:) bst_ok "avro-c/t-$name"; npass=$((npass + 1)) ;; FAIL:) bst_notok "avro-c/t-$name" "$(red_why "$name")"; nfail=$((nfail + 1)) failed="$failed $name" ;; SKIP:) bst_skip "avro-c/t-$name" "upstream self-skip"; nskip=$((nskip + 1)) ;; esac done < "$out" # The tallies are asserted separately from the individual cases because they fail # differently: a red above is one broken behaviour, whereas a short total means # entries never ran at all -- a truncated capture, a scratch directory the run # could not create, or a payload that lost files after do_install_ptest. Without # this, a run that produced three PASS lines and died would read as three green # cases and nothing else. check_eq avro-c/suite-total "$want_total" "$((npass + nfail + nskip))" # THE RED SET, NOT THE RED COUNT -- so a fixed platform gap and a newly broken # case cannot cancel out into a green tally. got=$(printf '%s\n' $failed | sort | tr '\n' ' ') want=$(printf '%s\n' $KNOWN_RED | sort | tr '\n' ' ') check_eq avro-c/known-red-set "$want" "$got" rm -rf "$tmp"