]> code.delx.au - pulseaudio/blobdiff - src/tests/thread-mainloop-test.c
tests: modify thread-mainloop-test to use 'check' framework
[pulseaudio] / src / tests / thread-mainloop-test.c
index 599f1959bdf34b9e0b17ee0aa9d5a9ed50e4aabd..d2f6152bf2401f95f8d07655397db1cdf7f22cb6 100644 (file)
@@ -25,6 +25,8 @@
 #include <unistd.h>
 #include <stdio.h>
 
+#include <check.h>
+
 #include <pulse/rtclock.h>
 #include <pulse/timeval.h>
 #include <pulse/util.h>
@@ -40,19 +42,21 @@ static void tcb(pa_mainloop_api *a, pa_time_event *e, const struct timeval *tv,
     fprintf(stderr, "TIME EVENT END\n");
 }
 
-int main(int argc, char *argv[]) {
+START_TEST (thread_mainloop_test) {
     pa_mainloop_api *a;
     pa_threaded_mainloop *m;
     struct timeval tv;
 
-    pa_assert_se(m = pa_threaded_mainloop_new());
-    pa_assert_se(a = pa_threaded_mainloop_get_api(m));
+    m = pa_threaded_mainloop_new();
+    fail_unless(m != NULL);
+    a = pa_threaded_mainloop_get_api(m);
+    fail_unless(m != NULL);
 
-    pa_assert_se(pa_threaded_mainloop_start(m) >= 0);
+    fail_unless(pa_threaded_mainloop_start(m) >= 0);
 
     pa_threaded_mainloop_lock(m);
 
-    pa_assert_se(!pa_threaded_mainloop_in_thread(m));
+    fail_unless(!pa_threaded_mainloop_in_thread(m));
 
     a->time_new(a, pa_timeval_rtstore(&tv, pa_rtclock_now() + 5 * PA_USEC_PER_SEC, TRUE), tcb, m);
 
@@ -70,5 +74,28 @@ int main(int argc, char *argv[]) {
     pa_threaded_mainloop_stop(m);
 
     pa_threaded_mainloop_free(m);
-    return 0;
+}
+END_TEST
+
+int main(int argc, char *argv[]) {
+    int failed = 0;
+    Suite *s;
+    TCase *tc;
+    SRunner *sr;
+
+    s = suite_create("Thread MainLoop");
+    tc = tcase_create("threadmainloop");
+    tcase_add_test(tc, thread_mainloop_test);
+    /* the default timeout is too small,
+     * set it to a reasonable large one.
+     */
+    tcase_set_timeout(tc, 60 * 60);
+    suite_add_tcase(s, tc);
+
+    sr = srunner_create(s);
+    srunner_run_all(sr, CK_NORMAL);
+    failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+
+    return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }