rsyslog/tests/omprog-restart-terminated-vg.sh
Joan Sala 845ffe603b testbench: fix omprog-output-capture-mt.sh test failure in Python 3
Make the test program explicitly flush lines written to stdout and
stderr, and do not use stdbuf to force line buffering for stdout.

In Python 2 stderr was unbuffered, but in Python 3 it is block-buffered
when redirected to a file/pipe. Besides, stdbuf seems to have no effect
on Python 3.

This solves one of the problems with this test described in #3361.
The problem ocurred with Python 3 and after the addition of the
wait_file_lines check in v8.40.0. The buffering that Python did caused
the last two lines of the output file to be written at shutdown time.

Other minor fixes and consistency enhancements in other omprog tests.
2018-12-26 17:32:06 +01:00

76 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# This file is part of the rsyslog project, released under ASL 2.0
# Same test than 'omprog-restart-terminated.sh', but checking for memory
# problems using valgrind. Note it is not necessary to repeat the
# rest of checks (this simplifies the maintenance of the tests).
. ${srcdir:=.}/diag.sh init
generate_conf
add_conf '
module(load="../plugins/omprog/.libs/omprog")
template(name="outfmt" type="string" string="%msg%\n")
:msg, contains, "msgnum:" {
action(
type="omprog"
binary="'$RSYSLOG_DYNNAME'.omprog-restart-terminated-bin.sh"
template="outfmt"
name="omprog_action"
queue.type="Direct" # the default; facilitates sync with the child process
confirmMessages="on" # facilitates sync with the child process
action.resumeRetryCount="3"
action.resumeInterval="1"
action.reportSuspensionContinuation="on"
signalOnClose="off"
)
}
'
# We need a test-specific program name, as the test needs to signal the child process
cp -f $srcdir/testsuites/omprog-restart-terminated-bin.sh $RSYSLOG_DYNNAME.omprog-restart-terminated-bin.sh
# On Solaris 10, the output of ps is truncated for long process names; use /usr/ucb/ps instead:
if [[ $(uname) = "SunOS" && $(uname -r) = "5.10" ]]; then
function get_child_pid {
/usr/ucb/ps -awwx | grep "$RSYSLOG_DYNNAME.[o]mprog-restart-terminated-bin.sh" | awk '{ print $1 }'
}
else
function get_child_pid {
ps -ef | grep "$RSYSLOG_DYNNAME.[o]mprog-restart-terminated-bin.sh" | awk '{ print $2 }'
}
fi
startup_vg
injectmsg 0 1
injectmsg 1 1
injectmsg 2 1
wait_queueempty
kill -s USR1 $(get_child_pid)
./msleep 100
injectmsg 3 1
injectmsg 4 1
wait_queueempty
kill -s TERM $(get_child_pid)
./msleep 100
injectmsg 5 1
injectmsg 6 1
injectmsg 7 1
wait_queueempty
kill -s USR1 $(get_child_pid)
./msleep 100
injectmsg 8 1
injectmsg 9 1
shutdown_when_empty
wait_shutdown_vg
check_exit_vg
exit_test