summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2019-07-31 19:20:27 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2019-08-02 12:29:15 -0400
commitaaa1d01d382031c47f4df2a06d9288324e5b7b94 (patch)
tree3f13c21a1416a73abd1352fbc24a6f0caa440658
parent9ae5fdb2a76048fa190b9e9f53ff7a4476b22883 (diff)
downloadlibnice-aaa1d01d382031c47f4df2a06d9288324e5b7b94.tar.gz
tests: Port test-fullmode-with-stun wrapper to C
Shell scripts don't work well on Windows and Python doesn't work with valgrind.
-rw-r--r--tests/meson.build17
-rw-r--r--tests/test-fullmode-with-stun.c56
2 files changed, 68 insertions, 5 deletions
diff --git a/tests/meson.build b/tests/meson.build
index 332a8a9..4cb1cb1 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -54,6 +54,18 @@ foreach tname : nice_tests
install: false)
set_variable(tname.underscorify(), exe)
test(tname, exe, env: tenv)
+
+ if tname == 'test-fullmode'
+ wrapper_exe = executable ('nice-test-fullmode-with-stun',
+ 'test-fullmode-with-stun.c',
+ dependencies: gio_deps,
+ install: false)
+ test('test-fullmode-with-stun', wrapper_exe,
+ args: [stund_exe, test_fullmode],
+ env: tenv,
+ is_parallel: false,
+ depends: exe)
+ endif
endforeach
if gst_dep.found()
@@ -81,11 +93,6 @@ if find_program('sh', required : false).found()
args: test_pseudotcp,
env: tenv)
endif
-
- test('test-fullmode-with-stun', files('check-test-fullmode-with-stun.sh'),
- args: [stund_exe, test_fullmode],
- env: tenv,
- is_parallel: false)
endif
debugenv = environment()
diff --git a/tests/test-fullmode-with-stun.c b/tests/test-fullmode-with-stun.c
new file mode 100644
index 0000000..7d0b9fd
--- /dev/null
+++ b/tests/test-fullmode-with-stun.c
@@ -0,0 +1,56 @@
+#include <gio/gio.h>
+
+int
+main (int argc, char ** argv)
+{
+ int retval = 0;
+ char *stund;
+ char *test_fullmode;
+ GSubprocessLauncher *launcher;
+ GSubprocess *stund_proc, *test_subprocess;
+ const gchar NICE_STUN_SERVER[] = "127.0.0.1";
+ const gchar NICE_STUN_SERVER_PORT[] = "3800";
+ GError *gerr = NULL;
+
+ if (argc < 3) {
+ g_printerr ("Usage: %s <stund path> <test fullmode path>\n",
+ argv[0]);
+ return 77;
+ }
+
+ stund = argv[1];
+ test_fullmode = argv[2];
+
+ g_print ("Starting ICE full-mode with STUN unit test.\n");
+ g_print ("Launching %s on port %s.\n", stund, NICE_STUN_SERVER_PORT);
+
+
+ stund_proc = g_subprocess_new (G_SUBPROCESS_FLAGS_NONE, &gerr,
+ stund, NICE_STUN_SERVER_PORT, NULL);
+
+ sleep(1);
+
+ launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
+
+ g_subprocess_launcher_setenv (launcher, "NICE_STUN_SERVER", NICE_STUN_SERVER,
+ TRUE);
+ g_subprocess_launcher_setenv (launcher, "NICE_STUN_SERVER_PORT",
+ NICE_STUN_SERVER_PORT, TRUE);
+ g_print ("Running test fullmode as %s\n", test_fullmode);
+ test_subprocess = g_subprocess_launcher_spawn (launcher, &gerr,
+ test_fullmode, NULL);
+ g_assert_no_error (gerr);
+ g_subprocess_wait (test_subprocess, NULL, &gerr);
+ g_assert_no_error (gerr);
+ retval = g_subprocess_get_exit_status (test_subprocess);
+ g_print ("Test process returned %d\n", retval);
+ g_object_unref (test_subprocess);
+ g_object_unref (launcher);
+
+ g_subprocess_force_exit (stund_proc);
+ g_subprocess_wait (stund_proc, NULL, &gerr);
+ g_assert_no_error (gerr);
+ g_object_unref(stund_proc);
+
+ return retval;
+}