From 1e1d21c2a2266eff74db9d46fa7efd073fb44677 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 15 Oct 2026 18:19:25 +0500 Subject: add a couple of basic tests --- test/lib/test.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/lib/test.sh (limited to 'test/lib') diff --git a/test/lib/test.sh b/test/lib/test.sh new file mode 100644 index 0000000..56920a2 --- /dev/null +++ b/test/lib/test.sh @@ -0,0 +1,39 @@ +test_run_harness() { + "$tests_dir/../harness" -d "$test_root_dir" 2>&1 +} + +test_check_harness_log() { + if [ "$#" -lt 1 ]; then + log "usage: ${FUNCNAME[0]} LOG [STR...]" + return 1 + fi + + local output="$1" + shift + + log "Checking output log for a substring..." + + local str + for str; do + if ! echo "$output" | grep -F $'\n'"$str"$'\n' > /dev/null; then + fail "Couldn't find the expected string: $str" + return 1 + fi + done +} + +test_check_harness_summary() { + if [ "$#" -ne 3 ]; then + log "usage: ${FUNCNAME[0]} LOG N_OK N_FAILED" + return 1 + fi + + local output="$1" + local n_ok="$2" + local n_failed="$3" + + log "Validating test summary..." + + test_check_harness_log "$output" "OK: $n_ok" + test_check_harness_log "$output" "FAIL: $n_failed" +} -- cgit v1.3