1 # Copyright 2019-2023 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Test that logging does not style.
18 # Do not run if gdb debug is enabled as it will interfere with log redirect.
19 if {[gdb_debug_enabled]} {
20 untested "debug is enabled"
24 if {[is_remote host]} {
25 untested "does not work on remote host"
29 standard_testfile style.c
31 save_vars { env(TERM) } {
32 # We need an ANSI-capable terminal to get the output.
35 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
43 gdb_test_no_output "set style enabled on"
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 .*"
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]
56 "$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*"
58 gdb_test "set logging enabled off" "Done logging to .*"
60 set fd [open $log_name]
61 set data [read -nonewline $fd]
64 set testname "log is escape-free"
65 if {[regexp "\033" $data]} {