diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 0df345338e5..07dc2463d90 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -37222,6 +37222,12 @@ If section was not specified, the section in which the symbol was found
 is also printed.  For dynamically linked executables, the name of
 executable or shared library containing the symbol is printed as well.
 
+@kindex maint test-settings
+@item maint test-settings set @var{kind}
+@itemx maint test-settings show @var{kind}
+These are representative commands for each @var{kind} of setting type
+@value{GDBN} supports.  They are used by the testsuite for exercising
+the settings infrastructure.
 @end table
 
 The following command is useful for non-interactive invocations of
diff --git a/gdb/NEWS b/gdb/NEWS
index ded1fce406c..861bdc61032 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -82,6 +82,10 @@ set style highlight background COLOR
 set style highlight intensity VALUE
   Control the styling of highlightings.
 
+maint test-settings KIND
+  A set of commands used by the testsuite for exercising the settings
+  infrastructure.
+
 * Changed commands
 
 help
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 0f495783600..e44df54ddea 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1062,6 +1062,7 @@ COMMON_SFILES = \
 	macrotab.c \
 	main.c \
 	maint.c \
+	maint-test-settings.c \
 	mdebugread.c \
 	mem-break.c \
 	memattr.c \
diff --git a/gdb/maint-test-settings.c b/gdb/maint-test-settings.c
new file mode 100644
index 00000000000..fa13519eb96
--- /dev/null
+++ b/gdb/maint-test-settings.c
@@ -0,0 +1,257 @@
+/* Support for GDB maintenance commands.
+
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+
+#include "defs.h"
+#include "gdbcmd.h"
+
+/* Command list for "maint test-settings".  */
+static cmd_list_element *maintenance_test_settings_list;
+
+/* Command list for "maint test-settings set/show".  */
+static cmd_list_element *maintenance_test_settings_set_list;
+static cmd_list_element *maintenance_test_settings_show_list;
+
+/* The "maintenance test-options" prefix command.  */
+
+static void
+maintenance_test_settings_cmd (const char *arg, int from_tty)
+{
+  printf_unfiltered
+    (_("\"maintenance test-settings\" must be followed "
+       "by the name of a subcommand.\n"));
+  help_list (maintenance_test_settings_list, "maintenance test-settings ",
+	     all_commands, gdb_stdout);
+}
+
+/* The "maintenance test-options set" prefix command.  */
+
+static void
+maintenance_test_settings_set_cmd (const char *args, int from_tty)
+{
+  printf_unfiltered (_("\"maintenance test-settings set\" must be followed "
+		       "by the name of a set command.\n"));
+  help_list (maintenance_test_settings_set_list,
+	     "maintenance test-settings set ",
+	     all_commands, gdb_stdout);
+}
+
+/* The "maintenance test-options show" prefix command.  */
+
+static void
+maintenance_test_settings_show_cmd (const char *args, int from_tty)
+{
+  cmd_show_list (maintenance_test_settings_show_list, from_tty, "");
+}
+
+/* Control variables for all the "maintenance test-options set/show
+   xxx" commands.  */
+
+static int maintenance_test_settings_boolean;
+
+static auto_boolean maintenance_test_settings_auto_boolean = AUTO_BOOLEAN_AUTO;
+
+static unsigned int maintenance_test_settings_uinteger;
+
+static int maintenance_test_settings_integer;
+
+static int maintenance_test_settings_zinteger;
+
+static unsigned int maintenance_test_settings_zuinteger;
+
+static int maintenance_test_settings_zuinteger_unlimited;
+
+static char *maintenance_test_settings_string;
+
+static char *maintenance_test_settings_string_noescape;
+
+static char *maintenance_test_settings_optional_filename;
+
+static char *maintenance_test_settings_filename;
+
+static const char *maintenance_test_settings_enum;
+
+/* Enum values for the "maintenance test-settings set/show boolean"
+   commands.  */
+static const char *const maintenance_test_settings_enums[] = {
+  "xxx", "yyy", "zzz", nullptr
+};
+
+/* The "maintenance test-options show xxx" commands.  */
+
+static void
+maintenance_test_settings_show_value_cmd
+  (struct ui_file *file, int from_tty,
+   struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, (("%s\n")), value);
+}
+
+
+void
+_initialize_maint_test_settings (void)
+{
+  add_prefix_cmd ("test-settings", no_class,
+		  maintenance_test_settings_cmd,
+		  _("\
+Generic command for testing the settings infrastructure."),
+		  &maintenance_test_settings_list,
+		  "maintenance test-settings ", 0,
+		  &maintenancelist);
+
+  add_prefix_cmd ("set", class_maintenance,
+		  maintenance_test_settings_set_cmd, _("\
+Set GDB internal variables used for set/show command infrastructure testing."),
+		  &maintenance_test_settings_set_list,
+		  "maintenance test-settings set ",
+		  0/*allow-unknown*/,
+		  &maintenance_test_settings_list);
+
+  add_prefix_cmd ("show", class_maintenance,
+		  maintenance_test_settings_show_cmd, _("\
+Show GDB internal variables used for set/show command infrastructure testing."),
+		  &maintenance_test_settings_show_list,
+		  "maintenance test-settings show ",
+		  0/*allow-unknown*/,
+		  &maintenance_test_settings_list);
+
+  add_setshow_boolean_cmd ("boolean", class_maintenance,
+			   &maintenance_test_settings_boolean, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+			   nullptr, /* help_doc */
+			   nullptr, /* set_cmd */
+			   maintenance_test_settings_show_value_cmd,
+			   &maintenance_test_settings_set_list,
+			   &maintenance_test_settings_show_list);
+
+  add_setshow_auto_boolean_cmd ("auto-boolean", class_maintenance,
+				&maintenance_test_settings_auto_boolean, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+				nullptr, /* help_doc */
+				nullptr, /* set_cmd */
+				maintenance_test_settings_show_value_cmd,
+				&maintenance_test_settings_set_list,
+				&maintenance_test_settings_show_list);
+
+  add_setshow_uinteger_cmd ("uinteger", class_maintenance,
+			   &maintenance_test_settings_uinteger, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+			   nullptr, /* help_doc */
+			   nullptr, /* set_cmd */
+			   maintenance_test_settings_show_value_cmd,
+			   &maintenance_test_settings_set_list,
+			   &maintenance_test_settings_show_list);
+
+  add_setshow_integer_cmd ("integer", class_maintenance,
+			   &maintenance_test_settings_integer, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+			   nullptr, /* help_doc */
+			   nullptr, /* set_cmd */
+			   maintenance_test_settings_show_value_cmd,
+			   &maintenance_test_settings_set_list,
+			   &maintenance_test_settings_show_list);
+
+  add_setshow_string_cmd ("string", class_maintenance,
+     &maintenance_test_settings_string, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+     nullptr, /* help_doc */
+     nullptr, /* set_cmd */
+     maintenance_test_settings_show_value_cmd,
+     &maintenance_test_settings_set_list,
+     &maintenance_test_settings_show_list);
+
+  add_setshow_string_noescape_cmd
+    ("string-noescape", class_maintenance,
+     &maintenance_test_settings_string_noescape, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+     nullptr, /* help_doc */
+     nullptr, /* set_cmd */
+     maintenance_test_settings_show_value_cmd,
+     &maintenance_test_settings_set_list,
+     &maintenance_test_settings_show_list);
+
+  add_setshow_optional_filename_cmd
+    ("optional-filename", class_maintenance,
+     &maintenance_test_settings_optional_filename, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+     nullptr, /* help_doc */
+     nullptr, /* set_cmd */
+     maintenance_test_settings_show_value_cmd,
+     &maintenance_test_settings_set_list,
+     &maintenance_test_settings_show_list);
+
+  add_setshow_filename_cmd ("filename", class_maintenance,
+			    &maintenance_test_settings_filename, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+			    nullptr, /* help_doc */
+			    nullptr, /* set_cmd */
+			    maintenance_test_settings_show_value_cmd,
+			    &maintenance_test_settings_set_list,
+			    &maintenance_test_settings_show_list);
+
+  add_setshow_zinteger_cmd ("zinteger", class_maintenance,
+			    &maintenance_test_settings_zinteger, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+			    nullptr, /* help_doc */
+			    nullptr, /* set_cmd */
+			    maintenance_test_settings_show_value_cmd,
+			    &maintenance_test_settings_set_list,
+			    &maintenance_test_settings_show_list);
+
+  add_setshow_zuinteger_cmd ("zuinteger", class_maintenance,
+			     &maintenance_test_settings_zuinteger, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+			     nullptr, /* help_doc */
+			     nullptr, /* set_cmd */
+			     maintenance_test_settings_show_value_cmd,
+			     &maintenance_test_settings_set_list,
+			     &maintenance_test_settings_show_list);
+
+  add_setshow_zuinteger_unlimited_cmd
+    ("zuinteger-unlimited", class_maintenance,
+     &maintenance_test_settings_zuinteger_unlimited, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+     nullptr, /* help_doc */
+     nullptr, /* set_cmd */
+     maintenance_test_settings_show_value_cmd,
+     &maintenance_test_settings_set_list,
+     &maintenance_test_settings_show_list);
+
+  add_setshow_enum_cmd ("enum", class_maintenance,
+			maintenance_test_settings_enums,
+			&maintenance_test_settings_enum, _("\
+command used for internal testing"), _("\
+command used for internal testing"),
+			nullptr, /* help_doc */
+			nullptr, /* set_cmd */
+			maintenance_test_settings_show_value_cmd,
+			&maintenance_test_settings_set_list,
+			&maintenance_test_settings_show_list);
+}
diff --git a/gdb/testsuite/gdb.base/settings.c b/gdb/testsuite/gdb.base/settings.c
new file mode 100644
index 00000000000..fd22b58603d
--- /dev/null
+++ b/gdb/testsuite/gdb.base/settings.c
@@ -0,0 +1,23 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2019 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int xxx1= 123;
+
+int
+main ()
+{
+}
diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp
new file mode 100644
index 00000000000..f96e9f614d8
--- /dev/null
+++ b/gdb/testsuite/gdb.base/settings.exp
@@ -0,0 +1,539 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2019 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test the set/show commands framework.  The test uses the
+# "maintenance test-settings set/show xxx" subcommands to exercise
+# TAB-completion and setting processing.
+
+load_lib completion-support.exp
+
+standard_testfile .c
+
+if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
+    return -1
+}
+
+clean_restart
+
+if { ![readline_is_used] } {
+    untested "no tab completion support without readline"
+    return -1
+}
+
+# Test the show command SHOW_CMD.  EXPECTED_RE is the expected output.
+# This procedure exists in order to make it easier to make the test
+# name/message unique, since we test the "show" commands many times.
+# EXPECTED_RE is made part of the test name.
+proc show_setting {show_cmd expected_re} {
+    gdb_test "$show_cmd" $expected_re "$show_cmd: $expected_re"
+}
+
+# var_Xinteger tests.  VARIANT determines which command/variant to
+# exercise.
+proc test-integer {variant} {
+    set set_cmd "maint test-settings set $variant"
+    set show_cmd "maint test-settings show $variant"
+
+    # A bogus value.
+    gdb_test "$set_cmd bogus" \
+	"No symbol table is loaded\\.  Use the \"file\" command\\."
+
+    # Seemingly-valid but not quite valid value.
+    gdb_test "$set_cmd 1a" \
+	"Invalid number \"1a\"\\."
+
+    # Valid value followed by garbage.
+    gdb_test "$set_cmd 1 1" \
+	"A syntax error in expression, near `1'\\."
+
+    # Valid value followed by garbage.
+    gdb_test "$set_cmd 1 x" \
+	"A syntax error in expression, near `x'\\."
+
+    if {$variant == "zuinteger-unlimited"} {
+	# -1 means unlimited.  Other negative values are rejected.  -1
+	# -is tested further below, along the "unlimited" tests.
+	gdb_test "$set_cmd -2" "only -1 is allowed to set as unlimited"
+    } elseif {$variant == "uinteger" || $variant == "zuinteger"} {
+	# Negative values are not accepted.
+	gdb_test "$set_cmd -1" "integer -1 out of range"
+	gdb_test "$set_cmd -2" "integer -2 out of range"
+    } else {
+	# Negative values are not accepted.
+	gdb_test_no_output "$set_cmd -1"
+	show_setting "$show_cmd" "-1"
+	gdb_test_no_output "$set_cmd -2"
+	show_setting "$show_cmd" "-2"
+    }
+
+    # Regular integer is accepted.
+    gdb_test_no_output "$set_cmd 999"
+    show_setting "$show_cmd" "999"
+
+    if {$variant == "zinteger" || $variant == "zuinteger"} {
+	# 0 means 0.
+	gdb_test_no_output "$set_cmd 0"
+	show_setting "$show_cmd" "0"
+    } else {
+	# Either 0 or -1 mean unlimited.  Test both the number and
+	# "unlimited".  For the latter, test both full name and
+	# abbreviations.
+
+	if {$variant == "zuinteger-unlimited"} {
+	    gdb_test_no_output "$set_cmd -1"
+	} else {
+	    gdb_test_no_output "$set_cmd 0"
+	}
+	show_setting "$show_cmd" "unlimited"
+
+	foreach_with_prefix value {
+	    "u"
+	    "un"
+	    "unl"
+	    "unli"
+	    "unlim"
+	    "unlimi"
+	    "unlimit"
+	    "unlimite"
+	    "unlimited"
+	} {
+	    # Alternate between integer and unlimited, to make sure the
+	    # setting really took effect.
+	    gdb_test_no_output "$set_cmd 1"
+	    show_setting "$show_cmd" "1"
+
+	    gdb_test_no_output "$set_cmd $value"
+	    show_setting "$show_cmd" "unlimited"
+	}
+    }
+
+    if {$variant == "zuinteger"} {
+	test_gdb_complete_multiple "maint test-settings set " "zuinteger" "" {
+	    "zuinteger"
+	    "zuinteger-unlimited"
+	}
+    } else {
+	test_gdb_complete_unique \
+	    "$set_cmd" \
+	    "$set_cmd"
+    }
+
+    if {$variant == "zinteger" || $variant == "zuinteger"} {
+	test_gdb_complete_none \
+	    "$set_cmd " \
+    } else {
+	test_gdb_complete_unique \
+	    "$set_cmd " \
+	    "$set_cmd unlimited"
+    }
+
+    gdb_test "$set_cmd unlimitedu" "No symbol table is loaded.*"
+
+    test_gdb_complete_none "$set_cmd unlimited "
+    test_gdb_complete_none "$set_cmd unlimitedu"
+    test_gdb_complete_none "$set_cmd unlimited u"
+    test_gdb_complete_none "$set_cmd unlimited 1"
+    test_gdb_complete_none "$set_cmd x"
+    test_gdb_complete_none "$set_cmd x "
+    test_gdb_complete_none "$set_cmd -1"
+    test_gdb_complete_none "$set_cmd -1 "
+    test_gdb_complete_none "$set_cmd 1 "
+
+    # Check show command completion.
+    if {$variant == "zuinteger"} {
+	test_gdb_complete_multiple "maintenance test-settings show " "zuinteger" "" {
+	    "zuinteger"
+	    "zuinteger-unlimited"
+	}
+    } else {
+	test_gdb_complete_unique \
+	    "$show_cmd" \
+	    "$show_cmd"
+    }
+    test_gdb_complete_none "$show_cmd "
+}
+
+# boolean tests.
+proc_with_prefix test-boolean {} {
+    # Use these variables to make sure we don't call the wrong command
+    # by mistake.
+    set set_cmd "maint test-settings set boolean"
+    set show_cmd "maint test-settings show boolean"
+
+    # A bogus value.
+    gdb_test "$set_cmd bogus" \
+	"\"on\" or \"off\" expected\\."
+
+    # Seemingly-valid but not quite valid value.
+    gdb_test "$set_cmd on1" \
+	"\"on\" or \"off\" expected\\."
+
+    # Valid value followed by garbage.
+    gdb_test "$set_cmd on 1" \
+	"\"on\" or \"off\" expected\\."
+
+    # Unlike auto-bool settings, "-1" is not accepted.
+    gdb_test "$set_cmd -1" \
+	"\"on\" or \"off\" expected\\."
+
+    # Nor "auto".
+    gdb_test "$set_cmd auto" \
+	"\"on\" or \"off\" expected\\."
+
+    # Various valid values.  Test both full value names and
+    # abbreviations.
+
+    # Note that unlike with auto-bool, empty value implies "on".
+    foreach_with_prefix value {
+	""
+	"o"
+	"on"
+	"1"
+	"y"
+	"ye"
+	"yes"
+	"e"
+	"en"
+	"ena"
+	"enab"
+	"enabl"
+	"enable"
+    } {
+	gdb_test_no_output "$set_cmd off"
+	show_setting "$show_cmd" "off"
+
+	gdb_test_no_output "$set_cmd $value"
+	show_setting "$show_cmd" "on"
+    }
+
+    foreach_with_prefix value {
+	"of"
+	"off"
+	"0"
+	"n"
+	"no"
+	"d"
+	"di"
+	"dis"
+	"disa"
+	"disab"
+	"disabl"
+	"disable"
+    } {
+	gdb_test_no_output "$set_cmd on"
+	show_setting "$show_cmd" "on"
+
+	gdb_test_no_output "$set_cmd $value"
+	show_setting "$show_cmd" "off"
+    }
+
+    test_gdb_complete_multiple "$set_cmd " "" "o" {
+	"off"
+	"on"
+    }
+
+    test_gdb_complete_unique \
+	"$set_cmd of" \
+	"$set_cmd off"
+
+    test_gdb_complete_none "$set_cmd x"
+
+    # Check that the show command doesn't complete anything.
+    test_gdb_complete_unique \
+	"$show_cmd" \
+	"$show_cmd"
+    test_gdb_complete_none "$show_cmd "
+}
+
+# auto-boolean tests.
+proc_with_prefix test-auto-boolean {} {
+    # Use these variables to make sure we don't call the wrong command
+    # by mistake.
+    set set_cmd "maint test-settings set auto-boolean"
+    set show_cmd "maint test-settings show auto-boolean"
+
+    # A bogus value.
+    gdb_test "$set_cmd bogus" \
+	"\"on\", \"off\" or \"auto\" expected\\."
+
+    # Seemingly-valid but not quite valid value.
+    gdb_test "$set_cmd on1" \
+	"\"on\", \"off\" or \"auto\" expected\\."
+
+    # Valid value followed by garbage.
+    gdb_test "$set_cmd on 1" \
+	"\"on\", \"off\" or \"auto\" expected\\."
+
+    # Various valid values.  Test both full value names and
+    # abbreviations.
+
+    foreach_with_prefix value {
+	"o"
+	"on"
+	"1"
+	"y"
+	"ye"
+	"yes"
+	"e"
+	"en"
+	"ena"
+	"enab"
+	"enabl"
+	"enable"
+    } {
+	gdb_test_no_output "$set_cmd off"
+	show_setting "$show_cmd" "off"
+
+	gdb_test_no_output "$set_cmd $value"
+	show_setting "$show_cmd" "on"
+    }
+
+    foreach_with_prefix value {
+	"of"
+	"off"
+	"0"
+	"n"
+	"no"
+	"d"
+	"di"
+	"dis"
+	"disa"
+	"disab"
+	"disabl"
+	"disable"
+    } {
+	gdb_test_no_output "$set_cmd on"
+	show_setting "$show_cmd" "on"
+
+	gdb_test_no_output "$set_cmd $value"
+	show_setting "$show_cmd" "off"
+    }
+
+    foreach_with_prefix value {
+	"a"
+	"au"
+	"aut"
+	"auto"
+	"-1"
+    } {
+	gdb_test_no_output "$set_cmd on"
+	show_setting "$show_cmd" "on"
+
+	gdb_test_no_output "$set_cmd $value"
+	show_setting "$show_cmd" "auto"
+    }
+
+    # "-" is not accepted as abbreviation of "-1".
+    gdb_test "$set_cmd -" \
+	"\"on\", \"off\" or \"auto\" expected\\."
+
+    test_gdb_complete_multiple "$set_cmd " "" "" {
+	"auto"
+	"off"
+	"on"
+    }
+
+    test_gdb_complete_unique \
+	"$set_cmd of" \
+	"$set_cmd off"
+
+    test_gdb_complete_none "$set_cmd x"
+
+    # Check that the show command doesn't complete anything.
+    test_gdb_complete_unique \
+	"$show_cmd" \
+	"$show_cmd"
+    test_gdb_complete_none "$show_cmd "
+}
+
+# Enum option tests.
+proc_with_prefix test-enum {} {
+    # Use these variables to make sure we don't call the wrong command
+    # by mistake.
+    set set_cmd "maint test-settings set enum"
+    set show_cmd "maint test-settings show enum"
+
+    # Missing value.
+    gdb_test "$set_cmd" \
+	"Requires an argument\\. Valid arguments are xxx, yyy, zzz\\."
+
+    # A bogus value.
+    gdb_test "$set_cmd bogus" \
+	"Undefined item: \"bogus\"."
+
+    # Seemingly-valid but not quite valid value.
+    gdb_test "$set_cmd xxx1" \
+	"Undefined item: \"xxx1\"."
+
+    # Valid value followed by garbage.
+    gdb_test "$set_cmd xxx 1" \
+	"Junk after item \"xxx\": 1"
+    # Valid value followed by garbage, with extra spaces.
+    gdb_test "$set_cmd xxx      1" \
+	"Junk after item \"xxx\": 1"
+    # Abbreviated value followed by garbage.
+    gdb_test "$set_cmd xx 1" \
+	"Junk after item \"xx\": 1"
+
+    # Various valid values.  Test both full value names and
+    # abbreviations.
+    gdb_test_no_output "$set_cmd x"
+    show_setting "$show_cmd" "xxx"
+    gdb_test_no_output "$set_cmd yy"
+    show_setting "$show_cmd" "yyy"
+    gdb_test_no_output "$set_cmd zzz"
+    show_setting "$show_cmd" "zzz"
+
+    test_gdb_complete_multiple "$set_cmd " "" "" {
+	"xxx"
+	"yyy"
+	"zzz"
+    }
+
+    test_gdb_complete_unique \
+	"$set_cmd x" \
+	"$set_cmd xxx"
+
+    test_gdb_complete_none "$set_cmd a"
+
+    # Check that the show command doesn't complete anything.
+    test_gdb_complete_unique \
+	"$show_cmd" \
+	"$show_cmd"
+    test_gdb_complete_none "$show_cmd "
+}
+
+# string settings tests.
+proc test-string {variant} {
+    global gdb_prompt
+    global srcfile binfile
+
+    # Load symbols for the completion test below.
+    clean_restart $binfile
+
+    # Use these variables to make sure we don't call the wrong command
+    # by mistake.
+    set set_cmd "maint test-settings set $variant"
+    set show_cmd "maint test-settings show $variant"
+
+    # Empty string.  Also checks that gdb doesn't crash if we haven't
+    # set the string yet.
+    gdb_test "$show_cmd" "^$show_cmd\r\n" "$show_cmd: empty first time"
+
+    # A string value.
+    gdb_test_no_output "$set_cmd hello world"
+    show_setting "$show_cmd" "hello world"
+
+    # A quoted string value.
+    if {$variant == "string"} {
+	gdb_test_no_output "$set_cmd \"hello world\""
+	show_setting "$show_cmd" "\\\\\"hello world\\\\\""
+    } else {
+	gdb_test_no_output "$set_cmd \"hello world\""
+	show_setting "$show_cmd" "\"hello world\""
+    }
+
+    # Test clearing the string.
+    with_test_prefix "clear string" {
+	if {$variant == "filename"} {
+	    gdb_test "$set_cmd" \
+		"Argument required \\(filename to set it to\\.\\)\\."
+
+	    # Check the value didn't change.
+	    show_setting "$show_cmd" "\"hello world\""
+	} else {
+	    gdb_test_no_output "$set_cmd"
+	    gdb_test "$show_cmd" \
+		"^$show_cmd\r\n" "$show_cmd: empty second time"
+	}
+    }
+
+    # Test completion.
+    if {$variant == "string" || $variant == "string-noescape" } {
+	# Make sure GDB doesn't try to complete on symbols, which
+	# doesn't make any sense.
+	test_gdb_complete_none "$set_cmd "
+    } else {
+	# Complete on filename.
+
+	# See comments in gdb.base/completion.exp.
+
+	# We `cd' to ${srcdir}, and then do the completion relative to
+	# the current directory.
+
+	# ${srcdir} may be a relative path.  We want to make sure we
+	# end up in the right directory - so make sure we know where
+	# it is.
+	global srcdir
+	set mydir [pwd]
+	cd ${srcdir}
+	set fullsrcdir [pwd]
+	cd ${mydir}
+
+	gdb_test "cd ${fullsrcdir}" \
+	    "Working directory [string_to_regexp ${fullsrcdir}].*" \
+	    "cd to \${srcdir}"
+
+	set unique_file ../testsuite/gdb.base/comp-dir/subdir/dummy
+
+	test_gdb_complete_unique \
+	    "$set_cmd ${unique_file}" \
+	    "$set_cmd ${unique_file}.txt"
+
+	test_gdb_complete_none "$set_cmd ${unique_file}.abc"
+    }
+
+    # Check show command completion.
+    if {$variant == "string"} {
+	test_gdb_complete_multiple "maint test-settings show " "string" "" {
+	    "string"
+	    "string-noescape"
+	}
+    } else {
+	test_gdb_complete_unique \
+	    "$show_cmd" \
+	    "$show_cmd"
+    }
+    test_gdb_complete_none "$show_cmd "
+}
+
+foreach variant {
+    uinteger
+    integer
+    zinteger
+    zuinteger
+    zuinteger-unlimited
+} {
+    with_test_prefix "test-integer $variant" {
+	test-integer $variant
+    }
+}
+
+test-boolean
+test-auto-boolean
+test-enum
+
+foreach variant {
+    string
+    string-noescape
+    optional-filename
+    filename
+} {
+    with_test_prefix "test-string $variant" {
+	test-string $variant
+    }
+}
