Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: Re: [_Complex test 4/4] _Complex tests in callfuncs.exp
Date: Fri, 20 May 2011 08:17:00 -0000	[thread overview]
Message-ID: <4DD6238D.40501@codesourcery.com> (raw)
In-Reply-To: <4DD4A5DC.9060004@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 229 bytes --]

On 05/19/2011 01:08 PM, Yao Qi wrote:
> +set compile_flags {debug}
> +if [support_complex_tests] {
> +    set compile_flags "$compile_flags additional_flags=-DTEST_COMPLEX"
> +}

Use lappend in new patch.

-- 
Yao (齐尧)

[-- Attachment #2: 0004-pass-args-of-type-complex-to-func.patch --]
[-- Type: text/x-patch, Size: 10665 bytes --]

From 1c0d4f9c00ccdcd94d797ef8767ebce6e508a556 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao@codesourcery.com>
Date: Wed, 18 May 2011 21:43:57 +0800
Subject: [PATCH 4/4] pass args of type complex to func

gdb/testsuite/

        * gdb.base/funcargs.c (callca, callcb, callcc): New.
        (callcd, callce, callcf, callc1a, callc1b): New.
        (callc2a, callc2b): New.
        * gdb.base/funcargs.exp (complex_args): New.
        (complex_integral_args, complex_float_integral_args): New.
        * lib/gdb.exp (support_complex_tests): New.  Determine
        whether to run test cases on _Complex types.
---
 gdb/testsuite/gdb.base/callfuncs.c   |  147 +++++++++++++++++++++++++++++++++-
 gdb/testsuite/gdb.base/callfuncs.exp |   55 ++++++++++++-
 2 files changed, 200 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/callfuncs.c
index 406d22a..946ebde 100644
--- a/gdb/testsuite/gdb.base/callfuncs.c
+++ b/gdb/testsuite/gdb.base/callfuncs.c
@@ -73,6 +73,30 @@ double double_val13 = 10.25;
 double double_val14 = 11.25;
 double double_val15 = 12.25;
 
+#ifdef TEST_COMPLEX
+extern float crealf (float _Complex);
+extern float cimagf (float _Complex);
+extern double creal (double _Complex);
+extern double cimag (double _Complex);
+extern long double creall (long double _Complex);
+extern long double cimagl (long double _Complex);
+
+float _Complex fc1 = 1.0F + 1.0iF;
+float _Complex fc2 = 2.0F + 2.0iF;
+float _Complex fc3 = 3.0F + 3.0iF;
+float _Complex fc4 = 4.0F + 4.0iF;
+
+double _Complex dc1 = 1.0 + 1.0i;
+double _Complex dc2 = 2.0 + 2.0i;
+double _Complex dc3 = 3.0 + 3.0i;
+double _Complex dc4 = 4.0 + 4.0i;
+
+long double _Complex ldc1 = 1.0L + 1.0Li;
+long double _Complex ldc2 = 2.0L + 2.0Li;
+long double _Complex ldc3 = 3.0L + 3.0Li;
+long double _Complex ldc4 = 4.0L + 4.0Li;
+#endif /* TEST_COMPLEX */
+
 #define DELTA (0.001)
 
 char *string_val1 = (char *)"string 1";
@@ -89,8 +113,15 @@ struct struct1 {
   float f;
   double d;
   char a[4];
+#ifdef TEST_COMPLEX
+  float _Complex fc;
+  double _Complex dc;
+  long double _Complex ldc;
+} struct_val1 ={ 'x', 87, 76, 51, 2.1234, 9.876, "foo", 3.0F + 3.0Fi,
+		 4.0L + 4.0Li, 5.0L + 5.0Li};
+#else
 } struct_val1 = { 'x', 87, 76, 51, 2.1234, 9.876, "foo" };
-
+#endif /* TEST_COMPLEX */
 /* Some functions that can be passed as arguments to other test
    functions, or called directly. */
 #ifdef PROTOTYPES
@@ -183,6 +214,11 @@ char  *t_structs_a (struct struct1 tstruct)
   strcpy (buf, tstruct.a);
   return buf;
 }
+#ifdef TEST_COMPLEX
+float _Complex t_structs_fc (struct struct1 tstruct) { return tstruct.fc;}
+double _Complex t_structs_dc (struct struct1 tstruct) { return tstruct.dc;}
+long double _Complex t_structs_fc (struct struct1 tstruct) { return tstruct.ldc;}
+#endif
 #else
 char   t_structs_c (tstruct) struct struct1 tstruct; { return (tstruct.c); }
 short  t_structs_s (tstruct) struct struct1 tstruct; { return (tstruct.s); }
@@ -196,6 +232,11 @@ char  *t_structs_a (tstruct) struct struct1 tstruct;
   strcpy (buf, tstruct.a);
   return buf;
 }
+#ifdef TEST_COMPLEX
+float _Complex t_structs_fc (tstruct) struct struct1 tstruct; { return tstruct.fc;}
+double _Complex t_structs_dc (tstruct) struct struct1 tstruct; { return tstruct.dc;}
+long double _Complex t_structs_ldc (tstruct) struct struct1 tstruct; { return tstruct.ldc;}
+#endif
 #endif
 
 /* Test that calling functions works if there are a lot of arguments.  */
@@ -400,6 +441,110 @@ t_double_many_args (double f1, double f2, double f3, double f4, double f5,
 	  && (sum_args - sum_values) > -DELTA);
 }
 
+/* Various functions for _Complex types.  */
+
+#ifdef TEST_COMPLEX
+
+#define COMPARE_WITHIN_RANGE(ARG1, ARG2, DEL, FUNC) \
+  ((FUNC(ARG1) - FUNC(ARG2)) < DEL) && ((FUNC(ARG1) - FUNC(ARG2) > -DEL))
+
+#define DEF_FUNC_MANY_ARGS_1(TYPE, NAME)			\
+t_##NAME##_complex_many_args (f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, \
+			      f12, f13, f14, f15, f16)			\
+     TYPE _Complex f1, TYPE _Complex f2, TYPE _Complex f3, \
+     TYPE _Complex f4, TYPE _Complex f5, TYPE _Complex f6, \
+     TYPE _Complex f7, TYPE _Complex f8, TYPE _Complex f9, \
+     TYPE _Complex f10, TYPE _Complex f11, TYPE _Complex f12, \
+     TYPE _Complex f13, TYPE _Complex f14, TYPE _Complex f15, \
+     TYPE _Complex f16;
+
+#define DEF_FUNC_MANY_ARGS_2(TYPE, NAME)		  \
+t_##NAME##_complex_many_args (TYPE _Complex f1, TYPE _Complex f2, \
+			      TYPE _Complex f3, TYPE _Complex f4, \
+			      TYPE _Complex f5, TYPE _Complex f6, \
+			      TYPE _Complex f7, TYPE _Complex f8, \
+			      TYPE _Complex f9, TYPE _Complex f10,	\
+			      TYPE _Complex f11, TYPE _Complex f12,	\
+			      TYPE _Complex f13, TYPE _Complex f14,	\
+			      TYPE _Complex f15, TYPE _Complex f16)
+
+#define DEF_FUNC_MANY_ARGS_3(TYPE, CREAL, CIMAG) \
+{ \
+   TYPE _Complex expected = fc1 + fc2 + fc3 + fc4 + fc1 + fc2 + fc3 + fc4 \
+    + fc1 + fc2 + fc3 + fc4 + fc1 + fc2 + fc3 + fc4; \
+  TYPE _Complex actual = f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10 \
+    + f11 + f12 + f13 + f14 + f15 + f16; \
+  return (COMPARE_WITHIN_RANGE(expected, actual, DELTA, creal) \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, creal) \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, cimag)   \
+	  && COMPARE_WITHIN_RANGE(expected, actual, DELTA, cimag)); \
+}
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(float, float)
+#else
+DEF_FUNC_MANY_ARGS_2(float, float)
+#endif
+DEF_FUNC_MANY_ARGS_3(float, crealf, cimagf)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(double, double)
+#else
+DEF_FUNC_MANY_ARGS_2(double, double)
+#endif
+DEF_FUNC_MANY_ARGS_3(double, creal, cimag)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_MANY_ARGS_1(long double, long_double)
+#else
+DEF_FUNC_MANY_ARGS_2(long double, long_double)
+#endif
+DEF_FUNC_MANY_ARGS_3(long double, creall, cimagl)
+
+#define DEF_FUNC_VALUES_1(TYPE, NAME)			\
+  t_##NAME##_complex_values (f1, f2) TYPE _Complex f1, TYPE _Complex f2;
+
+#define DEF_FUNC_VALUES_2(TYPE, NAME) \
+  t_##NAME##_complex_values (TYPE _Complex f1, TYPE _Complex f2)
+
+#define DEF_FUNC_VALUES_3(FORMAL_PARM, TYPE, CREAL, CIMAG)	\
+{ \
+ return (COMPARE_WITHIN_RANGE(f1, FORMAL_PARM##1, DELTA, CREAL) \
+	  && COMPARE_WITHIN_RANGE(f2, FORMAL_PARM##2, DELTA, CREAL) \
+	  && COMPARE_WITHIN_RANGE(f1,  FORMAL_PARM##1, DELTA, CIMAG) \
+	  && COMPARE_WITHIN_RANGE(f2,  FORMAL_PARM##2, DELTA, CIMAG)); \
+}
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(float, float)
+#else
+DEF_FUNC_VALUES_2(float, float)
+#endif
+DEF_FUNC_VALUES_3(fc, float, crealf, cimagf)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(double, double)
+#else
+DEF_FUNC_VALUES_2(double, double)
+#endif
+DEF_FUNC_VALUES_3(fc, double, creal, cimag)
+
+int
+#ifdef NO_PROTOTYPES
+DEF_FUNC_VALUES_1(long double, long_double)
+#else
+DEF_FUNC_VALUES_2(long double, long_double)
+#endif
+DEF_FUNC_VALUES_3(fc, long double, creall, cimagl)
+
+#endif /* TEST_COMPLEX */
+
+
 #ifdef PROTOTYPES
 int t_string_values (char *string_arg1, char *string_arg2)
 #else
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index ff86eb8..0e0dc45 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -25,7 +25,12 @@ set testfile "callfuncs"
 set srcfile ${testfile}.c
 set binfile ${objdir}/${subdir}/${testfile}
 
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+set compile_flags {debug}
+if [support_complex_tests] {
+    lappend compile_flags "additional_flags=-DTEST_COMPLEX"
+}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_flags] != "" } {
      untested callfuncs.exp
      return -1
 }
@@ -144,6 +149,23 @@ proc do_function_calls {} {
 	gdb_test "p t_int_double(99, 99.0)" " = 1"
     }
 
+    if [support_complex_tests] {
+	gdb_test "p t_float_complex_values(fc1, fc2)" " = 1"
+	gdb_test "p t_float_complex_values(fc3, fc4)" " = 0"
+	gdb_test "p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)" " = 1"
+	gdb_test "p t_float_complex_many_args(fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1, fc1)" " = 0"
+
+	gdb_test "p t_double_complex_values(dc1, dc2)" " = 1"
+	gdb_test "p t_double_complex_values(dc3, dc4)" " = 0"
+	gdb_test "p t_double_complex_many_args(dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4)" " = 1"
+	gdb_test "p t_double_complex_many_args(dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1)" " = 0"
+
+	gdb_test "p t_long_double_complex_values(ldc1, ldc2)" " = 1"
+	gdb_test "p t_long_double_complex_values(ldc3, ldc4)" " = 0"
+	gdb_test "p t_long_double_complex_many_args(ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4)" " = 1"
+	gdb_test "p t_long_double_complex_many_args(ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1,ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1)" " = 0"
+    }
+
     gdb_test "p t_string_values(string_val2,string_val1)" " = 0"
     gdb_test "p t_string_values(string_val1,string_val2)" " = 1"
     gdb_test "p t_string_values(\"string 1\",\"string 2\")" " = 1"
@@ -217,6 +239,37 @@ proc do_function_calls {} {
 	    "call inferior func with struct - returns double"
     }
 
+    if [support_complex_tests] {
+
+	gdb_test_multiple "p t_structs_fc(struct_val1)" \
+	    "call inferior func with struct - returns float _Complex" {
+		-re ".*= 3 \\+ 3 \\* I.*$gdb_prompt $" {
+		    pass "call inferior func with struct - returns float _Complex"
+		}
+		-r ".*$gdb_prompt $" {
+		    kfail gdb/12783 "call inferior func with struct - returns float _Complex"
+		}
+	    }
+	gdb_test_multiple "p t_structs_dc(struct_val1)" \
+	    "call inferior func with struct - returns double _Complex" {
+		-re  ".*= 4 \\+ 4 \\* I.*$gdb_prompt $" {
+		    pass "call inferior func with struct - returns double _Complex"
+		}
+		-re ".*$gdb_prompt $" {
+		    kfail gdb/12783 "call inferior func with struct - returns double _Complex"
+		}
+	    }
+	gdb_test_multiple "p t_structs_ldc(struct_val1)" \
+	    "call inferior func with struct - returns long double _Complex" {
+		-re  "= 5 \\+ 5 \\* I.*$gdb_prompt $" {
+		    pass "call inferior func with struct - returns long double _Complex"
+		}
+		-re ".*$gdb_prompt $" {
+		    kfail gdb/12783 "call inferior func with struct - returns long double _Complex"
+		}
+	    }
+    }
+
     gdb_test "p t_structs_a(struct_val1)" "= (.unsigned char .. )?\"foo\"" \
     	"call inferior func with struct - returns char *"
 }
-- 
1.7.0.4


  reply	other threads:[~2011-05-20  8:17 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-06 14:13 [patch, testsuite] Tests to _Complex type Yao Qi
2011-05-06 14:33 ` Joseph S. Myers
2011-05-09  2:24   ` Yao Qi
2011-05-09 15:06     ` Tom Tromey
2011-05-19  4:26       ` [_Complex test 1/4] support_complex_tests in gdb.exp and pass _Complex args to func Yao Qi
2011-05-19  8:16         ` Mark Kettenis
2011-05-19 10:16           ` Joseph S. Myers
2011-05-19 13:26             ` Yao Qi
2011-05-19 17:10               ` Tom Tromey
2011-05-20  8:10                 ` Yao Qi
2011-05-26 17:07                   ` Tom Tromey
2011-05-30  2:53                     ` [committed] " Yao Qi
2011-05-19 13:01           ` Yao Qi
2011-05-19 13:24             ` Mark Kettenis
2011-05-19 13:38               ` Mark Kettenis
2011-05-19 10:12         ` Joseph S. Myers
2011-05-19  4:34       ` [_Complex test 2/4] _Complex type in varargs.exp Yao Qi
2011-05-19 10:13         ` Joseph S. Myers
2011-05-19 13:42           ` Yao Qi
2011-05-19 15:27             ` Joseph S. Myers
2011-05-20  9:09               ` Pedro Alves
2011-05-20 15:22               ` Yao Qi
2011-05-20 15:37                 ` Pedro Alves
2011-05-23  4:09                   ` Yao Qi
2011-05-23 10:27                     ` Pedro Alves
2011-05-30  2:55                       ` [committed] " Yao Qi
2011-05-19 17:12         ` Tom Tromey
2011-05-20  8:11           ` Yao Qi
2011-05-19  4:46       ` [_Complex test 3/4] Isolate each test's effect in callfuncs.exp Yao Qi
2011-05-19 18:46         ` Tom Tromey
2011-05-30  2:56           ` [committed] " Yao Qi
2011-05-19  5:09       ` [_Complex test 4/4] _Complex tests " Yao Qi
2011-05-20  8:17         ` Yao Qi [this message]
2011-05-24  1:46           ` [_Complex test 4/4 V3] " Yao Qi
2011-05-24  9:00             ` Mark Kettenis
2011-05-24  9:34               ` Yao Qi
2011-05-24 10:00                 ` Mark Kettenis
2011-05-24 13:54                   ` Yao Qi
2011-05-26 17:07         ` [_Complex test 4/4] " Tom Tromey
2011-05-30  2:57           ` [committed] " Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DD6238D.40501@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox