summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Pino Garcia <dpino@igalia.com>2021-01-28 14:04:43 +0800
committerPatrick Griffis <tingping@tingping.se>2021-04-13 21:14:37 +0000
commit9dc160e1e83dac5f9e2261ad7223816024796ade (patch)
tree97aee009dfd8762e6d970b8972272c45865e1456
parentaf867b203176809df2458d77abcf9fd76900822d (diff)
downloadlibsoup-9dc160e1e83dac5f9e2261ad7223816024796ade.tar.gz
tests: start autobahn server
-rw-r--r--tests/autobahn/soup-autobahn-test-client.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/autobahn/soup-autobahn-test-client.c b/tests/autobahn/soup-autobahn-test-client.c
index b4f01b13..2fdcb28f 100644
--- a/tests/autobahn/soup-autobahn-test-client.c
+++ b/tests/autobahn/soup-autobahn-test-client.c
@@ -21,6 +21,7 @@
*/
#include <stdio.h>
+#include <unistd.h>
#include <libsoup/soup.h>
GMainLoop *loop;
@@ -189,12 +190,55 @@ update_reports (SoupSession *session)
g_free (path);
}
+static gboolean
+autobahn_server (const char *action)
+{
+ GPtrArray *argv;
+ char *cwd;
+
+ cwd = g_get_current_dir();
+
+ char *dirname = g_path_get_dirname (__FILE__);
+ char *path = g_build_filename(dirname, "autobahn-server.sh", NULL);
+
+ argv = g_ptr_array_new ();
+ g_ptr_array_add (argv, path);
+ g_ptr_array_add (argv, (char *) action);
+ g_ptr_array_add (argv, NULL);
+
+ gboolean ret = g_spawn_async (cwd, (char **) argv->pdata, NULL, 0, NULL, NULL,
+ NULL, NULL);
+ g_free (path);
+
+ return ret;
+}
+
+static void
+start_autobahn (void)
+{
+ gboolean code = autobahn_server ("--start");
+ if (code == FALSE) {
+ fprintf(stderr, "Could not start Autobahn server\n");
+ exit(1);
+ }
+}
+
+static void
+stop_autobahn (void)
+{
+ autobahn_server ("--stop");
+}
+
int main (int argc, char* argv[])
{
GOptionContext *context;
GError *error = NULL;
SoupSession *session;
+ fprintf (stderr, "Starting Autobahn server\n");
+ start_autobahn ();
+ sleep (2);
+
context = g_option_context_new ("- libsoup test runner for Autobahn WebSocket client tests.");
g_option_context_add_main_entries (context, entries, NULL);
@@ -229,5 +273,7 @@ int main (int argc, char* argv[])
g_object_unref (session);
+ stop_autobahn();
+
return 0;
}