]> sigrok.org Git - libsigrokdecode.git/commitdiff
tests: Factor out srdtest_setup() / srdtest_teardown().
authorUwe Hermann <redacted>
Thu, 14 Aug 2014 17:30:54 +0000 (19:30 +0200)
committerUwe Hermann <redacted>
Thu, 14 Aug 2014 17:30:54 +0000 (19:30 +0200)
tests/check_core.c
tests/check_decoder.c
tests/check_inst.c
tests/check_main.c
tests/check_session.c
tests/lib.h

index e5b7b356e580ec9851a8b32ec05f107ab7e33184..3b3d0227a00d80d34cc65d105040156dc7437d3c 100644 (file)
 #include <check.h>
 #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);
index 527845f9ae4e9406693041174554349ee38cec5f..21259929672bd0c8923622001a94b9eca0c85cd4 100644 (file)
 #include <check.h>
 #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);
index fccd2e18192bf0dc844e9410746afe0bffbf3b90..fe7e1f9977aebd26f2b32d20b6fe87e22dc8c050 100644 (file)
 #include <check.h>
 #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);
index 6af3c3f72dbce614621c1d645be0d29bb4efed6e..96b6f438ddd433281d7cd1cee6bc1a6b6864e959 100644 (file)
 #include <check.h>
 #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;
index f996df5849d391618d788149333b085e432c2be2..d6895af8f4ec174ee19c785f3ac0f2876f263741 100644 (file)
 #include <check.h>
 #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);
index e5609d44167856a1600a2de6c0acb1584b71c27e..75380a1aa0cccb38cdfb32b712178fc703e1b1f1 100644 (file)
@@ -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);