summaryrefslogtreecommitdiffstats
path: root/tests/ts
diff options
context:
space:
mode:
authorFred Mora2018-05-14 11:20:06 +0200
committerKarel Zak2018-05-14 11:32:23 +0200
commitaefe9893385f05c40ae44a6b9e782cf96751e4dd (patch)
treeaaa54a4d055d97fc5d7b493552f8e6c4d68de364 /tests/ts
parentbash-completion: add findmnt --real --pseudo (diff)
downloadkernel-qcow2-util-linux-aefe9893385f05c40ae44a6b9e782cf96751e4dd.tar.gz
kernel-qcow2-util-linux-aefe9893385f05c40ae44a6b9e782cf96751e4dd.tar.xz
kernel-qcow2-util-linux-aefe9893385f05c40ae44a6b9e782cf96751e4dd.zip
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 <fmora@datto.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/ts')
-rwxr-xr-xtests/ts/script/options7
-rwxr-xr-xtests/ts/script/race2
2 files changed, 8 insertions, 1 deletions
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/null >/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 >/dev/null 2>&1
+$TS_HELPER_SCRIPT -a -o 9 --command "echo 2:1234567890" $TS_OUTPUT </dev/null >/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