]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/permissions.exp
Fix some duplicate test names
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / permissions.exp
CommitLineData
b811d2c2 1# Copyright 2010-2020 Free Software Foundation, Inc.
d914c394
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
16# Tests for permissions and observer mode.
17
18# The permissions flags are only fully functional with stubs or targets
19# that can run asynchronously.
20
822bd149
TT
21standard_testfile start.c
22
23if {[build_executable $testfile.exp $testfile \
24 $srcfile {debug nowarnings}] == -1} {
5b362f04 25 untested "failed to compile"
822bd149
TT
26 return -1
27}
d914c394 28
4c93b1db 29if [get_compiler_info] {
d914c394
SS
30 return -1
31}
32
33gdb_exit
34gdb_start
35gdb_reinitialize_dir $srcdir/$subdir
36
c2b75043 37with_test_prefix "observer mode off" {
d914c394 38
c2b75043
LM
39 gdb_test "show may-write-registers" \
40 "Permission to write into registers is on."
d914c394 41
c2b75043
LM
42 gdb_test "show may-write-memory" \
43 "Permission to write into target memory is on."
d914c394 44
c2b75043
LM
45 gdb_test "show may-insert-breakpoints" \
46 "Permission to insert breakpoints in the target is on."
d914c394 47
c2b75043
LM
48 gdb_test "show may-insert-tracepoints" \
49 "Permission to insert tracepoints in the target is on."
d914c394 50
c2b75043
LM
51 gdb_test "show may-insert-fast-tracepoints" \
52 "Permission to insert fast tracepoints in the target is on."
53
54 gdb_test "show may-interrupt" \
55 "Permission to interrupt or signal the target is on."
56}
d914c394
SS
57
58gdb_test "set observer on" "Observer mode is now on." "enable observer mode"
59
c2b75043
LM
60with_test_prefix "observer mode on" {
61 gdb_test "show may-write-memory" \
62 "Permission to write into target memory is off."
d914c394 63
c2b75043
LM
64 gdb_test "show may-write-registers" \
65 "Permission to write into registers is off."
d914c394 66
c2b75043
LM
67 gdb_test "show may-insert-breakpoints" \
68 "Permission to insert breakpoints in the target is off."
d914c394 69
c2b75043
LM
70 gdb_test "show may-insert-tracepoints" \
71 "Permission to insert tracepoints in the target is off."
d914c394 72
c2b75043
LM
73 gdb_test "show may-insert-fast-tracepoints" \
74 "Permission to insert fast tracepoints in the target is on."
d914c394 75
c2b75043
LM
76 gdb_test "show may-interrupt" \
77 "Permission to interrupt or signal the target is off."
78}
d914c394
SS
79
80gdb_test "set observer off" "Observer mode is now off." "disable observer mode"
81
82# Go back to all-stop mode.
83
84gdb_test_no_output "set non-stop off"
85
86gdb_load ${binfile}
87
88if ![runto_main] then {
89 perror "couldn't run to breakpoint"
90 continue
91}
92
93gdb_test "print x = 45" "$decimal = 45" "set a global"
94
c2b75043 95gdb_test "print x" "$decimal = 45" "validate setting a global"
d914c394
SS
96
97gdb_test "set may-write-memory off"
98
99gdb_test "print x = 92" "Writing to memory is not allowed.*" \
c2b75043 100 "set a global, 2nd time"
d914c394 101
c2b75043 102gdb_test "print x" "$decimal = 45" "validate setting a global, 2nd time"
d914c394
SS
103
104# FIXME Add tests for other flags when a testsuite-able target becomes
105# available.