aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
authorGuinevere Larsen <blarsen@redhat.com>2023-08-11 11:58:11 +0200
committerGuinevere Larsen <blarsen@redhat.com>2023-10-04 17:43:23 +0200
commit1bdabb9e9fe8ac2c02640645a2ec42c496c5cb94 (patch)
tree43ee8352e0d39a1ea587110956d738fa98aa175c /gdb/testsuite/lib
parent2aafdd4de60e02dfa7b04fc0c6cc33ee90257700 (diff)
downloadgdb-1bdabb9e9fe8ac2c02640645a2ec42c496c5cb94.zip
gdb-1bdabb9e9fe8ac2c02640645a2ec42c496c5cb94.tar.gz
gdb-1bdabb9e9fe8ac2c02640645a2ec42c496c5cb94.tar.bz2
gdb/testsuite: XFAIL some gdb.base/fileio.exp
Some gdb.base/fileio.exp tests expect the inferior to not have write access to some files. If the test is being run as root, this is never possible. This commit adds a way to identify if the user is root and xfails the tests that expect no write access. Approved-By: Tom de Vries <tdevries@suse.de>
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index c9f1f66..3cad4f7 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -10230,5 +10230,25 @@ gdb_caching_proc have_system_header { file } {
return [gdb_can_simple_compile have_system_header_$name $src object]
}
+# Return 1 if the test is being run as root, 0 otherwise.
+
+gdb_caching_proc root_user {} {
+ # ID outputs to stdout, we have to use exec to capture it here.
+ set res [remote_exec target id]
+ set ret_val [lindex $res 0]
+ set output [lindex $res 1]
+
+ # If ret_val is not 0, we couldn't run `id` on the target for some
+ # reason. Return that we are not root, so problems are easier to
+ # spot.
+ if { $ret_val != 0 } {
+ return 0
+ }
+
+ regexp -all ".*uid=(\[0-9\]+).*" $output dummy uid
+
+ return [expr $uid == 0]
+}
+
# Always load compatibility stuff.
load_lib future.exp