From 130e33d8617e7663b397f35d34f3c2b2f48d9cfc Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Tue, 29 Aug 2023 11:02:08 +0200 Subject: [PATCH] [gdb/testsuite] Check for sys/random.h in gdb.reverse/getrandom.exp 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 ^ 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 -- 2.30.2