]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: enhance stdbuf and timeout tests
authorEric Blake <ebb9@byu.net>
Fri, 23 Oct 2009 14:54:53 +0000 (08:54 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 23 Oct 2009 22:31:23 +0000 (16:31 -0600)
* tests/misc/timeout-parameters: Validate exact exit status.
* tests/misc/stdbuf: Likewise.
* tests/misc/timeout: Likewise.  Use require_built_.
* tests/misc/arch: Likewise.

tests/misc/arch
tests/misc/stdbuf
tests/misc/timeout
tests/misc/timeout-parameters

index 9a437568dd7fff64150479abf7fb0fb4e244a00e..04bce0e1a3ea43814cac6234d07ea6f550fc6bfe 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . $srcdir/test-lib.sh
-
-# skip this test if arch isn't being built.
-case " $built_programs " in
-  *" arch "*) ;;
-  *) skip_test_ 'not building arch';;
-esac
+require_built_ arch
 
 if test "$VERBOSE" = yes; then
   set -x
index 337504028f51591cdf306f44c2b048378f25e70b..33bc658eaeb6833145b51bfdb6c017a3b322cdb9 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+. $srcdir/test-lib.sh
+getlimits_
+require_built_ stdbuf
+
 if test "$VERBOSE" = yes; then
   set -x
   stdbuf --version
 fi
 
-. $srcdir/test-lib.sh
-getlimits_
-
-# skip this test if stdbuf isn't being built.
-case " $built_programs " in
-  *" stdbuf "*) ;;
-  *) skip_test_ 'stdbuf not built';;
-esac
-
 # stdbuf fails when the absolute top build dir name contains e.g., space, TAB, NL
 lf='
 '
@@ -52,10 +47,17 @@ stdbuf -o1 true || fail=1 # verify size syntax
 stdbuf -oK true || fail=1 # verify size syntax
 stdbuf -o0 true || fail=1 # verify unbuffered syntax
 stdbuf -oL true || fail=1 # verify line buffered syntax
-stdbuf -ol true && fail=1 # Capital 'L' required
-stdbuf -o$SIZE_OFLOW true && fail=1 # size too large
-stdbuf -iL true && fail=1 # line buffering stdin disallowed
+stdbuf -ol true # Capital 'L' required
+test $? = 125 || fail=1 # Internal error is a particular status
+stdbuf -o$SIZE_OFLOW true # size too large
+test $? = 125 || fail=1
+stdbuf -iL true # line buffering stdin disallowed
+test $? = 125 || fail=1
 stdbuf -i0 -o0 -e0 true || fail=1 #check all files
+stdbuf -o1 . # invalid command
+test $? = 126 || fail=1
+stdbuf -o1 ... # no such command
+test $? = 127 || fail=1
 
 # Ensure line buffering stdout takes effect
 printf '1\n' > exp
index 36fdb73a560ed29607977a961d767a7ebd318745..08734e6f29fc641ebc15b93dc600cb7d9ade322b 100755 (executable)
@@ -36,6 +36,8 @@ timeout 0 true || fail=1
 
 # exit status propagation
 timeout 1 false && fail=1
+timeout 1 sh -c 'exit 2'
+test $? = 2 || fail=1
 
 # timeout
 timeout 1 sleep 2
index cf344b96224f2debfe6479f2c6badb4fec86afff..52d4c8aeed7f14b5ddd031fc52cbbcff0b7ae24b 100755 (executable)
@@ -26,28 +26,38 @@ getlimits_
 
 fail=0
 
+# internal errors are 125, distinct from execution failure
+
 # --help and --version must be specified alone
-timeout --help --version && fail=1
+timeout --help --version
+test $? = 125 || fail=1
 
 # invalid timeout
-timeout invalid sleep 0 && fail=1
+timeout invalid sleep 0
+test $? = 125 || fail=1
 
 # invalid timeout suffix
-timeout 42D sleep 0 && fail=1
+timeout 42D sleep 0
+test $? = 125 || fail=1
 
 # timeout overflow
-timeout $UINT_OFLOW sleep 0 && fail=1
+timeout $UINT_OFLOW sleep 0
+test $? = 125 || fail=1
 
 # timeout overflow
-timeout $(expr $UINT_MAX / 86400 + 1)d sleep 0 && fail=1
+timeout $(expr $UINT_MAX / 86400 + 1)d sleep 0
+test $? = 125 || fail=1
 
 # invalid signal spec
-timeout --signal=invalid 1 sleep 0 && fail=1
+timeout --signal=invalid 1 sleep 0
+test $? = 125 || fail=1
 
 # invalid command
-timeout 1 . && fail=1
+timeout 1 .
+test $? = 126 || fail=1
 
-# non existant command
-timeout 1 ... && fail=1
+# no such command
+timeout 1 ...
+test $? = 127 || fail=1
 
 Exit $fail