From: Uwe Hermann Date: Thu, 14 Aug 2014 17:30:54 +0000 (+0200) Subject: tests: Factor out srdtest_setup() / srdtest_teardown(). X-Git-Tag: libsigrokdecode-0.4.0~193 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=28c3c217cc70cf2eba41dbca2954c5d8382802d7;p=libsigrokdecode.git tests: Factor out srdtest_setup() / srdtest_teardown(). --- diff --git a/tests/check_core.c b/tests/check_core.c index e5b7b35..3b3d022 100644 --- a/tests/check_core.c +++ b/tests/check_core.c @@ -23,16 +23,6 @@ #include #include "lib.h" -static void setup(void) -{ - /* Silence libsigrokdecode while the unit tests run. */ - srd_log_loglevel_set(SRD_LOG_NONE); -} - -static void teardown(void) -{ -} - /* * Check various basic init related things. * @@ -104,7 +94,7 @@ Suite *suite_core(void) s = suite_create("core"); tc = tcase_create("init_exit"); - tcase_add_checked_fixture(tc, setup, teardown); + tcase_add_checked_fixture(tc, srdtest_setup, srdtest_teardown); tcase_add_test(tc, test_init_exit); tcase_add_test(tc, test_init_exit_2); tcase_add_test(tc, test_init_exit_3); diff --git a/tests/check_decoder.c b/tests/check_decoder.c index 527845f..2125992 100644 --- a/tests/check_decoder.c +++ b/tests/check_decoder.c @@ -23,16 +23,6 @@ #include #include "lib.h" -static void setup(void) -{ - /* Silence libsigrokdecode while the unit tests run. */ - srd_log_loglevel_set(SRD_LOG_NONE); -} - -static void teardown(void) -{ -} - /* * Check whether srd_decoder_load_all() works. * If it returns != SRD_OK (or segfaults) this test will fail. @@ -320,7 +310,7 @@ Suite *suite_decoder(void) s = suite_create("decoder"); tc = tcase_create("load"); - tcase_add_checked_fixture(tc, setup, teardown); + tcase_add_checked_fixture(tc, srdtest_setup, srdtest_teardown); tcase_add_test(tc, test_load_all); tcase_add_test(tc, test_load_all_no_init); tcase_add_test(tc, test_load); @@ -331,7 +321,7 @@ Suite *suite_decoder(void) suite_add_tcase(s, tc); tc = tcase_create("list"); - tcase_add_checked_fixture(tc, setup, teardown); + tcase_add_checked_fixture(tc, srdtest_setup, srdtest_teardown); tcase_add_test(tc, test_decoder_list); tcase_add_test(tc, test_decoder_list_no_load); tcase_add_test(tc, test_decoder_list_no_init); diff --git a/tests/check_inst.c b/tests/check_inst.c index fccd2e1..fe7e1f9 100644 --- a/tests/check_inst.c +++ b/tests/check_inst.c @@ -23,16 +23,6 @@ #include #include "lib.h" -static void setup(void) -{ - /* Silence libsigrokdecode while the unit tests run. */ - srd_log_loglevel_set(SRD_LOG_NONE); -} - -static void teardown(void) -{ -} - /* * Check whether srd_inst_new() works. * If it returns NULL (or segfaults) this test will fail. @@ -158,13 +148,13 @@ Suite *suite_inst(void) s = suite_create("inst"); tc = tcase_create("new"); - tcase_add_checked_fixture(tc, setup, teardown); + tcase_add_checked_fixture(tc, srdtest_setup, srdtest_teardown); tcase_add_test(tc, test_inst_new); tcase_add_test(tc, test_inst_new_multiple); suite_add_tcase(s, tc); tc = tcase_create("option"); - tcase_add_checked_fixture(tc, setup, teardown); + tcase_add_checked_fixture(tc, srdtest_setup, srdtest_teardown); tcase_add_test(tc, test_inst_option_set_empty); tcase_add_test(tc, test_inst_option_set_bogus); suite_add_tcase(s, tc); diff --git a/tests/check_main.c b/tests/check_main.c index 6af3c3f..96b6f43 100644 --- a/tests/check_main.c +++ b/tests/check_main.c @@ -23,6 +23,16 @@ #include #include "lib.h" +void srdtest_setup(void) +{ + /* Silence libsigrokdecode while the unit tests run. */ + srd_log_loglevel_set(SRD_LOG_NONE); +} + +void srdtest_teardown(void) +{ +} + int main(void) { int ret; diff --git a/tests/check_session.c b/tests/check_session.c index f996df5..d6895af 100644 --- a/tests/check_session.c +++ b/tests/check_session.c @@ -25,16 +25,6 @@ #include #include "lib.h" -static void setup(void) -{ - /* Silence libsigrokdecode while the unit tests run. */ - srd_log_loglevel_set(SRD_LOG_NONE); -} - -static void teardown(void) -{ -} - /* * Check whether srd_session_new() works. * If it returns != SRD_OK (or segfaults) this test will fail. @@ -242,7 +232,7 @@ Suite *suite_session(void) s = suite_create("session"); tc = tcase_create("new_destroy"); - tcase_add_checked_fixture(tc, setup, teardown); + tcase_add_checked_fixture(tc, srdtest_setup, srdtest_teardown); tcase_add_test(tc, test_session_new); tcase_add_test(tc, test_session_new_bogus); tcase_add_test(tc, test_session_new_multiple); @@ -251,7 +241,7 @@ Suite *suite_session(void) suite_add_tcase(s, tc); tc = tcase_create("config"); - tcase_add_checked_fixture(tc, setup, teardown); + tcase_add_checked_fixture(tc, srdtest_setup, srdtest_teardown); tcase_add_test(tc, test_session_metadata_set); tcase_add_test(tc, test_session_metadata_set_bogus); suite_add_tcase(s, tc); diff --git a/tests/lib.h b/tests/lib.h index e5609d4..75380a1 100644 --- a/tests/lib.h +++ b/tests/lib.h @@ -21,6 +21,9 @@ #ifndef LIBSIGROKDECODE_TESTS_LIB_H #define LIBSIGROKDECODE_TESTS_LIB_H +void srdtest_setup(void); +void srdtest_teardown(void); + Suite *suite_core(void); Suite *suite_decoder(void); Suite *suite_inst(void);