[gdb/testsuite] Handle missing gdc in gdb.dlang/dlang-start.exp

On openSUSE Leap 15.4, I get:
...
Running gdb.dlang/dlang-start.exp ...
gdb compile failed, default_target_compile: Can't find gdc.
UNTESTED: gdb.dlang/dlang-start.exp: failed to prepare
...

Fix this by:
- introducing a new proc can_compile, and
- requiring "can_compile d" in the test-case,
such that I have instead:
...
Running gdb.dlang/dlang-start.exp ...
UNSUPPORTED: gdb.dlang/dlang-start.exp: require failed: can_compile d
...

Tested on x86_64-linux, on openSUSE Leap 15.4 and Fedora 37.
This commit is contained in:
Tom de Vries
2023-03-27 11:35:26 +02:00
parent 16fbc917fa
commit 1770eca698
2 changed files with 17 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
load_lib d-support.exp
require allow_d_tests
require {can_compile d}
# This testcase verifies the behavior of the `start' command, which
# does not work when we use the gdb stub...

View File

@@ -2461,6 +2461,18 @@ proc allow_d_tests {} {
return 1
}
# Return a 1 if we can compile source files in LANG.
gdb_caching_proc can_compile { lang } {
if { $lang == "d" } {
set src { void main() {} }
return [gdb_can_simple_compile can_compile_$lang $src executable {d}]
}
error "can_compile doesn't support lang: $lang"
}
# Return 1 to try Rust tests, 0 to skip them.
proc allow_rust_tests {} {
if { ![isnative] } {
@@ -4634,6 +4646,10 @@ proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj}
set ext "cpp"
break
}
if { "$flag" eq "d" } {
set ext "d"
break
}
}
set src [standard_temp_file $name.$ext]
set obj [standard_temp_file $name.$postfix]