binutils-gdb/gdb/testsuite/gdb.trace/trace-buffer-size.exp
Pedro Alves c12440c923 Fix gdb.trace/trace-buffer-size.exp race.
Just the usual missing $gdb_prompt match:

 (gdb) tstatus
 No trace has been run on the target.
 Collected 0 trace frames.
 Trace buffer has 5242880 bytes of 5242880 bytes free (0% full).
 Trace will stop if GDB disconnects.
 Not looking at any trace frame.
 PASS: gdb.trace/trace-buffer-size.exp: get default buffer size
 (gdb) set trace-buffer-size 4
 (gdb) FAIL: gdb.trace/trace-buffer-size.exp: set trace buffer size 1

This fixes it.

gdb/testsuite/
2013-03-21  Pedro Alves  <palves@redhat.com>

	* gdb.trace/trace-buffer-size.exp (get default buffer size):
	Expect $gdb_prompt in gdb_test_multiple.
2013-03-21 19:18:25 +00:00

115 lines
3.4 KiB
Plaintext

# Copyright 1998-2013 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/>.
load_lib "trace-support.exp"
standard_testfile
if [prepare_for_testing ${testfile}.exp $testfile $srcfile \
{debug nowarnings}] {
untested "failed to prepare for trace tests"
return -1
}
if ![runto_main] {
fail "can't run to main to check for trace support"
return -1
}
if ![gdb_target_supports_trace] {
unsupported "target does not support trace"
return -1
}
set BUFFER_SIZE 4
set default_size -1
set test "get default buffer size"
# Save default trace buffer size in 'default_size'.
gdb_test_multiple "tstatus" $test {
-re ".*Trace buffer has ($decimal) bytes of ($decimal) bytes free.*$gdb_prompt $" {
set default_size $expect_out(2,string)
pass $test
}
}
# If we did not get the default size then there is no point in running the
# tests below.
if { $default_size < 0 } {
return -1
}
# Change buffer size to 'BUFFER_SIZE'.
gdb_test_no_output \
"set trace-buffer-size $BUFFER_SIZE" \
"set trace buffer size 1"
gdb_test "tstatus" \
".*Trace buffer has $decimal bytes of $BUFFER_SIZE bytes free.*" \
"tstatus check 2"
gdb_test "show trace-buffer-size $BUFFER_SIZE" \
"Requested size of trace buffer is $BUFFER_SIZE.*" \
"show trace buffer size"
gdb_test_no_output \
"set trace-buffer-size -1" \
"set trace buffer size 2"
# Test that tstatus gives us default buffer size now.
gdb_test "tstatus" \
".*Trace buffer has $decimal bytes of $default_size bytes free.*" \
"tstatus check 3"
gdb_test_no_output \
"set trace-buffer-size $BUFFER_SIZE" \
"set trace buffer size 3"
# We set trace buffer to very small size. Then after running trace,
# we check if it is full. This will show if setting trace buffer
# size really worked.
gdb_breakpoint ${srcfile}:[gdb_get_line_number "breakpoint1"]
gdb_test "trace test_function" \
"Tracepoint \[0-9\]+ at .*" \
"set tracepoint at test_function"
gdb_trace_setactions "Set action for trace point 1" "" \
"collect var" "^$"
gdb_test_no_output "tstart"
gdb_test "continue" \
"Continuing.*Breakpoint $decimal.*" \
"run trace experiment 1"
gdb_test "tstatus" \
".*Trace stopped because the buffer was full.*" \
"buffer full check 1"
# Use the default size -- the trace buffer should not end up
# full this time
clean_restart ${testfile}
runto_main
gdb_breakpoint ${srcfile}:[gdb_get_line_number "breakpoint1"]
gdb_test "trace test_function" \
"Tracepoint \[0-9\]+ at .*" \
"set tracepoint at test_function"
gdb_trace_setactions "Set action for trace point 2" "" \
"collect var" "^$"
gdb_test_no_output "tstart"
gdb_test "continue" \
"Continuing.*Breakpoint $decimal.*" \
"run trace experiment 2"
gdb_test "tstatus" \
".*Trace is running on the target.*" \
"buffer full check 2"
gdb_test_no_output "tstop"