From a5b438f8257e16c01371cb697dc242f5026b6b0d Mon Sep 17 00:00:00 2001 From: Deng Zhengrong Date: Sat, 28 Jul 2012 17:45:50 +0800 Subject: [PATCH] tests: modify get-binary-name-test to use 'check' framework --- src/Makefile.am | 4 ++-- src/tests/get-binary-name-test.c | 28 ++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 69189352..30380557 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -330,9 +330,9 @@ format_test_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINOR@.la libpulse.la libp format_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS) get_binary_name_test_SOURCES = tests/get-binary-name-test.c -get_binary_name_test_CFLAGS = $(AM_CFLAGS) +get_binary_name_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS) get_binary_name_test_LDADD = $(AM_LDADD) libpulse.la libpulsecommon-@PA_MAJORMINOR@.la -get_binary_name_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) +get_binary_name_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS) ipacl_test_SOURCES = tests/ipacl-test.c ipacl_test_CFLAGS = $(AM_CFLAGS) diff --git a/src/tests/get-binary-name-test.c b/src/tests/get-binary-name-test.c index 7a09bc2c..5d781c95 100644 --- a/src/tests/get-binary-name-test.c +++ b/src/tests/get-binary-name-test.c @@ -24,12 +24,14 @@ #include #include +#include + #include #include #include -int main(int argc, char *argv[]) { +START_TEST (getbinaryname_test) { char *exename; size_t allocated = 128; @@ -39,18 +41,36 @@ int main(int argc, char *argv[]) { if (!pa_get_binary_name(exename, allocated)) { pa_log_error("failed to read binary name"); pa_xfree(exename); - break; + fail(); } if (strlen(exename) < allocated - 1) { pa_log("%s", exename); pa_xfree(exename); - return 0; + return; } pa_xfree(exename); allocated *= 2; } +} +END_TEST + +int main(int argc, char *argv[]) { + int failed = 0; + Suite *s; + TCase *tc; + SRunner *sr; + + s = suite_create("Binary Name"); + tc = tcase_create("getbinaryname"); + tcase_add_test(tc, getbinaryname_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 1; + return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } -- 2.39.2