testsuite: Use feature test rather than enumeration for complex
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp
index 0e92bb0..1b8b008 100644
--- a/testsuite/lib/libffi.exp
+++ b/testsuite/lib/libffi.exp
@@ -223,6 +223,24 @@ proc libffi_target_compile { source dest type options } {
return [target_compile $source $dest $type $options]
}
+# TEST should be a preprocessor condition. Returns true if it holds.
+proc libffi_feature_test { test } {
+ set src "ffitest.c"
+
+ set f [open $src "w"]
+ puts $f "#include <ffi.h>"
+ puts $f $test
+ puts $f "xyzzy"
+ puts $f "#endif"
+ close $f
+
+ set lines [libffi_target_compile $src "" "preprocess" ""]
+ file delete $src
+
+ set last [lindex $lines end]
+ return [regexp -- "xyzzy" $last]
+}
+
# Utility routines.
#
diff --git a/testsuite/libffi.call/call.exp b/testsuite/libffi.call/call.exp
index 982c03e..54f2834 100644
--- a/testsuite/libffi.call/call.exp
+++ b/testsuite/libffi.call/call.exp
@@ -24,15 +24,7 @@ set ctlist [lsearch -inline -all -glob [lsort [glob -nocomplain -- $srcdir/$subd
run-many-tests $tlist ""
-# ??? We really should preprocess ffi.h and grep
-# for FFI_TARGET_HAS_COMPLEX_TYPE.
-if { [istarget aarch64*]
- || [istarget alpha*]
- || [istarget arm*]
- || [istarget i?86*]
- || [istarget s390*]
- || [istarget sparc*]
- || [istarget x86_64*] } {
+if { [libffi_feature_test "#ifdef FFI_TARGET_HAS_COMPLEX_TYPE"] } {
run-many-tests $ctlist ""
} else {
foreach test $ctlist {