summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorAnthony Green <green@moxielogic.com>2014-11-15 07:31:41 -0500
committerAnthony Green <green@moxielogic.com>2014-11-15 07:31:41 -0500
commit3316b666e3074fe0eebff4fe0458979961b26651 (patch)
treedb0514a1d9bfd94669c9c02e7dd9e9a40727aec5 /testsuite
parentb698638d7601de994410c5c1b2f5c2c648015b7b (diff)
parentdea49e2020b2fc97ba9293200f316f7a7b3ca73b (diff)
downloadlibffi-3316b666e3074fe0eebff4fe0458979961b26651.tar.gz
Merge pull request #145 from rth7680/master
Configure and testsuite cleanups, v2
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/lib/libffi.exp94
-rw-r--r--testsuite/libffi.call/call.exp17
-rw-r--r--testsuite/libffi.complex/cls_align_complex.inc (renamed from testsuite/libffi.call/cls_align_complex.inc)0
-rw-r--r--testsuite/libffi.complex/cls_align_complex_double.c (renamed from testsuite/libffi.call/cls_align_complex_double.c)0
-rw-r--r--testsuite/libffi.complex/cls_align_complex_float.c (renamed from testsuite/libffi.call/cls_align_complex_float.c)0
-rw-r--r--testsuite/libffi.complex/cls_align_complex_longdouble.c (renamed from testsuite/libffi.call/cls_align_complex_longdouble.c)0
-rw-r--r--testsuite/libffi.complex/cls_complex.inc (renamed from testsuite/libffi.call/cls_complex.inc)0
-rw-r--r--testsuite/libffi.complex/cls_complex_double.c (renamed from testsuite/libffi.call/cls_complex_double.c)0
-rw-r--r--testsuite/libffi.complex/cls_complex_float.c (renamed from testsuite/libffi.call/cls_complex_float.c)0
-rw-r--r--testsuite/libffi.complex/cls_complex_longdouble.c (renamed from testsuite/libffi.call/cls_complex_longdouble.c)0
-rw-r--r--testsuite/libffi.complex/cls_complex_struct.inc (renamed from testsuite/libffi.call/cls_complex_struct.inc)0
-rw-r--r--testsuite/libffi.complex/cls_complex_struct_double.c (renamed from testsuite/libffi.call/cls_complex_struct_double.c)0
-rw-r--r--testsuite/libffi.complex/cls_complex_struct_float.c (renamed from testsuite/libffi.call/cls_complex_struct_float.c)0
-rw-r--r--testsuite/libffi.complex/cls_complex_struct_longdouble.c (renamed from testsuite/libffi.call/cls_complex_struct_longdouble.c)0
-rw-r--r--testsuite/libffi.complex/cls_complex_va.inc (renamed from testsuite/libffi.call/cls_complex_va.inc)0
-rw-r--r--testsuite/libffi.complex/cls_complex_va_double.c (renamed from testsuite/libffi.call/cls_complex_va_double.c)0
-rw-r--r--testsuite/libffi.complex/cls_complex_va_float.c (renamed from testsuite/libffi.call/cls_complex_va_float.c)0
-rw-r--r--testsuite/libffi.complex/cls_complex_va_longdouble.c (renamed from testsuite/libffi.call/cls_complex_va_longdouble.c)0
-rw-r--r--testsuite/libffi.complex/complex.exp36
-rw-r--r--testsuite/libffi.complex/complex.inc (renamed from testsuite/libffi.call/complex.inc)0
-rw-r--r--testsuite/libffi.complex/complex_defs_double.inc (renamed from testsuite/libffi.call/complex_defs_double.inc)0
-rw-r--r--testsuite/libffi.complex/complex_defs_float.inc (renamed from testsuite/libffi.call/complex_defs_float.inc)0
-rw-r--r--testsuite/libffi.complex/complex_defs_longdouble.inc (renamed from testsuite/libffi.call/complex_defs_longdouble.inc)0
-rw-r--r--testsuite/libffi.complex/complex_double.c (renamed from testsuite/libffi.call/complex_double.c)0
-rw-r--r--testsuite/libffi.complex/complex_float.c (renamed from testsuite/libffi.call/complex_float.c)0
-rw-r--r--testsuite/libffi.complex/complex_int.c (renamed from testsuite/libffi.call/complex_int.c)0
-rw-r--r--testsuite/libffi.complex/complex_longdouble.c (renamed from testsuite/libffi.call/complex_longdouble.c)0
-rw-r--r--testsuite/libffi.complex/ffitest.h1
-rw-r--r--testsuite/libffi.complex/many_complex.inc (renamed from testsuite/libffi.call/many_complex.inc)0
-rw-r--r--testsuite/libffi.complex/many_complex_double.c (renamed from testsuite/libffi.call/many_complex_double.c)0
-rw-r--r--testsuite/libffi.complex/many_complex_float.c (renamed from testsuite/libffi.call/many_complex_float.c)0
-rw-r--r--testsuite/libffi.complex/many_complex_longdouble.c (renamed from testsuite/libffi.call/many_complex_longdouble.c)0
-rw-r--r--testsuite/libffi.complex/return_complex.inc (renamed from testsuite/libffi.call/return_complex.inc)0
-rw-r--r--testsuite/libffi.complex/return_complex1.inc (renamed from testsuite/libffi.call/return_complex1.inc)0
-rw-r--r--testsuite/libffi.complex/return_complex1_double.c (renamed from testsuite/libffi.call/return_complex1_double.c)0
-rw-r--r--testsuite/libffi.complex/return_complex1_float.c (renamed from testsuite/libffi.call/return_complex1_float.c)0
-rw-r--r--testsuite/libffi.complex/return_complex1_longdouble.c (renamed from testsuite/libffi.call/return_complex1_longdouble.c)0
-rw-r--r--testsuite/libffi.complex/return_complex2.inc (renamed from testsuite/libffi.call/return_complex2.inc)0
-rw-r--r--testsuite/libffi.complex/return_complex2_double.c (renamed from testsuite/libffi.call/return_complex2_double.c)0
-rw-r--r--testsuite/libffi.complex/return_complex2_float.c (renamed from testsuite/libffi.call/return_complex2_float.c)0
-rw-r--r--testsuite/libffi.complex/return_complex2_longdouble.c (renamed from testsuite/libffi.call/return_complex2_longdouble.c)0
-rw-r--r--testsuite/libffi.complex/return_complex_double.c (renamed from testsuite/libffi.call/return_complex_double.c)0
-rw-r--r--testsuite/libffi.complex/return_complex_float.c (renamed from testsuite/libffi.call/return_complex_float.c)0
-rw-r--r--testsuite/libffi.complex/return_complex_longdouble.c (renamed from testsuite/libffi.call/return_complex_longdouble.c)0
-rw-r--r--testsuite/libffi.go/aa-direct.c34
-rw-r--r--testsuite/libffi.go/closure1.c28
-rw-r--r--testsuite/libffi.go/ffitest.h1
-rw-r--r--testsuite/libffi.go/go.exp36
-rw-r--r--testsuite/libffi.go/static-chain.h19
49 files changed, 211 insertions, 55 deletions
diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp
index 5051d31..1b8b008 100644
--- a/testsuite/lib/libffi.exp
+++ b/testsuite/lib/libffi.exp
@@ -100,46 +100,39 @@ proc libffi-init { args } {
global libffi_link_flags
global tool_root_dir
global ld_library_path
-
- global using_gcc
+ global compiler_vendor
set blddirffi [pwd]/..
verbose "libffi $blddirffi"
- # Are we building with GCC?
- set tmp [grep ../config.status "GCC='yes'"]
- if { [string match $tmp "GCC='yes'"] } {
-
- set using_gcc "yes"
+ # Which compiler are we building with?
+ set tmp [grep ../config.log "^ax_cv_c_compiler_vendor.*$"]
+ regexp -- {^[^=]*=(.*)$} $tmp nil compiler_vendor
- set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
- if {$gccdir != ""} {
- set gccdir [file dirname $gccdir]
- }
- verbose "gccdir $gccdir"
-
- set ld_library_path "."
- append ld_library_path ":${gccdir}"
-
- set compiler "${gccdir}/xgcc"
- if { [is_remote host] == 0 && [which $compiler] != 0 } {
- foreach i "[exec $compiler --print-multi-lib]" {
- set mldir ""
- regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
- set mldir [string trimright $mldir "\;@"]
- if { "$mldir" == "." } {
- continue
- }
- if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
- append ld_library_path ":${gccdir}/${mldir}"
+ if { [string match $compiler_vendor "gnu"] } {
+ set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+ if {$gccdir != ""} {
+ set gccdir [file dirname $gccdir]
+ }
+ verbose "gccdir $gccdir"
+
+ set ld_library_path "."
+ append ld_library_path ":${gccdir}"
+
+ set compiler "${gccdir}/xgcc"
+ if { [is_remote host] == 0 && [which $compiler] != 0 } {
+ foreach i "[exec $compiler --print-multi-lib]" {
+ set mldir ""
+ regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
+ set mldir [string trimright $mldir "\;@"]
+ if { "$mldir" == "." } {
+ continue
+ }
+ if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+ append ld_library_path ":${gccdir}/${mldir}"
+ }
}
- }
- }
-
- } else {
-
- set using_gcc "no"
-
+ }
}
# add the library path for libffi.
@@ -230,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.
#
@@ -278,18 +289,25 @@ proc libffi-dg-runtest { testcases default-extra-flags } {
}
proc run-many-tests { testcases extra_flags } {
- global using_gcc
- if { [string match $using_gcc "yes"] } {
+ global compiler_vendor
+ switch $compiler_vendor {
+ "clang" {
+ set common "-W -Wall"
+ set optimizations { "-O0" "-O1" "-O2" "-O3" "-Os" }
+ }
+ "gnu" {
set common "-W -Wall -Wno-psabi"
set optimizations { "-O0" "-O2" "-O3" "-Os" "-O2 -fomit-frame-pointer" }
- } else {
+ }
+ default {
# Assume we are using the vendor compiler.
set common ""
set optimizations { "" }
+ }
}
set targetabis { "" }
- if [string match $using_gcc "yes"] {
+ if [string match $compiler_vendor "gnu"] {
if [istarget "i?86-*-*"] {
set targetabis {
""
diff --git a/testsuite/libffi.call/call.exp b/testsuite/libffi.call/call.exp
index 982c03e..46fb1eb 100644
--- a/testsuite/libffi.call/call.exp
+++ b/testsuite/libffi.call/call.exp
@@ -20,26 +20,9 @@ libffi-init
global srcdir subdir
set tlist [lsearch -inline -all -not -glob [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] *complex*]
-set ctlist [lsearch -inline -all -glob [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] *complex*]
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*] } {
- run-many-tests $ctlist ""
-} else {
- foreach test $ctlist {
- unsupported "$test"
- }
-}
-
dg-finish
# Local Variables:
diff --git a/testsuite/libffi.call/cls_align_complex.inc b/testsuite/libffi.complex/cls_align_complex.inc
index 4a812ed..4a812ed 100644
--- a/testsuite/libffi.call/cls_align_complex.inc
+++ b/testsuite/libffi.complex/cls_align_complex.inc
diff --git a/testsuite/libffi.call/cls_align_complex_double.c b/testsuite/libffi.complex/cls_align_complex_double.c
index 0dff23a..0dff23a 100644
--- a/testsuite/libffi.call/cls_align_complex_double.c
+++ b/testsuite/libffi.complex/cls_align_complex_double.c
diff --git a/testsuite/libffi.call/cls_align_complex_float.c b/testsuite/libffi.complex/cls_align_complex_float.c
index 0affbd0..0affbd0 100644
--- a/testsuite/libffi.call/cls_align_complex_float.c
+++ b/testsuite/libffi.complex/cls_align_complex_float.c
diff --git a/testsuite/libffi.call/cls_align_complex_longdouble.c b/testsuite/libffi.complex/cls_align_complex_longdouble.c
index 7889ba8..7889ba8 100644
--- a/testsuite/libffi.call/cls_align_complex_longdouble.c
+++ b/testsuite/libffi.complex/cls_align_complex_longdouble.c
diff --git a/testsuite/libffi.call/cls_complex.inc b/testsuite/libffi.complex/cls_complex.inc
index f937404..f937404 100644
--- a/testsuite/libffi.call/cls_complex.inc
+++ b/testsuite/libffi.complex/cls_complex.inc
diff --git a/testsuite/libffi.call/cls_complex_double.c b/testsuite/libffi.complex/cls_complex_double.c
index 05e3534..05e3534 100644
--- a/testsuite/libffi.call/cls_complex_double.c
+++ b/testsuite/libffi.complex/cls_complex_double.c
diff --git a/testsuite/libffi.call/cls_complex_float.c b/testsuite/libffi.complex/cls_complex_float.c
index 5df7849..5df7849 100644
--- a/testsuite/libffi.call/cls_complex_float.c
+++ b/testsuite/libffi.complex/cls_complex_float.c
diff --git a/testsuite/libffi.call/cls_complex_longdouble.c b/testsuite/libffi.complex/cls_complex_longdouble.c
index 2b1c320..2b1c320 100644
--- a/testsuite/libffi.call/cls_complex_longdouble.c
+++ b/testsuite/libffi.complex/cls_complex_longdouble.c
diff --git a/testsuite/libffi.call/cls_complex_struct.inc b/testsuite/libffi.complex/cls_complex_struct.inc
index df8708d..df8708d 100644
--- a/testsuite/libffi.call/cls_complex_struct.inc
+++ b/testsuite/libffi.complex/cls_complex_struct.inc
diff --git a/testsuite/libffi.call/cls_complex_struct_double.c b/testsuite/libffi.complex/cls_complex_struct_double.c
index ec71346..ec71346 100644
--- a/testsuite/libffi.call/cls_complex_struct_double.c
+++ b/testsuite/libffi.complex/cls_complex_struct_double.c
diff --git a/testsuite/libffi.call/cls_complex_struct_float.c b/testsuite/libffi.complex/cls_complex_struct_float.c
index 96fdf75..96fdf75 100644
--- a/testsuite/libffi.call/cls_complex_struct_float.c
+++ b/testsuite/libffi.complex/cls_complex_struct_float.c
diff --git a/testsuite/libffi.call/cls_complex_struct_longdouble.c b/testsuite/libffi.complex/cls_complex_struct_longdouble.c
index 005b467..005b467 100644
--- a/testsuite/libffi.call/cls_complex_struct_longdouble.c
+++ b/testsuite/libffi.complex/cls_complex_struct_longdouble.c
diff --git a/testsuite/libffi.call/cls_complex_va.inc b/testsuite/libffi.complex/cls_complex_va.inc
index 8a3e15f..8a3e15f 100644
--- a/testsuite/libffi.call/cls_complex_va.inc
+++ b/testsuite/libffi.complex/cls_complex_va.inc
diff --git a/testsuite/libffi.call/cls_complex_va_double.c b/testsuite/libffi.complex/cls_complex_va_double.c
index 879ccf3..879ccf3 100644
--- a/testsuite/libffi.call/cls_complex_va_double.c
+++ b/testsuite/libffi.complex/cls_complex_va_double.c
diff --git a/testsuite/libffi.call/cls_complex_va_float.c b/testsuite/libffi.complex/cls_complex_va_float.c
index 2b17826..2b17826 100644
--- a/testsuite/libffi.call/cls_complex_va_float.c
+++ b/testsuite/libffi.complex/cls_complex_va_float.c
diff --git a/testsuite/libffi.call/cls_complex_va_longdouble.c b/testsuite/libffi.complex/cls_complex_va_longdouble.c
index 6eca965..6eca965 100644
--- a/testsuite/libffi.call/cls_complex_va_longdouble.c
+++ b/testsuite/libffi.complex/cls_complex_va_longdouble.c
diff --git a/testsuite/libffi.complex/complex.exp b/testsuite/libffi.complex/complex.exp
new file mode 100644
index 0000000..4631db2
--- /dev/null
+++ b/testsuite/libffi.complex/complex.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+dg-init
+libffi-init
+
+global srcdir subdir
+
+set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]]
+
+if { [libffi_feature_test "#ifdef FFI_TARGET_HAS_COMPLEX_TYPE"] } {
+ run-many-tests $tlist ""
+} else {
+ foreach test $tlist {
+ unsupported "$test"
+ }
+}
+
+dg-finish
+
+# Local Variables:
+# tcl-indent-level:4
+# End:
diff --git a/testsuite/libffi.call/complex.inc b/testsuite/libffi.complex/complex.inc
index 515ae3e..515ae3e 100644
--- a/testsuite/libffi.call/complex.inc
+++ b/testsuite/libffi.complex/complex.inc
diff --git a/testsuite/libffi.call/complex_defs_double.inc b/testsuite/libffi.complex/complex_defs_double.inc
index 3583e16..3583e16 100644
--- a/testsuite/libffi.call/complex_defs_double.inc
+++ b/testsuite/libffi.complex/complex_defs_double.inc
diff --git a/testsuite/libffi.call/complex_defs_float.inc b/testsuite/libffi.complex/complex_defs_float.inc
index bbd9375..bbd9375 100644
--- a/testsuite/libffi.call/complex_defs_float.inc
+++ b/testsuite/libffi.complex/complex_defs_float.inc
diff --git a/testsuite/libffi.call/complex_defs_longdouble.inc b/testsuite/libffi.complex/complex_defs_longdouble.inc
index 14b9f24..14b9f24 100644
--- a/testsuite/libffi.call/complex_defs_longdouble.inc
+++ b/testsuite/libffi.complex/complex_defs_longdouble.inc
diff --git a/testsuite/libffi.call/complex_double.c b/testsuite/libffi.complex/complex_double.c
index 8a3297b..8a3297b 100644
--- a/testsuite/libffi.call/complex_double.c
+++ b/testsuite/libffi.complex/complex_double.c
diff --git a/testsuite/libffi.call/complex_float.c b/testsuite/libffi.complex/complex_float.c
index 5044ebb..5044ebb 100644
--- a/testsuite/libffi.call/complex_float.c
+++ b/testsuite/libffi.complex/complex_float.c
diff --git a/testsuite/libffi.call/complex_int.c b/testsuite/libffi.complex/complex_int.c
index bac3190..bac3190 100644
--- a/testsuite/libffi.call/complex_int.c
+++ b/testsuite/libffi.complex/complex_int.c
diff --git a/testsuite/libffi.call/complex_longdouble.c b/testsuite/libffi.complex/complex_longdouble.c
index 7e78366..7e78366 100644
--- a/testsuite/libffi.call/complex_longdouble.c
+++ b/testsuite/libffi.complex/complex_longdouble.c
diff --git a/testsuite/libffi.complex/ffitest.h b/testsuite/libffi.complex/ffitest.h
new file mode 100644
index 0000000..d27d362
--- /dev/null
+++ b/testsuite/libffi.complex/ffitest.h
@@ -0,0 +1 @@
+#include "../libffi.call/ffitest.h"
diff --git a/testsuite/libffi.call/many_complex.inc b/testsuite/libffi.complex/many_complex.inc
index e37a774..e37a774 100644
--- a/testsuite/libffi.call/many_complex.inc
+++ b/testsuite/libffi.complex/many_complex.inc
diff --git a/testsuite/libffi.call/many_complex_double.c b/testsuite/libffi.complex/many_complex_double.c
index 3fd53c3..3fd53c3 100644
--- a/testsuite/libffi.call/many_complex_double.c
+++ b/testsuite/libffi.complex/many_complex_double.c
diff --git a/testsuite/libffi.call/many_complex_float.c b/testsuite/libffi.complex/many_complex_float.c
index c43d21c..c43d21c 100644
--- a/testsuite/libffi.call/many_complex_float.c
+++ b/testsuite/libffi.complex/many_complex_float.c
diff --git a/testsuite/libffi.call/many_complex_longdouble.c b/testsuite/libffi.complex/many_complex_longdouble.c
index dbab723..dbab723 100644
--- a/testsuite/libffi.call/many_complex_longdouble.c
+++ b/testsuite/libffi.complex/many_complex_longdouble.c
diff --git a/testsuite/libffi.call/return_complex.inc b/testsuite/libffi.complex/return_complex.inc
index 8bf0c1f..8bf0c1f 100644
--- a/testsuite/libffi.call/return_complex.inc
+++ b/testsuite/libffi.complex/return_complex.inc
diff --git a/testsuite/libffi.call/return_complex1.inc b/testsuite/libffi.complex/return_complex1.inc
index 7cecc0f..7cecc0f 100644
--- a/testsuite/libffi.call/return_complex1.inc
+++ b/testsuite/libffi.complex/return_complex1.inc
diff --git a/testsuite/libffi.call/return_complex1_double.c b/testsuite/libffi.complex/return_complex1_double.c
index 727410d..727410d 100644
--- a/testsuite/libffi.call/return_complex1_double.c
+++ b/testsuite/libffi.complex/return_complex1_double.c
diff --git a/testsuite/libffi.call/return_complex1_float.c b/testsuite/libffi.complex/return_complex1_float.c
index a2aeada..a2aeada 100644
--- a/testsuite/libffi.call/return_complex1_float.c
+++ b/testsuite/libffi.complex/return_complex1_float.c
diff --git a/testsuite/libffi.call/return_complex1_longdouble.c b/testsuite/libffi.complex/return_complex1_longdouble.c
index 103504b..103504b 100644
--- a/testsuite/libffi.call/return_complex1_longdouble.c
+++ b/testsuite/libffi.complex/return_complex1_longdouble.c
diff --git a/testsuite/libffi.call/return_complex2.inc b/testsuite/libffi.complex/return_complex2.inc
index 265170b..265170b 100644
--- a/testsuite/libffi.call/return_complex2.inc
+++ b/testsuite/libffi.complex/return_complex2.inc
diff --git a/testsuite/libffi.call/return_complex2_double.c b/testsuite/libffi.complex/return_complex2_double.c
index ab9efac..ab9efac 100644
--- a/testsuite/libffi.call/return_complex2_double.c
+++ b/testsuite/libffi.complex/return_complex2_double.c
diff --git a/testsuite/libffi.call/return_complex2_float.c b/testsuite/libffi.complex/return_complex2_float.c
index d7f22c2..d7f22c2 100644
--- a/testsuite/libffi.call/return_complex2_float.c
+++ b/testsuite/libffi.complex/return_complex2_float.c
diff --git a/testsuite/libffi.call/return_complex2_longdouble.c b/testsuite/libffi.complex/return_complex2_longdouble.c
index 3edea62..3edea62 100644
--- a/testsuite/libffi.call/return_complex2_longdouble.c
+++ b/testsuite/libffi.complex/return_complex2_longdouble.c
diff --git a/testsuite/libffi.call/return_complex_double.c b/testsuite/libffi.complex/return_complex_double.c
index e2497cc..e2497cc 100644
--- a/testsuite/libffi.call/return_complex_double.c
+++ b/testsuite/libffi.complex/return_complex_double.c
diff --git a/testsuite/libffi.call/return_complex_float.c b/testsuite/libffi.complex/return_complex_float.c
index a35528f..a35528f 100644
--- a/testsuite/libffi.call/return_complex_float.c
+++ b/testsuite/libffi.complex/return_complex_float.c
diff --git a/testsuite/libffi.call/return_complex_longdouble.c b/testsuite/libffi.complex/return_complex_longdouble.c
index 142d7be..142d7be 100644
--- a/testsuite/libffi.call/return_complex_longdouble.c
+++ b/testsuite/libffi.complex/return_complex_longdouble.c
diff --git a/testsuite/libffi.go/aa-direct.c b/testsuite/libffi.go/aa-direct.c
new file mode 100644
index 0000000..b00c404
--- /dev/null
+++ b/testsuite/libffi.go/aa-direct.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+
+#include "static-chain.h"
+
+#if defined(__GNUC__) && !defined(__clang__) && defined(STATIC_CHAIN_REG)
+
+#include "ffitest.h"
+
+/* Blatent assumption here that the prologue doesn't clobber the
+ static chain for trivial functions. If this is not true, don't
+ define STATIC_CHAIN_REG, and we'll test what we can via other tests. */
+void *doit(void)
+{
+ register void *chain __asm__(STATIC_CHAIN_REG);
+ return chain;
+}
+
+int main()
+{
+ ffi_cif cif;
+ void *result;
+
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 0, &ffi_type_pointer, NULL) == FFI_OK);
+
+ ffi_call_go(&cif, FFI_FN(doit), &result, NULL, &result);
+
+ CHECK(result == &result);
+
+ return 0;
+}
+
+#else /* UNSUPPORTED */
+int main() { return 0; }
+#endif
diff --git a/testsuite/libffi.go/closure1.c b/testsuite/libffi.go/closure1.c
new file mode 100644
index 0000000..7b34afc
--- /dev/null
+++ b/testsuite/libffi.go/closure1.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+void doit(ffi_cif *cif, void *rvalue, void **avalue, void *closure)
+{
+ (void)cif;
+ (void)avalue;
+ *(void **)rvalue = closure;
+}
+
+typedef void * (*FN)(void);
+
+int main()
+{
+ ffi_cif cif;
+ ffi_go_closure cl;
+ void *result;
+
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 0, &ffi_type_pointer, NULL) == FFI_OK);
+ CHECK(ffi_prep_go_closure(&cl, &cif, doit) == FFI_OK);
+
+ ffi_call_go(&cif, FFI_FN(*(FN *)&cl), &result, NULL, &cl);
+
+ CHECK(result == &cl);
+
+ exit(0);
+}
diff --git a/testsuite/libffi.go/ffitest.h b/testsuite/libffi.go/ffitest.h
new file mode 100644
index 0000000..d27d362
--- /dev/null
+++ b/testsuite/libffi.go/ffitest.h
@@ -0,0 +1 @@
+#include "../libffi.call/ffitest.h"
diff --git a/testsuite/libffi.go/go.exp b/testsuite/libffi.go/go.exp
new file mode 100644
index 0000000..100c5e7
--- /dev/null
+++ b/testsuite/libffi.go/go.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+dg-init
+libffi-init
+
+global srcdir subdir
+
+set tlist [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]]
+
+if { [libffi_feature_test "#ifdef FFI_GO_CLOSURES"] } {
+ run-many-tests $tlist ""
+} else {
+ foreach test $tlist {
+ unsupported "$test"
+ }
+}
+
+dg-finish
+
+# Local Variables:
+# tcl-indent-level:4
+# End:
diff --git a/testsuite/libffi.go/static-chain.h b/testsuite/libffi.go/static-chain.h
new file mode 100644
index 0000000..56b7e31
--- /dev/null
+++ b/testsuite/libffi.go/static-chain.h
@@ -0,0 +1,19 @@
+#ifdef __aarch64__
+# define STATIC_CHAIN_REG "x18"
+#elif defined(__alpha__)
+# define STATIC_CHAIN_REG "r1"
+#elif defined(__arm__)
+# define STATIC_CHAIN_REG "ip"
+#elif defined(__sparc__)
+# if defined(__arch64__) || defined(__sparcv9)
+# define STATIC_CHAIN_REG "g5"
+# else
+# define STATIC_CHAIN_REG "g2"
+# endif
+#elif defined(__x86_64__)
+# define STATIC_CHAIN_REG "r10"
+#elif defined(__i386__)
+# ifndef ABI_NUM
+# define STATIC_CHAIN_REG "ecx" /* FFI_DEFAULT_ABI only */
+# endif
+#endif