testsuite: Factor out a function to run a matrix of tests
authorJosh Triplett <josh@joshtriplett.org>
Sun, 16 Mar 2014 23:04:58 +0000 (16:04 -0700)
committerJosh Triplett <josh@joshtriplett.org>
Mon, 17 Mar 2014 03:34:46 +0000 (20:34 -0700)
This commons up code from libffi.call/call.exp and
libffi.special/special.exp, unifies the optimization option matrix
between the two, and makes it easier to add more axes to the matrix
in the future.

testsuite/lib/libffi.exp
testsuite/libffi.call/call.exp
testsuite/libffi.special/special.exp

index 1ac2c36088725e6bffaa1f4ab9e80de67b46b5b6..014e520662e0066c4f4c15b8a562f0023cfa15a9 100644 (file)
@@ -273,6 +273,23 @@ proc libffi-dg-runtest { testcases default-extra-flags } {
     }
 }
 
+proc run-many-tests { testcases extra_flags } {
+    global using_gcc
+    if { [string match $using_gcc "yes"] } {
+        set common "-W -Wall"
+        set optimizations { "-O0" "-O2" "-O3" "-Os" "-O2 -fomit-frame-pointer" }
+    } else {
+        # Assume we are using the vendor compiler.
+        set common ""
+        set optimizations { "" }
+    }
+
+    set common [ concat $common $extra_flags ]
+    foreach opt $optimizations {
+        set options [ concat $common $opt ]
+        dg-runtest $testcases $options ""
+    }
+}
 
 # Like check_conditional_xfail, but callable from a dg test.
 
index c3346850a96b59afd492e93eb2acdae222c19395..c1ad7375a9811976e50f010e5122bb78cd8ff122 100644 (file)
@@ -19,20 +19,7 @@ libffi-init
 
 global srcdir subdir
 
-if { [string match $using_gcc "yes"] } {
-
-  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O0 -W -Wall" ""
-  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2" ""
-  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O3" ""
-  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-Os" ""
-  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2 -fomit-frame-pointer" ""
-} else { 
-
-  # Assume we are using the vendor compiler.
-  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" ""
-
-}
+run-many-tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] ""
 
 dg-finish
 
index f1a5fa6d8f5f4b57e76dbe69eff1d24583186074..f7155bf44f052856b3a6cb3cf6f54da2d0f5d5df 100644 (file)
@@ -19,17 +19,8 @@ libffi-init
 
 global srcdir subdir
 
-global cxx_options
-
-set cxx_options " -shared-libgcc -lstdc++"
-
 if { [string match $using_gcc "yes"] } {
-
-  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O0 -W -Wall"
-  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O2"
-  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-O3"
-  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] $cxx_options "-Os"
-
+  run-many-tests [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] "-shared-libgcc -lstdc++"
 }
 
 dg-finish