summaryrefslogtreecommitdiff
path: root/yaksh/evaluator_tests
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-04-27 17:28:44 +0530
committerGitHub2017-04-27 17:28:44 +0530
commita67f8597da19527669b596fab08083a18c7e1fcc (patch)
tree26484d05a23223df13aabb42fe674ce759e09187 /yaksh/evaluator_tests
parentea9e60c47b763515b324aa507da06a1e91c488c6 (diff)
parent4a8f9a117f6a784fe722b8b381368c41be86024a (diff)
downloadonline_test-a67f8597da19527669b596fab08083a18c7e1fcc.tar.gz
online_test-a67f8597da19527669b596fab08083a18c7e1fcc.tar.bz2
online_test-a67f8597da19527669b596fab08083a18c7e1fcc.zip
Merge pull request #274 from maheshgudi/kill_stray_processes
Kill stray processes
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r--yaksh/evaluator_tests/test_bash_evaluation.py10
-rw-r--r--yaksh/evaluator_tests/test_c_cpp_evaluation.py13
-rw-r--r--yaksh/evaluator_tests/test_java_evaluation.py16
-rw-r--r--yaksh/evaluator_tests/test_scilab_evaluation.py9
4 files changed, 47 insertions, 1 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py
index 482d45e..8bb8c81 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,10 @@ 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:
+ children_procs = Process(parent_proc[0].pid)
+ self.assertFalse(any(children_procs.children(recursive=True)))
def test_file_based_assert(self):
# Given
@@ -528,6 +534,10 @@ class BashHookEvaluationTestCases(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:
+ children_procs = Process(parent_proc[0].pid)
+ self.assertFalse(any(children_procs.children(recursive=True)))
if __name__ == '__main__':
diff --git a/yaksh/evaluator_tests/test_c_cpp_evaluation.py b/yaksh/evaluator_tests/test_c_cpp_evaluation.py
index 304f1cb..b15f766 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,10 @@ 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:
+ children_procs = Process(parent_proc[0].pid)
+ self.assertFalse(any(children_procs.children(recursive=True)))
def test_file_based_assert(self):
# Given
@@ -401,6 +406,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:
+ children_procs = Process(parent_proc[0].pid)
+ self.assertFalse(any(children_procs.children(recursive=True)))
def test_only_stdout(self):
# Given
@@ -967,6 +976,10 @@ class CppHookEvaluationTestCases(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:
+ children_procs = Process(parent_proc[0].pid)
+ self.assertFalse(any(children_procs.children(recursive=True)))
if __name__ == '__main__':
diff --git a/yaksh/evaluator_tests/test_java_evaluation.py b/yaksh/evaluator_tests/test_java_evaluation.py
index 3d127af..ea558ed 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:
+ children_procs = Process(parent_proc[0].pid)
+ self.assertFalse(any(children_procs.children(recursive=True)))
def test_file_based_assert(self):
# Given
@@ -398,6 +405,10 @@ 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:
+ children_procs = Process(parent_proc[0].pid)
+ self.assertFalse(any(children_procs.children(recursive=True)))
def test_only_stdout(self):
# Given
@@ -832,8 +843,13 @@ class JavaHookEvaluationTestCases(EvaluatorBaseTest):
result = grader.evaluate(kwargs)
# 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:
+ children_procs = Process(parent_proc[0].pid)
+ self.assertFalse(any(children_procs.children(recursive=True)))
if __name__ == '__main__':
diff --git a/yaksh/evaluator_tests/test_scilab_evaluation.py b/yaksh/evaluator_tests/test_scilab_evaluation.py
index 5a452a3..c3a1c83 100644
--- a/yaksh/evaluator_tests/test_scilab_evaluation.py
+++ b/yaksh/evaluator_tests/test_scilab_evaluation.py
@@ -3,13 +3,15 @@ import unittest
import os
import shutil
import tempfile
+from psutil import Process
from textwrap import dedent
+
+#Local Import
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
-
class ScilabEvaluationTestCases(EvaluatorBaseTest):
def setUp(self):
tmp_in_dir_path = tempfile.mkdtemp()
@@ -136,6 +138,11 @@ 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:
+ children_procs = Process(parent_proc[0].pid)
+ self.assertFalse(any(children_procs.children(recursive=True)))
+
if __name__ == '__main__':
unittest.main()