public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] [gdb/testsuite] Check for sys/random.h in gdb.reverse/getrandom.exp
@ 2023-08-29  9:02 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2023-08-29  9:02 UTC (permalink / raw)
  To: gdb-patches

When running test-case gdb.reverse/getrandom.exp on a system with eglibc 2.19,
we run into:
...
 gdb compile failed, gdb.reverse/getrandom.c:18:24: fatal error: \
   sys/random.h: No such file or directory
  #include <sys/random.h>
                         ^
 compilation terminated.

                 === gdb Summary ===

 # of untested testcases        1
...
and:
...
UNTESTED: gdb.reverse/getrandom.exp: failed to prepare
...

Fix this by testing for the presence of the header, such that we have instead:
...
UNSUPPORTED: gdb.reverse/getrandom.exp: require failed: \
  have_system_header sys/random.h
...

Tested on x86_64-linux and i686-linux.
---
 gdb/testsuite/gdb.reverse/getrandom.exp | 1 +
 gdb/testsuite/lib/gdb.exp               | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/gdb/testsuite/gdb.reverse/getrandom.exp b/gdb/testsuite/gdb.reverse/getrandom.exp
index ef8899358f9..1561d842dc9 100644
--- a/gdb/testsuite/gdb.reverse/getrandom.exp
+++ b/gdb/testsuite/gdb.reverse/getrandom.exp
@@ -20,6 +20,7 @@
 #
 
 require supports_reverse
+require {have_system_header sys/random.h}
 
 standard_testfile
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 8432e636ecc..bcf536e0cc5 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9952,5 +9952,13 @@ proc have_host_locale { locale } {
     return [expr $idx != -1]
 }
 
+# Return 1 if we can use '#include <$file>' in source file.
+
+gdb_caching_proc have_system_header { file } {
+    set src "#include <$file>"
+    set name [string map { "/" "_sep_" } $file]
+    return [gdb_can_simple_compile have_system_header_$name $src object]
+}
+
 # Always load compatibility stuff.
 load_lib future.exp

base-commit: c58d51c612cdfd8914cefab80c350e1aa9ea3ed4
-- 
2.35.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-29  9:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-29  9:02 [pushed] [gdb/testsuite] Check for sys/random.h in gdb.reverse/getrandom.exp Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).