diff options
author | Sami Kerola | 2015-05-24 19:14:58 +0200 |
---|---|---|
committer | Sami Kerola | 2015-06-06 15:36:38 +0200 |
commit | 6a40c65f81d393667bb7059be7d89eaf5cc99791 (patch) | |
tree | e7456e1463cc79f8aff14a200e30bad2710cde8e /tests | |
parent | tests: add script output buffering race check (diff) | |
download | kernel-qcow2-util-linux-6a40c65f81d393667bb7059be7d89eaf5cc99791.tar.gz kernel-qcow2-util-linux-6a40c65f81d393667bb7059be7d89eaf5cc99791.tar.xz kernel-qcow2-util-linux-6a40c65f81d393667bb7059be7d89eaf5cc99791.zip |
tests: check script options work as expected
Options --flush and --timing remain unchecked, as I do not have an idea
how to check them reliably.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/commands.sh | 1 | ||||
-rw-r--r-- | tests/expected/script/options | 0 | ||||
-rw-r--r-- | tests/expected/script/options-append | 8 | ||||
-rw-r--r-- | tests/expected/script/options-force | 14 | ||||
-rw-r--r-- | tests/expected/script/options-quiet | 4 | ||||
-rw-r--r-- | tests/expected/script/options-return | 16 | ||||
-rwxr-xr-x | tests/ts/script/options | 60 |
7 files changed, 103 insertions, 0 deletions
diff --git a/tests/commands.sh b/tests/commands.sh index dfb19e315..f865c0773 100644 --- a/tests/commands.sh +++ b/tests/commands.sh @@ -25,6 +25,7 @@ TS_HELPER_MD5="$top_builddir/test_md5" TS_HELPER_MORE=${TS_HELPER_MORE-"$top_builddir/test_more"} TS_HELPER_PARTITIONS="$top_builddir/sample-partitions" TS_HELPER_PATHS="$top_builddir/test_pathnames" +TS_HELPER_SCRIPT="$top_builddir/test_script" TS_HELPER_SIGRECEIVE="$top_builddir/test_sigreceive" TS_HELPER_STRUTILS="$top_builddir/test_strutils" TS_HELPER_SYSINFO="$top_builddir/test_sysinfo" diff --git a/tests/expected/script/options b/tests/expected/script/options new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/expected/script/options diff --git a/tests/expected/script/options-append b/tests/expected/script/options-append new file mode 100644 index 000000000..b2455f02c --- /dev/null +++ b/tests/expected/script/options-append @@ -0,0 +1,8 @@ +Script started on Sun May 24 17:43:18 2015 +append1
+ +Script done on Sun May 24 17:43:18 2015 +Script started on Sun May 24 17:43:18 2015 +append2
+ +Script done on Sun May 24 17:43:18 2015 diff --git a/tests/expected/script/options-force b/tests/expected/script/options-force new file mode 100644 index 000000000..f462b9858 --- /dev/null +++ b/tests/expected/script/options-force @@ -0,0 +1,14 @@ +test_script: output file `typescript' is a link +Use --force if you really want to use it. +Program not started. +1 +Script started on Sun May 24 17:43:18 2015 +with force
+ +Script done on Sun May 24 17:43:18 2015 +0 +Script started on Sun May 24 17:43:18 2015 +not typescript
+ +Script done on Sun May 24 17:43:18 2015 +0 diff --git a/tests/expected/script/options-quiet b/tests/expected/script/options-quiet new file mode 100644 index 000000000..2f7028777 --- /dev/null +++ b/tests/expected/script/options-quiet @@ -0,0 +1,4 @@ +Script started on Sun May 24 17:43:18 2015 +quiet1
+Script started on Sun May 24 17:43:18 2015 +quiet2
diff --git a/tests/expected/script/options-return b/tests/expected/script/options-return new file mode 100644 index 000000000..3b6058935 --- /dev/null +++ b/tests/expected/script/options-return @@ -0,0 +1,16 @@ +Script started on Sun May 24 17:43:18 2015 + +Script done on Sun May 24 17:43:18 2015 +0 +Script started on Sun May 24 17:43:18 2015 + +Script done on Sun May 24 17:43:18 2015 +0 +Script started on Sun May 24 17:43:18 2015 + +Script done on Sun May 24 17:43:18 2015 +42 +Script started on Sun May 24 17:43:18 2015 + +Script done on Sun May 24 17:43:18 2015 +127 diff --git a/tests/ts/script/options b/tests/ts/script/options new file mode 100755 index 000000000..2656c4238 --- /dev/null +++ b/tests/ts/script/options @@ -0,0 +1,60 @@ +#!/bin/bash + +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="options" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +export SCRIPT_TEST_SECOND_SINCE_EPOCH=1432489398 +export TZ="GMT" + +ts_check_test_command "$TS_HELPER_SCRIPT" + +ts_init_subtest "append" +$TS_HELPER_SCRIPT --command "echo append1" $TS_OUTPUT </dev/null >/dev/null 2>&1 +$TS_HELPER_SCRIPT --append -c "echo append2" $TS_OUTPUT </dev/null >/dev/null 2>&1 +ts_finalize_subtest + +ts_init_subtest "force" +ln -s $TS_OUTPUT typescript +$TS_HELPER_SCRIPT --command "echo no force" </dev/null >/dev/null 2>> $TS_OUTPUT +echo $? >> $TS_OUTPUT +$TS_HELPER_SCRIPT -a --force --command "echo with force" </dev/null >/dev/null +echo $? >> $TS_OUTPUT +rm -f typescript +ln -s $TS_OUTPUT tpircsepyt +$TS_HELPER_SCRIPT -a --command "echo not typescript" tpircsepyt </dev/null >/dev/null +echo $? >> $TS_OUTPUT +rm -f tpircsepyt +ts_finalize_subtest + +ts_init_subtest "quiet" +$TS_HELPER_SCRIPT --quiet --command "echo quiet1" $TS_OUTPUT </dev/null >/dev/null 2>&1 +$TS_HELPER_SCRIPT -a -q --command "echo quiet2" $TS_OUTPUT </dev/null >/dev/null 2>&1 +ts_finalize_subtest + +ts_init_subtest "return" +$TS_HELPER_SCRIPT --command "exit 1" $TS_OUTPUT </dev/null >/dev/null 2>&1 +echo $? >> $TS_OUTPUT +$TS_HELPER_SCRIPT -a --command "exit 0" $TS_OUTPUT </dev/null >/dev/null 2>&1 +echo $? >> $TS_OUTPUT +$TS_HELPER_SCRIPT -e --append -c "exit 42" $TS_OUTPUT </dev/null >/dev/null 2>&1 +echo $? >> $TS_OUTPUT +$TS_HELPER_SCRIPT --return --append -c "exit 127" $TS_OUTPUT </dev/null >/dev/null 2>&1 +echo $? >> $TS_OUTPUT +ts_finalize_subtest + +ts_finalize |