Hi, I've been working on (at least some) test coverage for the recently added rlCleanup* functions and the (rather separate) testwatcher.py and I found a few bugs in the process as well.
Everything related (patches) should be in References to this email, see the commit messages or code comments for more details.
Thanks for the review (if any). Also thanks to Roman Rakus for help with escaping quotes in bash.
-- JJ
Signed-off-by: Jiri Jaburek jjaburek@redhat.com --- src/infrastructure.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/infrastructure.sh b/src/infrastructure.sh index 9994e3e..1c4f76a 100644 --- a/src/infrastructure.sh +++ b/src/infrastructure.sh @@ -1155,9 +1155,9 @@ rlCleanupPrepend() { rlLogError "rlCleanupPrepend: not enough arguments" return 1 elif [ -z "$__INTERNAL_TESTWATCHER_ACTIVE" ]; then - rlLogWarning "rlCleanupAppend: Running outside of the test watcher" - rlLogWarning "rlCleanupAppend: Check your 'run' target in the test Makefile" - rlLogWarning "rlCleanupAppend: Cleanup will be executed only if rlJournalEnd is called properly" + rlLogWarning "rlCleanupPrepend: Running outside of the test watcher" + rlLogWarning "rlCleanupPrepend: Check your 'run' target in the test Makefile" + rlLogWarning "rlCleanupPrepend: Cleanup will be executed only if rlJournalEnd is called properly" fi
local tmpbuff="$__INTERNAL_CLEANUP_BUFF".tmp
On Thu, 2013-10-17 at 18:46 +0200, Jiri Jaburek wrote:
Signed-off-by: Jiri Jaburek jjaburek@redhat.com
src/infrastructure.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/infrastructure.sh b/src/infrastructure.sh index 9994e3e..1c4f76a 100644 --- a/src/infrastructure.sh +++ b/src/infrastructure.sh @@ -1155,9 +1155,9 @@ rlCleanupPrepend() { rlLogError "rlCleanupPrepend: not enough arguments" return 1 elif [ -z "$__INTERNAL_TESTWATCHER_ACTIVE" ]; then
rlLogWarning "rlCleanupAppend: Running outside of the test watcher"rlLogWarning "rlCleanupAppend: Check your 'run' target in the test Makefile"rlLogWarning "rlCleanupAppend: Cleanup will be executed only if rlJournalEnd is called properly"
rlLogWarning "rlCleanupPrepend: Running outside of the test watcher"rlLogWarning "rlCleanupPrepend: Check your 'run' target in the test Makefile"rlLogWarning "rlCleanupPrepend: Cleanup will be executed only if rlJournalEnd is called properly"fi
local tmpbuff="$__INTERNAL_CLEANUP_BUFF".tmp
OK, applied.
PM
As opposed to using a brand new one, sourced from /usr.
This has several benefits:
- if the user sourced ie. a different version of beakerlib in the test, we shouldn't source a system-wide one
- if there's no beakerlib installed on the system, but the user created an environment using custom exports (ie. beakerlib test suite), we should use the current (test) environment instead of failing to source nonexistent files into the cleanup environment
- the user might have also exported custom variables/functions in the test and this change makes them available to the cleanup upon a next append/prepend function call - this currently doesn't include non-exported variables
Also note that we can't easily store variables/functions in a separate file, because the move atomicity would be broken - a (rare) possibility of an old cleanup executing with new environment would be present. Therefore, we need to embed everything into cleanup.sh.
Signed-off-by: Jiri Jaburek jjaburek@redhat.com --- src/infrastructure.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/infrastructure.sh b/src/infrastructure.sh index 1c4f76a..ce6df41 100644 --- a/src/infrastructure.sh +++ b/src/infrastructure.sh @@ -105,14 +105,25 @@ __INTERNAL_rlCleanupGenFinal() # head cat > "$newfinal" <<EOF #!/bin/bash -export BEAKERLIB_DIR="$BEAKERLIB_DIR" -. /usr/bin/rhts-environment.sh -. /usr/share/beakerlib/beakerlib.sh +EOF + + # environment + # - env variables (incl. BEAKERLIB_DIR) + # NOTE: even works around possible single quotes in variables + env | sed -r -e "s/'/'\''/g" -e "s/^([^=]+)=(.*)$/export \1='\2'/" \ + >> "$newfinal" + # - functions + declare -f >> "$newfinal" + + # journal/phase start + cat >> "$newfinal" <<EOF rlJournalStart rlPhaseStartCleanup EOF + # body cat "$__INTERNAL_CLEANUP_BUFF" >> "$newfinal" + # tail cat >> "$newfinal" <<EOF rlPhaseEnd
On Thu, 2013-10-17 at 18:46 +0200, Jiri Jaburek wrote:
As opposed to using a brand new one, sourced from /usr.
This has several benefits:
if the user sourced ie. a different version of beakerlib in the test, we shouldn't source a system-wide one
if there's no beakerlib installed on the system, but the user created an environment using custom exports (ie. beakerlib test suite), we should use the current (test) environment instead of failing to source nonexistent files into the cleanup environment
the user might have also exported custom variables/functions in the test and this change makes them available to the cleanup upon a next append/prepend function call - this currently doesn't include non-exported variables
Also note that we can't easily store variables/functions in a separate file, because the move atomicity would be broken - a (rare) possibility of an old cleanup executing with new environment would be present. Therefore, we need to embed everything into cleanup.sh.
OK, understood.
(...)
- # environment
- # - env variables (incl. BEAKERLIB_DIR)
- # NOTE: even works around possible single quotes in variables
- env | sed -r -e "s/'/'\''/g" -e "s/^([^=]+)=(.*)$/export \1='\2'/" \
shellcheck does not like the unescaped '$' character, but I guess it's harmless here. I'll probably fix it just to get rid of the warning.
Good otherwise, applied.
I tried making a shared function and calling it from the two test_rlCleanup* functions, but due to "onetwo" vs "twoone" and one more condition, the shared function ended up having ~ the same amount of lines as the two separate functions combined, while being more complex to the human eye.
Therefore I went with the "duplicated, but simple / readable" approach.
Signed-off-by: Jiri Jaburek jjaburek@redhat.com --- src/test/infrastructureTest.sh | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
diff --git a/src/test/infrastructureTest.sh b/src/test/infrastructureTest.sh index a330ac0..2a7b854 100644 --- a/src/test/infrastructureTest.sh +++ b/src/test/infrastructureTest.sh @@ -454,3 +454,46 @@ test_rlSEBooleanTest() { assertTrue "rlSEBooleanRestore of $TESTED_BOOLEAN is successful" "rlSEBooleanRestore $TESTED_BOOLEAN" assertTrue "rlSEBooleanRestore of $TESTED_BOOLEAN resets state" "[ "$( getsebool $TESTED_BOOLEAN | cut -d ' ' -f 3 )" == "$OLDSTATE" ]" } + +# NOTE: these two tests (Append/Prepend) verify ONLY the "no testwatcher" +# (bash only) scenario as incorporating the test watcher in this suite +# would be rather difficult +test_rlCleanupAppend() +{ + assertTrue 'journalReset' + local tmpfile=$(mktemp) + + assertTrue "rlCleanupAppend succeeds on initialized journal" "rlCleanupAppend "echo -n one >> \"$tmpfile\""" + assertTrue "rlCleanupAppend issued a warning (no testwatcher)" \ + "grep "<message\ severity=\"WARNING\">rlCleanupAppend: Running outside of the test watcher" "$BEAKERLIB_JOURNAL"" + + rlCleanupAppend "echo -n two >> "$tmpfile"" + + rlJournalEnd >/dev/null + + assertTrue "Temporary file should contain 'onetwo' after rlJournalEnd" "grep 'onetwo' < "$tmpfile"" || cat "$tmpfile" + assertTrue "rlJournalEnd issued a warning (no testwatcher)" \ + "grep "<message\ severity=\"WARNING\">rlJournalEnd: Not running in test watcher" "$BEAKERLIB_JOURNAL"" + + rm -f "$tmpfile" +} +test_rlCleanupPrepend() +{ + assertTrue 'journalReset' + local tmpfile=$(mktemp) + + assertTrue "rlCleanupPrepend succeeds on initialized journal" "rlCleanupPrepend "echo -n one >> \"$tmpfile\""" + assertTrue "rlCleanupPrepend issued a warning (no testwatcher)" \ + "grep "<message\ severity=\"WARNING\">rlCleanupPrepend: Running outside of the test watcher" "$BEAKERLIB_JOURNAL"" + + rlCleanupPrepend "echo -n two >> "$tmpfile"" + + rlJournalEnd >/dev/null + + assertTrue "Temporary file should contain 'twoone' after rlJournalEnd" "grep 'twoone' < "$tmpfile"" || cat "$tmpfile" + assertTrue "rlJournalEnd issued a warning (no testwatcher)" \ + "grep "<message\ severity=\"WARNING\">rlJournalEnd: Not running in test watcher" "$BEAKERLIB_JOURNAL"" + + rm -f "$tmpfile" +} +
On Thu, 2013-10-17 at 18:46 +0200, Jiri Jaburek wrote:
I tried making a shared function and calling it from the two test_rlCleanup* functions, but due to "onetwo" vs "twoone" and one more condition, the shared function ended up having ~ the same amount of lines as the two separate functions combined, while being more complex to the human eye.
Therefore I went with the "duplicated, but simple / readable" approach.
Good call.
Signed-off-by: Jiri Jaburek jjaburek@redhat.com
(...)
No problems with the code. It adds some unmuted output to the testsuite execution (we generally want no output unless DEBUG is set), but thats a minor thing and I'll fix it afterwards. Applied.
PM
Signed-off-by: Jiri Jaburek jjaburek@redhat.com --- src/python/testwatcher.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/python/testwatcher.py b/src/python/testwatcher.py index 5231675..4f76531 100755 --- a/src/python/testwatcher.py +++ b/src/python/testwatcher.py @@ -66,8 +66,11 @@ import tempfile ### CONFIG # # Beaker External watchdog = 30 minutes after LWD -# (25 minutes = 1500 secs) -ewd_maxsecs = 1500 +# (25 minutes = 1500 secs by default, configurable via env) +if 'TESTWATCHER_EWD_SECS' in os.environ: + ewd_maxsecs = int(os.environ['TESTWATCHER_EWD_SECS']) +else: + ewd_maxsecs = 1500
# beah LWD hook lwd_guard_file = '/usr/share/rhts/hooks/watchdog/testwatcher-cleanup-guard'
On Thu, 2013-10-17 at 18:46 +0200, Jiri Jaburek wrote:
Signed-off-by: Jiri Jaburek jjaburek@redhat.com
src/python/testwatcher.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/python/testwatcher.py b/src/python/testwatcher.py
(...)
-# (25 minutes = 1500 secs) -ewd_maxsecs = 1500 +# (25 minutes = 1500 secs by default, configurable via env) +if 'TESTWATCHER_EWD_SECS' in os.environ:
- ewd_maxsecs = int(os.environ['TESTWATCHER_EWD_SECS'])
+else:
- ewd_maxsecs = 1500
This will burn down on any bad input - perhaps we should make it burn down at least a bit gracefully, with an explanation of what went wrong?
But that is not a showstopper. Applied.
Signed-off-by: Jiri Jaburek jjaburek@redhat.com --- src/python/testwatcher.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/python/testwatcher.py b/src/python/testwatcher.py index 4f76531..d44e8c7 100755 --- a/src/python/testwatcher.py +++ b/src/python/testwatcher.py @@ -278,11 +278,11 @@ def exec_test(): # processes (from the parent) when interrupted os.setpgrp()
- debug('child executing '+' '.join(sys.argv[1:])) + debug('executing test at '+' '.join(sys.argv[1:])) os.execvp(sys.argv[1], sys.argv[1:])
else: - debug('parent waiting for '+str(testpid)) + debug('parent waiting for test '+str(testpid)) while testpid != 0: try: # wait for entire process group @@ -309,9 +309,10 @@ if beah: beah_lwd_hook()
exec_test() -debug('parent done waiting') +debug('parent done waiting for test')
exec_cleanup() +debug('parent done waiting for cleanup')
# remove temporary (mkstemp'ed) file # no-reboot os.unlink(clpath)
On Thu, 2013-10-17 at 18:47 +0200, Jiri Jaburek wrote:
Signed-off-by: Jiri Jaburek jjaburek@redhat.com
src/python/testwatcher.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/python/testwatcher.py b/src/python/testwatcher.py index 4f76531..d44e8c7 100755 --- a/src/python/testwatcher.py +++ b/src/python/testwatcher.py @@ -278,11 +278,11 @@ def exec_test(): # processes (from the parent) when interrupted os.setpgrp()
debug('child executing '+' '.join(sys.argv[1:]))
debug('executing test at '+' '.join(sys.argv[1:])) os.execvp(sys.argv[1], sys.argv[1:])else:
debug('parent waiting for '+str(testpid))
debug('parent waiting for test '+str(testpid)) while testpid != 0: try: # wait for entire process group@@ -309,9 +309,10 @@ if beah: beah_lwd_hook()
exec_test() -debug('parent done waiting') +debug('parent done waiting for test')
exec_cleanup() +debug('parent done waiting for cleanup')
# remove temporary (mkstemp'ed) file # no-reboot os.unlink(clpath)
Good, applied.
PM
Signed-off-by: Jiri Jaburek jjaburek@redhat.com --- src/python/testwatcher.py | 1 + 1 file changed, 1 insertion(+)
diff --git a/src/python/testwatcher.py b/src/python/testwatcher.py index d44e8c7..aa7b452 100755 --- a/src/python/testwatcher.py +++ b/src/python/testwatcher.py @@ -110,6 +110,7 @@ def debug(msg): def fatal(msg): print >> sys.stderr, 'TESTWATCHER fatal: '+msg sys.stderr.flush() + sys.exit(1)
def sigpgkill_safe(pid):
On Thu, 2013-10-17 at 18:47 +0200, Jiri Jaburek wrote:
Signed-off-by: Jiri Jaburek jjaburek@redhat.com
src/python/testwatcher.py | 1 + 1 file changed, 1 insertion(+)
diff --git a/src/python/testwatcher.py b/src/python/testwatcher.py index d44e8c7..aa7b452 100755 --- a/src/python/testwatcher.py +++ b/src/python/testwatcher.py @@ -110,6 +110,7 @@ def debug(msg): def fatal(msg): print >> sys.stderr, 'TESTWATCHER fatal: '+msg sys.stderr.flush()
- sys.exit(1)
Good, applied.
PM
Signed-off-by: Jiri Jaburek jjaburek@redhat.com --- src/test/testwatcher.sh | 281 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100755 src/test/testwatcher.sh
diff --git a/src/test/testwatcher.sh b/src/test/testwatcher.sh new file mode 100755 index 0000000..66537ad --- /dev/null +++ b/src/test/testwatcher.sh @@ -0,0 +1,281 @@ +#!/bin/bash +# +# Authors: Jiri Jaburek jjaburek@redhat.com +# +# Description: A one-file test suite for testwatcher.py +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. This copyrighted +# material is made available to anyone wishing to use, modify, copy, or +# redistribute it subject to the terms and conditions of the GNU General +# Public License v.2. +# +# This program 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# +# this is a testing script for the test watcher tool (python/testwatcher.sh), +# the goal being verification in a standalone, beakerlib-independent fashion, +# since the tool is also standalone by design +# +# beakerlib side is covered by infrastructureTest.sh to some extent, the TODO +# being combination of test watcher with the beakerlib rlCleanup* functions, +# somehow +# +# also note that while testwatcher.py has a certain logic of detecting whether +# the beaker harness (beah) is running, this logic is only used for very beah +# specific things like reportning WARN to journal and hooking the LWD, neither +# of which is directly related to handling the test/cleanup pair +# therefore, we don't stimulate that beah logic here, at least for now + +error() +{ + echo "error: $@" 1>&2 + exit 1 +} +FAILED=0 +fail() +{ + (( FAILED++ )) + echo -e "\e[1;31m:::::::: FAILED ::::::::\e[0m" +} +testcase() +{ + echo + echo -e "\e[1;34m--------------------------------------------------------------------------------\e[0m" + echo -e "\e[1;34mtestcase:\e[0m $1" + echo +} +mktest() +{ + filename="$1" + shift + { + echo "#!/bin/bash" + while [ $# -gt 0 ]; do + echo "$1" + shift + done; + } > "$filename" + chmod +x "$filename" +} ++() +{ + local rc= + local PS4="\e[1;33m+\e[0m " + { set -x; } 2>/dev/null + "$@" + { rc=$?; set +x; } 2>/dev/null + return $rc +} + + +# be strict during setup +set -e + +tmpdir=$(mktemp -d) +trap "rm -rf "$tmpdir"" EXIT + +#copy testwatcher.py +watcherloc="../python/testwatcher.py" +[ -f "$watcherloc" ] || watcherloc="python/testwatcher.py" +[ -f "$watcherloc" ] || error "could not find testwatcher.py" +cp "$watcherloc" "$tmpdir/." +cd "$tmpdir" + +chmod +x testwatcher.py + +set +e + + +################################################################################ + +# +# basic sanity success operations: +# - test successful, cleanup not set up +# - test successful, cleanup successful +######## +testcase "sanity: test successful, cleanup not set up" +mktest test.sh 'echo end > test.log' ++ ./testwatcher.py ./test.sh ++ grep 'end' test.log || fail +rm -f test.sh test.log + +######## +testcase "sanity: test successful, cleanup successful" +mktest test.sh 'echo ./cleanup.sh > "$TESTWATCHER_CLPATH"' \ + 'echo end > test.log' +mktest cleanup.sh 'echo end > cleanup.log' ++ ./testwatcher.py ./test.sh ++ grep 'end' test.log || fail ++ grep 'end' cleanup.log || fail +rm -f test.sh test.log cleanup.sh cleanup.log + +# +# extended sanity testing: +# - arguments with spaces +# - ... +# TODO more sanity here (no argument passed, ...) +######## +testcase "sanity: successful execution with passed arguments" +mktest test.sh 'while [ $# -gt 0 ]; do echo "> $1" >> test.log; shift; done;' ++ ./testwatcher.py ./test.sh "first argument" "second argument" ++ grep '^> first argument' test.log || fail ++ grep '^> second argument' test.log || fail +rm -f test.sh test.log + +# +# user-controlled (no beah) scenarios (SIGINT): +# - test interrupted, cleanup not set up +# - test interrupted, cleanup successful +# - test successful, cleanup interrupted +# - test interrupted, cleanup interrupted +######## +testcase "user(SIGINT): test interrupted, cleanup not set up" +mktest test.sh 'echo start > test.log; sleep 10; echo end >> test.log' ++ ./testwatcher.py ./test.sh & +sleep 1 ++ pkill -INT -P $! testwatcher.py # $! is the '+' function, parent of tw.py +wait ++ grep 'start' test.log || fail ++ grep 'end' test.log && fail # test is supposed to be killed before end! +rm -f test.sh test.log + +######## +testcase "user(SIGINT): test interrupted, cleanup successful" +mktest test.sh 'echo ./cleanup.sh > "$TESTWATCHER_CLPATH"' \ + 'echo start > test.log; sleep 10; echo end >> test.log' +mktest cleanup.sh 'echo end > cleanup.log' ++ ./testwatcher.py ./test.sh & +sleep 1 ++ pkill -INT -P $! testwatcher.py +wait ++ grep 'start' test.log || fail ++ grep 'end' test.log && fail ++ grep 'end' cleanup.log || fail +rm -f test.sh test.log cleanup.sh cleanup.log + +######## +testcase "user(SIGINT): test successful, cleanup interrupted" +mktest test.sh 'echo ./cleanup.sh > "$TESTWATCHER_CLPATH"' \ + 'echo end > test.log' +mktest cleanup.sh 'echo start > cleanup.log; sleep 10; echo end >> cleanup.log' ++ ./testwatcher.py ./test.sh & +sleep 1 ++ pkill -INT -P $! testwatcher.py +wait ++ grep 'end' test.log || fail ++ grep 'start' cleanup.log || fail ++ grep 'end' cleanup.log && fail # cleanup is supposed to be killed +rm -f test.sh test.log cleanup.sh cleanup.log + +######## +testcase "user(SIGINT): test interrupted, cleanup interrupted" +mktest test.sh 'echo ./cleanup.sh > "$TESTWATCHER_CLPATH"' \ + 'echo start > test.log; sleep 10; echo end >> test.log' +mktest cleanup.sh 'echo start > cleanup.log; sleep 10; echo end >> cleanup.log' ++ ./testwatcher.py ./test.sh & +sleep 1 ++ pkill -INT -P $! testwatcher.py +sleep 1 ++ pkill -INT -P $! testwatcher.py +wait ++ grep 'start' test.log || fail ++ grep 'end' cleanup.log && fail ++ grep 'start' cleanup.log || fail ++ grep 'end' cleanup.log && fail +rm -f test.sh test.log cleanup.sh cleanup.log + +# +# beaker-controlled (beah) scenarios (SIGHUP/SIGTERM): +# - test successful, cleanup successful, LWD expired during cleanup +# - test interrupted (LWD), cleanup not set up +# - test interrupted (LWD), cleanup successful +# - test successful, cleanup interrupted (EWD) +# - test interrupted (LWD), cleanup interrupted (EWD) +######## +testcase "beah(SIGHUP): test successful, cleanup successful, LWD during cleanup" +mktest test.sh 'echo ./cleanup.sh > "$TESTWATCHER_CLPATH"' \ + 'echo end > test.log' +mktest cleanup.sh 'echo start > cleanup.log; sleep 2; echo end >> cleanup.log' ++ ./testwatcher.py ./test.sh & +sleep 1 ++ pkill -HUP -P $! testwatcher.py # only schedules EWD kill in 1 more sec +wait ++ grep 'end' test.log || fail ++ grep 'start' cleanup.log || fail ++ grep 'end' cleanup.log || fail +rm -f test.sh test.log cleanup.sh cleanup.log + +######## +testcase "beah(SIGHUP): test interrupted (LWD), cleanup not set up" +mktest test.sh 'echo start > test.log; sleep 10; echo end >> test.log' ++ ./testwatcher.py ./test.sh & +sleep 1 ++ pkill -HUP -P $! testwatcher.py +wait ++ grep 'start' test.log || fail ++ grep 'end' test.log && fail +rm -f test.sh test.log + +######## +testcase "beah(SIGHUP): test interrupted (LWD), cleanup successful" +mktest test.sh 'echo ./cleanup.sh > "$TESTWATCHER_CLPATH"' \ + 'echo start > test.log; sleep 10; echo end >> test.log' +mktest cleanup.sh 'echo end > cleanup.log' ++ ./testwatcher.py ./test.sh & +sleep 1 ++ pkill -HUP -P $! testwatcher.py +wait ++ grep 'start' test.log || fail ++ grep 'end' test.log && fail ++ grep 'end' cleanup.log || fail +rm -f test.sh test.log cleanup.sh cleanup.log + +######## +testcase "beah(SIGHUP): test successful, cleanup interrupted (EWD)" +mktest test.sh 'echo ./cleanup.sh > "$TESTWATCHER_CLPATH"' \ + 'echo end > test.log' +mktest cleanup.sh 'echo start > cleanup.log; sleep 10; echo end >> cleanup.log' +TESTWATCHER_EWD_SECS=1 + ./testwatcher.py ./test.sh & +sleep 1 ++ pkill -HUP -P $! testwatcher.py # only schedules EWD kill in 1 more sec +wait ++ grep 'end' test.log || fail ++ grep 'start' cleanup.log || fail ++ grep 'end' cleanup.log && fail +rm -f test.sh test.log cleanup.sh cleanup.log + +######## +testcase "beah(SIGHUP): test interrupted (LWD), cleanup interrupted (EWD)" +mktest test.sh 'echo ./cleanup.sh > "$TESTWATCHER_CLPATH"' \ + 'echo start > test.log; sleep 10; echo end >> test.log' +mktest cleanup.sh 'echo start > cleanup.log; sleep 10; echo end >> cleanup.log' +TESTWATCHER_EWD_SECS=1 + ./testwatcher.py ./test.sh & +sleep 1 ++ pkill -HUP -P $! testwatcher.py +#sleep 1 +#+ pkill -HUP -P $! testwatcher.py # not needed, first HUP scheduled EWD kill +wait ++ grep 'start' test.log || fail ++ grep 'end' cleanup.log && fail ++ grep 'start' cleanup.log || fail ++ grep 'end' cleanup.log && fail +rm -f test.sh test.log cleanup.sh cleanup.log + + + +################################################################################ + +echo +echo +echo "==========" +echo "FAILED: $FAILED" +exit $FAILED + +# vim: sts=4 sw=4 et :
On Thu, 2013-10-17 at 18:47 +0200, Jiri Jaburek wrote:
Signed-off-by: Jiri Jaburek jjaburek@redhat.com
src/test/testwatcher.sh | 281 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100755 src/test/testwatcher.sh
diff --git a/src/test/testwatcher.sh b/src/test/testwatcher.sh new file mode 100755 index 0000000..66537ad
(...)
Good, applied. I'll add a line to use this test in 'make check'.
PM
beakerlib-devel@lists.fedorahosted.org