about summary refs log tree commit diff stats
path: root/test
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
parente61116884ac7879db08313542c6c28a8b00297c5 (diff)
downloadmiasm-8e6b39d80e9f8db8389bd2a8106d0f64b91c19e9.tar.gz
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')
-rw-r--r--test/jitter/test_post_instr.py2
-rwxr-xr-xtest/test_all.py7
-rw-r--r--test/utils/cosmetics.py8
-rw-r--r--test/utils/testset.py74
4 files changed, 49 insertions, 42 deletions
diff --git a/test/jitter/test_post_instr.py b/test/jitter/test_post_instr.py
index 39e87616..97ba167f 100644
--- a/test/jitter/test_post_instr.py
+++ b/test/jitter/test_post_instr.py
@@ -35,7 +35,7 @@ jitter.add_exception_handler(EXCEPT_BREAKPOINT_MEMORY,
 jitter.vm.add_memory_breakpoint(0x11000-4, 4, PAGE_READ | PAGE_WRITE)
 
 # The memory write pending will raise automod execption
-# The RET should not re evalueate PC @ [ESP+4]
+# The RET should not re evaluate PC @ [ESP+4]
 jitter.init_run(0x1000)
 try:
     jitter.continue_run()
diff --git a/test/test_all.py b/test/test_all.py
index a69ec229..d1ccb19f 100755
--- a/test/test_all.py
+++ b/test/test_all.py
@@ -6,12 +6,15 @@ import os
 import platform
 import time
 import tempfile
+import platform
 
 from utils.test import Test
 from utils.testset import TestSet
 from utils import cosmetics, multithread
 from multiprocessing import Queue
 
+is_win = platform.system() == "Windows"
+
 testset = TestSet("../")
 TAGS = {"regression": "REGRESSION", # Regression tests
         "example": "EXAMPLE", # Examples
@@ -99,6 +102,8 @@ for script in ["x86/sem.py",
         if jitter in blacklist.get(script, []):
             continue
         tags = [TAGS[jitter]] if jitter in TAGS else []
+        if is_win and script.endswith("mn_div.py"):
+            continue
         testset += ArchUnitTest(script, jitter, base_dir="arch", tags=tags)
 
 testset += ArchUnitTest("x86/unit/access_xmm.py", "python", base_dir="arch")
@@ -653,7 +658,7 @@ for strategy in ["code-cov", "branch-cov", "path-cov"]:
     testset += ExampleSymbolExec(["dse_strategies.py",
                                   Example.get_sample("simple_test.bin"),
                                   strategy],
-                                 tags=[TAGS["z3"]])
+                                  tags=[TAGS["z3"]])
 
 ## Jitter
 class ExampleJitter(Example):
diff --git a/test/utils/cosmetics.py b/test/utils/cosmetics.py
index d870507b..e80e1f09 100644
--- a/test/utils/cosmetics.py
+++ b/test/utils/cosmetics.py
@@ -1,5 +1,7 @@
 import os
+import platform
 
+is_win = platform.system() == "Windows"
 
 def getTerminalSize():
     "Return the size of the terminal : COLUMNS, LINES"
@@ -37,6 +39,12 @@ colors = {"red": "\033[91;1m",
           "lightcyan": "\033[96m",
           "blue": "\033[94;1m"}
 
+if is_win:
+    colors = {"red": "",
+              "end": "",
+              "green": "",
+              "lightcyan": "",
+              "blue": ""}
 
 def write_colored(text, color, already_printed=0):
     text_colored = colors[color] + text + colors["end"]
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