From eb2447249540ca568b0b464f6107501dcc0f65ab Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Fri, 16 Jul 2021 14:33:04 +0000 Subject: Use CHECK to assert more things in test suite (#654) * Use CHECK to assert more things in test suite * Use snprintf instead of sprintf * Fix va_struct1 and va_struct3 --- testsuite/Makefile.am | 2 +- testsuite/libffi.call/ffitest.h | 19 ++++ testsuite/libffi.call/float_va.c | 3 + testsuite/libffi.call/pyobjc-tc.c | 114 --------------------- testsuite/libffi.call/pyobjc_tc.c | 114 +++++++++++++++++++++ testsuite/libffi.call/return_ll1.c | 5 + testsuite/libffi.call/return_sl.c | 4 + testsuite/libffi.call/return_ul.c | 4 + testsuite/libffi.call/va_2.c | 24 +++++ testsuite/libffi.call/va_struct1.c | 13 +++ testsuite/libffi.call/va_struct2.c | 11 ++ testsuite/libffi.call/va_struct3.c | 15 +++ testsuite/libffi.closures/closure_fn0.c | 5 +- testsuite/libffi.closures/closure_fn1.c | 2 + testsuite/libffi.closures/closure_fn2.c | 2 + testsuite/libffi.closures/closure_fn3.c | 22 +++- testsuite/libffi.closures/closure_fn4.c | 2 + testsuite/libffi.closures/closure_fn5.c | 2 + testsuite/libffi.closures/closure_fn6.c | 2 + testsuite/libffi.closures/closure_loc_fn0.c | 7 +- testsuite/libffi.closures/closure_simple.c | 6 ++ testsuite/libffi.closures/cls_12byte.c | 18 ++++ testsuite/libffi.closures/cls_16byte.c | 22 ++++ testsuite/libffi.closures/cls_18byte.c | 24 +++++ testsuite/libffi.closures/cls_19byte.c | 29 ++++++ testsuite/libffi.closures/cls_1_1byte.c | 4 + testsuite/libffi.closures/cls_20byte.c | 18 ++++ testsuite/libffi.closures/cls_20byte1.c | 20 ++++ testsuite/libffi.closures/cls_24byte.c | 32 ++++++ testsuite/libffi.closures/cls_2byte.c | 13 +++ testsuite/libffi.closures/cls_3_1byte.c | 19 ++++ testsuite/libffi.closures/cls_3byte1.c | 13 +++ testsuite/libffi.closures/cls_3byte2.c | 13 +++ testsuite/libffi.closures/cls_3float.c | 18 ++++ testsuite/libffi.closures/cls_4_1byte.c | 22 ++++ testsuite/libffi.closures/cls_4byte.c | 13 +++ testsuite/libffi.closures/cls_5_1_byte.c | 28 +++++ testsuite/libffi.closures/cls_5byte.c | 18 ++++ testsuite/libffi.closures/cls_64byte.c | 24 +++++ testsuite/libffi.closures/cls_6_1_byte.c | 27 +++++ testsuite/libffi.closures/cls_6byte.c | 24 ++++- testsuite/libffi.closures/cls_7_1_byte.c | 38 +++++++ testsuite/libffi.closures/cls_7byte.c | 24 +++++ testsuite/libffi.closures/cls_8byte.c | 14 +++ testsuite/libffi.closures/cls_9byte1.c | 13 +++ testsuite/libffi.closures/cls_9byte2.c | 14 ++- testsuite/libffi.closures/cls_align_double.c | 18 ++++ testsuite/libffi.closures/cls_align_float.c | 18 ++++ testsuite/libffi.closures/cls_align_longdouble.c | 19 ++++ .../libffi.closures/cls_align_longdouble_split.c | 61 ++++++----- .../libffi.closures/cls_align_longdouble_split2.c | 39 ++++++- testsuite/libffi.closures/cls_align_pointer.c | 18 ++++ testsuite/libffi.closures/cls_align_sint16.c | 17 +++ testsuite/libffi.closures/cls_align_sint32.c | 19 +++- testsuite/libffi.closures/cls_align_sint64.c | 17 +++ testsuite/libffi.closures/cls_align_uint16.c | 17 +++ testsuite/libffi.closures/cls_align_uint32.c | 18 ++++ testsuite/libffi.closures/cls_align_uint64.c | 18 ++++ testsuite/libffi.closures/cls_dbls_struct.c | 2 + testsuite/libffi.closures/cls_double_va.c | 8 ++ testsuite/libffi.closures/cls_float.c | 4 + testsuite/libffi.closures/cls_longdouble.c | 10 ++ testsuite/libffi.closures/cls_longdouble_va.c | 8 ++ testsuite/libffi.closures/cls_multi_schar.c | 4 + testsuite/libffi.closures/cls_multi_sshort.c | 5 + testsuite/libffi.closures/cls_multi_sshortchar.c | 8 ++ testsuite/libffi.closures/cls_multi_uchar.c | 8 ++ testsuite/libffi.closures/cls_multi_ushort.c | 6 +- testsuite/libffi.closures/cls_multi_ushortchar.c | 8 ++ testsuite/libffi.closures/cls_pointer.c | 5 + testsuite/libffi.closures/cls_pointer_stack.c | 10 ++ testsuite/libffi.closures/cls_schar.c | 3 + testsuite/libffi.closures/cls_sint.c | 2 + testsuite/libffi.closures/cls_sshort.c | 3 + testsuite/libffi.closures/cls_struct_va1.c | 11 ++ testsuite/libffi.closures/cls_uchar.c | 3 + testsuite/libffi.closures/cls_uint.c | 4 + testsuite/libffi.closures/cls_uint_va.c | 4 + testsuite/libffi.closures/cls_ulong_va.c | 4 + testsuite/libffi.closures/cls_ulonglong.c | 2 + testsuite/libffi.closures/cls_ushort.c | 3 + testsuite/libffi.closures/ffitest.h | 19 ++++ testsuite/libffi.closures/huge_struct.c | 2 +- testsuite/libffi.closures/nested_struct.c | 39 +++++-- testsuite/libffi.closures/nested_struct10.c | 12 +++ testsuite/libffi.closures/nested_struct11.c | 26 ++++- testsuite/libffi.closures/nested_struct12.c | 2 +- testsuite/libffi.closures/nested_struct13.c | 20 ++-- testsuite/libffi.closures/nested_struct2.c | 9 ++ testsuite/libffi.closures/nested_struct3.c | 9 ++ testsuite/libffi.closures/nested_struct4.c | 9 ++ testsuite/libffi.closures/nested_struct5.c | 9 ++ testsuite/libffi.closures/nested_struct6.c | 11 ++ testsuite/libffi.closures/nested_struct7.c | 9 ++ testsuite/libffi.closures/nested_struct8.c | 11 ++ testsuite/libffi.closures/nested_struct9.c | 11 ++ testsuite/libffi.closures/testclosure.c | 5 + 97 files changed, 1316 insertions(+), 171 deletions(-) delete mode 100644 testsuite/libffi.call/pyobjc-tc.c create mode 100644 testsuite/libffi.call/pyobjc_tc.c (limited to 'testsuite') diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 1e4b35a..50cc84b 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -9,7 +9,7 @@ CLEANFILES = *.exe core* *.log *.sum EXTRA_DIST = lib/target-libpath.exp lib/libffi.exp lib/wrapper.exp \ libffi.call/strlen4.c libffi.call/struct10.c libffi.call/many_mixed.c \ libffi.call/float.c libffi.call/struct5.c libffi.call/return_fl3.c \ -libffi.call/return_fl1.c libffi.call/call.exp libffi.call/pyobjc-tc.c \ +libffi.call/return_fl1.c libffi.call/call.exp libffi.call/pyobjc_tc.c \ libffi.call/float_va.c libffi.call/struct8.c libffi.call/pr1172638.c \ libffi.call/return_sc.c libffi.call/va_struct1.c \ libffi.call/align_stdcall.c libffi.call/struct9.c libffi.call/va_1.c \ diff --git a/testsuite/libffi.call/ffitest.h b/testsuite/libffi.call/ffitest.h index 95d96a8..53b009c 100644 --- a/testsuite/libffi.call/ffitest.h +++ b/testsuite/libffi.call/ffitest.h @@ -5,6 +5,9 @@ #include #include "fficonfig.h" +#include +#include + #if defined HAVE_STDINT_H #include #endif @@ -23,6 +26,22 @@ } \ } while(0) +#define CHECK_FLOAT_EQ(x, y) \ + do { \ + if(fabs((x) - (y)) > FLT_EPSILON){ \ + printf("Check failed CHECK_FLOAT_EQ(%s, %s)\n", #x, #y); \ + abort(); \ + } \ + } while(0) + +#define CHECK_DOUBLE_EQ(x, y) \ + do { \ + if(fabs((x) - (y)) > DBL_EPSILON){ \ + printf("Check failed CHECK_FLOAT_EQ(%s, %s)\n", #x, #y); \ + abort(); \ + } \ + } while(0) + /* Define macros so that compilers other than gcc can run the tests. */ #undef __UNUSED__ #if defined(__GNUC__) diff --git a/testsuite/libffi.call/float_va.c b/testsuite/libffi.call/float_va.c index 5acff91..d01d9d0 100644 --- a/testsuite/libffi.call/float_va.c +++ b/testsuite/libffi.call/float_va.c @@ -74,6 +74,7 @@ int main (void) /* { dg-output "\n0: 2.0 : total: 2.0" } */ printf("ffi: %.1f\n", resfp); /* { dg-output "\nffi: 2.0" } */ + CHECK_DOUBLE_EQ(resfp, 2); /* Second test, float_va_fn(2,2.0,3.0,4.0), now with variadic params */ /* Call it statically and then via ffi */ @@ -81,6 +82,7 @@ int main (void) /* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */ printf("compiled: %.1f\n", resfp); /* { dg-output "\ncompiled: 11.0" } */ + CHECK_DOUBLE_EQ(resfp, 11); arg_types[0] = &ffi_type_uint; arg_types[1] = &ffi_type_double; @@ -102,6 +104,7 @@ int main (void) /* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */ printf("ffi: %.1f\n", resfp); /* { dg-output "\nffi: 11.0" } */ + CHECK_DOUBLE_EQ(resfp, 11); exit(0); } diff --git a/testsuite/libffi.call/pyobjc-tc.c b/testsuite/libffi.call/pyobjc-tc.c deleted file mode 100644 index e29bd6c..0000000 --- a/testsuite/libffi.call/pyobjc-tc.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Area: ffi_call - Purpose: Check different structures. - Limitations: none. - PR: none. - Originator: Ronald Oussoren 20030824 */ - -/* { dg-do run } */ -#include "ffitest.h" - -typedef struct Point { - float x; - float y; -} Point; - -typedef struct Size { - float h; - float w; -} Size; - -typedef struct Rect { - Point o; - Size s; -} Rect; - -int doit(int o, char* s, Point p, Rect r, int last) -{ - printf("CALLED WITH %d %s {%f %f} {{%f %f} {%f %f}} %d\n", - o, s, p.x, p.y, r.o.x, r.o.y, r.s.h, r.s.w, last); - return 42; -} - - -int main(void) -{ - ffi_type point_type; - ffi_type size_type; - ffi_type rect_type; - ffi_cif cif; - ffi_type* arglist[6]; - void* values[6]; - int r; - - /* - * First set up FFI types for the 3 struct types - */ - - point_type.size = 0; /*sizeof(Point);*/ - point_type.alignment = 0; /*__alignof__(Point);*/ - point_type.type = FFI_TYPE_STRUCT; - point_type.elements = malloc(3 * sizeof(ffi_type*)); - point_type.elements[0] = &ffi_type_float; - point_type.elements[1] = &ffi_type_float; - point_type.elements[2] = NULL; - - size_type.size = 0;/* sizeof(Size);*/ - size_type.alignment = 0;/* __alignof__(Size);*/ - size_type.type = FFI_TYPE_STRUCT; - size_type.elements = malloc(3 * sizeof(ffi_type*)); - size_type.elements[0] = &ffi_type_float; - size_type.elements[1] = &ffi_type_float; - size_type.elements[2] = NULL; - - rect_type.size = 0;/*sizeof(Rect);*/ - rect_type.alignment =0;/* __alignof__(Rect);*/ - rect_type.type = FFI_TYPE_STRUCT; - rect_type.elements = malloc(3 * sizeof(ffi_type*)); - rect_type.elements[0] = &point_type; - rect_type.elements[1] = &size_type; - rect_type.elements[2] = NULL; - - /* - * Create a CIF - */ - arglist[0] = &ffi_type_sint; - arglist[1] = &ffi_type_pointer; - arglist[2] = &point_type; - arglist[3] = &rect_type; - arglist[4] = &ffi_type_sint; - arglist[5] = NULL; - - r = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, - 5, &ffi_type_sint, arglist); - if (r != FFI_OK) { - abort(); - } - - - /* And call the function through the CIF */ - - { - Point p = { 1.0, 2.0 }; - Rect r = { { 9.0, 10.0}, { -1.0, -2.0 } }; - int o = 0; - int l = 42; - char* m = "myMethod"; - ffi_arg result; - - values[0] = &o; - values[1] = &m; - values[2] = &p; - values[3] = &r; - values[4] = &l; - values[5] = NULL; - - printf("CALLING WITH %d %s {%f %f} {{%f %f} {%f %f}} %d\n", - o, m, p.x, p.y, r.o.x, r.o.y, r.s.h, r.s.w, l); - - ffi_call(&cif, FFI_FN(doit), &result, values); - - printf ("The result is %d\n", (int)result); - - } - exit(0); -} diff --git a/testsuite/libffi.call/pyobjc_tc.c b/testsuite/libffi.call/pyobjc_tc.c new file mode 100644 index 0000000..e29bd6c --- /dev/null +++ b/testsuite/libffi.call/pyobjc_tc.c @@ -0,0 +1,114 @@ +/* Area: ffi_call + Purpose: Check different structures. + Limitations: none. + PR: none. + Originator: Ronald Oussoren 20030824 */ + +/* { dg-do run } */ +#include "ffitest.h" + +typedef struct Point { + float x; + float y; +} Point; + +typedef struct Size { + float h; + float w; +} Size; + +typedef struct Rect { + Point o; + Size s; +} Rect; + +int doit(int o, char* s, Point p, Rect r, int last) +{ + printf("CALLED WITH %d %s {%f %f} {{%f %f} {%f %f}} %d\n", + o, s, p.x, p.y, r.o.x, r.o.y, r.s.h, r.s.w, last); + return 42; +} + + +int main(void) +{ + ffi_type point_type; + ffi_type size_type; + ffi_type rect_type; + ffi_cif cif; + ffi_type* arglist[6]; + void* values[6]; + int r; + + /* + * First set up FFI types for the 3 struct types + */ + + point_type.size = 0; /*sizeof(Point);*/ + point_type.alignment = 0; /*__alignof__(Point);*/ + point_type.type = FFI_TYPE_STRUCT; + point_type.elements = malloc(3 * sizeof(ffi_type*)); + point_type.elements[0] = &ffi_type_float; + point_type.elements[1] = &ffi_type_float; + point_type.elements[2] = NULL; + + size_type.size = 0;/* sizeof(Size);*/ + size_type.alignment = 0;/* __alignof__(Size);*/ + size_type.type = FFI_TYPE_STRUCT; + size_type.elements = malloc(3 * sizeof(ffi_type*)); + size_type.elements[0] = &ffi_type_float; + size_type.elements[1] = &ffi_type_float; + size_type.elements[2] = NULL; + + rect_type.size = 0;/*sizeof(Rect);*/ + rect_type.alignment =0;/* __alignof__(Rect);*/ + rect_type.type = FFI_TYPE_STRUCT; + rect_type.elements = malloc(3 * sizeof(ffi_type*)); + rect_type.elements[0] = &point_type; + rect_type.elements[1] = &size_type; + rect_type.elements[2] = NULL; + + /* + * Create a CIF + */ + arglist[0] = &ffi_type_sint; + arglist[1] = &ffi_type_pointer; + arglist[2] = &point_type; + arglist[3] = &rect_type; + arglist[4] = &ffi_type_sint; + arglist[5] = NULL; + + r = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, + 5, &ffi_type_sint, arglist); + if (r != FFI_OK) { + abort(); + } + + + /* And call the function through the CIF */ + + { + Point p = { 1.0, 2.0 }; + Rect r = { { 9.0, 10.0}, { -1.0, -2.0 } }; + int o = 0; + int l = 42; + char* m = "myMethod"; + ffi_arg result; + + values[0] = &o; + values[1] = &m; + values[2] = &p; + values[3] = &r; + values[4] = &l; + values[5] = NULL; + + printf("CALLING WITH %d %s {%f %f} {{%f %f} {%f %f}} %d\n", + o, m, p.x, p.y, r.o.x, r.o.y, r.s.h, r.s.w, l); + + ffi_call(&cif, FFI_FN(doit), &result, values); + + printf ("The result is %d\n", (int)result); + + } + exit(0); +} diff --git a/testsuite/libffi.call/return_ll1.c b/testsuite/libffi.call/return_ll1.c index 593e8a3..a2426ec 100644 --- a/testsuite/libffi.call/return_ll1.c +++ b/testsuite/libffi.call/return_ll1.c @@ -9,6 +9,9 @@ #include "ffitest.h" static long long return_ll(int ll0, long long ll1, int ll2) { + CHECK(ll0 == 11111111); + CHECK(ll1 == 11111111111000LL); + CHECK(ll2 == 11111111); return ll0 + ll1 + ll2; } @@ -39,5 +42,7 @@ int main (void) ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values); printf("res: %" PRIdLL ", %" PRIdLL "\n", rlonglong, ll0 + ll1 + ll2); /* { dg-output "res: 11111133333222, 11111133333222" } */ + CHECK(rlonglong == 11111133333222); + CHECK(ll0 + ll1 + ll2 == 11111133333222); exit(0); } diff --git a/testsuite/libffi.call/return_sl.c b/testsuite/libffi.call/return_sl.c index f0fd345..4fe5e9a 100644 --- a/testsuite/libffi.call/return_sl.c +++ b/testsuite/libffi.call/return_sl.c @@ -8,6 +8,8 @@ #include "ffitest.h" static long return_sl(long l1, long l2) { + CHECK(l1 == 1073741823L); + CHECK(l2 == 1073741824L); return l1 - l2; } @@ -33,6 +35,8 @@ int main (void) ffi_call(&cif, FFI_FN(return_sl), &res, values); printf("res: %ld, %ld\n", (long)res, l1 - l2); /* { dg-output "res: -1, -1" } */ + CHECK(res == -1); + CHECK(l1 - l2 == -1); exit(0); } diff --git a/testsuite/libffi.call/return_ul.c b/testsuite/libffi.call/return_ul.c index 12b266f..fedcc25 100644 --- a/testsuite/libffi.call/return_ul.c +++ b/testsuite/libffi.call/return_ul.c @@ -8,6 +8,8 @@ #include "ffitest.h" static unsigned long return_ul(unsigned long ul1, unsigned long ul2) { + CHECK(ul1 == 1073741823L); + CHECK(ul2 == 1073741824L); return ul1 + ul2; } @@ -33,6 +35,8 @@ int main (void) ffi_call(&cif, FFI_FN(return_ul), &res, values); printf("res: %lu, %lu\n", (unsigned long)res, ul1 + ul2); /* { dg-output "res: 2147483647, 2147483647" } */ + CHECK(res == 2147483647L); + CHECK(ul1 + ul2 == 2147483647L); exit(0); } diff --git a/testsuite/libffi.call/va_2.c b/testsuite/libffi.call/va_2.c index 0589d08..cb88db9 100644 --- a/testsuite/libffi.call/va_2.c +++ b/testsuite/libffi.call/va_2.c @@ -25,6 +25,7 @@ struct large_tag unsigned e; }; + static int test_fn (int n, ...) { @@ -72,7 +73,29 @@ test_fn (int n, ...) ui, si, ul, sl, f, d); + va_end (ap); + + CHECK(s1.a == 5); + CHECK(s1.b == 6); + CHECK(l.a == 10); + CHECK(l.b == 11); + CHECK(l.c == 12); + CHECK(l.d == 13); + CHECK(l.e == 14); + CHECK(s2.a == 7); + CHECK(s2.b == 8); + CHECK(uc == 9); + CHECK(sc == 10); + CHECK(us == 11); + CHECK(ss == 12); + CHECK(ui == 13); + CHECK(si == 14); + CHECK(ul == 15); + CHECK(sl == 16); + CHECK((int)f == 2); + CHECK((int)d == 3); + return n + 1; } @@ -191,6 +214,7 @@ main (void) /* { dg-output "5 6 10 11 12 13 14 7 8 uc=9 sc=10 11 12 13 14 15 16 2.120000 3.130000" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 42" } */ + CHECK(res == 42); return 0; } diff --git a/testsuite/libffi.call/va_struct1.c b/testsuite/libffi.call/va_struct1.c index e645206..fff5c9a 100644 --- a/testsuite/libffi.call/va_struct1.c +++ b/testsuite/libffi.call/va_struct1.c @@ -40,6 +40,18 @@ test_fn (int n, ...) printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, s2.a, s2.b); va_end (ap); + + CHECK(s1.a == 5); + CHECK(s1.b == 6); + + CHECK(l.a == 10); + CHECK(l.b == 11); + CHECK(l.c == 12); + CHECK(l.d == 13); + CHECK(l.e == 14); + + CHECK(s2.a == 7); + CHECK(s2.b == 8); return n + 1; } @@ -116,6 +128,7 @@ main (void) /* { dg-output "5 6 10 11 12 13 14 7 8" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 42" } */ + CHECK(res == 42); return 0; } diff --git a/testsuite/libffi.call/va_struct2.c b/testsuite/libffi.call/va_struct2.c index 56f5b9c..a8daff3 100644 --- a/testsuite/libffi.call/va_struct2.c +++ b/testsuite/libffi.call/va_struct2.c @@ -39,6 +39,15 @@ test_fn (int n, ...) s2 = va_arg (ap, struct small_tag); printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, s2.a, s2.b); + CHECK(s1.a == 5); + CHECK(s1.b == 6); + CHECK(l.a == 10); + CHECK(l.b == 11); + CHECK(l.c == 12); + CHECK(l.d == 13); + CHECK(l.e == 14); + CHECK(s2.a == 7); + CHECK(s2.b == 8); va_end (ap); s1.a += s2.a; s1.b += s2.b; @@ -118,6 +127,8 @@ main (void) /* { dg-output "5 6 10 11 12 13 14 7 8" } */ printf("res: %d %d\n", res.a, res.b); /* { dg-output "\nres: 12 14" } */ + CHECK(res.a == 12); + CHECK(res.b == 14); return 0; } diff --git a/testsuite/libffi.call/va_struct3.c b/testsuite/libffi.call/va_struct3.c index 9a27e7f..d3bd280 100644 --- a/testsuite/libffi.call/va_struct3.c +++ b/testsuite/libffi.call/va_struct3.c @@ -39,6 +39,16 @@ test_fn (int n, ...) s2 = va_arg (ap, struct small_tag); printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e, s2.a, s2.b); + + CHECK(s1.a == 5); + CHECK(s1.b == 6); + CHECK(l.a == 10); + CHECK(l.b == 11); + CHECK(l.c == 12); + CHECK(l.d == 13); + CHECK(l.e == 14); + CHECK(s2.a == 7); + CHECK(s2.b == 8); va_end (ap); l.a += s1.a; l.b += s1.b; @@ -120,6 +130,11 @@ main (void) /* { dg-output "5 6 10 11 12 13 14 7 8" } */ printf("res: %d %d %d %d %d\n", res.a, res.b, res.c, res.d, res.e); /* { dg-output "\nres: 15 17 19 21 14" } */ + CHECK(res.a == 15); + CHECK(res.b == 17); + CHECK(res.c == 19); + CHECK(res.d == 21); + CHECK(res.e == 14); return 0; } diff --git a/testsuite/libffi.closures/closure_fn0.c b/testsuite/libffi.closures/closure_fn0.c index a579ff6..dfadb05 100644 --- a/testsuite/libffi.closures/closure_fn0.c +++ b/testsuite/libffi.closures/closure_fn0.c @@ -38,7 +38,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(int *)args[12], (int)(*(int *)args[13]), (int)(*(int *)args[14]),*(int *)args[15], (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); - + CHECK((int)*(ffi_arg *)resp == 680); } typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long, @@ -85,5 +85,6 @@ int main (void) /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ printf("res: %d\n",res); /* { dg-output "\nres: 680" } */ - exit(0); + CHECK(res == 680); + exit(0); } diff --git a/testsuite/libffi.closures/closure_fn1.c b/testsuite/libffi.closures/closure_fn1.c index 9123173..a90bb29 100644 --- a/testsuite/libffi.closures/closure_fn1.c +++ b/testsuite/libffi.closures/closure_fn1.c @@ -33,6 +33,7 @@ static void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(int *)args[12], (int)(*(int *)args[13]), (int)(*(int *)args[14]), *(int *)args[15], (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + CHECK((int)*(ffi_arg *)resp == 255); } typedef int (*closure_test_type1)(float, float, float, float, signed short, @@ -77,5 +78,6 @@ int main (void) /* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */ printf("res: %d\n",res); /* { dg-output "\nres: 255" } */ + CHECK(res == 255); exit(0); } diff --git a/testsuite/libffi.closures/closure_fn2.c b/testsuite/libffi.closures/closure_fn2.c index 08ff9d9..7d7af4b 100644 --- a/testsuite/libffi.closures/closure_fn2.c +++ b/testsuite/libffi.closures/closure_fn2.c @@ -32,6 +32,7 @@ static void closure_test_fn2(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(int *)args[12], (int)(*(float *)args[13]), (int)(*(int *)args[14]), *(int *)args[15], (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + CHECK((int)*(ffi_arg *)resp == 255); } typedef int (*closure_test_type2)(double, double, double, double, signed short, @@ -77,5 +78,6 @@ int main (void) /* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */ printf("res: %d\n",res); /* { dg-output "\nres: 255" } */ + CHECK(res == 255); exit(0); } diff --git a/testsuite/libffi.closures/closure_fn3.c b/testsuite/libffi.closures/closure_fn3.c index 9b54d80..1ad8f9d 100644 --- a/testsuite/libffi.closures/closure_fn3.c +++ b/testsuite/libffi.closures/closure_fn3.c @@ -31,8 +31,27 @@ static void closure_test_fn3(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)(*(float *)args[10]), (int)(*(float *)args[11]), (int)*(int *)args[12], (int)(*(float *)args[13]), (int)(*(float *)args[14]), *(int *)args[15], (int)(intptr_t)userdata, - (int)*(ffi_arg *)resp); + (int)*(ffi_arg *)resp); + CHECK((int)*(float *)args[0] == 1); + CHECK((int)(*(float *)args[1]) == 2); + CHECK((int)(*(float *)args[2]) == 3); + CHECK((int)(*(float *)args[3]) == 4); + CHECK((int)(*(float *)args[4]) == 5); + CHECK((int)(*(float *)args[5]) == 6); + CHECK((int)*(float *)args[6] == 7); + CHECK((int)(*(float *)args[7]) == 8); + CHECK((int)(*(double *)args[8]) == 9); + CHECK((int)*(int *)args[9] == 10); + CHECK((int)(*(float *)args[10]) == 11); + CHECK((int)(*(float *)args[11]) == 12); + CHECK((int)*(int *)args[12] == 13); + CHECK((int)(*(float *)args[13]) == 19); + CHECK((int)(*(float *)args[14]) == 21); + CHECK(*(int *)args[15] == 1); + CHECK((int)(intptr_t)userdata == 3); + + CHECK((int)*(ffi_arg *)resp == 135); } typedef int (*closure_test_type3)(float, float, float, float, float, float, @@ -78,5 +97,6 @@ int main (void) /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 19 21 1 3: 135" } */ printf("res: %d\n",res); /* { dg-output "\nres: 135" } */ + CHECK(res == 135); exit(0); } diff --git a/testsuite/libffi.closures/closure_fn4.c b/testsuite/libffi.closures/closure_fn4.c index d4a1530..e5f1f53 100644 --- a/testsuite/libffi.closures/closure_fn4.c +++ b/testsuite/libffi.closures/closure_fn4.c @@ -45,6 +45,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(unsigned long long *)args[14], *(int *)args[15], (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + CHECK((int)*(ffi_arg *)resp == 680); } @@ -84,6 +85,7 @@ int main (void) /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ printf("res: %d\n",res); /* { dg-output "\nres: 680" } */ + CHECK(res == 680); exit(0); } diff --git a/testsuite/libffi.closures/closure_fn5.c b/testsuite/libffi.closures/closure_fn5.c index 9907442..97277f5 100644 --- a/testsuite/libffi.closures/closure_fn5.c +++ b/testsuite/libffi.closures/closure_fn5.c @@ -44,6 +44,7 @@ closure_test_fn5(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(unsigned long long *)args[14], *(int *)args[15], (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + CHECK((int)*(ffi_arg *)resp == 680); } @@ -87,6 +88,7 @@ int main (void) /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ printf("res: %d\n",res); /* { dg-output "\nres: 680" } */ + CHECK(res == 680); exit(0); } diff --git a/testsuite/libffi.closures/closure_fn6.c b/testsuite/libffi.closures/closure_fn6.c index 73c54fd..fb079e2 100644 --- a/testsuite/libffi.closures/closure_fn6.c +++ b/testsuite/libffi.closures/closure_fn6.c @@ -37,6 +37,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args, (int)*(int *)args[12], (int)(*(int *)args[13]), (int)(*(double *)args[14]), (int)(*(double *)args[15]), (int)(intptr_t)userdata, (int)*(ffi_arg *)resp); + CHECK((int)*(ffi_arg *)resp == 680); } @@ -86,5 +87,6 @@ int main (void) /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ printf("res: %d\n",res); /* { dg-output "\nres: 680" } */ + CHECK(res == 680); exit(0); } diff --git a/testsuite/libffi.closures/closure_loc_fn0.c b/testsuite/libffi.closures/closure_loc_fn0.c index ad488ac..4f2f4f8 100644 --- a/testsuite/libffi.closures/closure_loc_fn0.c +++ b/testsuite/libffi.closures/closure_loc_fn0.c @@ -9,7 +9,7 @@ -/* { dg-do run } */ +/* { dg-do run { xfail wasm32*-*-* } } */ #include "ffitest.h" static void @@ -82,7 +82,7 @@ int main (void) CHECK(ffi_prep_closure_loc(pcl, &cif, closure_loc_test_fn0, (void *) 3 /* userdata */, codeloc) == FFI_OK); - + #ifndef FFI_EXEC_STATIC_TRAMP /* With static trampolines, the codeloc does not point to closure */ CHECK(memcmp(pcl, codeloc, sizeof(*pcl)) == 0); @@ -94,5 +94,6 @@ int main (void) /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */ printf("res: %d\n",res); /* { dg-output "\nres: 680" } */ - exit(0); + CHECK(res == 680); + exit(0); } diff --git a/testsuite/libffi.closures/closure_simple.c b/testsuite/libffi.closures/closure_simple.c index 5a4e728..a18b4a4 100644 --- a/testsuite/libffi.closures/closure_simple.c +++ b/testsuite/libffi.closures/closure_simple.c @@ -20,6 +20,11 @@ closure_test(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata) (int)(*(int *)args[2]), (int)(*(int *)args[3]), (int)*(ffi_arg *)resp); + CHECK((int)*(int *)args[0] == 0); + CHECK((int)*(int *)args[1] == 1); + CHECK((int)*(int *)args[2] == 2); + CHECK((int)*(int *)args[3] == 3); + CHECK((int)*(ffi_arg *)resp == 9); } typedef int (ABI_ATTR *closure_test_type0)(int, int, int, int); @@ -50,6 +55,7 @@ int main (void) printf("res: %d\n",res); /* { dg-output "\nres: 9" } */ + CHECK(res == 9); exit(0); } diff --git a/testsuite/libffi.closures/cls_12byte.c b/testsuite/libffi.closures/cls_12byte.c index ea0825d..a1fdcd7 100644 --- a/testsuite/libffi.closures/cls_12byte.c +++ b/testsuite/libffi.closures/cls_12byte.c @@ -25,6 +25,17 @@ cls_struct_12byte cls_struct_12byte_fn(struct cls_struct_12byte b1, printf("%d %d %d %d %d %d: %d %d %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c, result.a, result.b, result.c); + CHECK(b1.a == 7); + CHECK(b1.b == 4); + CHECK(b1.c == 9); + + CHECK(b2.a == 1); + CHECK(b2.b == 5); + CHECK(b2.c == 3); + + CHECK(result.a == 8); + CHECK(result.b == 9); + CHECK(result.c == 12); return result; } @@ -78,6 +89,9 @@ int main (void) /* { dg-output "7 4 9 1 5 3: 8 9 12" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 8 9 12" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 9); + CHECK(res_dbl.c == 12); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_12byte_gn, NULL, code) == FFI_OK); @@ -87,8 +101,12 @@ int main (void) res_dbl = ((cls_struct_12byte(*)(cls_struct_12byte, cls_struct_12byte))(code))(h_dbl, j_dbl); /* { dg-output "\n7 4 9 1 5 3: 8 9 12" } */ + printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 8 9 12" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 9); + CHECK(res_dbl.c == 12); exit(0); } diff --git a/testsuite/libffi.closures/cls_16byte.c b/testsuite/libffi.closures/cls_16byte.c index 89a08a2..57fe873 100644 --- a/testsuite/libffi.closures/cls_16byte.c +++ b/testsuite/libffi.closures/cls_16byte.c @@ -26,6 +26,19 @@ cls_struct_16byte cls_struct_16byte_fn(struct cls_struct_16byte b1, printf("%d %g %d %d %g %d: %d %g %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c, result.a, result.b, result.c); + CHECK(b1.a == 7); + CHECK(b1.b == 8); + CHECK(b1.c == 9); + + CHECK(b2.a == 1); + CHECK(b2.b == 9); + CHECK(b2.c == 3); + + CHECK(result.a == 8); + CHECK(result.b == 17); + CHECK(result.c == 12); + + return result; } @@ -80,6 +93,10 @@ int main (void) printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 8 17 12" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); + CHECK(res_dbl.c == 12); + res_dbl.a = 0; res_dbl.b = 0.0; res_dbl.c = 0; @@ -91,5 +108,10 @@ int main (void) printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 8 17 12" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); + CHECK(res_dbl.c == 12); + + exit(0); } diff --git a/testsuite/libffi.closures/cls_18byte.c b/testsuite/libffi.closures/cls_18byte.c index 9f75da8..3783121 100644 --- a/testsuite/libffi.closures/cls_18byte.c +++ b/testsuite/libffi.closures/cls_18byte.c @@ -29,6 +29,22 @@ cls_struct_18byte cls_struct_18byte_fn(struct cls_struct_18byte a1, printf("%g %d %d %g %g %d %d %g: %g %d %d %g\n", a1.a, a1.b, a1.c, a1.d, a2.a, a2.b, a2.c, a2.d, result.a, result.b, result.c, result.d); + + CHECK(a1.a == 1); + CHECK(a1.b == 127); + CHECK(a1.c == 126); + CHECK(a1.d == 3); + + CHECK(a2.a == 4); + CHECK(a2.b == 125); + CHECK(a2.c == 124); + CHECK(a2.d == 5); + + CHECK(result.a == 5); + CHECK(result.b == 252); + CHECK(result.c == 250); + CHECK(result.d == 8); + return result; } @@ -84,6 +100,10 @@ int main (void) /* { dg-output "1 127 126 3 4 125 124 5: 5 252 250 8" } */ printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 5 252 250 8" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 252); + CHECK(res_dbl.c == 250); + CHECK(res_dbl.d == 8); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_18byte_gn, NULL, code) == FFI_OK); @@ -91,6 +111,10 @@ int main (void) /* { dg-output "\n1 127 126 3 4 125 124 5: 5 252 250 8" } */ printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 5 252 250 8" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 252); + CHECK(res_dbl.c == 250); + CHECK(res_dbl.d == 8); exit(0); } diff --git a/testsuite/libffi.closures/cls_19byte.c b/testsuite/libffi.closures/cls_19byte.c index 278794b..98ce65a 100644 --- a/testsuite/libffi.closures/cls_19byte.c +++ b/testsuite/libffi.closures/cls_19byte.c @@ -32,6 +32,25 @@ cls_struct_19byte cls_struct_19byte_fn(struct cls_struct_19byte a1, a1.a, a1.b, a1.c, a1.d, a1.e, a2.a, a2.b, a2.c, a2.d, a2.e, result.a, result.b, result.c, result.d, result.e); + + CHECK(a1.a == 1); + CHECK(a1.b == 127); + CHECK(a1.c == 126); + CHECK(a1.d == 3); + CHECK(a1.e == 120); + + CHECK(a2.a == 4); + CHECK(a2.b == 125); + CHECK(a2.c == 124); + CHECK(a2.d == 5); + CHECK(a2.e == 119); + + CHECK(result.a == 5); + CHECK(result.b == 252); + CHECK(result.c == 250); + CHECK(result.d == 8); + CHECK(result.e == 239); + return result; } @@ -89,6 +108,11 @@ int main (void) printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e); /* { dg-output "\nres: 5 252 250 8 239" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 252); + CHECK(res_dbl.c == 250); + CHECK(res_dbl.d == 8); + CHECK(res_dbl.e == 239); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_19byte_gn, NULL, code) == FFI_OK); @@ -97,6 +121,11 @@ int main (void) printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e); /* { dg-output "\nres: 5 252 250 8 239" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 252); + CHECK(res_dbl.c == 250); + CHECK(res_dbl.d == 8); + CHECK(res_dbl.e == 239); exit(0); } diff --git a/testsuite/libffi.closures/cls_1_1byte.c b/testsuite/libffi.closures/cls_1_1byte.c index 82492c0..49e33b9 100644 --- a/testsuite/libffi.closures/cls_1_1byte.c +++ b/testsuite/libffi.closures/cls_1_1byte.c @@ -23,6 +23,9 @@ cls_struct_1_1byte cls_struct_1_1byte_fn(struct cls_struct_1_1byte a1, result.a = a1.a + a2.a; printf("%d %d: %d\n", a1.a, a2.a, result.a); + CHECK(a1.a == 12); + CHECK(a2.a == 178); + CHECK(result.a == 190); return result; } @@ -84,6 +87,7 @@ int main (void) /* { dg-output "\n12 178: 190" } */ printf("res: %d\n", res_dbl.a); /* { dg-output "\nres: 190" } */ + CHECK(res_dbl.a == 190); exit(0); } diff --git a/testsuite/libffi.closures/cls_20byte.c b/testsuite/libffi.closures/cls_20byte.c index 34ea021..fdae6f7 100644 --- a/testsuite/libffi.closures/cls_20byte.c +++ b/testsuite/libffi.closures/cls_20byte.c @@ -25,6 +25,18 @@ static cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, printf("%g %g %d %g %g %d: %g %g %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + CHECK(a1.a == 1); + CHECK(a1.b == 2); + CHECK(a1.c == 3); + + CHECK(a2.a == 4); + CHECK(a2.b == 5); + CHECK(a2.c == 7); + + CHECK(result.a == 5); + CHECK(result.b == 7); + CHECK(result.c == 10); return result; } @@ -79,6 +91,9 @@ int main (void) /* { dg-output "1 2 3 4 5 7: 5 7 10" } */ printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 5 7 10" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 7); + CHECK(res_dbl.c == 10); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK); @@ -86,6 +101,9 @@ int main (void) /* { dg-output "\n1 2 3 4 5 7: 5 7 10" } */ printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 5 7 10" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 7); + CHECK(res_dbl.c == 10); exit(0); } diff --git a/testsuite/libffi.closures/cls_20byte1.c b/testsuite/libffi.closures/cls_20byte1.c index eab4be6..e6979b5 100644 --- a/testsuite/libffi.closures/cls_20byte1.c +++ b/testsuite/libffi.closures/cls_20byte1.c @@ -27,6 +27,19 @@ static cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1, printf("%d %g %g %d %g %g: %d %g %g\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + + CHECK(a1.a == 1); + CHECK(a1.b == 2); + CHECK(a1.c == 3); + + CHECK(a2.a == 4); + CHECK(a2.b == 5); + CHECK(a2.c == 7); + + CHECK(result.a == 5); + CHECK(result.b == 7); + CHECK(result.c == 10); + return result; } @@ -81,6 +94,9 @@ int main (void) /* { dg-output "1 2 3 4 5 7: 5 7 10" } */ printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 5 7 10" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 7); + CHECK(res_dbl.c == 10); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK); @@ -89,5 +105,9 @@ int main (void) printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 5 7 10" } */ + CHECK(res_dbl.a == 5); + CHECK(res_dbl.b == 7); + CHECK(res_dbl.c == 10); + exit(0); } diff --git a/testsuite/libffi.closures/cls_24byte.c b/testsuite/libffi.closures/cls_24byte.c index 78796da..b204966 100644 --- a/testsuite/libffi.closures/cls_24byte.c +++ b/testsuite/libffi.closures/cls_24byte.c @@ -33,6 +33,30 @@ cls_struct_24byte cls_struct_24byte_fn(struct cls_struct_24byte b0, b2.a, b2.b, b2.c, b2.d, b3.a, b3.b, b3.c, b3.d, result.a, result.b, result.c, result.d); + CHECK_DOUBLE_EQ(b0.a, 9); + CHECK_DOUBLE_EQ(b0.b, 2); + CHECK(b0.c == 6); + CHECK_FLOAT_EQ(b0.d, 5); + + CHECK_DOUBLE_EQ(b1.a, 1); + CHECK_DOUBLE_EQ(b1.b, 2); + CHECK(b1.c == 3); + CHECK_FLOAT_EQ(b1.d, 7); + + CHECK_DOUBLE_EQ(b2.a, 4); + CHECK_DOUBLE_EQ(b2.b, 5); + CHECK(b2.c == 7); + CHECK_FLOAT_EQ(b2.d, 9); + + CHECK_DOUBLE_EQ(b3.a, 8); + CHECK_DOUBLE_EQ(b3.b, 6); + CHECK(b3.c == 1); + CHECK_FLOAT_EQ(b3.d, 4); + + CHECK_DOUBLE_EQ(result.a, 22); + CHECK_DOUBLE_EQ(result.b, 15); + CHECK(result.c == 17); + CHECK_FLOAT_EQ(result.d, 25); return result; } @@ -97,6 +121,10 @@ int main (void) /* { dg-output "9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 4: 22 15 17 25" } */ printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 22 15 17 25" } */ + CHECK_DOUBLE_EQ(res_dbl.a, 22); + CHECK_DOUBLE_EQ(res_dbl.b, 15); + CHECK(res_dbl.c == 17); + CHECK_FLOAT_EQ(res_dbl.d, 25); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_24byte_gn, NULL, code) == FFI_OK); @@ -108,6 +136,10 @@ int main (void) /* { dg-output "\n9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 4: 22 15 17 25" } */ printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 22 15 17 25" } */ + CHECK_DOUBLE_EQ(res_dbl.a, 22); + CHECK_DOUBLE_EQ(res_dbl.b, 15); + CHECK(res_dbl.c == 17); + CHECK_FLOAT_EQ(res_dbl.d, 25); exit(0); } diff --git a/testsuite/libffi.closures/cls_2byte.c b/testsuite/libffi.closures/cls_2byte.c index 81bb0a6..c5209b7 100644 --- a/testsuite/libffi.closures/cls_2byte.c +++ b/testsuite/libffi.closures/cls_2byte.c @@ -24,6 +24,15 @@ cls_struct_2byte cls_struct_2byte_fn(struct cls_struct_2byte a1, printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + CHECK(a1.a == 12); + CHECK(a1.b == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 13); + + CHECK(result.a == 13); + CHECK(result.b == 140); + return result; } @@ -78,6 +87,8 @@ int main (void) /* { dg-output "12 127 1 13: 13 140" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 13 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_2byte_gn, NULL, code) == FFI_OK); @@ -85,6 +96,8 @@ int main (void) /* { dg-output "\n12 127 1 13: 13 140" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 13 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_3_1byte.c b/testsuite/libffi.closures/cls_3_1byte.c index b782746..aaa7ccc 100644 --- a/testsuite/libffi.closures/cls_3_1byte.c +++ b/testsuite/libffi.closures/cls_3_1byte.c @@ -28,6 +28,18 @@ cls_struct_3_1byte cls_struct_3_1byte_fn(struct cls_struct_3_1byte a1, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 13); + CHECK(a1.c == 14); + + CHECK(a2.a == 178); + CHECK(a2.b == 179); + CHECK(a2.c == 180); + + CHECK(result.a == 190); + CHECK(result.b == 192); + CHECK(result.c == 194); + return result; } @@ -83,6 +95,9 @@ int main (void) /* { dg-output "12 13 14 178 179 180: 190 192 194" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 190 192 194" } */ + CHECK(res_dbl.a == 190); + CHECK(res_dbl.b == 192); + CHECK(res_dbl.c == 194); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3_1byte_gn, NULL, code) == FFI_OK); @@ -91,5 +106,9 @@ int main (void) printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 190 192 194" } */ + CHECK(res_dbl.a == 190); + CHECK(res_dbl.b == 192); + CHECK(res_dbl.c == 194); + exit(0); } diff --git a/testsuite/libffi.closures/cls_3byte1.c b/testsuite/libffi.closures/cls_3byte1.c index a02c463..b424917 100644 --- a/testsuite/libffi.closures/cls_3byte1.c +++ b/testsuite/libffi.closures/cls_3byte1.c @@ -24,6 +24,15 @@ cls_struct_3byte cls_struct_3byte_fn(struct cls_struct_3byte a1, printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + CHECK(a1.a == 12); + CHECK(a1.b == 119); + + CHECK(a2.a == 1); + CHECK(a2.b == 15); + + CHECK(result.a == 13); + CHECK(result.b == 134); + return result; } @@ -78,6 +87,8 @@ int main (void) /* { dg-output "12 119 1 15: 13 134" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 13 134" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 134); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn, NULL, code) == FFI_OK); @@ -85,6 +96,8 @@ int main (void) /* { dg-output "\n12 119 1 15: 13 134" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 13 134" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 134); exit(0); } diff --git a/testsuite/libffi.closures/cls_3byte2.c b/testsuite/libffi.closures/cls_3byte2.c index c7251ce..f13590e 100644 --- a/testsuite/libffi.closures/cls_3byte2.c +++ b/testsuite/libffi.closures/cls_3byte2.c @@ -24,6 +24,15 @@ cls_struct_3byte_1 cls_struct_3byte_fn1(struct cls_struct_3byte_1 a1, printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + CHECK(a1.a == 15); + CHECK(a1.b == 125); + + CHECK(a2.a == 9); + CHECK(a2.b == 19); + + CHECK(result.a == 24); + CHECK(result.b == 144); + return result; } @@ -78,6 +87,8 @@ int main (void) /* { dg-output "15 125 9 19: 24 144" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 24 144" } */ + CHECK(res_dbl.a == 24); + CHECK(res_dbl.b == 144); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn1, NULL, code) == FFI_OK); @@ -85,6 +96,8 @@ int main (void) /* { dg-output "\n15 125 9 19: 24 144" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 24 144" } */ + CHECK(res_dbl.a == 24); + CHECK(res_dbl.b == 144); exit(0); } diff --git a/testsuite/libffi.closures/cls_3float.c b/testsuite/libffi.closures/cls_3float.c index 48888f8..63171bc 100644 --- a/testsuite/libffi.closures/cls_3float.c +++ b/testsuite/libffi.closures/cls_3float.c @@ -27,6 +27,18 @@ cls_struct_3float cls_struct_3float_fn(struct cls_struct_3float a1, printf("%g %g %g %g %g %g: %g %g %g\n", a1.f, a1.g, a1.h, a2.f, a2.g, a2.h, result.f, result.g, result.h); + CHECK_FLOAT_EQ(a1.f, 1); + CHECK_FLOAT_EQ(a1.g, 2); + CHECK_FLOAT_EQ(a1.h, 3); + + CHECK_FLOAT_EQ(a2.f, 1); + CHECK_FLOAT_EQ(a2.g, 2); + CHECK_FLOAT_EQ(a2.h, 3); + + CHECK_FLOAT_EQ(result.f, 2); + CHECK_FLOAT_EQ(result.g, 4); + CHECK_FLOAT_EQ(result.h, 6); + return result; } @@ -81,6 +93,9 @@ int main (void) /* { dg-output "1 2 3 1 2 3: 2 4 6" } */ printf("res: %g %g %g\n", res_dbl.f, res_dbl.g, res_dbl.h); /* { dg-output "\nres: 2 4 6" } */ + CHECK_FLOAT_EQ(res_dbl.f, 2); + CHECK_FLOAT_EQ(res_dbl.g, 4); + CHECK_FLOAT_EQ(res_dbl.h, 6); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3float_gn, NULL, code) == FFI_OK); @@ -90,6 +105,9 @@ int main (void) /* { dg-output "\n1 2 3 1 2 3: 2 4 6" } */ printf("res: %g %g %g\n", res_dbl.f, res_dbl.g, res_dbl.h); /* { dg-output "\nres: 2 4 6" } */ + CHECK_FLOAT_EQ(res_dbl.f, 2); + CHECK_FLOAT_EQ(res_dbl.g, 4); + CHECK_FLOAT_EQ(res_dbl.h, 6); exit(0); } diff --git a/testsuite/libffi.closures/cls_4_1byte.c b/testsuite/libffi.closures/cls_4_1byte.c index 2d6d8b6..b5d3f70 100644 --- a/testsuite/libffi.closures/cls_4_1byte.c +++ b/testsuite/libffi.closures/cls_4_1byte.c @@ -30,6 +30,20 @@ cls_struct_4_1byte cls_struct_4_1byte_fn(struct cls_struct_4_1byte a1, a2.a, a2.b, a2.c, a2.d, result.a, result.b, result.c, result.d); + CHECK(a1.a == 12); + CHECK(a1.b == 13); + CHECK(a1.c == 14); + CHECK(a1.d == 15); + + CHECK(a2.a == 178); + CHECK(a2.b == 179); + CHECK(a2.c == 180); + CHECK(a2.d == 181); + + CHECK(result.a == 190); + CHECK(result.b == 192); + CHECK(result.c == 194); + CHECK(result.d == 196); return result; } @@ -86,6 +100,10 @@ int main (void) /* { dg-output "12 13 14 15 178 179 180 181: 190 192 194 196" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 190 192 194 196" } */ + CHECK(res_dbl.a == 190); + CHECK(res_dbl.b == 192); + CHECK(res_dbl.c == 194); + CHECK(res_dbl.d == 196); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4_1byte_gn, NULL, code) == FFI_OK); @@ -93,6 +111,10 @@ int main (void) /* { dg-output "\n12 13 14 15 178 179 180 181: 190 192 194 196" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 190 192 194 196" } */ + CHECK(res_dbl.a == 190); + CHECK(res_dbl.b == 192); + CHECK(res_dbl.c == 194); + CHECK(res_dbl.d == 196); exit(0); } diff --git a/testsuite/libffi.closures/cls_4byte.c b/testsuite/libffi.closures/cls_4byte.c index 4ac3787..4f8d173 100644 --- a/testsuite/libffi.closures/cls_4byte.c +++ b/testsuite/libffi.closures/cls_4byte.c @@ -24,6 +24,15 @@ cls_struct_4byte cls_struct_4byte_fn(struct cls_struct_4byte a1, printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + + CHECK(result.a == 139); + CHECK(result.b == 248); + return result; } @@ -78,6 +87,8 @@ int main (void) /* { dg-output "127 120 12 128: 139 248" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 139 248" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4byte_gn, NULL, code) == FFI_OK); @@ -85,6 +96,8 @@ int main (void) /* { dg-output "\n127 120 12 128: 139 248" } */ printf("res: %d %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 139 248" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); exit(0); } diff --git a/testsuite/libffi.closures/cls_5_1_byte.c b/testsuite/libffi.closures/cls_5_1_byte.c index 8db761c..07552cd 100644 --- a/testsuite/libffi.closures/cls_5_1_byte.c +++ b/testsuite/libffi.closures/cls_5_1_byte.c @@ -32,6 +32,24 @@ static cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, a2.a, a2.b, a2.c, a2.d, a2.e, result.a, result.b, result.c, result.d, result.e); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + CHECK(a1.d == 3); + CHECK(a1.e == 4); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + CHECK(a2.d == 3); + CHECK(a2.e == 4); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + CHECK(result.d == 6); + CHECK(result.e == 8); + return result; } @@ -90,6 +108,11 @@ int main (void) printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e); /* { dg-output "\nres: 139 248 10 6 8" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 6); + CHECK(res_dbl.e == 8); res_dbl.a = 0; res_dbl.b = 0; @@ -104,6 +127,11 @@ int main (void) printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e); /* { dg-output "\nres: 139 248 10 6 8" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 6); + CHECK(res_dbl.e == 8); exit(0); } diff --git a/testsuite/libffi.closures/cls_5byte.c b/testsuite/libffi.closures/cls_5byte.c index fbb69ce..9f8936b 100644 --- a/testsuite/libffi.closures/cls_5byte.c +++ b/testsuite/libffi.closures/cls_5byte.c @@ -27,6 +27,18 @@ static cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + return result; } @@ -82,6 +94,9 @@ int main (void) /* { dg-output "127 120 1 12 128 9: 139 248 10" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 139 248 10" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); res_dbl.a = 0; res_dbl.b = 0; @@ -93,6 +108,9 @@ int main (void) /* { dg-output "\n127 120 1 12 128 9: 139 248 10" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 139 248 10" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); exit(0); } diff --git a/testsuite/libffi.closures/cls_64byte.c b/testsuite/libffi.closures/cls_64byte.c index a55edc2..5adedc9 100644 --- a/testsuite/libffi.closures/cls_64byte.c +++ b/testsuite/libffi.closures/cls_64byte.c @@ -38,6 +38,14 @@ cls_struct_64byte cls_struct_64byte_fn(struct cls_struct_64byte b0, printf("%g %g %g %g %g %g %g %g\n", result.a, result.b, result.c, result.d, result.e, result.f, result.g, result.h); + CHECK(result.a == 22); + CHECK(result.b == 15); + CHECK(result.c == 17); + CHECK(result.d == 25); + CHECK(result.e == 6); + CHECK(result.f == 13); + CHECK(result.g == 19); + CHECK(result.h == 18); return result; } @@ -107,6 +115,14 @@ int main (void) printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h); /* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */ + CHECK(res_dbl.a == 22); + CHECK(res_dbl.b == 15); + CHECK(res_dbl.c == 17); + CHECK(res_dbl.d == 25); + CHECK(res_dbl.e == 6); + CHECK(res_dbl.f == 13); + CHECK(res_dbl.g == 19); + CHECK(res_dbl.h == 18); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_64byte_gn, NULL, code) == FFI_OK); @@ -119,6 +135,14 @@ int main (void) printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h); /* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */ + CHECK(res_dbl.a == 22); + CHECK(res_dbl.b == 15); + CHECK(res_dbl.c == 17); + CHECK(res_dbl.d == 25); + CHECK(res_dbl.e == 6); + CHECK(res_dbl.f == 13); + CHECK(res_dbl.g == 19); + CHECK(res_dbl.h == 18); exit(0); } diff --git a/testsuite/libffi.closures/cls_6_1_byte.c b/testsuite/libffi.closures/cls_6_1_byte.c index 7970986..05e2945 100644 --- a/testsuite/libffi.closures/cls_6_1_byte.c +++ b/testsuite/libffi.closures/cls_6_1_byte.c @@ -34,6 +34,27 @@ static cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, result.a, result.b, result.c, result.d, result.e, result.f); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + CHECK(a1.d == 3); + CHECK(a1.e == 4); + CHECK(a1.f == 5); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + CHECK(a2.d == 3); + CHECK(a2.e == 4); + CHECK(a2.f == 5); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + CHECK(result.d == 6); + CHECK(result.e == 8); + CHECK(result.f == 10); + return result; } @@ -109,5 +130,11 @@ int main (void) res_dbl.d, res_dbl.e, res_dbl.f); /* { dg-output "\nres: 139 248 10 6 8 10" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 6); + CHECK(res_dbl.e == 8); + CHECK(res_dbl.f == 10); exit(0); } diff --git a/testsuite/libffi.closures/cls_6byte.c b/testsuite/libffi.closures/cls_6byte.c index e89c73c..a8e3ea0 100644 --- a/testsuite/libffi.closures/cls_6byte.c +++ b/testsuite/libffi.closures/cls_6byte.c @@ -30,6 +30,21 @@ static cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1, a2.a, a2.b, a2.c, a2.d, result.a, result.b, result.c, result.d); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + CHECK(a1.d == 128); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + CHECK(a2.d == 127); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + CHECK(result.d == 255); + return result; } @@ -86,6 +101,10 @@ int main (void) /* { dg-output "127 120 1 128 12 128 9 127: 139 248 10 255" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 139 248 10 255" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 255); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_6byte_gn, NULL, code) == FFI_OK); @@ -93,7 +112,10 @@ int main (void) /* { dg-output "\n127 120 1 128 12 128 9 127: 139 248 10 255" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 139 248 10 255" } */ - + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 255); exit(0); } diff --git a/testsuite/libffi.closures/cls_7_1_byte.c b/testsuite/libffi.closures/cls_7_1_byte.c index 94b1a44..3f17964 100644 --- a/testsuite/libffi.closures/cls_7_1_byte.c +++ b/testsuite/libffi.closures/cls_7_1_byte.c @@ -36,6 +36,30 @@ static cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, result.a, result.b, result.c, result.d, result.e, result.f, result.g); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + CHECK(a1.d == 3); + CHECK(a1.e == 4); + CHECK(a1.f == 5); + CHECK(a1.g == 6); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + CHECK(a2.d == 3); + CHECK(a2.e == 4); + CHECK(a2.f == 5); + CHECK(a2.g == 6); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + CHECK(result.d == 6); + CHECK(result.e == 8); + CHECK(result.f == 10); + CHECK(result.g == 12); + return result; } @@ -96,6 +120,13 @@ int main (void) printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 139 248 10 6 8 10 12" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 6); + CHECK(res_dbl.e == 8); + CHECK(res_dbl.f == 10); + CHECK(res_dbl.g == 12); res_dbl.a = 0; res_dbl.b = 0; @@ -112,6 +143,13 @@ int main (void) printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 139 248 10 6 8 10 12" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 6); + CHECK(res_dbl.e == 8); + CHECK(res_dbl.f == 10); + CHECK(res_dbl.g == 12); exit(0); } diff --git a/testsuite/libffi.closures/cls_7byte.c b/testsuite/libffi.closures/cls_7byte.c index 3aa8d6c..dcfc29b 100644 --- a/testsuite/libffi.closures/cls_7byte.c +++ b/testsuite/libffi.closures/cls_7byte.c @@ -29,6 +29,22 @@ static cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1, a2.a, a2.b, a2.c, a2.d, result.a, result.b, result.c, result.d); + CHECK(a1.a == 127); + CHECK(a1.b == 120); + CHECK(a1.c == 1); + CHECK(a1.d == 254); + + CHECK(a2.a == 12); + CHECK(a2.b == 128); + CHECK(a2.c == 9); + CHECK(a2.d == 255); + + CHECK(result.a == 139); + CHECK(result.b == 248); + CHECK(result.c == 10); + CHECK(result.d == 509); + + return result; } @@ -85,6 +101,10 @@ int main (void) /* { dg-output "127 120 1 254 12 128 9 255: 139 248 10 509" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 139 248 10 509" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 509); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_7byte_gn, NULL, code) == FFI_OK); @@ -92,6 +112,10 @@ int main (void) /* { dg-output "\n127 120 1 254 12 128 9 255: 139 248 10 509" } */ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d); /* { dg-output "\nres: 139 248 10 509" } */ + CHECK(res_dbl.a == 139); + CHECK(res_dbl.b == 248); + CHECK(res_dbl.c == 10); + CHECK(res_dbl.d == 509); exit(0); } diff --git a/testsuite/libffi.closures/cls_8byte.c b/testsuite/libffi.closures/cls_8byte.c index f6c1ea5..7a519e9 100644 --- a/testsuite/libffi.closures/cls_8byte.c +++ b/testsuite/libffi.closures/cls_8byte.c @@ -23,6 +23,15 @@ cls_struct_8byte cls_struct_8byte_fn(struct cls_struct_8byte a1, printf("%d %g %d %g: %d %g\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b); + CHECK(a1.a == 1); + CHECK_FLOAT_EQ(a1.b, 2); + + CHECK(a2.a == 4); + CHECK_FLOAT_EQ(a2.b, 5); + + CHECK(result.a == 5); + CHECK_FLOAT_EQ(result.b, 7); + return result; } @@ -76,6 +85,9 @@ int main (void) ffi_call(&cif, FFI_FN(cls_struct_8byte_fn), &res_dbl, args_dbl); /* { dg-output "1 2 4 5: 5 7" } */ printf("res: %d %g\n", res_dbl.a, res_dbl.b); + CHECK(res_dbl.a == 5); + CHECK_FLOAT_EQ(res_dbl.b, 7); + /* { dg-output "\nres: 5 7" } */ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_8byte_gn, NULL, code) == FFI_OK); @@ -83,6 +95,8 @@ int main (void) /* { dg-output "\n1 2 4 5: 5 7" } */ printf("res: %d %g\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 5 7" } */ + CHECK(res_dbl.a == 5); + CHECK_FLOAT_EQ(res_dbl.b, 7); exit(0); } diff --git a/testsuite/libffi.closures/cls_9byte1.c b/testsuite/libffi.closures/cls_9byte1.c index 6eb4520..9d3b609 100644 --- a/testsuite/libffi.closures/cls_9byte1.c +++ b/testsuite/libffi.closures/cls_9byte1.c @@ -26,6 +26,15 @@ static cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, printf("%d %g %d %g: %d %g\n", b1.a, b1.b, b2.a, b2.b, result.a, result.b); + CHECK(b1.a == 7); + CHECK(b1.b == 8); + + CHECK(b2.a == 1); + CHECK(b2.b == 9); + + CHECK(result.a == 8); + CHECK(result.b == 17); + return result; } @@ -78,6 +87,8 @@ int main (void) /* { dg-output "7 8 1 9: 8 17" } */ printf("res: %d %g\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 8 17" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK); @@ -85,6 +96,8 @@ int main (void) /* { dg-output "\n7 8 1 9: 8 17" } */ printf("res: %d %g\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 8 17" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); exit(0); } diff --git a/testsuite/libffi.closures/cls_9byte2.c b/testsuite/libffi.closures/cls_9byte2.c index 26e460b..6cfaaf3 100644 --- a/testsuite/libffi.closures/cls_9byte2.c +++ b/testsuite/libffi.closures/cls_9byte2.c @@ -26,6 +26,15 @@ static cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1, printf("%g %d %g %d: %g %d\n", b1.a, b1.b, b2.a, b2.b, result.a, result.b); + CHECK(b1.a == 7); + CHECK(b1.b == 8); + + CHECK(b2.a == 1); + CHECK(b2.b == 9); + + CHECK(result.a == 8); + CHECK(result.b == 17); + return result; } @@ -78,7 +87,8 @@ int main (void) /* { dg-output "7 8 1 9: 8 17" } */ printf("res: %g %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 8 17" } */ - + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK); @@ -86,6 +96,8 @@ int main (void) /* { dg-output "\n7 8 1 9: 8 17" } */ printf("res: %g %d\n", res_dbl.a, res_dbl.b); /* { dg-output "\nres: 8 17" } */ + CHECK(res_dbl.a == 8); + CHECK(res_dbl.b == 17); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_double.c b/testsuite/libffi.closures/cls_align_double.c index 910e228..036cca3 100644 --- a/testsuite/libffi.closures/cls_align_double.c +++ b/testsuite/libffi.closures/cls_align_double.c @@ -26,6 +26,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); + return result; } @@ -81,6 +93,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -88,6 +103,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_float.c b/testsuite/libffi.closures/cls_align_float.c index 56161ef..c7dbdfd 100644 --- a/testsuite/libffi.closures/cls_align_float.c +++ b/testsuite/libffi.closures/cls_align_float.c @@ -24,6 +24,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, (double)a1.b, a1.c, a2.a, (double)a2.b, a2.c, result.a, (double)result.b, result.c); + CHECK(a1.a == 12); + CHECK_FLOAT_EQ(a1.b, 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK_FLOAT_EQ(a2.b, 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK_FLOAT_EQ(result.b, 14271); + CHECK(result.c == 140); + return result; } @@ -79,6 +91,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK_FLOAT_EQ(res_dbl.b, 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -86,6 +101,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK_FLOAT_EQ(res_dbl.b, 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_longdouble.c b/testsuite/libffi.closures/cls_align_longdouble.c index 3dccdef..1cdb10b 100644 --- a/testsuite/libffi.closures/cls_align_longdouble.c +++ b/testsuite/libffi.closures/cls_align_longdouble.c @@ -25,6 +25,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, (double)a1.b, a1.c, a2.a, (double)a2.b, a2.c, result.a, (double)result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); + return result; } @@ -80,6 +92,10 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); + CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -87,6 +103,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_longdouble_split.c b/testsuite/libffi.closures/cls_align_longdouble_split.c index 9b01cbd..fe874c2 100644 --- a/testsuite/libffi.closures/cls_align_longdouble_split.c +++ b/testsuite/libffi.closures/cls_align_longdouble_split.c @@ -39,32 +39,34 @@ static cls_struct_align cls_struct_align_fn( a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, r.a, r.b, r.c, r.d, r.e, r.f, r.g); - return r; -} - -cls_struct_align cls_struct_align_fn2( - cls_struct_align a1) -{ - struct cls_struct_align r; - - r.a = a1.a + 1; - r.b = a1.b + 1; - r.c = a1.c + 1; - r.d = a1.d + 1; - r.e = a1.e + 1; - r.f = a1.f + 1; - r.g = a1.g + 1; - - printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg: " - "%Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", - a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g, - r.a, r.b, r.c, r.d, r.e, r.f, r.g); - + CHECK(a1.a == 1); + CHECK(a1.b == 2); + CHECK(a1.c == 3); + CHECK(a1.d == 4); + CHECK(a1.e == 5); + CHECK(a1.f == 6); + CHECK(a1.g == 7); + + CHECK(a2.a == 8); + CHECK(a2.b == 9); + CHECK(a2.c == 10); + CHECK(a2.d == 11); + CHECK(a2.e == 12); + CHECK(a2.f == 13); + CHECK(a2.g == 14); + + CHECK(r.a == 9); + CHECK(r.b == 11); + CHECK(r.c == 13); + CHECK(r.d == 15); + CHECK(r.e == 17); + CHECK(r.f == 19); + CHECK(r.g == 21); return r; } static void -cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, +cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) { struct cls_struct_align a1, a2; @@ -119,6 +121,13 @@ int main (void) printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ + CHECK(res_dbl.a == 9); + CHECK(res_dbl.b == 11); + CHECK(res_dbl.c == 13); + CHECK(res_dbl.d == 15); + CHECK(res_dbl.e == 17); + CHECK(res_dbl.f == 19); + CHECK(res_dbl.g == 21); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -127,6 +136,12 @@ int main (void) printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ - + CHECK(res_dbl.a == 9); + CHECK(res_dbl.b == 11); + CHECK(res_dbl.c == 13); + CHECK(res_dbl.d == 15); + CHECK(res_dbl.e == 17); + CHECK(res_dbl.f == 19); + CHECK(res_dbl.g == 21); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_longdouble_split2.c b/testsuite/libffi.closures/cls_align_longdouble_split2.c index 8a973e7..88d239d 100644 --- a/testsuite/libffi.closures/cls_align_longdouble_split2.c +++ b/testsuite/libffi.closures/cls_align_longdouble_split2.c @@ -40,6 +40,30 @@ static cls_struct_align cls_struct_align_fn( a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g, r.a, r.b, r.c, r.d, r.e, r.f, r.g); + CHECK(a1.a == 1); + CHECK(a1.b == 2); + CHECK(a1.c == 3); + CHECK(a1.d == 4); + CHECK(a1.e == 5); + CHECK(a1.f == 6); + CHECK(a1.g == 7); + + CHECK(a2.a == 8); + CHECK(a2.b == 9); + CHECK(a2.c == 10); + CHECK(a2.d == 11); + CHECK(a2.e == 12); + CHECK(a2.f == 13); + CHECK(a2.g == 14); + + CHECK(r.a == 9); + CHECK(r.b == 11); + CHECK(r.c == 13); + CHECK(r.d == 15); + CHECK(r.e == 17); + CHECK(r.f == 19); + CHECK(r.g == 21); + return r; } @@ -99,6 +123,13 @@ int main (void) printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ + CHECK(res_dbl.a == 9); + CHECK(res_dbl.b == 11); + CHECK(res_dbl.c == 13); + CHECK(res_dbl.d == 15); + CHECK(res_dbl.e == 17); + CHECK(res_dbl.f == 19); + CHECK(res_dbl.g == 21); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -107,7 +138,13 @@ int main (void) printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g); /* { dg-output "\nres: 9 11 13 15 17 19 21" } */ - + CHECK(res_dbl.a == 9); + CHECK(res_dbl.b == 11); + CHECK(res_dbl.c == 13); + CHECK(res_dbl.d == 15); + CHECK(res_dbl.e == 17); + CHECK(res_dbl.f == 19); + CHECK(res_dbl.g == 21); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_pointer.c b/testsuite/libffi.closures/cls_align_pointer.c index ef59259..5fb3f09 100644 --- a/testsuite/libffi.closures/cls_align_pointer.c +++ b/testsuite/libffi.closures/cls_align_pointer.c @@ -28,6 +28,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, result.a, (uintptr_t)result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == (void *)4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == (void *)9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == (void *)14271); + CHECK(result.c == 140); + return result; } @@ -83,6 +95,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == (void *)14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -90,6 +105,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == (void *)14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_sint16.c b/testsuite/libffi.closures/cls_align_sint16.c index 7997709..d2c9bf4 100644 --- a/testsuite/libffi.closures/cls_align_sint16.c +++ b/testsuite/libffi.closures/cls_align_sint16.c @@ -23,6 +23,17 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, result.c = a1.c + a2.c; printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); return result; } @@ -79,6 +90,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -86,6 +100,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_sint32.c b/testsuite/libffi.closures/cls_align_sint32.c index 5edde72..570f45f 100644 --- a/testsuite/libffi.closures/cls_align_sint32.c +++ b/testsuite/libffi.closures/cls_align_sint32.c @@ -23,6 +23,17 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, result.c = a1.c + a2.c; printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); return result; } @@ -79,13 +90,17 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ - + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl); /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ - + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_sint64.c b/testsuite/libffi.closures/cls_align_sint64.c index bcba22f..49ee561 100644 --- a/testsuite/libffi.closures/cls_align_sint64.c +++ b/testsuite/libffi.closures/cls_align_sint64.c @@ -24,6 +24,17 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, result.c = a1.c + a2.c; printf("%d %" PRIdLL " %d %d %" PRIdLL " %d: %d %" PRIdLL " %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); return result; } @@ -80,6 +91,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -87,6 +101,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_uint16.c b/testsuite/libffi.closures/cls_align_uint16.c index f33c0ec..2204dff 100644 --- a/testsuite/libffi.closures/cls_align_uint16.c +++ b/testsuite/libffi.closures/cls_align_uint16.c @@ -23,6 +23,17 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, result.c = a1.c + a2.c; printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); return result; } @@ -79,6 +90,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -86,6 +100,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_uint32.c b/testsuite/libffi.closures/cls_align_uint32.c index c96eee6..1ce23da 100644 --- a/testsuite/libffi.closures/cls_align_uint32.c +++ b/testsuite/libffi.closures/cls_align_uint32.c @@ -24,6 +24,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); + return result; } @@ -79,6 +91,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -86,6 +101,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_align_uint64.c b/testsuite/libffi.closures/cls_align_uint64.c index 958e1c2..aee958a 100644 --- a/testsuite/libffi.closures/cls_align_uint64.c +++ b/testsuite/libffi.closures/cls_align_uint64.c @@ -26,6 +26,18 @@ static cls_struct_align cls_struct_align_fn(struct cls_struct_align a1, printf("%d %" PRIdLL " %d %d %" PRIdLL " %d: %d %" PRIdLL " %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c); + CHECK(a1.a == 12); + CHECK(a1.b == 4951); + CHECK(a1.c == 127); + + CHECK(a2.a == 1); + CHECK(a2.b == 9320); + CHECK(a2.c == 13); + + CHECK(result.a == 13); + CHECK(result.b == 14271); + CHECK(result.c == 140); + return result; } @@ -81,6 +93,9 @@ int main (void) /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK); @@ -88,6 +103,9 @@ int main (void) /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c); /* { dg-output "\nres: 13 14271 140" } */ + CHECK(res_dbl.a == 13); + CHECK(res_dbl.b == 14271); + CHECK(res_dbl.c == 140); exit(0); } diff --git a/testsuite/libffi.closures/cls_dbls_struct.c b/testsuite/libffi.closures/cls_dbls_struct.c index 25b8b63..00e247e 100644 --- a/testsuite/libffi.closures/cls_dbls_struct.c +++ b/testsuite/libffi.closures/cls_dbls_struct.c @@ -17,6 +17,8 @@ void closure_test_fn(Dbls p) { printf("%.1f %.1f\n", p.x, p.y); + CHECK(p.x == 1); + CHECK(p.y == 2); } void diff --git a/testsuite/libffi.closures/cls_double_va.c b/testsuite/libffi.closures/cls_double_va.c index e077f92..6fc8dfb 100644 --- a/testsuite/libffi.closures/cls_double_va.c +++ b/testsuite/libffi.closures/cls_double_va.c @@ -10,6 +10,9 @@ #include "ffitest.h" +#define BUF_SIZE 50 +static char buffer[BUF_SIZE]; + static void cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) @@ -18,6 +21,9 @@ cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, double doubleValue = *(double*)args[1]; *(ffi_arg*)resp = printf(format, doubleValue); + CHECK(*(ffi_arg*)resp == 4); + snprintf(buffer, BUF_SIZE, format, doubleValue); + CHECK(strncmp(buffer, "7.0\n", BUF_SIZE)); } int main (void) @@ -48,6 +54,7 @@ int main (void) /* { dg-output "7.0" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 4" } */ + CHECK(res == 4); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL, code) == FFI_OK); @@ -56,6 +63,7 @@ int main (void) /* { dg-output "\n7.0" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 4" } */ + CHECK(res == 4); exit(0); } diff --git a/testsuite/libffi.closures/cls_float.c b/testsuite/libffi.closures/cls_float.c index 0090fed..97c2ac0 100644 --- a/testsuite/libffi.closures/cls_float.c +++ b/testsuite/libffi.closures/cls_float.c @@ -14,6 +14,9 @@ static void cls_ret_float_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, printf("%g: %g\n",*(float *)args[0], *(float *)resp); + + CHECK((int)(*(float *)args[0]) == -2122); + CHECK((int)(*(float *)resp) == -2122); } typedef float (*cls_ret_float)(float); @@ -38,5 +41,6 @@ int main (void) /* { dg-output "\\-2122.12: \\-2122.12" } */ printf("res: %.6f\n", res); /* { dg-output "\nres: \-2122.120117" } */ + CHECK((int)res == -2122); exit(0); } diff --git a/testsuite/libffi.closures/cls_longdouble.c b/testsuite/libffi.closures/cls_longdouble.c index d24e72e..2023172 100644 --- a/testsuite/libffi.closures/cls_longdouble.c +++ b/testsuite/libffi.closures/cls_longdouble.c @@ -25,6 +25,14 @@ long double cls_ldouble_fn( printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg: %Lg\n", a1, a2, a3, a4, a5, a6, a7, a8, r); + CHECK(a1 == 1); + CHECK(a2 == 2); + CHECK(a3 == 3); + CHECK(a4 == 4); + CHECK(a5 == 5); + CHECK(a6 == 6); + CHECK(a7 == 7); + CHECK(a8 == 8); return r; } @@ -91,6 +99,7 @@ int main(void) /* { dg-output "1 2 3 4 5 6 7 8: 36" } */ printf("res: %Lg\n", res); /* { dg-output "\nres: 36" } */ + CHECK(res == 36); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ldouble_gn, NULL, code) == FFI_OK); @@ -100,6 +109,7 @@ int main(void) /* { dg-output "\n1 2 3 4 5 6 7 8: 36" } */ printf("res: %Lg\n", res); /* { dg-output "\nres: 36" } */ + CHECK(res == 36); return 0; } diff --git a/testsuite/libffi.closures/cls_longdouble_va.c b/testsuite/libffi.closures/cls_longdouble_va.c index 39b438b..79b42b0 100644 --- a/testsuite/libffi.closures/cls_longdouble_va.c +++ b/testsuite/libffi.closures/cls_longdouble_va.c @@ -10,6 +10,9 @@ #include "ffitest.h" +#define BUF_SIZE 50 +static char buffer[BUF_SIZE]; + static void cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__) @@ -18,6 +21,9 @@ cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp, long double ldValue = *(long double*)args[1]; *(ffi_arg*)resp = printf(format, ldValue); + CHECK(*(ffi_arg*)resp == 4); + snprintf(buffer, BUF_SIZE, format, ldValue); + CHECK(strncmp(buffer, "7.0\n", BUF_SIZE) == 0); } int main (void) @@ -48,6 +54,7 @@ int main (void) /* { dg-output "7.0" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 4" } */ + CHECK(res == 4); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL, code) == FFI_OK); @@ -56,6 +63,7 @@ int main (void) /* { dg-output "\n7.0" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 4" } */ + CHECK(res == 4); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_schar.c b/testsuite/libffi.closures/cls_multi_schar.c index 417f7be..921777a 100644 --- a/testsuite/libffi.closures/cls_multi_schar.c +++ b/testsuite/libffi.closures/cls_multi_schar.c @@ -26,6 +26,8 @@ static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, a1 = *(signed char *)avals[0]; a2 = *(signed char *)avals[1]; + CHECK(a1 == 2); + CHECK(a2 == 125); *(ffi_arg *)rval = test_func_fn(a1, a2); @@ -62,6 +64,7 @@ int main (void) /* { dg-output "2 125: 127" } */ printf("res: %d\n", (signed char)res_call); /* { dg-output "\nres: 127" } */ + CHECK(res_call == 127); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); @@ -69,6 +72,7 @@ int main (void) /* { dg-output "\n2 125: 127" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 127" } */ + CHECK(res_closure == 127); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_sshort.c b/testsuite/libffi.closures/cls_multi_sshort.c index 467146d..d78c62d 100644 --- a/testsuite/libffi.closures/cls_multi_sshort.c +++ b/testsuite/libffi.closures/cls_multi_sshort.c @@ -14,6 +14,9 @@ static signed short test_func_fn(signed short a1, signed short a2) result = a1 + a2; printf("%d %d: %d\n", a1, a2, result); + CHECK(a1 == 2); + CHECK(a2 == 32765); + CHECK(result == 32767); return result; @@ -62,6 +65,7 @@ int main (void) /* { dg-output "2 32765: 32767" } */ printf("res: %d\n", (unsigned short)res_call); /* { dg-output "\nres: 32767" } */ + CHECK(res_call == 32767); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); @@ -69,6 +73,7 @@ int main (void) /* { dg-output "\n2 32765: 32767" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 32767" } */ + CHECK(res_closure == 32767); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_sshortchar.c b/testsuite/libffi.closures/cls_multi_sshortchar.c index de45b59..a2b3708 100644 --- a/testsuite/libffi.closures/cls_multi_sshortchar.c +++ b/testsuite/libffi.closures/cls_multi_sshortchar.c @@ -16,6 +16,12 @@ static signed short test_func_fn(signed char a1, signed short a2, printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); + CHECK(a1 == 1); + CHECK(a2 == 32765); + CHECK(a3 == 127); + CHECK(a4 == -128); + CHECK(result == 32765); + return result; } @@ -74,6 +80,7 @@ int main (void) /* { dg-output "1 32765 127 -128: 32765" } */ printf("res: %d\n", (signed short)res_call); /* { dg-output "\nres: 32765" } */ + CHECK(res_call == 32765); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); @@ -81,6 +88,7 @@ int main (void) /* { dg-output "\n1 32765 127 -128: 32765" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 32765" } */ + CHECK(res_closure == 32765); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_uchar.c b/testsuite/libffi.closures/cls_multi_uchar.c index eb93e95..5d6ae7c 100644 --- a/testsuite/libffi.closures/cls_multi_uchar.c +++ b/testsuite/libffi.closures/cls_multi_uchar.c @@ -16,6 +16,12 @@ static unsigned char test_func_fn(unsigned char a1, unsigned char a2, printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); + CHECK(a1 == 1); + CHECK(a2 == 2); + CHECK(a3 == 127); + CHECK(a4 == 125); + CHECK(result == 255); + return result; } @@ -79,6 +85,7 @@ int main (void) /* { dg-output "1 2 127 125: 255" } */ printf("res: %d\n", (unsigned char)res_call); /* { dg-output "\nres: 255" } */ + CHECK(res_call == 255); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); @@ -86,6 +93,7 @@ int main (void) /* { dg-output "\n1 2 127 125: 255" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 255" } */ + CHECK(res_closure == 255); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_ushort.c b/testsuite/libffi.closures/cls_multi_ushort.c index 0e5838d..f61a627 100644 --- a/testsuite/libffi.closures/cls_multi_ushort.c +++ b/testsuite/libffi.closures/cls_multi_ushort.c @@ -15,8 +15,11 @@ static unsigned short test_func_fn(unsigned short a1, unsigned short a2) printf("%d %d: %d\n", a1, a2, result); - return result; + CHECK(a1 == 2); + CHECK(a2 == 32765); + CHECK(result == 32767); + return result; } static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals, @@ -69,6 +72,7 @@ int main (void) /* { dg-output "\n2 32765: 32767" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 32767" } */ + CHECK(res_closure == 32767); exit(0); } diff --git a/testsuite/libffi.closures/cls_multi_ushortchar.c b/testsuite/libffi.closures/cls_multi_ushortchar.c index 69aedfe..3315c99 100644 --- a/testsuite/libffi.closures/cls_multi_ushortchar.c +++ b/testsuite/libffi.closures/cls_multi_ushortchar.c @@ -16,6 +16,12 @@ static unsigned short test_func_fn(unsigned char a1, unsigned short a2, printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result); + CHECK(a1 == 1); + CHECK(a2 == 2); + CHECK(a3 == 127); + CHECK(a4 == 128); + CHECK(result == 258); + return result; } @@ -74,6 +80,7 @@ int main (void) /* { dg-output "1 2 127 128: 258" } */ printf("res: %d\n", (unsigned short)res_call); /* { dg-output "\nres: 258" } */ + CHECK(res_call == 258); CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK); @@ -81,6 +88,7 @@ int main (void) /* { dg-output "\n1 2 127 128: 258" } */ printf("res: %d\n", res_closure); /* { dg-output "\nres: 258" } */ + CHECK(res_closure == 258); exit(0); } diff --git a/testsuite/libffi.closures/cls_pointer.c b/testsuite/libffi.closures/cls_pointer.c index d82a87a..73a4cba 100644 --- a/testsuite/libffi.closures/cls_pointer.c +++ b/testsuite/libffi.closures/cls_pointer.c @@ -16,6 +16,10 @@ void* cls_pointer_fn(void* a1, void* a2) (unsigned int)(uintptr_t) a2, (unsigned int)(uintptr_t) result); + CHECK((unsigned int)(uintptr_t) a1 == 0x12345678); + CHECK((unsigned int)(uintptr_t) a2 == 0x89abcdef); + CHECK((unsigned int)(uintptr_t) result == 0x9be02467); + return result; } @@ -69,6 +73,7 @@ int main (void) /* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */ printf("res: 0x%08x\n", (unsigned int) res); /* { dg-output "\nres: 0x9be02467" } */ + CHECK(res == 0x9be02467); exit(0); } diff --git a/testsuite/libffi.closures/cls_pointer_stack.c b/testsuite/libffi.closures/cls_pointer_stack.c index 1f1d915..2054f25 100644 --- a/testsuite/libffi.closures/cls_pointer_stack.c +++ b/testsuite/libffi.closures/cls_pointer_stack.c @@ -40,6 +40,10 @@ void* cls_pointer_fn2(void* a1, void* a2) (unsigned int)(uintptr_t) a2, (unsigned int)(uintptr_t) result); + CHECK((unsigned int)(uintptr_t) a1 == 0x8acf1356); + CHECK((unsigned int)(uintptr_t) a2 == 0x01234567); + CHECK((unsigned int)(uintptr_t) result == 0x8bf258bd); + return result; } @@ -65,6 +69,10 @@ void* cls_pointer_fn1(void* a1, void* a2) (unsigned int)(intptr_t) a2, (unsigned int)(intptr_t) result); + CHECK((unsigned int)(uintptr_t) a1 == 0x01234567); + CHECK((unsigned int)(uintptr_t) a2 == 0x89abcdef); + CHECK((unsigned int)(uintptr_t) result == 0x8acf1356); + result = cls_pointer_fn2(result, a1); return result; @@ -128,6 +136,7 @@ int main (void) /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */ /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */ /* { dg-output "\nres: 0x8bf258bd" } */ + CHECK(res == 0x8bf258bd); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK); @@ -137,6 +146,7 @@ int main (void) /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */ /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */ /* { dg-output "\nres: 0x8bf258bd" } */ + CHECK(res == 0x8bf258bd); exit(0); } diff --git a/testsuite/libffi.closures/cls_schar.c b/testsuite/libffi.closures/cls_schar.c index 82986b1..22446c3 100644 --- a/testsuite/libffi.closures/cls_schar.c +++ b/testsuite/libffi.closures/cls_schar.c @@ -15,6 +15,8 @@ static void cls_ret_schar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(ffi_arg*)resp = *(signed char *)args[0]; printf("%d: %d\n",*(signed char *)args[0], (int)*(ffi_arg *)(resp)); + CHECK(*(signed char *)args[0] == 127); + CHECK((int)*(ffi_arg *)(resp) == 127); } typedef signed char (*cls_ret_schar)(signed char); @@ -39,6 +41,7 @@ int main (void) /* { dg-output "127: 127" } */ printf("res: %d\n", res); /* { dg-output "\nres: 127" } */ + CHECK(res == 127); exit(0); } diff --git a/testsuite/libffi.closures/cls_sint.c b/testsuite/libffi.closures/cls_sint.c index c7e13b7..a3f72c1 100644 --- a/testsuite/libffi.closures/cls_sint.c +++ b/testsuite/libffi.closures/cls_sint.c @@ -13,6 +13,8 @@ static void cls_ret_sint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(ffi_arg*)resp = *(signed int *)args[0]; printf("%d: %d\n",*(signed int *)args[0], (int)*(ffi_arg *)(resp)); + CHECK(*(signed int *)args[0] == 65534); + CHECK((int)*(ffi_arg *)(resp) == 65534); } typedef signed int (*cls_ret_sint)(signed int); diff --git a/testsuite/libffi.closures/cls_sshort.c b/testsuite/libffi.closures/cls_sshort.c index 846d57e..8061a02 100644 --- a/testsuite/libffi.closures/cls_sshort.c +++ b/testsuite/libffi.closures/cls_sshort.c @@ -13,6 +13,8 @@ static void cls_ret_sshort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(ffi_arg*)resp = *(signed short *)args[0]; printf("%d: %d\n",*(signed short *)args[0], (int)*(ffi_arg *)(resp)); + CHECK(*(signed short *)args[0] == 255); + CHECK((int)*(ffi_arg *)(resp) == 255); } typedef signed short (*cls_ret_sshort)(signed short); @@ -37,6 +39,7 @@ int main (void) /* { dg-output "255: 255" } */ printf("res: %d\n",res); /* { dg-output "\nres: 255" } */ + CHECK(res == 255); exit(0); } diff --git a/testsuite/libffi.closures/cls_struct_va1.c b/testsuite/libffi.closures/cls_struct_va1.c index 6d1fdae..c59a27f 100644 --- a/testsuite/libffi.closures/cls_struct_va1.c +++ b/testsuite/libffi.closures/cls_struct_va1.c @@ -35,6 +35,16 @@ test_fn (ffi_cif* cif __UNUSED__, void* resp, printf ("%d %d %d %d %d %d %d %d %d %d\n", n, s1.a, s1.b, l1.a, l1.b, l1.c, l1.d, l1.e, s2.a, s2.b); + CHECK(n == 4); + CHECK(s1.a == 5); + CHECK(s1.b == 6); + CHECK(l1.a == 10); + CHECK(l1.b == 11); + CHECK(l1.c == 12); + CHECK(l1.d == 13); + CHECK(l1.e == 14); + CHECK(s2.a == 20); + CHECK(s2.b == 21); * (ffi_arg*) resp = 42; } @@ -109,6 +119,7 @@ main (void) /* { dg-output "4 5 6 10 11 12 13 14 20 21" } */ printf("res: %d\n", (int) res); /* { dg-output "\nres: 42" } */ + CHECK(res == 42); exit(0); } diff --git a/testsuite/libffi.closures/cls_uchar.c b/testsuite/libffi.closures/cls_uchar.c index c1317e7..aa2023f 100644 --- a/testsuite/libffi.closures/cls_uchar.c +++ b/testsuite/libffi.closures/cls_uchar.c @@ -13,6 +13,8 @@ static void cls_ret_uchar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(ffi_arg*)resp = *(unsigned char *)args[0]; printf("%d: %d\n",*(unsigned char *)args[0], (int)*(ffi_arg *)(resp)); + CHECK(*(unsigned char *)args[0] == 127); + CHECK((int)*(ffi_arg *)(resp) == 127); } typedef unsigned char (*cls_ret_uchar)(unsigned char); @@ -37,6 +39,7 @@ int main (void) /* { dg-output "127: 127" } */ printf("res: %d\n",res); /* { dg-output "\nres: 127" } */ + CHECK(res == 127); exit(0); } diff --git a/testsuite/libffi.closures/cls_uint.c b/testsuite/libffi.closures/cls_uint.c index 885cff5..23b88de 100644 --- a/testsuite/libffi.closures/cls_uint.c +++ b/testsuite/libffi.closures/cls_uint.c @@ -14,6 +14,9 @@ static void cls_ret_uint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, printf("%d: %d\n",*(unsigned int *)args[0], (int)*(ffi_arg *)(resp)); + + CHECK(*(unsigned int *)args[0] == 2147483647); + CHECK((int)*(ffi_arg *)(resp) == 2147483647); } typedef unsigned int (*cls_ret_uint)(unsigned int); @@ -38,6 +41,7 @@ int main (void) /* { dg-output "2147483647: 2147483647" } */ printf("res: %d\n",res); /* { dg-output "\nres: 2147483647" } */ + CHECK(res == 2147483647); exit(0); } diff --git a/testsuite/libffi.closures/cls_uint_va.c b/testsuite/libffi.closures/cls_uint_va.c index b04cfd1..0048a02 100644 --- a/testsuite/libffi.closures/cls_uint_va.c +++ b/testsuite/libffi.closures/cls_uint_va.c @@ -16,6 +16,9 @@ static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(ffi_arg *)resp = *(T *)args[0]; printf("%d: %d %d\n", (int)*(ffi_arg *)resp, *(T *)args[0], *(T *)args[1]); + CHECK(*(T *)args[0] == 67); + CHECK(*(T *)args[1] == 4); + CHECK((int)*(ffi_arg *)resp == 67); } typedef T (*cls_ret_T)(T, ...); @@ -41,5 +44,6 @@ int main (void) /* { dg-output "67: 67 4" } */ printf("res: %d\n", res); /* { dg-output "\nres: 67" } */ + CHECK(res == 67); exit(0); } diff --git a/testsuite/libffi.closures/cls_ulong_va.c b/testsuite/libffi.closures/cls_ulong_va.c index 0315082..79f4170 100644 --- a/testsuite/libffi.closures/cls_ulong_va.c +++ b/testsuite/libffi.closures/cls_ulong_va.c @@ -16,6 +16,9 @@ static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, *(T *)resp = *(T *)args[0]; printf("%ld: %ld %ld\n", *(T *)resp, *(T *)args[0], *(T *)args[1]); + CHECK(*(T *)args[0] == 67); + CHECK(*(T *)args[1] == 4); + CHECK(*(T *)resp == 67); } typedef T (*cls_ret_T)(T, ...); @@ -41,5 +44,6 @@ int main (void) /* { dg-output "67: 67 4" } */ printf("res: %ld\n", res); /* { dg-output "\nres: 67" } */ + CHECK(res == 67); exit(0); } diff --git a/testsuite/libffi.closures/cls_ulonglong.c b/testsuite/libffi.closures/cls_ulonglong.c index 62f2cae..813bb2e 100644 --- a/testsuite/libffi.closures/cls_ulonglong.c +++ b/testsuite/libffi.closures/cls_ulonglong.c @@ -37,11 +37,13 @@ int main (void) /* { dg-output "214: 1152921504606846761" } */ printf("res: %" PRIdLL "\n", res); /* { dg-output "\nres: 1152921504606846761" } */ + CHECK(res == 1152921504606846761LL); res = (*((cls_ret_ulonglong)code))(9223372035854775808LL); /* { dg-output "\n9223372035854775808: 8070450533247928831" } */ printf("res: %" PRIdLL "\n", res); /* { dg-output "\nres: 8070450533247928831" } */ + CHECK(res == 8070450533247928831LL); exit(0); } diff --git a/testsuite/libffi.closures/cls_ushort.c b/testsuite/libffi.closures/cls_ushort.c index a00100e..bfe5e65 100644 --- a/testsuite/libffi.closures/cls_ushort.c +++ b/testsuite/libffi.closures/cls_ushort.c @@ -14,6 +14,8 @@ static void cls_ret_ushort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, printf("%d: %d\n",*(unsigned short *)args[0], (int)*(ffi_arg *)(resp)); + CHECK(*(unsigned short *)args[0] == 65535); + CHECK((int)*(ffi_arg *)(resp) == 65535); } typedef unsigned short (*cls_ret_ushort)(unsigned short); @@ -38,6 +40,7 @@ int main (void) /* { dg-output "65535: 65535" } */ printf("res: %d\n",res); /* { dg-output "\nres: 65535" } */ + CHECK(res == 65535); exit(0); } diff --git a/testsuite/libffi.closures/ffitest.h b/testsuite/libffi.closures/ffitest.h index 95d96a8..53b009c 100644 --- a/testsuite/libffi.closures/ffitest.h +++ b/testsuite/libffi.closures/ffitest.h @@ -5,6 +5,9 @@ #include #include "fficonfig.h" +#include +#include + #if defined HAVE_STDINT_H #include #endif @@ -23,6 +26,22 @@ } \ } while(0) +#define CHECK_FLOAT_EQ(x, y) \ + do { \ + if(fabs((x) - (y)) > FLT_EPSILON){ \ + printf("Check failed CHECK_FLOAT_EQ(%s, %s)\n", #x, #y); \ + abort(); \ + } \ + } while(0) + +#define CHECK_DOUBLE_EQ(x, y) \ + do { \ + if(fabs((x) - (y)) > DBL_EPSILON){ \ + printf("Check failed CHECK_FLOAT_EQ(%s, %s)\n", #x, #y); \ + abort(); \ + } \ + } while(0) + /* Define macros so that compilers other than gcc can run the tests. */ #undef __UNUSED__ #if defined(__GNUC__) diff --git a/testsuite/libffi.closures/huge_struct.c b/testsuite/libffi.closures/huge_struct.c index e8e1d86..6dc631f 100644 --- a/testsuite/libffi.closures/huge_struct.c +++ b/testsuite/libffi.closures/huge_struct.c @@ -5,7 +5,7 @@ Originator: Blake Chaffin 6/18/2007 */ -/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */ +/* { dg-do run { xfail strongarm*-*-* xscale*-*-* wasm32*-*-* } } */ /* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */ /* { dg-options -Wformat=0 { target moxie*-*-elf or1k-*-* } } */ diff --git a/testsuite/libffi.closures/nested_struct.c b/testsuite/libffi.closures/nested_struct.c index 10797a3..8b1b4ba 100644 --- a/testsuite/libffi.closures/nested_struct.c +++ b/testsuite/libffi.closures/nested_struct.c @@ -46,6 +46,29 @@ static cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0, result.d.a, result.d.b, result.d.c, result.e.ii, result.e.dd, result.e.ff); + CHECK_DOUBLE_EQ(b0.a, 9); + CHECK_FLOAT_EQ(b0.b, 2); + CHECK(b0.c == 6); + + CHECK(b1.ii == 1); + CHECK_DOUBLE_EQ(b1.dd, 2); + CHECK_FLOAT_EQ(b1.ff, 3); + + CHECK_DOUBLE_EQ(b2.d.a, 4); + CHECK_FLOAT_EQ(b2.d.b, 5); + CHECK(b2.d.c == 6); + + CHECK(b2.e.ii == 3); + CHECK_DOUBLE_EQ(b2.e.dd, 1); + CHECK_FLOAT_EQ(b2.e.ff, 8); + + CHECK_DOUBLE_EQ(result.d.a, 15); + CHECK_FLOAT_EQ(result.d.b, 10); + CHECK(result.d.c == 13); + CHECK(result.e.ii == 10); + CHECK_DOUBLE_EQ(result.e.dd, 12); + CHECK_FLOAT_EQ(result.e.ff, 13); + return result; } @@ -128,12 +151,12 @@ int main (void) ffi_call(&cif, FFI_FN(cls_struct_combined_fn), &res_dbl, args_dbl); /* { dg-output "9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */ - CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); - CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); + CHECK_DOUBLE_EQ( res_dbl.d.a, (e_dbl.a + f_dbl.dd + g_dbl.d.a)); + CHECK_FLOAT_EQ( res_dbl.d.b, (e_dbl.b + f_dbl.ff + g_dbl.d.b)); CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); - CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); - CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); + CHECK_DOUBLE_EQ( res_dbl.e.dd, (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); + CHECK_FLOAT_EQ( res_dbl.e.ff, (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK); @@ -142,11 +165,11 @@ int main (void) cls_struct_combined)) (code))(e_dbl, f_dbl, g_dbl); /* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */ - CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a)); - CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b)); + CHECK_DOUBLE_EQ( res_dbl.d.a, (e_dbl.a + f_dbl.dd + g_dbl.d.a)); + CHECK_FLOAT_EQ( res_dbl.d.b, (e_dbl.b + f_dbl.ff + g_dbl.d.b)); CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c)); CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii)); - CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); - CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); + CHECK_DOUBLE_EQ( res_dbl.e.dd, (e_dbl.a + f_dbl.dd + g_dbl.e.dd)); + CHECK_FLOAT_EQ( res_dbl.e.ff, (e_dbl.b + f_dbl.ff + g_dbl.e.ff)); exit(0); } diff --git a/testsuite/libffi.closures/nested_struct10.c b/testsuite/libffi.closures/nested_struct10.c index 3cf2b44..a2cdc64 100644 --- a/testsuite/libffi.closures/nested_struct10.c +++ b/testsuite/libffi.closures/nested_struct10.c @@ -38,6 +38,18 @@ static B B_fn(struct A b2, struct B b3, struct C b4) (int)b3.x.a, b3.x.b, b3.y, b3.z, (int)b4.d, b4.e, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK(b3.z == 255); + CHECK((int)b4.d == 2); + CHECK(b4.e == 9); + CHECK((int)result.x.a == 270); + CHECK(result.x.b == 242); + CHECK(result.y == 143); + return result; } diff --git a/testsuite/libffi.closures/nested_struct11.c b/testsuite/libffi.closures/nested_struct11.c index 3510493..c9821e4 100644 --- a/testsuite/libffi.closures/nested_struct11.c +++ b/testsuite/libffi.closures/nested_struct11.c @@ -35,6 +35,13 @@ static C C_fn (int x, int y, int z, C source, int i, int j, int k) printf ("%d, %d, %d, %d, %d, %d\n", x, y, z, i, j, k); + CHECK(x == 1); + CHECK(y == 1); + CHECK(z == 1); + CHECK(i == 1); + CHECK(j == 1); + CHECK(k == 1); + printf ("%.1f, %.1f, %.1f, %.1f, " "%.1f, %.1f, %.1f, %.1f\n", source.a.a_x, source.a.a_y, @@ -42,6 +49,15 @@ static C C_fn (int x, int y, int z, C source, int i, int j, int k) result.a.a_x, result.a.a_y, result.b.b_x, result.b.b_y); + CHECK_FLOAT_EQ(source.a.a_x, 1.0); + CHECK_FLOAT_EQ(source.a.a_y, 2.0); + CHECK_FLOAT_EQ(source.b.b_x, 4.0); + CHECK_FLOAT_EQ(source.b.b_y, 8.0); + CHECK_FLOAT_EQ(result.a.a_x, 1.0); + CHECK_FLOAT_EQ(result.a.a_y, 2.0); + CHECK_FLOAT_EQ(result.b.b_x, 4.0); + CHECK_FLOAT_EQ(result.b.b_y, 8.0); + return result; } @@ -113,9 +129,9 @@ int main (void) ffi_call (&cif, FFI_FN (C_fn), &result, args); /* { dg-output "1, 1, 1, 1, 1, 1\n" } */ /* { dg-output "1.0, 2.0, 4.0, 8.0, 1.0, 2.0, 4.0, 8.0" } */ - CHECK (result.a.a_x == source.a.a_x); - CHECK (result.a.a_y == source.a.a_y); - CHECK (result.b.b_x == source.b.b_x); - CHECK (result.b.b_y == source.b.b_y); - exit (0); + CHECK_FLOAT_EQ(result.a.a_x, source.a.a_x); + CHECK_FLOAT_EQ(result.a.a_y, source.a.a_y); + CHECK_FLOAT_EQ(result.b.b_x, source.b.b_x); + CHECK_FLOAT_EQ(result.b.b_y, source.b.b_y); + exit(0); } diff --git a/testsuite/libffi.closures/nested_struct12.c b/testsuite/libffi.closures/nested_struct12.c index 0d307ae..7ca16c1 100644 --- a/testsuite/libffi.closures/nested_struct12.c +++ b/testsuite/libffi.closures/nested_struct12.c @@ -75,7 +75,7 @@ int main (void) CHECK( ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, retType, args) == FFI_OK); ffi_call(&cif, FFI_FN(testNestedFloatStruct), &ts12_result, values); - CHECK(ts12_result == 138.2f); + CHECK_FLOAT_EQ(ts12_result, 138.2f); free(struct_float1); free(struct_float2); diff --git a/testsuite/libffi.closures/nested_struct13.c b/testsuite/libffi.closures/nested_struct13.c index 6c139b9..6edfdcb 100644 --- a/testsuite/libffi.closures/nested_struct13.c +++ b/testsuite/libffi.closures/nested_struct13.c @@ -27,6 +27,14 @@ B B_fn(float b0, struct B b1) printf("%g %g %g %g: %g %g %g\n", b0, b1.x, b1.y.a, b1.y.b, result.x, result.y.a, result.y.b); + CHECK_FLOAT_EQ(b0, 12.125); + CHECK_FLOAT_EQ(b1.x, 24.75); + CHECK_FLOAT_EQ(b1.y.a, 31.625); + CHECK_FLOAT_EQ(b1.y.b, 32.25); + CHECK_FLOAT_EQ(result.x, 36.875); + CHECK_FLOAT_EQ(result.y.a, 43.75); + CHECK_FLOAT_EQ(result.y.b, 44.375); + return result; } @@ -91,17 +99,17 @@ int main (void) ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl); /* { dg-output "12.125 24.75 31.625 32.25: 36.875 43.75 44.375" } */ - CHECK( res_dbl.x == (e_dbl + f_dbl.x)); - CHECK( res_dbl.y.a == (e_dbl + f_dbl.y.a)); - CHECK( res_dbl.y.b == (e_dbl + f_dbl.y.b)); + CHECK_FLOAT_EQ( res_dbl.x, (e_dbl + f_dbl.x)); + CHECK_FLOAT_EQ( res_dbl.y.a, (e_dbl + f_dbl.y.a)); + CHECK_FLOAT_EQ( res_dbl.y.b, (e_dbl + f_dbl.y.b)); CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK); res_dbl = ((B(*)(float, B))(code))(e_dbl, f_dbl); /* { dg-output "\n12.125 24.75 31.625 32.25: 36.875 43.75 44.375" } */ - CHECK( res_dbl.x == (e_dbl + f_dbl.x)); - CHECK( res_dbl.y.a == (e_dbl + f_dbl.y.a)); - CHECK( res_dbl.y.b == (e_dbl + f_dbl.y.b)); + CHECK_FLOAT_EQ( res_dbl.x, (e_dbl + f_dbl.x)); + CHECK_FLOAT_EQ( res_dbl.y.a, (e_dbl + f_dbl.y.a)); + CHECK_FLOAT_EQ( res_dbl.y.b, (e_dbl + f_dbl.y.b)); exit(0); } diff --git a/testsuite/libffi.closures/nested_struct2.c b/testsuite/libffi.closures/nested_struct2.c index d919e5c..93a913d 100644 --- a/testsuite/libffi.closures/nested_struct2.c +++ b/testsuite/libffi.closures/nested_struct2.c @@ -30,6 +30,15 @@ static B B_fn(struct A b0, struct B b1) printf("%lu %d %lu %d %d: %lu %d %d\n", b0.a, b0.b, b1.x.a, b1.x.b, b1.y, result.x.a, result.x.b, result.y); + CHECK(b0.a == 1); + CHECK(b0.b == 7); + CHECK(b1.x.a == 12); + CHECK(b1.x.b == 127); + CHECK(b1.y == 99); + CHECK(result.x.a == 13); + CHECK(result.x.b == 233); + CHECK(result.y == 134); + return result; } diff --git a/testsuite/libffi.closures/nested_struct3.c b/testsuite/libffi.closures/nested_struct3.c index 7d4c2cf..d39a9cc 100644 --- a/testsuite/libffi.closures/nested_struct3.c +++ b/testsuite/libffi.closures/nested_struct3.c @@ -31,6 +31,15 @@ static B B_fn(struct A b0, struct B b1) (int)b1.x.a, b1.x.b, b1.y, (int)result.x.a, result.x.b, result.y); + CHECK((int)b0.a == 1); + CHECK(b0.b == 7); + CHECK((int)b1.x.a == 12); + CHECK(b1.x.b == 127); + CHECK(b1.y == 99); + CHECK((int)result.x.a == 13); + CHECK(result.x.b == 233); + CHECK(result.y == 134); + return result; } diff --git a/testsuite/libffi.closures/nested_struct4.c b/testsuite/libffi.closures/nested_struct4.c index 2ffb4d6..d5c960d 100644 --- a/testsuite/libffi.closures/nested_struct4.c +++ b/testsuite/libffi.closures/nested_struct4.c @@ -31,6 +31,15 @@ static B B_fn(struct A b2, struct B b3) (int)b3.x.a, b3.x.b, b3.y, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)result.x.a == 13); + CHECK(result.x.b == 233); + CHECK(result.y == 134); + return result; } diff --git a/testsuite/libffi.closures/nested_struct5.c b/testsuite/libffi.closures/nested_struct5.c index 6c79845..b053f52 100644 --- a/testsuite/libffi.closures/nested_struct5.c +++ b/testsuite/libffi.closures/nested_struct5.c @@ -31,6 +31,15 @@ static B B_fn(struct A b2, struct B b3) (int)b3.x.a, b3.x.b, b3.y, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)result.x.a == 13); + CHECK(result.x.b == 233); + CHECK(result.y == 134); + return result; } diff --git a/testsuite/libffi.closures/nested_struct6.c b/testsuite/libffi.closures/nested_struct6.c index 59d3579..690ec0b 100644 --- a/testsuite/libffi.closures/nested_struct6.c +++ b/testsuite/libffi.closures/nested_struct6.c @@ -36,6 +36,17 @@ static B B_fn(struct A b2, struct B b3, struct C b4) (int)b3.x.a, b3.x.b, b3.y, (int)b4.d, b4.e, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)b4.d == 2); + CHECK(b4.e == 9); + CHECK((int)result.x.a == 15); + CHECK(result.x.b == 242); + CHECK(result.y == 143); + return result; } diff --git a/testsuite/libffi.closures/nested_struct7.c b/testsuite/libffi.closures/nested_struct7.c index 27595e6..b3ddd03 100644 --- a/testsuite/libffi.closures/nested_struct7.c +++ b/testsuite/libffi.closures/nested_struct7.c @@ -31,6 +31,15 @@ static B B_fn(struct A b2, struct B b3) (int)b3.x.a, b3.x.b, b3.y, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)result.x.a == 13); + CHECK(result.x.b == 233); + CHECK(result.y == 134); + return result; } diff --git a/testsuite/libffi.closures/nested_struct8.c b/testsuite/libffi.closures/nested_struct8.c index 0e6c682..768f333 100644 --- a/testsuite/libffi.closures/nested_struct8.c +++ b/testsuite/libffi.closures/nested_struct8.c @@ -36,6 +36,17 @@ static B B_fn(struct A b2, struct B b3, struct C b4) (int)b3.x.a, b3.x.b, b3.y, (int)b4.d, b4.e, (int)result.x.a, result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)b4.d == 2); + CHECK(b4.e == 9); + CHECK((int)result.x.a == 15); + CHECK(result.x.b == 242); + CHECK(result.y == 143); + return result; } diff --git a/testsuite/libffi.closures/nested_struct9.c b/testsuite/libffi.closures/nested_struct9.c index 5f7ac67..f88ab0a 100644 --- a/testsuite/libffi.closures/nested_struct9.c +++ b/testsuite/libffi.closures/nested_struct9.c @@ -36,6 +36,17 @@ static B B_fn(struct A b2, struct B b3, struct C b4) b3.x.a, (int)b3.x.b, b3.y, (int)b4.d, b4.e, result.x.a, (int)result.x.b, result.y); + CHECK((int)b2.a == 1); + CHECK(b2.b == 7); + CHECK((int)b3.x.a == 12); + CHECK(b3.x.b == 127); + CHECK(b3.y == 99); + CHECK((int)b4.d == 2); + CHECK(b4.e == 9); + CHECK((int)result.x.a == 15); + CHECK(result.x.b == 242); + CHECK(result.y == 143); + return result; } diff --git a/testsuite/libffi.closures/testclosure.c b/testsuite/libffi.closures/testclosure.c index 600368e..e738a01 100644 --- a/testsuite/libffi.closures/testclosure.c +++ b/testsuite/libffi.closures/testclosure.c @@ -20,6 +20,11 @@ static void cls_struct_combined_fn(struct cls_struct_combined arg) arg.a, arg.b, arg.c, arg.d); fflush(stdout); + + CHECK_FLOAT_EQ(arg.a, 4); + CHECK_FLOAT_EQ(arg.b, 5); + CHECK_FLOAT_EQ(arg.c, 1); + CHECK_FLOAT_EQ(arg.d, 8); } static void -- cgit v1.2.1