commit 4338f18609c3fc2a80b9a3a67fdd521e80569386 Author: Jiri Pirko jpirko@redhat.com Date: Fri Jul 1 17:12:58 2011 +0200
NetTestCommand: add intr command
This patch also reverts kill command and improves it by sending SIGKILL
Signed-off-by: Jiri Pirko jpirko@redhat.com
NetTest/NetTestCommand.py | 15 +++++++++++++-- NetTest/NetTestParse.py | 2 +- example_recipes/jpirko_test/recipe_brpktgen.xml | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) --- diff --git a/NetTest/NetTestCommand.py b/NetTest/NetTestCommand.py index 24f432c..1605401 100644 --- a/NetTest/NetTestCommand.py +++ b/NetTest/NetTestCommand.py @@ -129,17 +129,26 @@ class NetTestCommandWait(NetTestCommandGeneric): bg_processes.remove(bg_id) self.set_result(result)
-class NetTestCommandKill(NetTestCommandGeneric): +class NetTestCommandIntr(NetTestCommandGeneric): def run(self): bg_id = int(self._command["value"]) pid = bg_processes.get_pid(bg_id) - logging.debug("Killing background id "%d", pid "%d"" % (bg_id, pid)) + logging.debug("Interrupting background id "%d", pid "%d"" % (bg_id, pid)) os.killpg(os.getpgid(pid), signal.SIGINT) os.waitpid(pid, 0) result = get_bg_process_result(bg_id) bg_processes.remove(bg_id) self.set_result(result)
+class NetTestCommandKill(NetTestCommandGeneric): + def run(self): + bg_id = int(self._command["value"]) + pid = bg_processes.get_pid(bg_id) + logging.debug("Killing background id "%d", pid "%d"" % (bg_id, pid)) + os.killpg(os.getpgid(pid), signal.SIGKILL) + bg_processes.remove(bg_id) + self.set_result({"passed": True}) + def get_command_class(command): cmd_type = command["type"] if cmd_type == "exec": @@ -148,6 +157,8 @@ def get_command_class(command): return NetTestCommandTest(command) elif cmd_type == "wait": return NetTestCommandWait(command) + elif cmd_type == "intr": + return NetTestCommandIntr(command) elif cmd_type == "kill": return NetTestCommandKill(command) else: diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py index f0be155..c042292 100644 --- a/NetTest/NetTestParse.py +++ b/NetTest/NetTestParse.py @@ -159,7 +159,7 @@ class NetTestParse: bg_ids[machine_id] = set()
cmd_type = command["type"] - if cmd_type in ["kill", "wait"]: + if cmd_type in ["wait", "intr", "kill"]: bg_id = int(command["value"]) if bg_id in bg_ids[machine_id]: bg_ids[machine_id].remove(bg_id) diff --git a/example_recipes/jpirko_test/recipe_brpktgen.xml b/example_recipes/jpirko_test/recipe_brpktgen.xml index 1fcd8c8..0e186de 100644 --- a/example_recipes/jpirko_test/recipe_brpktgen.xml +++ b/example_recipes/jpirko_test/recipe_brpktgen.xml @@ -48,6 +48,6 @@ <option name="netdev_name" type="recipe_eval" value="['machines'][2]['netconfig'][2]['name']"/> </options> </command> - <command machine_id="1" type="kill" value="1"/> + <command machine_id="1" type="intr" value="1"/> </command_sequence> </nettestrecipe>