From 1d28da18cec51a6f6a0946c6347b4c406b78392d Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Sun, 19 Apr 2026 23:12:10 +0100 Subject: [PATCH] Add a basic test for monitoring, each of the "in" and "out" sides. --- Makefile.am | 1 + tests/Monitor_-_Basic.test | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100755 tests/Monitor_-_Basic.test diff --git a/Makefile.am b/Makefile.am index 486b230..3a873e9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -97,6 +97,7 @@ tests/Modifiers_-_--size_from_file_size.test \ tests/Modifiers_-_--size_from_dir_size.test \ tests/Modifiers_-_--size.test \ tests/Modifiers_-_--sync.test \ +tests/Monitor_-_Basic.test \ tests/Sparse_-_Basic.test \ tests/Terminal_-_Detect_width.test \ tests/Transfer_-_--rate-limit.test \ diff --git a/tests/Monitor_-_Basic.test b/tests/Monitor_-_Basic.test new file mode 100755 index 0000000..8a26eec --- /dev/null +++ b/tests/Monitor_-_Basic.test @@ -0,0 +1,27 @@ +#!/bin/sh +# +# Check that monitoring of a simple command works. + +# Allow all tests to be skipped, e.g. during a release build +test "${SKIP_ALL_TESTS}" = "1" && exit 77 + +true "${testSubject:?not set - call this from 'make check'}" +true "${workFile1:?not set - call this from 'make check'}" + +seq 1 100 | "${testSubject}" -M in -f -l -b -- sed '1~2d' >/dev/null 2>"${workFile1}" + +counterValue=$(tr '\r' '\n' < "${workFile1}" | awk '/[0-9]/{print int($1)}' | sed -n '$p') +if ! test "${counterValue}" = "100"; then + echo "in monitor: unexpected byte counter value: ${counterValue}" + exit 1 +fi + +seq 1 100 | "${testSubject}" -M out -f -l -b -- sed '1~2d' >/dev/null 2>"${workFile1}" + +counterValue=$(tr '\r' '\n' < "${workFile1}" | awk '/[0-9]/{print int($1)}' | sed -n '$p') +if ! test "${counterValue}" = "50"; then + echo "out monitor: unexpected byte counter value: ${counterValue}" + exit 1 +fi + +exit 0