diff options
-rw-r--r-- | yaksh/base_evaluator.py | 2 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_bash_evaluation.py | 8 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_c_cpp_evaluation.py | 10 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_java_evaluation.py | 12 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_scilab_evaluation.py | 6 |
5 files changed, 36 insertions, 2 deletions
diff --git a/yaksh/base_evaluator.py b/yaksh/base_evaluator.py index 653aef0..e702f68 100644 --- a/yaksh/base_evaluator.py +++ b/yaksh/base_evaluator.py @@ -35,7 +35,7 @@ class BaseEvaluator(object): stdout, stderr = proc.communicate() except TimeoutException: # Runaway code, so kill it. - os.killpg(os.getpgid(proc.pid), signal.SIGTERM) + os.killpg(os.getpgid(proc.pid), signal.SIGKILL) # Re-raise exception. raise return proc, stdout.decode('utf-8'), stderr.decode('utf-8') diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py index 482d45e..ee6949d 100644 --- a/yaksh/evaluator_tests/test_bash_evaluation.py +++ b/yaksh/evaluator_tests/test_bash_evaluation.py @@ -3,6 +3,8 @@ import unittest import os import shutil import tempfile +from psutil import Process, pid_exists +# Local Imports from yaksh.grader import Grader from yaksh.bash_code_evaluator import BashCodeEvaluator from yaksh.bash_stdio_evaluator import BashStdIOEvaluator @@ -103,6 +105,12 @@ class BashAssertionEvaluationTestCases(EvaluatorBaseTest): # Then self.assertFalse(result.get("success")) self.assert_correct_output(self.timeout_msg, result.get("error")) + parent_proc = Process(os.getpid()).children() + if parent_proc: + self.assertFalse(any(Process(parent_proc[0].pid)\ + .children(recursive=True))) + + def test_file_based_assert(self): # Given diff --git a/yaksh/evaluator_tests/test_c_cpp_evaluation.py b/yaksh/evaluator_tests/test_c_cpp_evaluation.py index 304f1cb..d3147f5 100644 --- a/yaksh/evaluator_tests/test_c_cpp_evaluation.py +++ b/yaksh/evaluator_tests/test_c_cpp_evaluation.py @@ -4,6 +4,7 @@ import os import shutil import tempfile from textwrap import dedent +from psutil import Process # Local import from yaksh.grader import Grader @@ -151,6 +152,11 @@ class CAssertionEvaluationTestCases(EvaluatorBaseTest): # Then self.assertFalse(result.get("success")) self.assert_correct_output(self.timeout_msg, result.get("error")) + parent_proc = Process(os.getpid()).children() + if parent_proc: + self.assertFalse(any(Process(parent_proc[0].pid)\ + .children(recursive=True))) + def test_file_based_assert(self): # Given @@ -401,6 +407,10 @@ class CppStdIOEvaluationTestCases(EvaluatorBaseTest): # Then self.assertFalse(result.get("success")) self.assert_correct_output(self.timeout_msg, result.get("error")) + parent_proc = Process(os.getpid()).children() + if parent_proc: + self.assertFalse(any(Process(parent_proc[0].pid)\ + .children(recursive=True))) def test_only_stdout(self): # Given diff --git a/yaksh/evaluator_tests/test_java_evaluation.py b/yaksh/evaluator_tests/test_java_evaluation.py index 3d127af..2c49a50 100644 --- a/yaksh/evaluator_tests/test_java_evaluation.py +++ b/yaksh/evaluator_tests/test_java_evaluation.py @@ -4,6 +4,9 @@ import os import shutil import tempfile from textwrap import dedent +from psutil import Process, pid_exists +import time + # Local Import from yaksh import grader as gd @@ -158,6 +161,10 @@ class JavaAssertionEvaluationTestCases(EvaluatorBaseTest): # Then self.assertFalse(result.get("success")) self.assert_correct_output(self.timeout_msg, result.get("error")) + parent_proc = Process(os.getpid()).children() + if parent_proc: + self.assertFalse(any(Process(parent_proc[0].pid)\ + .children(recursive=True))) def test_file_based_assert(self): # Given @@ -398,6 +405,11 @@ class JavaStdIOEvaluationTestCases(EvaluatorBaseTest): # Then self.assertFalse(result.get("success")) self.assert_correct_output(self.timeout_msg, result.get("error")) + parent_proc = Process(os.getpid()).children() + if parent_proc: + self.assertFalse(any(Process(parent_proc[0].pid)\ + .children(recursive=True))) + def test_only_stdout(self): # Given diff --git a/yaksh/evaluator_tests/test_scilab_evaluation.py b/yaksh/evaluator_tests/test_scilab_evaluation.py index 5a452a3..1792937 100644 --- a/yaksh/evaluator_tests/test_scilab_evaluation.py +++ b/yaksh/evaluator_tests/test_scilab_evaluation.py @@ -8,7 +8,7 @@ from yaksh import grader as gd from yaksh.grader import Grader from yaksh.scilab_code_evaluator import ScilabCodeEvaluator from yaksh.evaluator_tests.test_python_evaluation import EvaluatorBaseTest - +from psutil import Process class ScilabEvaluationTestCases(EvaluatorBaseTest): def setUp(self): @@ -136,6 +136,10 @@ class ScilabEvaluationTestCases(EvaluatorBaseTest): self.assertFalse(result.get("success")) self.assert_correct_output(self.timeout_msg, result.get("error")) + parent_proc = Process(os.getpid()).children() + if parent_proc: + self.assertFalse(any(Process(parent_proc[0].pid)\ + .children(recursive=True))) if __name__ == '__main__': unittest.main() |