From aefe9893385f05c40ae44a6b9e782cf96751e4dd Mon Sep 17 00:00:00 2001 From: Fred Mora Date: Mon, 14 May 2018 11:20:06 +0200 Subject: script: add the -o/--output-limit option. Fix race test. When script is used on a host with a relatively small free disk space, it is sometimes desirable to limit the size of the captured output. This can now be enforced with the --output-limit option. The --output-limit option lets the user specify a maximum size. The program uses the size parsing from strutils and thus supports the usual multiplicative suffixes (kiB, KB, MiB, MB, etc.). After the specified number of bytes have been written to the output file, the script program will terminate the child process. Due to buffering, the size of the output file might exceed the specified limit. This limit also does not include the start and done messages. The race test was throwing an error dur to a variable being "" in some cases. Quoting the variable in the equal test took care of that test. [kzak@redhat.com: - use done() to stop script - count also timing file - remove unnamed member initialization in ctl struct - add to bash-completion] Signed-off-by: Fred Mora Signed-off-by: Karel Zak --- tests/ts/script/options | 7 +++++++ tests/ts/script/race | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'tests/ts') diff --git a/tests/ts/script/options b/tests/ts/script/options index 2656c4238..67a8b444d 100755 --- a/tests/ts/script/options +++ b/tests/ts/script/options @@ -57,4 +57,11 @@ $TS_HELPER_SCRIPT --return --append -c "exit 127" $TS_OUTPUT /dev/nu echo $? >> $TS_OUTPUT ts_finalize_subtest +ts_init_subtest "size" +$TS_HELPER_SCRIPT --output-limit 9 --command "echo 1:1234567890" $TS_OUTPUT /dev/null 2>&1 +$TS_HELPER_SCRIPT -a -o 9 --command "echo 2:1234567890" $TS_OUTPUT /dev/null 2>&1 +echo $? >> $TS_OUTPUT +cp /home/fmora/u/src/util-linux/tests/output/script/options-size /tmp +ts_finalize_subtest + ts_finalize diff --git a/tests/ts/script/race b/tests/ts/script/race index 86e383814..2c26b89fc 100755 --- a/tests/ts/script/race +++ b/tests/ts/script/race @@ -36,7 +36,7 @@ for i in `seq 1 $count`; do done | grep -c Bingo >> $TS_OUTPUT seen=$(<$TS_OUTPUT) -if [ $seen = $count ]; then +if [ "$seen" = "$count" ]; then echo "all bingos seen" > $TS_OUTPUT else echo "only $seen of $count bingos seen" > $TS_OUTPUT -- cgit v1.2.3-55-g7522