Put selftests api into selftests namespace
authorYao Qi <yao.qi@linaro.org>
Fri, 18 Aug 2017 08:20:43 +0000 (09:20 +0100)
committerYao Qi <yao.qi@linaro.org>
Fri, 18 Aug 2017 08:20:43 +0000 (09:20 +0100)
This patch changes register_self_test to selftests::register_test,
and run_self_tests to selftest::run_tests.

gdb:

2017-08-18  Yao Qi  <yao.qi@linaro.org>

* selftest.c (register_self_test): Rename it to
selftests::register_test.
(run_self_tests): selftest::run_tests.
* selftest.h: Update declarations.
* selftest-arch.c (register_self_test_foreach_arch): Rename it to
selftests::register_test_foreach_arch.
* selftest-arch.h: Update declaration.
* aarch64-tdep.c: Update.
* arm-tdep.c: Likewise.
* disasm-selftests.c: Likewise.
* dwarf2loc.c: Likewise.
* dwarf2-frame.c: Likewise.
* findvar.c: Likewise.
* gdbarch-selftests.c: Likewise.
* maint.c (maintenance_selftest): Likewise.
* regcache.c: Likewise.
* rust-exp.y: Likewise.
* selftest-arch.c: Likewise.
* unittests/environ-selftests.c: Likewise.
* unittests/function-view-selftests.c: Likewise.
* unittests/offset-type-selftests.c: Likewise.
* unittests/optional-selftests.c: Likewise.
* unittests/scoped_restore-selftests.c: Likewise.
* utils-selftests.c: Likewise.

21 files changed:
gdb/ChangeLog
gdb/aarch64-tdep.c
gdb/arm-tdep.c
gdb/disasm-selftests.c
gdb/dwarf2-frame.c
gdb/dwarf2loc.c
gdb/findvar.c
gdb/gdbarch-selftests.c
gdb/maint.c
gdb/regcache.c
gdb/rust-exp.y
gdb/selftest-arch.c
gdb/selftest-arch.h
gdb/selftest.c
gdb/selftest.h
gdb/unittests/environ-selftests.c
gdb/unittests/function-view-selftests.c
gdb/unittests/offset-type-selftests.c
gdb/unittests/optional-selftests.c
gdb/unittests/scoped_restore-selftests.c
gdb/utils-selftests.c

index 083e312736cebabd361aae4fccf7271e391d9a70..ec138de66f063d99ab97f6e01bf5c87e4d4f8475 100644 (file)
@@ -1,3 +1,30 @@
+2017-08-18  Yao Qi  <yao.qi@linaro.org>
+
+       * selftest.c (register_self_test): Rename it to
+       selftests::register_test.
+       (run_self_tests): selftest::run_tests.
+       * selftest.h: Update declarations.
+       * selftest-arch.c (register_self_test_foreach_arch): Rename it to
+       selftests::register_test_foreach_arch.
+       * selftest-arch.h: Update declaration.
+       * aarch64-tdep.c: Update.
+       * arm-tdep.c: Likewise.
+       * disasm-selftests.c: Likewise.
+       * dwarf2loc.c: Likewise.
+       * dwarf2-frame.c: Likewise.
+       * findvar.c: Likewise.
+       * gdbarch-selftests.c: Likewise.
+       * maint.c (maintenance_selftest): Likewise.
+       * regcache.c: Likewise.
+       * rust-exp.y: Likewise.
+       * selftest-arch.c: Likewise.
+       * unittests/environ-selftests.c: Likewise.
+       * unittests/function-view-selftests.c: Likewise.
+       * unittests/offset-type-selftests.c: Likewise.
+       * unittests/optional-selftests.c: Likewise.
+       * unittests/scoped_restore-selftests.c: Likewise.
+       * utils-selftests.c: Likewise.
+
 2017-08-17  Pedro Alves  <palves@redhat.com>
 
        * cli/cli-cmds.c (source_command): Delete 'old_source_verbose'
index 78162810b29fbc8adb75027b0f01abf74bfb865d..5a627a3a18606f742719fb198979136df5889d87 100644 (file)
@@ -3068,8 +3068,8 @@ When on, AArch64 specific debugging is enabled."),
                            &setdebuglist, &showdebuglist);
 
 #if GDB_SELF_TEST
-  register_self_test (selftests::aarch64_analyze_prologue_test);
-  register_self_test (selftests::aarch64_process_record_test);
+  selftests::register_test (selftests::aarch64_analyze_prologue_test);
+  selftests::register_test (selftests::aarch64_process_record_test);
 #endif
 }
 
index 99433243b4836e46c7f255b0bc9cff1fbbef0185..a1075847d685c57e49439b4233f3f40726d776c4 100644 (file)
@@ -9719,7 +9719,7 @@ vfp - VFP co-processor."),
                           &setdebuglist, &showdebuglist);
 
 #if GDB_SELF_TEST
-  register_self_test (selftests::arm_record_test);
+  selftests::register_test (selftests::arm_record_test);
 #endif
 
 }
index 9eb80b4b2bbc29953a8b84f57aad2feecadc5515..4d38ccf251b0c433656fffeeaa75c5d91874e67d 100644 (file)
@@ -214,7 +214,7 @@ void
 _initialize_disasm_selftests (void)
 {
 #if GDB_SELF_TEST
-  register_self_test_foreach_arch (selftests::print_one_insn_test);
-  register_self_test_foreach_arch (selftests::memory_error_test);
+  selftests::register_test_foreach_arch (selftests::print_one_insn_test);
+  selftests::register_test_foreach_arch (selftests::memory_error_test);
 #endif
 }
index f8e652237cb779a16ec2b3947c987a04ec79edd7..aaf3aee33d1be34ca67d5edc5207818e6118db45 100644 (file)
@@ -2406,6 +2406,6 @@ _initialize_dwarf2_frame (void)
   dwarf2_frame_objfile_data = register_objfile_data ();
 
 #if GDB_SELF_TEST
-  register_self_test_foreach_arch (selftests::execute_cfa_program_test);
+  selftests::register_test_foreach_arch (selftests::execute_cfa_program_test);
 #endif
 }
index 927d9500366a4096a9a33e6470cc0102c9b46cb7..1a1b06a1b268f323c327a8cbb9e98f0eee67523a 100644 (file)
@@ -4687,6 +4687,6 @@ _initialize_dwarf2loc (void)
                             &setdebuglist, &showdebuglist);
 
 #if GDB_SELF_TEST
-  register_self_test (selftests::copy_bitwise_tests);
+  selftests::register_test (selftests::copy_bitwise_tests);
 #endif
 }
index beb127ecc2a1bdffe2817c70702e7ae7e6331e15..de6b6edbd2e2ccb59a143fa4189a24e6f9a62ca7 100644 (file)
@@ -1095,6 +1095,6 @@ void
 _initialize_findvar (void)
 {
 #if GDB_SELF_TEST
-  register_self_test (selftests::findvar_tests::copy_integer_to_size_test);
+  selftests::register_test (selftests::findvar_tests::copy_integer_to_size_test);
 #endif
 }
index 096ba975f75edf6e2de81a767f2b645ff2405fd7..cb1596411c789cd2941708c69be7a9e0d3bb1f28 100644 (file)
@@ -151,6 +151,6 @@ void
 _initialize_gdbarch_selftests (void)
 {
 #if GDB_SELF_TEST
-  register_self_test_foreach_arch (selftests::register_to_value_test);
+  selftests::register_test_foreach_arch (selftests::register_to_value_test);
 #endif
 }
index a0d43ec7c0edd02e2741676a3320437379f99ec5..28f7287b31b5aa45ea31b0d3a64702421d31063a 100644 (file)
@@ -959,7 +959,7 @@ show_per_command_cmd (char *args, int from_tty)
 static void
 maintenance_selftest (char *args, int from_tty)
 {
-  run_self_tests ();
+  selftests::run_tests ();
 }
 
 \f
index e8f92d684dd80a197e055aa1b1bbe2caaab2392a..dcbcedd7a3b545f99820221533c4fc2cd3697b9e 100644 (file)
@@ -1776,6 +1776,6 @@ remote register number and buffer offset in the g/G packets.\n\
 Takes an optional file parameter."),
           &maintenanceprintlist);
 #if GDB_SELF_TEST
-  register_self_test (selftests::current_regcache_test);
+  selftests::register_test (selftests::current_regcache_test);
 #endif
 }
index 30c0cb46eb27e2fdf061004ba4d3099c52cfba2a..4cb3aa28a8b77a14cd38e91902360f46f363f74c 100644 (file)
@@ -2781,6 +2781,6 @@ _initialize_rust_exp (void)
   gdb_assert (code == 0);
 
 #if GDB_SELF_TEST
-  register_self_test (rust_lex_tests);
+  selftests::register_test (rust_lex_tests);
 #endif
 }
index c4fe60db898d79dd880f682515d77b5f26a4e7d3..dfcbe274328b35350db17969208f5f75b3daefc1 100644 (file)
 #include "selftest-arch.h"
 #include "arch-utils.h"
 
+namespace selftests {
+
 static std::vector<self_test_foreach_arch_function *> gdbarch_tests;
 
 void
-register_self_test_foreach_arch (self_test_foreach_arch_function *function)
+register_test_foreach_arch (self_test_foreach_arch_function *function)
 {
   gdbarch_tests.push_back (function);
 }
 
-namespace selftests {
-
 static void
 tests_with_arch ()
 {
@@ -101,6 +101,6 @@ void
 _initialize_selftests_foreach_arch ()
 {
 #if GDB_SELF_TEST
-  register_self_test (selftests::tests_with_arch);
+  selftests::register_test (selftests::tests_with_arch);
 #endif
 }
index d1725cd0a2b7e2a398d89c7277d4c44180d275cb..dc16c4d74b5dce3b9eed022aa09ab6cb5efc5fa9 100644 (file)
 
 typedef void self_test_foreach_arch_function (struct gdbarch *);
 
+namespace selftests
+{
 extern void
-  register_self_test_foreach_arch (self_test_foreach_arch_function *function);
+  register_test_foreach_arch (self_test_foreach_arch_function *function);
+}
 
 #endif /* SELFTEST_ARCH_H */
index 14b76f6f2596ee6c7a0f9959c75823dec1c3781f..31d16af4eabaf5610f4f1f5238209ff46e364b21 100644 (file)
@@ -20,6 +20,9 @@
 #include "selftest.h"
 #include <vector>
 
+namespace selftests
+{
+
 /* All the tests that have been registered.  */
 
 static std::vector<self_test_function *> tests;
@@ -27,7 +30,7 @@ static std::vector<self_test_function *> tests;
 /* See selftest.h.  */
 
 void
-register_self_test (self_test_function *function)
+register_test (self_test_function *function)
 {
   tests.push_back (function);
 }
@@ -35,7 +38,7 @@ register_self_test (self_test_function *function)
 /* See selftest.h.  */
 
 void
-run_self_tests (void)
+run_tests (void)
 {
   int failed = 0;
 
@@ -62,3 +65,4 @@ run_self_tests (void)
   printf_filtered (_("Ran %lu unit tests, %d failed\n"),
                   (long) tests.size (), failed);
 }
+} // namespace selftests
index 94684ff959a733cba030bdd6915eeaf51437428d..8a01a5d3c96874cb15792276e81987c95367d3dc 100644 (file)
 
 typedef void self_test_function (void);
 
+namespace selftests
+{
+
 /* Register a new self-test.  */
 
-extern void register_self_test (self_test_function *function);
+extern void register_test (self_test_function *function);
 
 /* Run all the self tests.  This print a message describing the number
    of test and the number of failures.  */
 
-extern void run_self_tests (void);
+extern void run_tests (void);
+
+}
 
 /* Check that VALUE is true, and, if not, throw an exception.  */
 
index 28b16f828f36a14c939e9b9aa947a85d637f9241..1e938e6746cdfdadcfae9ca1f3fca93de7047d53 100644 (file)
@@ -155,5 +155,5 @@ run_tests ()
 void
 _initialize_environ_selftests ()
 {
-  register_self_test (selftests::gdb_environ_tests::run_tests);
+  selftests::register_test (selftests::gdb_environ_tests::run_tests);
 }
index 310f2ad16c46b58975aee628974e9b1c79940882..d3018ba7957e94d9f266e887b2831068b2b8c378 100644 (file)
@@ -174,5 +174,5 @@ run_tests ()
 void
 _initialize_function_view_selftests ()
 {
-  register_self_test (selftests::function_view::run_tests);
+  selftests::register_test (selftests::function_view::run_tests);
 }
index a11e9085af843fa8df5a3d455ce51dfb6838b994..3e66547d8e7c5dfdd71b1779d90ea8890a795a02 100644 (file)
@@ -174,5 +174,5 @@ run_tests ()
 void
 _initialize_offset_type_selftests ()
 {
-  register_self_test (selftests::offset_type::run_tests);
+  selftests::register_test (selftests::offset_type::run_tests);
 }
index 76343c65427e2d1e571380c8ca82840972a9e903..0bcf96414f51a237f9bd21f84ba4b432ccc108db 100644 (file)
@@ -90,5 +90,5 @@ run_tests ()
 void
 _initialize_optional_selftests ()
 {
-  register_self_test (selftests::optional::run_tests);
+  selftests::register_test (selftests::optional::run_tests);
 }
index e97d6225c4285583aa9e4802768d3cb445d60e69..ea7492b352362600147ff171f92312b7fb0c0f40 100644 (file)
@@ -106,5 +106,5 @@ run_tests ()
 void
 _initialize_scoped_restore_selftests ()
 {
-  register_self_test (selftests::scoped_restore_tests::run_tests);
+  selftests::register_test (selftests::scoped_restore_tests::run_tests);
 }
index ebaeef002945a5ed55c65afb605d1d341be86759..08feac678aba4703d7531fb42d67c52b4398a93f 100644 (file)
@@ -55,6 +55,6 @@ void
 _initialize_utils_selftests (void)
 {
 #if GDB_SELF_TEST
-  register_self_test (selftests::common_utils_tests);
+  selftests::register_test (selftests::common_utils_tests);
 #endif
 }