]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdbsupport/selftest.h
Always use std::function for self-tests
[thirdparty/binutils-gdb.git] / gdbsupport / selftest.h
index e0086132f7b97b29814892159fdc7a8551d61678..2326ebad495eb932161fc580e1056d666fb06b9e 100644 (file)
@@ -1,5 +1,5 @@
 /* GDB self-testing.
-   Copyright (C) 2016-2020 Free Software Foundation, Inc.
+   Copyright (C) 2016-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 /* A test is just a function that does some checks and throws an
    exception if something has gone wrong.  */
 
-typedef void self_test_function (void);
-
 namespace selftests
 {
 
-/* Interface for the various kinds of selftests.  */
-
-struct selftest
-{
-  virtual ~selftest () = default;
-  virtual void operator() () const = 0;
-};
-
-/* Register a new self-test.  */
+/* True if selftest should run verbosely.  */
 
-extern void register_test (const std::string &name, selftest *test);
+extern bool run_verbose ();
 
 /* Register a new self-test.  */
 
 extern void register_test (const std::string &name,
-                          self_test_function *function);
+                          std::function<void(void)> function);
 
 /* Run all the self tests.  This print a message describing the number
    of test and the number of failures.
@@ -52,7 +42,8 @@ extern void register_test (const std::string &name,
    If FILTERS is not empty, only run tests with names containing one of the
    element of FILTERS.  */
 
-extern void run_tests (gdb::array_view<const char *const> filters);
+extern void run_tests (gdb::array_view<const char *const> filters,
+                      bool verbose = false);
 
 /* Reset GDB or GDBserver's internal state.  */
 extern void reset ();