1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

ctdb-tests: Avoid early exits in scripts that appear on tail of a pipe

When executing a shell script code "foo | bar", if "bar" terminates early,
then "foo" can get I/O error when writing to stdout.

The tdbtool stub did not wait to read anything from stdin when it is
expected to.  This would cause tests to fail randomly under load when
tdbtool process exited early.

Similarly, debug function read from stdin only under certain conditions
(higher debug and when not reading from tty).  Otherwise, exited early.

Thanks to Andrew Bartlett for noticing the problem and Catalyst Cloud
(http://catalyst.net.nz/cloud) for providing resources to test fixes.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Pair-Programmed-With: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Fri Mar 20 16:26:37 CET 2015 on sn-devel-104
This commit is contained in:
Amitay Isaacs 2015-03-20 14:36:51 +11:00 committed by Michael Adam
parent 4f82ef4b38
commit 1f523a628a
2 changed files with 30 additions and 8 deletions

View File

@ -65,9 +65,13 @@ debug ()
# here document.
if [ -n "$1" ] ; then
echo "DEBUG: $*"
elif ! tty -s ; then
else
sed -e 's@^@DEBUG: @'
fi
else
if [ -z "$1" ] ; then
cat >/dev/null
fi
fi
}

View File

@ -1,15 +1,33 @@
#!/bin/sh
if [ -z "$1" ] ; then
do_help ()
{
if [ "$FAKE_TDBTOOL_SUPPORTS_CHECK" = "yes" ] ; then
echo "check"
fi
fi
exit 0
}
if [ "$FAKE_TDB_IS_OK" = "yes" ] ; then
echo "Database integrity is OK"
else
echo "Database is busted"
fi
do_check ()
{
if [ "$FAKE_TDB_IS_OK" = "yes" ] ; then
echo "Database integrity is OK"
else
echo "Database is busted"
fi
exit 0
}
do_cmd ()
{
case "$*" in
*check) do_check ;;
help) do_help ;;
"") read tdb_cmd && [ -n "$tdb_cmd" ] && do_cmd $tdb_cmd ;;
*) echo "$0: Not implemented: $*" ; exit 1 ;;
esac
}
do_cmd $*
exit 0