Writing Shell Tests

From SambaWiki
Revision as of 20:36, 1 August 2017 by Abartlet (talk | contribs) (shell based testing)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Writing shell tests

Avoid writing new shell-based tests

New tests should be written in Python

Avoid bashisms

On many systems (Debian and Ubuntu in particular)

/bin/sh

is actually *dash* not *bash*. Therefore avoid bash specific syntax.

Use helper functions

If your test is in testprogs/blackbox you can use:

. `dirname $0`/subunit.sh
. `dirname $0`/common_test_fns.inc

otherwise you will need to use a ../ path to find these.

testit

testit is the primary test command, testing one particular command for success.

testit "change dc password" $samba4srcdir/scripting/devel/chgtdcpass -s $PROVDIR/etc/smb.conf || failed=`expr $failed + 1`

exit code

The script should exit with the number of failures

exit $failed