]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/gdb.base/early-init-file.exp
gdb: add "set startup-quietly" command
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / early-init-file.exp
index 4873e5be3aea84d5be70f4aa8c3ff850267f6361..9d5e84cdad1d4ccc3776d030c61dafcf60abf410 100644 (file)
@@ -66,6 +66,21 @@ proc setup_home_directories { prefix content } {
     return [list $home_dir $xdg_home_dir]
 }
 
+# Restart GDB and ensure that there's no license text, we should just
+# drop straight to the prompt.
+proc check_gdb_startups_up_quietly { message } {
+    global gdb_prompt
+
+    gdb_exit
+    gdb_spawn
+
+    gdb_test_multiple "" $message {
+       -re "^$gdb_prompt $" {
+           pass $gdb_test_name
+       }
+    }
+}
+
 save_vars { env(TERM) } {
     # We need an ANSI-capable terminal to get the output.
     setenv TERM ansi
@@ -106,4 +121,28 @@ save_vars { env(TERM) } {
        check_gdb_startup_version_string none \
            "check version string is unstyled using XDG_CONFIG_HOME"
     }
+
+    # Create two directories to use for the quiet startup test.
+    set dirs [setup_home_directories "quiet" "set startup-quietly on"]
+    set home_dir [lindex $dirs 0]
+    set xdg_home_dir [lindex $dirs 1]
+
+    # Now arrange to use the fake home directory startup file.
+    save_vars { INTERNAL_GDBFLAGS env(HOME) env(XDG_CONFIG_HOME) } {
+       set INTERNAL_GDBFLAGS [string map {"-nx" ""} $INTERNAL_GDBFLAGS]
+
+       # Now test GDB when using the HOME directory.
+       set env(HOME) $home_dir
+       unset -nocomplain env(XDG_CONFIG_HOME)
+       check_gdb_startups_up_quietly \
+           "check GDB starts quietly using HOME"
+
+       # Now test using the XDG_CONFIG_HOME folder.  We still need to
+       # have a HOME directory set otherwise GDB will issue an error
+       # about not knowing where to place the index cache.
+       set env(XDG_CONFIG_HOME) $xdg_home_dir
+       set env(HOME) $empty_home_dir
+       check_gdb_startups_up_quietly \
+           "check GDB starts quietly using XDG_CONFIG_HOME"
+    }
 }