about summary refs log tree commit diff stats
path: root/test/utils/testset.py
diff options
context:
space:
mode:
authorAxel Souchet <0vercl0k@tuxfamily.org>2018-09-09 06:11:00 -0700
committerserpilliere <serpilliere@users.noreply.github.com>2018-09-09 15:11:00 +0200
commit8e6b39d80e9f8db8389bd2a8106d0f64b91c19e9 (patch)
treedbf342089690704e89c10532b83d1d81709a49f4 /test/utils/testset.py
parente61116884ac7879db08313542c6c28a8b00297c5 (diff)
downloadfocaccia-miasm-8e6b39d80e9f8db8389bd2a8106d0f64b91c19e9.tar.gz
focaccia-miasm-8e6b39d80e9f8db8389bd2a8106d0f64b91c19e9.zip
Adds Windows support and AppVeyor CI (#835)
* Get miasm to work on Windows, also add AppVeyor CI

* Fix gcc jitter on Linux

* Make the dse_crackme tests work on Windows

* calling build and then install is less confusing than install twice

* fix os.rename race condition on Windows

* clean it up

* Clean up after the unused cl.exe's artifacts

* Use is_win instead of an additional check

* Fix issue on Windows where 'w' and 'wb' modes are different

* Address review feedback

* setuptools is actually not required, so reverting
Diffstat (limited to 'test/utils/testset.py')
-rw-r--r--test/utils/testset.py74
1 files changed, 34 insertions, 40 deletions
diff --git a/test/utils/testset.py b/test/utils/testset.py
index 29a4e5d0..5688b7e5 100644
--- a/test/utils/testset.py
+++ b/test/utils/testset.py
@@ -35,11 +35,45 @@ class MessageClose(Message):
     "Close the channel"
     pass
 
+def worker(todo_queue, message_queue, init_args):
+    """Worker launched in parrallel
+    @todo_queue: task to do
+    @message_queue: communication with Host
+    @init_args: additionnal arguments for command line
+    """
+
+    # Main loop
+    while True:
+        # Acquire a task
+        test = todo_queue.get()
+        if test is None:
+            break
+        test.start_time = time.time()
+        message_queue.put(MessageTaskNew(test))
+
+        # Launch test
+        executable = test.executable if test.executable else sys.executable
+        testpy = subprocess.Popen(([executable] +
+                                   init_args + test.command_line),
+                                  stdout=subprocess.PIPE,
+                                  stderr=subprocess.PIPE,
+                                  cwd=test.base_dir)
+        outputs = testpy.communicate()
+
+        # Check result
+        error = None
+        if testpy.returncode != 0:
+            error = outputs[1]
+
+        # Report task finish
+        message_queue.put(MessageTaskDone(test, error))
 
 class TestSet(object):
 
     "Manage a set of test"
 
+    worker = staticmethod(worker)
+
     def __init__(self, base_dir):
         """Initalise a test set
         @base_dir: base directory for tests
@@ -132,46 +166,6 @@ class TestSet(object):
                 raise ValueError("Unknown message type %s" % type(message))
 
     @staticmethod
-    def worker(todo_queue, message_queue, init_args):
-        """Worker launched in parrallel
-        @todo_queue: task to do
-        @message_queue: communication with Host
-        @init_args: additionnal arguments for command line
-        """
-
-        # Main loop
-        while True:
-            # Acquire a task
-            test = todo_queue.get()
-            if test is None:
-                break
-            test.start_time = time.time()
-            message_queue.put(MessageTaskNew(test))
-
-            # Go to the expected directory
-            current_directory = os.getcwd()
-            os.chdir(test.base_dir)
-
-            # Launch test
-            executable = test.executable if test.executable else sys.executable
-            testpy = subprocess.Popen(([executable] +
-                                       init_args + test.command_line),
-                                      stdout=subprocess.PIPE,
-                                      stderr=subprocess.PIPE)
-            outputs = testpy.communicate()
-
-            # Check result
-            error = None
-            if testpy.returncode != 0:
-                error = outputs[1]
-
-            # Restore directory
-            os.chdir(current_directory)
-
-            # Report task finish
-            message_queue.put(MessageTaskDone(test, error))
-
-    @staticmethod
     def fast_unify(seq, idfun=None):
         """Order preserving unifying list function
         @seq: list to unify