From 1d6b8489ce97c1de2a1c194f997c207208ce098d Mon Sep 17 00:00:00 2001 From: Martin Vidner Date: Thu, 28 Nov 2019 14:31:06 +0100 Subject: [PATCH] Better comments, TAP conformance This test has been quickly and dirtily converted to TAP, the Test Anything Protocol, http://testanything.org/tap-specification.html --- testsuite-real/CAUTION | 5 ++++- testsuite-real/run-all | 22 +++++++++++++++++----- testsuite-real/setup-and-run-all | 9 +++++++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/testsuite-real/CAUTION b/testsuite-real/CAUTION index ac0d3dc2..25c61065 100644 --- a/testsuite-real/CAUTION +++ b/testsuite-real/CAUTION @@ -7,7 +7,7 @@ The tests in this directory only work when run as the root user. They operate - on a scratch BTRFS filesystem (`/testsuite`) -- created in a loopback-mounted file (`/testsuite.img`), +- created in a loopback-mounted file (`/testsuite-of-snapper.img`), - using a scratch Snapper configuration (`testsuite`). However bugs do happen so it is recommended that you @@ -16,3 +16,6 @@ LOSS OR CORRUPTION OF YOUR OWN BTRFS SNAPSHOTS AND DATA. See `setup-and-run-all` for the scratch setup and `run-all` for the actual test set. + +The tests conform to the Test Anything Protocol (sloppily). +`prove setup-and-run-all` works. diff --git a/testsuite-real/run-all b/testsuite-real/run-all index 70afdfbd..d24075f3 100755 --- a/testsuite-real/run-all +++ b/testsuite-real/run-all @@ -6,19 +6,28 @@ if [ "$(id -u)" != "0" ]; then exit 1 fi +# This test has been quickly and dirtily converted to TAP, +# the Test Anything Protocol, http://testanything.org/tap-specification.html +COUNT=0 +SUCCESS=true + function run() { + COUNT=$((COUNT + 1)) cmd=$1 - echo - echo "*** running $cmd ***" - echo + echo >&2 + echo >&2 "*** running $cmd ***" + echo >&2 ./$cmd if [ $? != 0 ] ; then - echo "failed" - exit 1 + echo "not ok $COUNT $cmd" + SUCCESS=false + # exit 1 + else + echo "ok $COUNT $cmd" fi } @@ -45,3 +54,6 @@ test -x xattrs1 && run xattrs1 test -x xattrs2 && run xattrs2 test -x xattrs3 && run xattrs3 test -x xattrs4 && run xattrs4 + +echo "1..$COUNT" # TAP test plan +$SUCCESS diff --git a/testsuite-real/setup-and-run-all b/testsuite-real/setup-and-run-all index f3edd0dc..1e0485ae 100755 --- a/testsuite-real/setup-and-run-all +++ b/testsuite-real/setup-and-run-all @@ -1,6 +1,11 @@ #!/bin/bash -set -eu -set -x +set -e # exit on failure. +# ^ +# This also ensures that a failed test does not run the teardown step +# and we can inspect the artifacts. +set -u # unset variables are an error +set -x # echo what's being done + if [ "$(id -u)" != "0" ]; then set +x echo "These tests only work when run as root." >&2 -- 2.47.3