gdb/testsuite: Improve detection of bug gdb/24541
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-logging.exp
index b66f5c2bc1954af7d19a6adf39ffdf8a33206521..1a5f67342a63fe65558888f41028d703da08f9c3 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2012-2016 Free Software Foundation, Inc.
+# Copyright 2012-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
@@ -25,7 +25,7 @@ standard_testfile basics.c
 set opts {debug}
 
 if [build_executable $testfile.exp $testfile $srcfile $opts] {
-    untested mi-logging.exp
+    untested "failed to compile"
     return -1
 }
 
@@ -54,9 +54,9 @@ close $chan
 set mi_log_prompt "\[(\]gdb\[)\] \[\r\n\]+"
 
 if [regexp "\\^done\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] {
-    pass "Log file contents"
+    pass "log file contents"
 } else {
-    fail "Log file contents"
+    fail "log file contents"
 }
 
 # Now try the redirect, which writes into the file only.
@@ -77,9 +77,23 @@ set logcontent [read $chan]
 close $chan
 
 if [regexp "1001\\^done\[\r\n\]+$mi_log_prompt.*1002\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt.*1003\\^running\[\r\n\]+\\*running,thread-id=\"all\"\[\r\n\]+$mi_log_prompt\\*stopped,reason=\"end-stepping-range\",.*\[\r\n\]+$mi_log_prompt" $logcontent] {
-    pass "Redirect log file contents"
+    pass "redirect log file contents"
 } else {
-    fail "Redirect log file contents"
+    fail "redirect log file contents"
+}
+
+# Now try enabling a redirect while GDB is already logging.  This used
+# to crash GDB.
+with_test_prefix "redirect while already logging" {
+    mi_gdb_test "-gdb-set logging redirect off" ".*" \
+       "logging redirect off"
+    mi_gdb_test "-gdb-set logging on" ".*" \
+       "logging on"
+    mi_gdb_test "-gdb-set logging redirect on" \
+       ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*" \
+       "logging redirect on"
+    mi_gdb_test "-gdb-set logging off" ".*" \
+       "logging off"
 }
 
 mi_gdb_exit
This page took 0.057862 seconds and 4 git commands to generate.