1# Copyright 2019-2023 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16# Test that logging does not style. 17 18# Do not run if gdb debug is enabled as it will interfere with log redirect. 19if {[gdb_debug_enabled]} { 20 untested "debug is enabled" 21 return 0 22} 23 24if {[is_remote host]} { 25 untested "does not work on remote host" 26 return 0 27} 28 29standard_testfile style.c 30 31save_vars { env(TERM) } { 32 # We need an ANSI-capable terminal to get the output. 33 setenv TERM ansi 34 35 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { 36 return -1 37 } 38 39 if {![runto_main]} { 40 return 41 } 42 43 gdb_test_no_output "set style enabled on" 44 45 set log_name [standard_output_file log.txt] 46 gdb_test_no_output "set logging file $log_name" \ 47 "set logging filename" 48 gdb_test_no_output "set logging overwrite on" 49 gdb_test "set logging enabled on" "Copying output to .*" 50 51 set main_expr [style main function] 52 set base_file_expr [style ".*style\\.c" file] 53 set file_expr "$base_file_expr:\[0-9\]" 54 set arg_expr [style "arg." variable] 55 gdb_test "frame" \ 56 "$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*" 57 58 gdb_test "set logging enabled off" "Done logging to .*" 59 60 set fd [open $log_name] 61 set data [read -nonewline $fd] 62 close $fd 63 64 set testname "log is escape-free" 65 if {[regexp "\033" $data]} { 66 fail $testname 67 } else { 68 pass $testname 69 } 70} 71