{
auto grp = make_maintenance_selftest_option_group (nullptr);
- gdb::option::complete_options
- (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp);
+ if (gdb::option::complete_options
+ (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp))
+ return;
+
+ selftests::for_each_selftest ([&tracker, text] (const std::string &name)
+ {
+ if (startswith (name.c_str (), text))
+ tracker.add_completion (make_unique_xstrdup (name.c_str ()));
+ });
}
static void
return 0
}
+load_lib completion-support.exp
+
set do_xml_test [expr ![gdb_skip_xml_test]]
standard_testfile
}
}
+# Test completion of command "maintenance selftest".
+
+proc_with_prefix test_completion {} {
+ clean_restart
+ test_gdb_complete_tab_multiple "maintenance selftest string_v" "" \
+ {string_vappendf string_view string_vprintf}
+ test_gdb_complete_tab_unique "maintenance selftest string_vie" "maintenance selftest string_view" " "
+ test_gdb_complete_tab_unique "maintenance selftest -ver" "maintenance selftest -verbose" " "
+ test_gdb_complete_tab_none "maintenance selftest name_that_does_not_exist"
+}
+
with_test_prefix "no executable loaded" {
run_selftests ""
}
run_selftests ${binfile}
}
+test_completion
+
if { ![is_remote host] && $do_xml_test } {
gdb_test "maintenance check xml-descriptions ${srcdir}/../features" \
"Tested $decimal XML files, 0 failed" \
#define COMMON_SELFTEST_H
#include "gdbsupport/array-view.h"
+#include "gdbsupport/function-view.h"
/* A test is just a function that does some checks and throws an
exception if something has gone wrong. */
/* Reset GDB or GDBserver's internal state. */
extern void reset ();
-typedef void for_each_selftest_ftype (const std::string &name);
+using for_each_selftest_ftype
+ = gdb::function_view<void(const std::string &name)>;
/* Call FUNC for each registered selftest. */