]> code.delx.au - pulseaudio/commitdiff
tests: modify thread-test to use 'check' framework
authorDeng Zhengrong <dzrongg@gmail.com>
Sat, 28 Jul 2012 10:01:41 +0000 (18:01 +0800)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Mon, 20 Aug 2012 01:35:59 +0000 (07:05 +0530)
src/Makefile.am
src/tests/thread-test.c

index 3038055721c8d62524ce043beedbd6f10052e62e..7b0d057b19b937a29f5404c160397f6a9a5cb20f 100644 (file)
@@ -350,9 +350,9 @@ memblock_test_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINOR@.la libpulse.la li
 memblock_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 thread_test_SOURCES = tests/thread-test.c
-thread_test_CFLAGS = $(AM_CFLAGS)
+thread_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
 thread_test_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINOR@.la libpulse.la libpulsecommon-@PA_MAJORMINOR@.la
-thread_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
+thread_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
 
 once_test_SOURCES = tests/once-test.c
 once_test_CFLAGS = $(AM_CFLAGS)
index 6441dc7e08bf8768876b4ab1254d71b36bcc06bd..de4813c967f52c9d4503de9f7ef830b4f4409293 100644 (file)
@@ -21,6 +21,8 @@
 #include <config.h>
 #endif
 
+#include <check.h>
+
 #include <pulse/xmalloc.h>
 #include <pulsecore/thread.h>
 #include <pulsecore/macro.h>
@@ -91,7 +93,7 @@ quit:
     pa_log_info("thread_func() for %s done...", (char*) pa_tls_get(tls));
 }
 
-int main(int argc, char *argv[]) {
+START_TEST (thread_test) {
     int i, k;
     pa_thread* t[THREADS_MAX];
 
@@ -104,7 +106,8 @@ int main(int argc, char *argv[]) {
     tls = pa_tls_new(pa_xfree);
 
     for (i = 0; i < THREADS_MAX; i++) {
-        pa_assert_se(t[i] = pa_thread_new("test", thread_func, pa_sprintf_malloc("Thread #%i", i+1)));
+        t[i] = pa_thread_new("test", thread_func, pa_sprintf_malloc("Thread #%i", i+1));
+        fail_unless(t[i] != 0);
     }
 
     pa_mutex_lock(mutex);
@@ -137,6 +140,24 @@ int main(int argc, char *argv[]) {
     pa_cond_free(cond1);
     pa_cond_free(cond2);
     pa_tls_free(tls);
+}
+END_TEST
 
-    return 0;
+int main(int argc, char *argv[]) {
+    int failed = 0;
+    Suite *s;
+    TCase *tc;
+    SRunner *sr;
+
+    s = suite_create("Thread");
+    tc = tcase_create("thread");
+    tcase_add_test(tc, thread_test);
+    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;
 }