summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeng Zhengrong <dzrongg@gmail.com>2012-07-28 21:34:58 +0800
committerArun Raghavan <arun.raghavan@collabora.co.uk>2012-08-20 07:05:59 +0530
commit5f8c22e6f193c0f5fb1bf689e0751b19c53d9f2d (patch)
tree08f9319258f3ba8af9a55593f0fcdf8ef862bccf
parentdbf176acbdc4a6dccdd870348cdedf7a9d8d963d (diff)
tests: modify cpulimit-test to use 'check' framework
-rw-r--r--src/Makefile.am8
-rw-r--r--src/tests/cpulimit-test.c28
2 files changed, 29 insertions, 7 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index a8046271e..18bccb4ea 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -425,14 +425,14 @@ channelmap_test_LDADD = $(AM_LDADD) libpulse.la
channelmap_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
cpulimit_test_SOURCES = tests/cpulimit-test.c daemon/cpulimit.c daemon/cpulimit.h
-cpulimit_test_CFLAGS = $(AM_CFLAGS)
+cpulimit_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
cpulimit_test_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINOR@.la libpulse.la libpulsecommon-@PA_MAJORMINOR@.la
-cpulimit_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
+cpulimit_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
cpulimit_test2_SOURCES = tests/cpulimit-test.c daemon/cpulimit.c daemon/cpulimit.h
-cpulimit_test2_CFLAGS = $(AM_CFLAGS) -DTEST2
+cpulimit_test2_CFLAGS = $(AM_CFLAGS) -DTEST2 $(LIBCHECK_CFLAGS)
cpulimit_test2_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINOR@.la libpulse.la libpulsecommon-@PA_MAJORMINOR@.la
-cpulimit_test2_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
+cpulimit_test2_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
mainloop_test_glib_SOURCES = $(mainloop_test_SOURCES)
mainloop_test_glib_CFLAGS = $(mainloop_test_CFLAGS) $(LIBCHECK_CFLAGS) $(GLIB20_CFLAGS) -DGLIB_MAIN_LOOP
diff --git a/src/tests/cpulimit-test.c b/src/tests/cpulimit-test.c
index 8bd03417a..8988c1ad2 100644
--- a/src/tests/cpulimit-test.c
+++ b/src/tests/cpulimit-test.c
@@ -27,6 +27,8 @@
#include <stdio.h>
#include <signal.h>
+#include <check.h>
+
#include <pulse/mainloop.h>
#ifdef TEST2
@@ -48,17 +50,18 @@ static void func(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata
if ((now - start) >= 30) {
m->quit(m, 1);
fprintf(stderr, "Test failed\n");
+ fail();
} else
raise(SIGUSR1);
}
#endif
-int main(int argc, char *argv[]) {
+START_TEST (cpulimit_test) {
pa_mainloop *m;
m = pa_mainloop_new();
- assert(m);
+ fail_unless(m != NULL);
pa_cpu_limit_init(pa_mainloop_get_api(m));
@@ -77,6 +80,7 @@ int main(int argc, char *argv[]) {
if ((now - start) >= 30) {
fprintf(stderr, "Test failed\n");
+ fail();
break;
}
}
@@ -85,6 +89,24 @@ int main(int argc, char *argv[]) {
pa_cpu_limit_done();
pa_mainloop_free(m);
+}
+END_TEST
- return 0;
+int main(int argc, char *argv[]) {
+ int failed = 0;
+ Suite *s;
+ TCase *tc;
+ SRunner *sr;
+
+ s = suite_create("CPU Limit");
+ tc = tcase_create("cpulimit");
+ tcase_add_test(tc, cpulimit_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;
}