Mark some cases as xfail due to GCC bug
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp
index 76ef29c..28f793a 100644
--- a/testsuite/lib/libffi.exp
+++ b/testsuite/lib/libffi.exp
@@ -24,6 +24,183 @@ load_lib libgloss.exp
load_gcc_lib target-libpath.exp
load_gcc_lib wrapper.exp
+proc check_effective_target_gccbug { } {
+ global has_gccbug
+ return $has_gccbug
+}
+
+# Return 1 if the target matches the effective target 'arg', 0 otherwise.
+# This can be used with any check_* proc that takes no argument and
+# returns only 1 or 0. It could be used with check_* procs that take
+# arguments with keywords that pass particular arguments.
+
+proc is-effective-target { arg } {
+ global et_index
+ set selected 0
+ if { ![info exists et_index] } {
+ # Initialize the effective target index that is used in some
+ # check_effective_target_* procs.
+ set et_index 0
+ }
+ if { [info procs check_effective_target_${arg}] != [list] } {
+ set selected [check_effective_target_${arg}]
+ } else {
+ error "unknown effective target keyword `$arg'"
+ }
+ verbose "is-effective-target: $arg $selected" 2
+ return $selected
+}
+
+proc is-effective-target-keyword { arg } {
+ if { [info procs check_effective_target_${arg}] != [list] } {
+ return 1
+ } else {
+ return 0
+ }
+}
+
+# Intercept the call to the DejaGnu version of dg-process-target to
+# support use of an effective-target keyword in place of a list of
+# target triplets to xfail or skip a test.
+#
+# The argument to dg-process-target is the keyword "target" or "xfail"
+# followed by a selector:
+# target-triplet-1 ...
+# effective-target-keyword
+# selector-expression
+#
+# For a target list the result is "S" if the target is selected, "N" otherwise.
+# For an xfail list the result is "F" if the target is affected, "P" otherwise.
+
+# In contexts that allow either "target" or "xfail" the argument can be
+# target selector1 xfail selector2
+# which returns "N" if selector1 is not selected, otherwise the result of
+# "xfail selector2".
+#
+# A selector expression appears within curly braces and uses a single logical
+# operator: !, &&, or ||. An operand is another selector expression, an
+# effective-target keyword, or a list of target triplets within quotes or
+# curly braces.
+
+if { [info procs saved-dg-process-target] == [list] } {
+ rename dg-process-target saved-dg-process-target
+
+ # Evaluate an operand within a selector expression.
+ proc selector_opd { op } {
+ set selector "target"
+ lappend selector $op
+ set answer [ expr { [dg-process-target $selector] == "S" } ]
+ verbose "selector_opd: `$op' $answer" 2
+ return $answer
+ }
+
+ # Evaluate a target triplet list within a selector expression.
+ # Unlike other operands, this needs to be expanded from a list to
+ # the same string as "target".
+ proc selector_list { op } {
+ set selector "target [join $op]"
+ set answer [ expr { [dg-process-target $selector] == "S" } ]
+ verbose "selector_list: `$op' $answer" 2
+ return $answer
+ }
+
+ # Evaluate a selector expression.
+ proc selector_expression { exp } {
+ if { [llength $exp] == 2 } {
+ if [string match "!" [lindex $exp 0]] {
+ set op1 [lindex $exp 1]
+ set answer [expr { ! [selector_opd $op1] }]
+ } else {
+ # Assume it's a list of target triplets.
+ set answer [selector_list $exp]
+ }
+ } elseif { [llength $exp] == 3 } {
+ set op1 [lindex $exp 0]
+ set opr [lindex $exp 1]
+ set op2 [lindex $exp 2]
+ if [string match "&&" $opr] {
+ set answer [expr { [selector_opd $op1] && [selector_opd $op2] }]
+ } elseif [string match "||" $opr] {
+ set answer [expr { [selector_opd $op1] || [selector_opd $op2] }]
+ } else {
+ # Assume it's a list of target triplets.
+ set answer [selector_list $exp]
+ }
+ } else {
+ # Assume it's a list of target triplets.
+ set answer [selector_list $exp]
+ }
+
+ verbose "selector_expression: `$exp' $answer" 2
+ return $answer
+ }
+
+ # Evaluate "target selector" or "xfail selector".
+
+ proc dg-process-target-1 { args } {
+ verbose "dg-process-target-1: `$args'" 2
+
+ # Extract the 'what' keyword from the argument list.
+ set selector [string trim [lindex $args 0]]
+ if [regexp "^xfail " $selector] {
+ set what "xfail"
+ } elseif [regexp "^target " $selector] {
+ set what "target"
+ } else {
+ error "syntax error in target selector \"$selector\""
+ }
+
+ # Extract the rest of the list, which might be a keyword.
+ regsub "^${what}" $selector "" rest
+ set rest [string trim $rest]
+
+ if [is-effective-target-keyword $rest] {
+ # The selector is an effective target keyword.
+ if [is-effective-target $rest] {
+ return [expr { $what == "xfail" ? "F" : "S" }]
+ } else {
+ return [expr { $what == "xfail" ? "P" : "N" }]
+ }
+ }
+
+ if [string match "{*}" $rest] {
+ if [selector_expression [lindex $rest 0]] {
+ return [expr { $what == "xfail" ? "F" : "S" }]
+ } else {
+ return [expr { $what == "xfail" ? "P" : "N" }]
+ }
+ }
+
+ # The selector is not an effective-target keyword, so process
+ # the list of target triplets.
+ return [saved-dg-process-target $selector]
+ }
+
+ # Intercept calls to the DejaGnu function. In addition to
+ # processing "target selector" or "xfail selector", handle
+ # "target selector1 xfail selector2".
+
+ proc dg-process-target { args } {
+ verbose "replacement dg-process-target: `$args'" 2
+
+ set selector [string trim [lindex $args 0]]
+
+ # If the argument list contains both 'target' and 'xfail',
+ # process 'target' and, if that succeeds, process 'xfail'.
+ if [regexp "^target .* xfail .*" $selector] {
+ set xfail_index [string first "xfail" $selector]
+ set xfail_selector [string range $selector $xfail_index end]
+ set target_selector [string range $selector 0 [expr $xfail_index-1]]
+ set target_selector [string trim $target_selector]
+ if { [dg-process-target-1 $target_selector] == "N" } {
+ return "N"
+ }
+ return [dg-process-target-1 $xfail_selector]
+
+ }
+ return [dg-process-target-1 $selector]
+ }
+}
# Define libffi callbacks for dg.exp.
@@ -299,6 +476,7 @@ proc libffi-dg-runtest { testcases default-extra-flags } {
proc run-many-tests { testcases extra_flags } {
global compiler_vendor
+ global has_gccbug
switch $compiler_vendor {
"clang" {
set common "-W -Wall"
@@ -329,7 +507,7 @@ proc run-many-tests { testcases extra_flags } {
&& !defined __i386__"] } {
set targetabis {
""
- "-DABI_NUM=FFI_WIN64 -DABI_ATTR=__MSABI__"
+ "-DABI_NUM=FFI_GNUW64 -DABI_ATTR=__MSABI__"
}
}
}
@@ -345,6 +523,17 @@ proc run-many-tests { testcases extra_flags } {
foreach opt $optimizations {
foreach abi $abis {
set options [concat $common $opt $abi]
+ set has_gccbug false;
+ if { [string match $compiler_vendor "gnu"] \
+ && [string match "*MSABI*" $abi] \
+ && ( ( [string match "*DGTEST=57 *" $common] \
+ && [string match "*call.c*" $testname] ) \
+ || ( [string match "*DGTEST=54 *" $common] \
+ && [string match "*callback*" $testname] ) \
+ || [string match "*DGTEST=55 *" $common] \
+ || [string match "*DGTEST=56 *" $common] ) } then {
+ set has_gccbug true;
+ }
verbose "Testing $testname, $options" 1
dg-test $test $options ""
}
diff --git a/testsuite/libffi.bhaible/bhaible.exp b/testsuite/libffi.bhaible/bhaible.exp
index 6a0bb45..4e5051b 100644
--- a/testsuite/libffi.bhaible/bhaible.exp
+++ b/testsuite/libffi.bhaible/bhaible.exp
@@ -19,6 +19,7 @@ libffi-init
global srcdir subdir
global compiler_vendor
+global has_gccbug
# The conversion of this testsuite into a dejagnu compatible testsuite
# was done in a pretty lazy fashion, and requires the use of compiler
@@ -37,6 +38,7 @@ if { ![string match $compiler_vendor "microsoft"] && ![string match $compiler_ve
set warning_options "-Wno-unused-variable -Wno-unused-parameter -Wno-uninitialized";
}
+
set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/test-call.c]]
for {set i 1} {$i < 82} {incr i} {
diff --git a/testsuite/libffi.bhaible/test-call.c b/testsuite/libffi.bhaible/test-call.c
index 01a8a21..caa77de 100644
--- a/testsuite/libffi.bhaible/test-call.c
+++ b/testsuite/libffi.bhaible/test-call.c
@@ -16,7 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
-/* { dg-do run } */
+/* { dg-do run { xfail gccbug } }*/
#include <stdio.h>
#include <stdlib.h>
diff --git a/testsuite/libffi.bhaible/test-callback.c b/testsuite/libffi.bhaible/test-callback.c
index c2633c7..67a8145 100644
--- a/testsuite/libffi.bhaible/test-callback.c
+++ b/testsuite/libffi.bhaible/test-callback.c
@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* { dg-do run } */
+/* { dg-do run { xfail gccbug } }*/
#include <stdio.h>
#include <stdlib.h>