tests: add extra protection against unexpected exits
commit58cff8a009ed9b8280c5f35074cef97231286023
authorPádraig Brady <P@draigBrady.com>
Tue, 13 Jan 2015 03:30:33 +0000 (13 03:30 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 14 Jan 2015 12:20:32 +0000 (14 12:20 +0000)
tree771e8b3fa70fab99b548790931803b75dd272603
parent924b1cadff3f2782475516d7eca9aabe856dbf0f
tests: add extra protection against unexpected exits

Many tests use `program ... && fail=1` to ensure expected
error situations are indicated.  However that would mask
an unexpected exit (like a crash).  Therefore explicitly
check the expected exit code.
Note where error messages are also verified, the extra
protection is not added.

* tests/init.sh (returns_): A new helper function to
check the return code of a command, and used
throughout the tests.
* cfg.mk (sc_prohibit_and_fail_1): Add a syntax check
to avoid new instances of this issue.
93 files changed:
cfg.mk
tests/chmod/octal.sh
tests/chmod/umask-x.sh
tests/chmod/usage.sh
tests/chown/basic.sh
tests/chown/separator.sh
tests/cp/cp-HL.sh
tests/cp/cp-a-selinux.sh
tests/cp/cp-i.sh
tests/cp/cp-parents.sh
tests/cp/dir-vs-file.sh
tests/cp/fail-perm.sh
tests/cp/no-ctx.sh
tests/cp/reflink-auto.sh
tests/cp/sparse.sh
tests/dd/misc.sh
tests/dd/nocache.sh
tests/dd/stderr.sh
tests/df/no-mtab-status.sh
tests/df/skip-rootfs.sh
tests/du/deref.sh
tests/id/context.sh
tests/id/gnu-zero-uids.sh
tests/id/uid.sh
tests/id/zero.sh
tests/init.sh
tests/install/basic-1.sh
tests/install/install-C.sh
tests/install/strip-program.sh
tests/ln/misc.sh
tests/ln/slash-decorated-nonexistent-dest.sh
tests/ls/dangle.sh
tests/ls/follow-slink.sh
tests/ls/stat-failed.sh
tests/misc/cat-self.sh
tests/misc/chcon-fail.sh
tests/misc/chroot-credentials.sh
tests/misc/close-stdout.sh
tests/misc/cut-huge-range.sh
tests/misc/env.sh
tests/misc/false-status.sh
tests/misc/md5sum-bsd.sh
tests/misc/nproc-positive.sh
tests/misc/pathchk1.sh
tests/misc/printf.sh
tests/misc/realpath.sh
tests/misc/selinux.sh
tests/misc/shred-remove.sh
tests/misc/sort-compress-proc.sh
tests/misc/sort-exit-early.sh
tests/misc/stat-hyphen.sh
tests/misc/stat-slash.sh
tests/misc/stty-invalid.sh
tests/misc/stty.sh
tests/misc/tr-case-class.sh
tests/misc/truncate-dir-fail.sh
tests/misc/truncate-overflow.sh
tests/misc/truncate-parameters.sh
tests/misc/truncate-relative.sh
tests/misc/wc-parallel.sh
tests/mkdir/p-3.sh
tests/mkdir/parents.sh
tests/mkdir/perm.sh
tests/mkdir/special-1.sh
tests/mv/childproof.sh
tests/mv/dir-file.sh
tests/mv/hardlink-case.sh
tests/mv/into-self-4.sh
tests/mv/mv-n.sh
tests/mv/no-target-dir.sh
tests/mv/part-rename.sh
tests/mv/trailing-slash.sh
tests/readlink/can-e.sh
tests/readlink/can-f.sh
tests/readlink/can-m.sh
tests/readlink/multi.sh
tests/readlink/rl-1.sh
tests/rm/i-no-r.sh
tests/rm/no-give-up.sh
tests/rm/r-4.sh
tests/rm/r-root.sh
tests/rm/rm4.sh
tests/rm/sunos-1.sh
tests/rmdir/fail-perm.sh
tests/split/additional-suffix.sh
tests/split/fail.sh
tests/split/filter.sh
tests/split/guard-input.sh
tests/split/numeric.sh
tests/split/suffix-auto-length.sh
tests/split/suffix-length.sh
tests/touch/no-dereference.sh
tests/touch/trailing-slash.sh