#!/usr/bin/env bash # Build and run the C++ test suite in Debian 13, because the Void dev host # cannot: protobuf 35 removed google/protobuf/map_field_inl.h, which the # database's generated protos include, so libsmartbotic-db-client neither # compiles nor links there. # # Runs smartbotic-database inside the same container, so the ApiFixture # integration tests actually execute instead of GTEST_SKIP()ing. # # packaging/devstack/run-tests.sh # whole suite # packaging/devstack/run-tests.sh 'ApiFixture.*' # a ctest -R filter set -euo pipefail REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" BASE_IMAGE="${BASE_IMAGE:-smartbotic-vectorapi-build-base:debian13}" DEB_REPO_DIR="${DEB_REPO_DIR:-/data/dev/smartbotics/smartbotics-deb-repo}" DB_DEB="${DB_DEB:-$DEB_REPO_DIR/dist/smartbotic-database_2.12.0-1_amd64.deb}" # The base image pins a client version; tests must compile against the same one # the release does, so the dev package is installed here rather than assumed. CLIENT_DEV_DEB="${CLIENT_DEV_DEB:-$DEB_REPO_DIR/dist/libsmartbotic-db-client-dev_2.12.0-1_amd64.deb}" CLIENT_DEB="${CLIENT_DEB:-$DEB_REPO_DIR/dist/libsmartbotic-db-client_2.12.0-1_amd64.deb}" FILTER="${1:-}" # BUILD_RUNNER=ON also builds and tests the QuickJS runner. Off by default # because it vendors QuickJS from GitHub at configure time. BUILD_RUNNER="${BUILD_RUNNER:-OFF}" docker image inspect "$BASE_IMAGE" >/dev/null 2>&1 || { echo "base image $BASE_IMAGE missing; build it with packaging/build.sh --rebuild-base" >&2 exit 1 } [[ -f "$DB_DEB" ]] || { echo "database deb not found: $DB_DEB" >&2; exit 1; } # The build tree is kept inside the container (a named volume) rather than in # the repo: objects built against Debian's toolchain must never be mixed with # whatever the host left in build/. docker run --rm \ -v "$REPO:/src:ro" \ -v svapi-testbuild:/build \ -v "$DB_DEB:/tmp/db.deb:ro" \ -v "$CLIENT_DEB:/tmp/client.deb:ro" \ -v "$CLIENT_DEV_DEB:/tmp/client-dev.deb:ro" \ -e "CTEST_FILTER=$FILTER" \ -e "BUILD_RUNNER=$BUILD_RUNNER" \ "$BASE_IMAGE" bash -euo pipefail -c ' apt-get update -qq >/dev/null apt-get install -y -qq --no-install-recommends \ /tmp/client.deb /tmp/client-dev.deb /tmp/db.deb >/dev/null 2>&1 || \ dpkg -i /tmp/client.deb /tmp/client-dev.deb /tmp/db.deb >/dev/null 2>&1 || true mkdir -p /var/lib/smartbotic-database /usr/bin/smartbotic-database --config /etc/smartbotic-database/config.json >/tmp/db.log 2>&1 & for i in $(seq 1 60); do (exec 3<>/dev/tcp/127.0.0.1/9004) 2>/dev/null && break sleep 1 done (exec 3<>/dev/tcp/127.0.0.1/9004) 2>/dev/null || { echo "database never came up:"; tail -20 /tmp/db.log; exit 1; } cmake -B /build -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DBUILD_TESTS=ON -DBUILD_WEBUI=OFF \ -DBUILD_RUNNER="${BUILD_RUNNER}" -S /src cmake --build /build -j"$(nproc)" if [[ -n "${CTEST_FILTER:-}" ]]; then ctest --test-dir /build --output-on-failure -R "$CTEST_FILTER" else ctest --test-dir /build --output-on-failure fi '