From: Ondrej Lichtner olichtne@redhat.com
The exec syscall resets all signal handlers except for SIG_IGN. This means that exec_cmd() doesn't work with <intr> commands. The original regression test didn't catch this because ping sets it's own SIGINT handler. To fix this we will use our own handler function that will just ignore the signal, it has the same behaviour as SIG_IGN, but will get reset on exec syscall, which is what we want.
The patch also adds a new recipe to the regression test.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Common/NetTestCommand.py | 9 ++++++--- regression-tests/tests/25/recipe3.xml | 28 ++++++++++++++++++++++++++++ regression-tests/tests/25/run.sh | 6 ++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 regression-tests/tests/25/recipe3.xml
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py index c1a796f..cfa2b3b 100644 --- a/lnst/Common/NetTestCommand.py +++ b/lnst/Common/NetTestCommand.py @@ -137,11 +137,14 @@ class NetTestCommand: "res_header": self._cmd_cls._format_cmd_res_header(), "msg": "Running in background."}
+ def _sig_ign(self, signum, frame): + pass + def _run(self): os.setpgrp() - signal.signal(signal.SIGHUP, signal.SIG_IGN) - signal.signal(signal.SIGINT, signal.SIG_IGN) - signal.signal(signal.SIGTERM, signal.SIG_IGN) + signal.signal(signal.SIGHUP, self._sig_ign) + signal.signal(signal.SIGINT, self._sig_ign) + signal.signal(signal.SIGTERM, self._sig_ign)
self._connection_pipe = self._write_pipe
diff --git a/regression-tests/tests/25/recipe3.xml b/regression-tests/tests/25/recipe3.xml new file mode 100644 index 0000000..4cdb6f4 --- /dev/null +++ b/regression-tests/tests/25/recipe3.xml @@ -0,0 +1,28 @@ +<lnstrecipe> + <network> + <host id="testmachine1"> + <interfaces> + <eth id="test_if" label="tnet"> + <addresses> + <address value="192.168.0.1/24" /> + </addresses> + </eth> + </interfaces> + </host> + <host id="testmachine2"> + <interfaces> + <eth id="test_if" label="tnet"> + <addresses> + <address value="192.168.0.2/24" /> + </addresses> + </eth> + </interfaces> + </host> + </network> + + <task> + <run command="sleep 120" host="testmachine1" bg_id="1" timeout="125"/> + <ctl_wait seconds="5"/> + <intr host="testmachine1" bg_id="1"/> + </task> +</lnstrecipe> diff --git a/regression-tests/tests/25/run.sh b/regression-tests/tests/25/run.sh index 8e1daa2..745a06b 100755 --- a/regression-tests/tests/25/run.sh +++ b/regression-tests/tests/25/run.sh @@ -12,9 +12,15 @@ lnst-ctl -d run recipe2.xml | tee test.log rv2=${PIPESTATUS[0]} log2=`cat test.log`
+lnst-ctl -d run recipe3.xml | tee test.log +rv3=${PIPESTATUS[0]} +log3=`cat test.log` + print_separator assert_status "pass" "$rv1" assert_status "pass" "$rv2" +assert_status "pass" "$rv3" +assert_log "ERROR" "Command execution failed (exited with -2)" "$log3"
rm -f test.log
lnst-developers@lists.fedorahosted.org