#!/bin/sh # Run avro-c's upstream test suite -- every entry cmake registered with CTest -- # and report one PASS:/FAIL: line each, which is the protocol ptest-runner reads. # # THIS IS NOT `ctest`, AND IT CANNOT BE. ctest needs cmake, the generated # CTestTestfile.cmake tree and the build directory; the image ships none of those # and the tree does not survive packaging. What ctest would do with these entries # is exactly what the loop below does -- chdir to the working directory the entry # declares, run the programme, exit status is the verdict -- so the suite's own # semantics are preserved while the harness around it is not. # # THE WORKING DIRECTORY IS PART OF EACH TEST, not a detail of the harness. Every # entry upstream registers is `cmake -E chdir `, and the tests use that # in three ways: they read fixtures from it by relative name (the six .avro files, # schema_tests/), they WRITE their outputs into it (test.db, copy.avro, # test-1379.avro, quickstop.db), and one of them -- test_avro_commons_schema -- # resolves the cross-language corpus as "../../../share/test/data/schemas", three # levels ABOVE it. So do_install_ptest staged the payload in the source # repository's own shape and recorded each test's directory relative to the # repository root; this script recreates that shape somewhere writable and runs # each entry in its own declared directory. # # WHY THE PAYLOAD IS COPIED RATHER THAN USED IN PLACE: the deployed rootfs is # read-only at browser runtime, and two thirds of these tests write into their # working directory. A read-only cwd would fail them all for a reason that has # nothing to do with avro. set -u pdir=$(cd "$(dirname "$0")" && pwd) [ -f "$pdir/tests-list" ] || { echo "FAIL: avro-c-ptest-setup (no tests-list; the ptest package is incomplete)" exit 1 } work=$(mktemp -d "${TMPDIR:-/tmp}/avro-c-ptest.XXXXXX" 2>/dev/null) \ || { work="${TMPDIR:-/tmp}/avro-c-ptest.$$"; mkdir -p "$work"; } [ -d "$work" ] || { echo "FAIL: avro-c-ptest-setup (no writable scratch dir)"; exit 1; } cp -a "$pdir/data/." "$work/" 2>/dev/null || { echo "FAIL: avro-c-ptest-setup (cannot stage the fixtures into $work)" rm -rf "$work" exit 1 } while read -r name rel; do [ -n "$name" ] || continue prog="$pdir/progs/$name" dir="$work/$rel" if [ ! -x "$prog" ]; then echo "FAIL: $name" continue fi if [ ! -d "$dir" ]; then echo "FAIL: $name" continue fi ( cd "$dir" && "$prog" ) >/dev/null 2>&1 if [ $? -eq 0 ]; then echo "PASS: $name" else echo "FAIL: $name" fi done < "$pdir/tests-list" cd / rm -rf "$work" # The per-test verdicts above are the report; ptest-runner tallies them itself # and a non-zero exit here would be counted a second time as a harness failure. exit 0