gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-logging.exp
CommitLineData
8acc9f48 1# Copyright 2012-2013 Free Software Foundation, Inc.
37ce89eb
SS
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
16load_lib mi-support.exp
17set MIFLAGS "-i=mi"
18
19gdb_exit
20if [mi_gdb_start] {
21 continue
22}
23
298a9cf0 24standard_testfile basics.c
37ce89eb
SS
25set opts {debug}
26
298a9cf0 27if [build_executable $testfile.exp $testfile $srcfile $opts] {
37ce89eb 28 untested mi-logging.exp
ae59b1da 29 return -1
37ce89eb
SS
30}
31
32if {[mi_run_to_main] < 0} {
33 return -1
34}
35
36set milogfile "milog.txt"
37
38mi_gdb_test "-gdb-set logging file $milogfile" ".*"
39
40mi_gdb_test "-gdb-set logging overwrite on" ".*"
41
42mi_gdb_test "-gdb-set logging on" ".*" "logging on"
43
44mi_step "logged step"
45
46mi_next "logged next"
47
48mi_gdb_test "-gdb-set logging off" ".*" "logging off"
49
50set chan [open $milogfile]
51set logcontent [read $chan]
52close $chan
53
54set mi_log_prompt "\[(\]gdb\[)\] \[\r\n\]+"
55
56if [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] {
57 pass "Log file contents"
58} else {
59 fail "Log file contents"
60}
61
62# Now try the redirect, which writes into the file only.
63
64mi_gdb_test "-gdb-set logging redirect on" ".*" "redirect logging on"
65
66# Since all output will be going into the file, just keep sending commands
67# and don't expect anything to appear until logging is turned off.
68
69send_gdb "1001-gdb-set logging on\n"
70send_gdb "1002-exec-step\n"
71send_gdb "1003-exec-next\n"
72
73mi_gdb_test "1004-gdb-set logging off" ".*" "redirect logging off"
74
75set chan [open $milogfile]
76set logcontent [read $chan]
77close $chan
78
79if [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] {
80 pass "Redirect log file contents"
81} else {
82 fail "Redirect log file contents"
83}
84
85mi_gdb_exit
86
87remote_file host delete $milogfile
This page took 0.186688 seconds and 4 git commands to generate.