]> code.delx.au - pulseaudio/commitdiff
tests: modify lock-autospawn-test to use 'check' framework
authorDeng Zhengrong <dzrongg@gmail.com>
Sat, 28 Jul 2012 22:58:30 +0000 (06:58 +0800)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Mon, 20 Aug 2012 01:36:00 +0000 (07:06 +0530)
src/Makefile.am
src/tests/lock-autospawn-test.c

index d91c22623028f7f29b23991f109e9165703d06a6..56e71f54c35124b9a176a0f6acc3cac2dd39db51 100644 (file)
@@ -501,8 +501,8 @@ stripnul_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 lock_autospawn_test_SOURCES = tests/lock-autospawn-test.c
 lock_autospawn_test_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINOR@.la libpulse.la libpulsecommon-@PA_MAJORMINOR@.la
-lock_autospawn_test_CFLAGS = $(AM_CFLAGS)
-lock_autospawn_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
+lock_autospawn_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
+lock_autospawn_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
 
 sigbus_test_SOURCES = tests/sigbus-test.c
 sigbus_test_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINOR@.la libpulse.la libpulsecommon-@PA_MAJORMINOR@.la
index e2db24ce01beb66ea9971b9e080f8f5fd1d675fe..1aa3bcae2cddf01bce7d9cbed614b47d84edc241 100644 (file)
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <check.h>
+
 #include <string.h>
 
 #include <pulsecore/poll.h>
 #include <pulse/util.h>
 
 static void thread_func(void*k) {
-    pa_assert_se(pa_autospawn_lock_init() >= 0);
+    fail_unless(pa_autospawn_lock_init() >= 0);
 
     pa_log("%i, Trying to acquire lock.", PA_PTR_TO_INT(k));
 
-    pa_assert_se(pa_autospawn_lock_acquire(TRUE) > 0);
+    fail_unless(pa_autospawn_lock_acquire(TRUE) > 0);
 
     pa_log("%i, Got the lock!, Sleeping for 5s", PA_PTR_TO_INT(k));
 
@@ -52,7 +54,7 @@ static void thread_func(void*k) {
 static void thread_func2(void *k) {
     int fd;
 
-    pa_assert_se((fd = pa_autospawn_lock_init()) >= 0);
+    fail_unless((fd = pa_autospawn_lock_init()) >= 0);
 
     pa_log("%i, Trying to acquire lock.", PA_PTR_TO_INT(k));
 
@@ -63,13 +65,13 @@ static void thread_func2(void *k) {
         if ((j = pa_autospawn_lock_acquire(FALSE)) > 0)
             break;
 
-        pa_assert(j == 0);
+        fail_unless(j == 0);
 
         memset(&pollfd, 0, sizeof(pollfd));
         pollfd.fd = fd;
         pollfd.events = POLLIN;
 
-        pa_assert_se(pa_poll(&pollfd, 1, -1) == 1);
+        fail_unless(pa_poll(&pollfd, 1, -1) == 1);
 
         pa_log("%i, woke up", PA_PTR_TO_INT(k));
     }
@@ -85,7 +87,7 @@ static void thread_func2(void *k) {
     pa_autospawn_lock_done(FALSE);
 }
 
-int main(int argc, char**argv) {
+START_TEST (lockautospawn_test) {
     pa_thread *a, *b, *c, *d;
 
     pa_assert_se((a = pa_thread_new("test1", thread_func, PA_INT_TO_PTR(1))));
@@ -102,6 +104,28 @@ int main(int argc, char**argv) {
     pa_thread_free(b);
     pa_thread_free(c);
     pa_thread_free(d);
-
-    return 0;
+}
+END_TEST
+
+int main(int argc, char *argv[]) {
+    int failed = 0;
+    Suite *s;
+    TCase *tc;
+    SRunner *sr;
+
+    s = suite_create("Lock Auto Spawn");
+    tc = tcase_create("lockautospawn");
+    tcase_add_test(tc, lockautospawn_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;
 }