[Spice-commits] 2 commits - server/tests

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jan 3 13:26:23 UTC 2019


 server/tests/regression-test.py  |    4 ++--
 server/tests/replay.c            |    5 ++++-
 server/tests/test-display-base.c |   37 +++++++++++++++++--------------------
 3 files changed, 23 insertions(+), 23 deletions(-)

New commits:
commit 5cbdf1a2351e3318423603f6d779fefef95f836e
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Jun 24 21:41:34 2018 +0100

    test-display-base: Port to Windows
    
    Use GLib function to launch and wait process exit.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Reviewed-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/server/tests/regression-test.py b/server/tests/regression-test.py
index 5aad1a7b..81eaecf1 100755
--- a/server/tests/regression-test.py
+++ b/server/tests/regression-test.py
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 from subprocess import PIPE, Popen
-import Image
-import ImageChops
+from PIL import Image
+from PIL import ImageChops
 
 
 def spicy_screenshot():
diff --git a/server/tests/test-display-base.c b/server/tests/test-display-base.c
index 3ca85f3a..20b97833 100644
--- a/server/tests/test-display-base.c
+++ b/server/tests/test-display-base.c
@@ -89,17 +89,19 @@ static int has_automated_tests = 0; //automated test flag
 // between multiple threads so use a mutex
 static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER;
 
-__attribute__((noreturn))
-static void sigchld_handler(SPICE_GNUC_UNUSED int signal_num) // wait for the child process and exit
+// wait for the child process and exit
+static void child_exited(GPid pid, gint status, gpointer user_data)
 {
-    int status;
-    wait(&status);
+    g_spawn_close_pid(pid);
     exit(0);
 }
 
 static void regression_test(void)
 {
-    pid_t pid;
+    GPid pid;
+    GError *error = NULL;
+    gboolean retval;
+    gchar **argv;
 
     if (--rects != 0) {
         return;
@@ -111,17 +113,17 @@ static void regression_test(void)
         return;
     }
 
-    pid = fork();
-    if (pid == 0) {
-        char buf[PATH_MAX];
-        char *argv[] = { NULL };
-        char *envp[] = {buf, NULL};
+    argv = g_strsplit("./regression-test.py", " ", -1);
+    retval = g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD,
+                           NULL, NULL, &pid, &error);
+    g_strfreev(argv);
+    g_assert(retval);
 
-        snprintf(buf, sizeof(buf), "PATH=%s", getenv("PATH"));
-        execve("regression-test.py", argv, envp);
-    } else if (pid > 0) {
-        return;
-    }
+    GSource *source = g_child_watch_source_new(pid);
+    g_source_set_callback(source, (GSourceFunc)(void*)child_exited, NULL, NULL);
+    guint id = g_source_attach(source, basic_event_loop_get_context());
+    g_assert(id != 0);
+    g_source_unref(source);
 }
 
 static void set_cmd(QXLCommandExt *ext, uint32_t type, QXLPHYSICAL data)
@@ -967,11 +969,6 @@ void test_destroy(Test *test)
 
 static void init_automated(void)
 {
-    struct sigaction sa;
-
-    memset(&sa, 0, sizeof sa);
-    sa.sa_handler = &sigchld_handler;
-    sigaction(SIGCHLD, &sa, NULL);
 }
 
 static __attribute__((noreturn))
commit f5103aed1f9e2049a98a95d3f5afa8528031b6b1
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Jun 24 19:25:56 2018 +0100

    replay: Force binary mode on input on Windows
    
    If input contains the binary record we can't have it modified
    during read.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Reviewed-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/server/tests/replay.c b/server/tests/replay.c
index bd9420b8..095b112e 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -390,8 +390,11 @@ int main(int argc, char **argv)
 
     if (strncmp(file[0], "-", 1) == 0) {
         fd = stdin;
+#ifdef _WIN32
+        _setmode(fileno(fd), _O_BINARY);
+#endif
     } else {
-        fd = fopen(file[0], "r");
+        fd = fopen(file[0], "rb");
     }
     if (fd == NULL) {
         g_printerr("error opening %s\n", file[0]);


More information about the Spice-commits mailing list