From: Martin Liska Date: Wed, 13 Nov 2019 15:13:16 +0000 (+0100) Subject: Come up with selftests for dbgcnt. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5024c8bb463fe7bfd20972cff37e3c917001172e;p=gcc.git Come up with selftests for dbgcnt. 2019-11-13 Martin Liska * dbgcnt.c (test_sorted_dbg_counters): New. (dbgcnt_c_tests): Likewise. * selftest-run-tests.c (selftest::run_tests): Likewise. * selftest.h (dbgcnt_c_tests): Likewise. From-SVN: r278144 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 05046e6b1b1..fdc7805d574 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-11-13 Martin Liska + + * dbgcnt.c (test_sorted_dbg_counters): New. + (dbgcnt_c_tests): Likewise. + * selftest-run-tests.c (selftest::run_tests): Likewise. + * selftest.h (dbgcnt_c_tests): Likewise. + 2019-11-13 Jan Hubicka Martin Jambor diff --git a/gcc/dbgcnt.c b/gcc/dbgcnt.c index 283a4575425..c675c644007 100644 --- a/gcc/dbgcnt.c +++ b/gcc/dbgcnt.c @@ -24,6 +24,7 @@ See dbgcnt.def for usage information. */ #include "coretypes.h" #include "diagnostic-core.h" #include "dumpfile.h" +#include "selftest.h" #include "dbgcnt.h" @@ -245,3 +246,26 @@ dbg_cnt_list_all_counters (void) } printf ("\n"); } + +#if CHECKING_P + +namespace selftest { + +/* Selftests. */ + +static void +test_sorted_dbg_counters () +{ + for (unsigned i = 0; i < debug_counter_number_of_counters - 1; i++) + ASSERT_LT (strcmp (map[i].name, map[i + 1].name), 0); +} + +void +dbgcnt_c_tests () +{ + test_sorted_dbg_counters (); +} + +} // namespace selftest + +#endif /* #if CHECKING_P */ diff --git a/gcc/selftest-run-tests.c b/gcc/selftest-run-tests.c index 6ed7d82beeb..a35452caf48 100644 --- a/gcc/selftest-run-tests.c +++ b/gcc/selftest-run-tests.c @@ -108,6 +108,7 @@ selftest::run_tests () store_merging_c_tests (); predict_c_tests (); simplify_rtx_c_tests (); + dbgcnt_c_tests (); /* Run any lang-specific selftests. */ lang_hooks.run_lang_selftests (); diff --git a/gcc/selftest.h b/gcc/selftest.h index 933c0aab539..cc7212317c3 100644 --- a/gcc/selftest.h +++ b/gcc/selftest.h @@ -254,6 +254,7 @@ extern void vec_c_tests (); extern void vec_perm_indices_c_tests (); extern void wide_int_cc_tests (); extern void opt_proposer_c_tests (); +extern void dbgcnt_c_tests (); extern int num_passes;