This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Simplify libm-test extra-output initialization


The structures describing libm-test tests for functions with extra
outputs (through pointers or implicitly through global variables) have
fields for how to initialize those extra outputs.  These are
unnecessary and this patch changes the initialization to compute at
runtime a value known to be different from the expected output value.
Tested x86_64 and x86.

(This patch is intended as a step towards the goal of gen-libm-test.pl
not having anything hardcoded about particular named functions.)

2013-05-17  Joseph Myers  <joseph@codesourcery.com>

	* math/libm-test.inc (struct test_f_f1_data): Remove field
	extra_init.
	(struct test_fF_f1_data): Likewise.
	(struct test_ffI_f1_data): Likewise.
	(RUN_TEST_f_f1): Remove argument EXTRA_INIT.  Initialize EXTRA_VAR
	based on value of EXTRA_EXPECTED.
	(RUN_TEST_LOOP_f_f1): Update call to RUN_TEST_f_f1.
	(RUN_TEST_fF_f1): Remove argument EXTRA_INIT.  Initialize
	EXTRA_VAR based on value of EXTRA_EXPECTED.
	(RUN_TEST_LOOP_fF_f1): Update call to RUN_TEST_fF_f1.
	(RUN_TEST_fI_f1): Remove argument EXTRA_INIT.  Initialize
	EXTRA_VAR based on value of EXTRA_EXPECTED.
	(RUN_TEST_LOOP_fI_f1): Update call to RUN_TEST_fI_f1.
	(RUN_TEST_ffI_f1): Remove argument EXTRA_INIT.  Initialize
	EXTRA_VAR based on value of EXTRA_EXPECTED.
	(RUN_TEST_LOOP_ffI_f1): Update call to RUN_TEST_ffI_f1.
	* math/gen-libm-test.pl (parse_args): Don't output initializers
	for extra output values.

diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl
index 217d74d..2217948 100755
--- a/math/gen-libm-test.pl
+++ b/math/gen-libm-test.pl
@@ -345,7 +345,7 @@ sub parse_args {
 	$str = "";
 	$extra_expected = "0";
       }
-      $cline .= ", \"$str\", 123456789, $run_extra, $extra_expected";
+      $cline .= ", \"$str\", $run_extra, $extra_expected";
       if ($run_extra) {
 	$cline .= &new_test ($str, undef, 0);
       } else {
@@ -361,7 +361,7 @@ sub parse_args {
 	$str = "";
 	$extra_expected = "0";
       }
-      $cline .= ", \"$str\", 0, $run_extra, $extra_expected";
+      $cline .= ", \"$str\", $run_extra, $extra_expected";
       if ($run_extra) {
 	$cline .= &new_test ($str, undef, 0);
       } else {
@@ -377,7 +377,7 @@ sub parse_args {
 	$str = "";
 	$extra_expected = "0";
       }
-      $cline .= ", \"$str\", 123.456789, $run_extra, $extra_expected";
+      $cline .= ", \"$str\", $run_extra, $extra_expected";
       if ($run_extra) {
 	$cline .= &new_test ($str, undef, 0);
       } else {
@@ -393,7 +393,7 @@ sub parse_args {
 	$str = "";
 	$extra_expected = "0";
       }
-      $cline .= ", \"$str\", 123456789, $run_extra, $extra_expected";
+      $cline .= ", \"$str\", $run_extra, $extra_expected";
       if ($run_extra) {
 	$cline .= &new_test ($str, undef, 0);
       } else {
diff --git a/math/libm-test.inc b/math/libm-test.inc
index f5fabd3..d49a5fa 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -940,7 +940,6 @@ struct test_f_f1_data
   FLOAT max_ulp;
   int exceptions;
   const char *extra_name;
-  int extra_init;
   int extra_test;
   int extra_expected;
   int extra_ulp;
@@ -953,7 +952,6 @@ struct test_fF_f1_data
   FLOAT max_ulp;
   int exceptions;
   const char *extra_name;
-  FLOAT extra_init;
   int extra_test;
   FLOAT extra_expected;
   FLOAT extra_ulp;
@@ -966,7 +964,6 @@ struct test_ffI_f1_data
   FLOAT max_ulp;
   int exceptions;
   const char *extra_name;
-  int extra_init;
   int extra_test;
   int extra_expected;
   int extra_ulp;
@@ -1113,19 +1110,19 @@ struct test_sincos_data
 		    (ARRAY)[i].argc, (ARRAY)[i].expected,		\
 		    (ARRAY)[i].max_ulp, (ARRAY)[i].exceptions);		\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_f_f1(TEST_NAME, FUNC_NAME, ARG, EXPECTED,		\
-		      MAX_ULP, EXCEPTIONS,				\
-		      EXTRA_NAME, EXTRA_VAR, EXTRA_INIT, EXTRA_TEST,	\
-		      EXTRA_EXPECTED, EXTRA_ULP)			\
-  do									\
-    {									\
-      (EXTRA_VAR) = (EXTRA_INIT);					\
-      check_float (TEST_NAME, FUNC (FUNC_NAME) (ARG), EXPECTED,		\
-		   MAX_ULP, EXCEPTIONS);				\
-      if (EXTRA_TEST)							\
-	check_int (EXTRA_NAME, EXTRA_VAR, EXTRA_EXPECTED,		\
-		   EXTRA_ULP, 0);					\
-    }									\
+#define RUN_TEST_f_f1(TEST_NAME, FUNC_NAME, ARG, EXPECTED,	\
+		      MAX_ULP, EXCEPTIONS,			\
+		      EXTRA_NAME, EXTRA_VAR, EXTRA_TEST,	\
+		      EXTRA_EXPECTED, EXTRA_ULP)		\
+  do								\
+    {								\
+      (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0;		\
+      check_float (TEST_NAME, FUNC (FUNC_NAME) (ARG), EXPECTED,	\
+		   MAX_ULP, EXCEPTIONS);			\
+      if (EXTRA_TEST)						\
+	check_int (EXTRA_NAME, EXTRA_VAR, EXTRA_EXPECTED,	\
+		   EXTRA_ULP, 0);				\
+    }								\
   while (0)
 #define RUN_TEST_LOOP_f_f1(FUNC_NAME, ARRAY, ROUNDING_MODE, EXTRA_VAR)	\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
@@ -1133,17 +1130,16 @@ struct test_sincos_data
       RUN_TEST_f_f1 ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
 		     (ARRAY)[i].expected, (ARRAY)[i].max_ulp,		\
 		     (ARRAY)[i].exceptions, (ARRAY)[i].extra_name,	\
-		     EXTRA_VAR, (ARRAY)[i].extra_init,			\
-		     (ARRAY)[i].extra_test, (ARRAY)[i].extra_expected,	\
-		     (ARRAY)[i].extra_ulp);				\
+		     EXTRA_VAR, (ARRAY)[i].extra_test,			\
+		     (ARRAY)[i].extra_expected, (ARRAY)[i].extra_ulp);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
 #define RUN_TEST_fF_f1(TEST_NAME, FUNC_NAME, ARG, EXPECTED,		\
 		       MAX_ULP, EXCEPTIONS,				\
-		       EXTRA_NAME, EXTRA_VAR, EXTRA_INIT, EXTRA_TEST,	\
+		       EXTRA_NAME, EXTRA_VAR, EXTRA_TEST,		\
 		       EXTRA_EXPECTED, EXTRA_ULP)			\
   do									\
     {									\
-      (EXTRA_VAR) = (EXTRA_INIT);					\
+      (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0;			\
       check_float (TEST_NAME, FUNC (FUNC_NAME) (ARG, &(EXTRA_VAR)),	\
 		   EXPECTED, MAX_ULP, EXCEPTIONS);			\
       if (EXTRA_TEST)							\
@@ -1157,17 +1153,16 @@ struct test_sincos_data
       RUN_TEST_fF_f1 ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
 		      (ARRAY)[i].expected, (ARRAY)[i].max_ulp,		\
 		      (ARRAY)[i].exceptions, (ARRAY)[i].extra_name,	\
-		      EXTRA_VAR, (ARRAY)[i].extra_init,			\
-		      (ARRAY)[i].extra_test, (ARRAY)[i].extra_expected,	\
-		      (ARRAY)[i].extra_ulp);				\
+		      EXTRA_VAR, (ARRAY)[i].extra_test,			\
+		      (ARRAY)[i].extra_expected, (ARRAY)[i].extra_ulp);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
 #define RUN_TEST_fI_f1(TEST_NAME, FUNC_NAME, ARG, EXPECTED,		\
 		       MAX_ULP, EXCEPTIONS,				\
-		       EXTRA_NAME, EXTRA_VAR, EXTRA_INIT, EXTRA_TEST,	\
+		       EXTRA_NAME, EXTRA_VAR, EXTRA_TEST,		\
 		       EXTRA_EXPECTED, EXTRA_ULP)			\
   do									\
     {									\
-      (EXTRA_VAR) = (EXTRA_INIT);					\
+      (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0;			\
       check_float (TEST_NAME, FUNC (FUNC_NAME) (ARG, &(EXTRA_VAR)),	\
 		   EXPECTED, MAX_ULP, EXCEPTIONS);			\
       if (EXTRA_TEST)							\
@@ -1181,17 +1176,16 @@ struct test_sincos_data
       RUN_TEST_fI_f1 ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
 		      (ARRAY)[i].expected, (ARRAY)[i].max_ulp,		\
 		      (ARRAY)[i].exceptions, (ARRAY)[i].extra_name,	\
-		      EXTRA_VAR, (ARRAY)[i].extra_init,			\
-		      (ARRAY)[i].extra_test, (ARRAY)[i].extra_expected,	\
-		      (ARRAY)[i].extra_ulp);				\
+		      EXTRA_VAR, (ARRAY)[i].extra_test,			\
+		      (ARRAY)[i].extra_expected, (ARRAY)[i].extra_ulp);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
 #define RUN_TEST_ffI_f1(TEST_NAME, FUNC_NAME, ARG1, ARG2, EXPECTED,	\
 			MAX_ULP, EXCEPTIONS,				\
-			EXTRA_NAME, EXTRA_VAR, EXTRA_INIT, EXTRA_TEST,	\
+			EXTRA_NAME, EXTRA_VAR, EXTRA_TEST,		\
 			EXTRA_EXPECTED, EXTRA_ULP)			\
   do									\
     {									\
-      (EXTRA_VAR) = (EXTRA_INIT);					\
+      (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0;			\
       check_float (TEST_NAME,						\
 		   FUNC (FUNC_NAME) (ARG1, ARG2, &(EXTRA_VAR)),		\
 		   EXPECTED, MAX_ULP, EXCEPTIONS);			\
@@ -1208,8 +1202,7 @@ struct test_sincos_data
 		       (ARRAY)[i].arg1, (ARRAY)[i].arg2,		\
 		       (ARRAY)[i].expected, (ARRAY)[i].max_ulp,		\
 		       (ARRAY)[i].exceptions, (ARRAY)[i].extra_name,	\
-		       EXTRA_VAR, (ARRAY)[i].extra_init,		\
-		       (ARRAY)[i].extra_test,				\
+		       EXTRA_VAR, (ARRAY)[i].extra_test,		\
 		       (ARRAY)[i].extra_expected,			\
 		       (ARRAY)[i].extra_ulp);				\
   ROUND_RESTORE_ ## ROUNDING_MODE

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]