about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog86
-rwxr-xr-xmath/gen-libm-test.pl27
-rw-r--r--math/libm-test.inc346
3 files changed, 327 insertions, 132 deletions
diff --git a/ChangeLog b/ChangeLog
index d04f3900e5..04dc3afe24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,89 @@
+2013-05-22  Joseph Myers  <joseph@codesourcery.com>
+
+	* math/gen-libm-test.pl (parse_args): Output only string of
+	arguments as text for test name, not full call or descriptions of
+	tests for extra outputs.
+	(generate_testfile): Do not pass function name to parse_args.
+	Generate this_func variable from START.
+	* math/libm-test.inc (struct test_f_f_data): Rename test_name
+	field to arg_str.
+	(struct test_ff_f_data): Likewise.
+	(test_ff_f_data_nexttoward): Likewise.
+	(struct test_fi_f_data): Likewise.
+	(struct test_fl_f_data): Likewise.
+	(struct test_if_f_data): Likewise.
+	(struct test_fff_f_data): Likewise.
+	(struct test_c_f_data): Likewise.
+	(struct test_f_f1_data): Likewise.  Remove field extra_name.
+	(struct test_fF_f1_data): Likewise.
+	(struct test_ffI_f1_data): Likewise.
+	(struct test_c_c_data): Rename test_name field to arg_str.
+	(struct test_cc_c_data): Likewise.
+	(struct test_f_i_data): Likewise.
+	(struct test_ff_i_data): Likewise.
+	(struct test_f_l_data): Likewise.
+	(struct test_f_L_data): Likewise.
+	(struct test_fFF_11_data): Likewise.  Remove fields extra1_name
+	and extra2_name.
+	(COMMON_TEST_SETUP): New macro.
+	(EXTRA_OUTPUT_TEST_SETUP): Likewise.
+	(COMMON_TEST_CLEANUP): Likewise.
+	(EXTRA_OUTPUT_TEST_CLEANUP): Likewise.
+	(RUN_TEST_f_f): Take argument string.  Call new setup and cleanup
+	macros.
+	(RUN_TEST_LOOP_f_f): Update call to RUN_TEST_f_f.
+	(RUN_TEST_2_f): Take argument string.  Call new setup and cleanup
+	macros.
+	(RUN_TEST_LOOP_2_f): Update call to RUN_TEST_2_f.
+	(RUN_TEST_fff_f): Take argument string.  Call new setup and
+	cleanup macros.
+	(RUN_TEST_LOOP_fff_f): Update call to RUN_TEST_fff_f.
+	(RUN_TEST_c_f): Take argument string.  Call new setup and cleanup
+	macros.
+	(RUN_TEST_LOOP_c_f): Update call to RUN_TEST_c_f.
+	(RUN_TEST_f_f1): Take argument string.  Call new setup and cleanup
+	macros.
+	(RUN_TEST_LOOP_f_f1): Update call to RUN_TEST_f_f1.
+	(RUN_TEST_fF_f1): Take argument string.  Call new setup and
+	cleanup macros.
+	(RUN_TEST_LOOP_fF_f1): Update call to RUN_TEST_fF_f1.
+	(RUN_TEST_fI_f1): Take argument string.  Call new setup and
+	cleanup macros.
+	(RUN_TEST_LOOP_fI_f1): Update call to RUN_TEST_fI_f1.
+	(RUN_TEST_ffI_f1): Take argument string.  Call new setup and
+	cleanup macros.
+	(RUN_TEST_LOOP_ffI_f1): Update call to RUN_TEST_ffI_f1.
+	(RUN_TEST_c_c): Take argument string.  Call new setup and cleanup
+	macros.
+	(RUN_TEST_LOOP_c_c): Update call to RUN_TEST_c_c.
+	(RUN_TEST_cc_c): Take argument string.  Call new setup and cleanup
+	macros.
+	(RUN_TEST_LOOP_cc_c): Update call to RUN_TEST_cc_c.
+	(RUN_TEST_f_i): Take argument string.  Call new setup and cleanup
+	macros.
+	(RUN_TEST_LOOP_f_i): Update call to RUN_TEST_f_i.
+	(RUN_TEST_f_i_tg): Take argument string.  Call new setup and
+	cleanup macros.
+	(RUN_TEST_LOOP_f_i_tg): Update call to RUN_TEST_f_i_tg.
+	(RUN_TEST_ff_i_tg): Take argument string.  Call new setup and
+	cleanup macros.
+	(RUN_TEST_LOOP_ff_i_tg): Update call to RUN_TEST_ff_i_tg.
+	(RUN_TEST_f_b): Take argument string.  Call new setup and cleanup
+	macros.
+	(RUN_TEST_LOOP_f_b): Update call to RUN_TEST_f_b.
+	(RUN_TEST_f_b_tg): Take argument string.  Call new setup and
+	cleanup macros.
+	(RUN_TEST_LOOP_f_b_tg): Update call to RUN_TEST_f_b_tg.
+	(RUN_TEST_f_l): Take argument string.  Call new setup and cleanup
+	macros.
+	(RUN_TEST_LOOP_f_l): Update call to RUN_TEST_f_l.
+	(RUN_TEST_f_L): Take argument string.  Call new setup and cleanup
+	macros.
+	(RUN_TEST_LOOP_f_L): Update call to RUN_TEST_f_L.
+	(RUN_TEST_fFF_11): Take argument string.  Call new setup and
+	cleanup macros.
+	(RUN_TEST_LOOP_fFF_11): Update call to RUN_TEST_fFF_11.
+
 2013-05-22  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
 
 	* sysdeps/unix/sysv/linux/bits/siginfo.h (siginfo_t): Add si_addr_lsb
diff --git a/math/gen-libm-test.pl b/math/gen-libm-test.pl
index e1a32e53c4..a6004a8e4d 100755
--- a/math/gen-libm-test.pl
+++ b/math/gen-libm-test.pl
@@ -158,17 +158,17 @@ sub show_exceptions {
 
 # Parse the arguments to TEST_x_y
 sub parse_args {
-  my ($file, $descr, $fct, $args) = @_;
-  my (@args, $str, $descr_args, $descr_res, @descr);
+  my ($file, $descr, $args) = @_;
+  my (@args, $descr_args, $descr_res, @descr);
   my ($current_arg, $cline, $i);
   my (@special);
-  my ($call);
+  my ($call_args);
 
   ($descr_args, $descr_res) = split /_/,$descr, 2;
 
   @args = split /,\s*/, $args;
 
-  $call = "$fct (";
+  $call_args = "";
 
   # Generate first the string that's shown to the user
   $current_arg = 1;
@@ -180,7 +180,7 @@ sub parse_args {
     }
     # FLOAT, int, long int, long long int
     if ($descr[$i] =~ /f|i|l|L/) {
-      $call .= $comma . &beautify ($args[$current_arg]);
+      $call_args .= $comma . &beautify ($args[$current_arg]);
       ++$current_arg;
       next;
     }
@@ -190,15 +190,13 @@ sub parse_args {
     }
     # complex
     if ($descr[$i] eq 'c') {
-      $call .= $comma . &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
+      $call_args .= $comma . &build_complex_beautify ($args[$current_arg], $args[$current_arg+1]);
       $current_arg += 2;
       next;
     }
 
     die ("$descr[$i] is unknown");
   }
-  $call .= ')';
-  $str = $call;
 
   # Result
   @descr = split //,$descr_res;
@@ -230,7 +228,7 @@ sub parse_args {
   # Put the C program line together
   # Reset some variables to start again
   $current_arg = 1;
-  $cline = "{ \"$str\"";
+  $cline = "{ \"$call_args\"";
   @descr = split //,$descr_args;
   for ($i=0; $i <= $#descr; $i++) {
     # FLOAT, int, long int, long long int
@@ -275,12 +273,10 @@ sub parse_args {
     ++$i;
     my ($extra_expected) = $_;
     my ($run_extra) = ($extra_expected ne "IGNORE" ? 1 : 0);
-    my ($str) = "$call extra output $i";
     if (!$run_extra) {
-      $str = "";
       $extra_expected = "0";
     }
-    $cline .= ", \"$str\", $run_extra, $extra_expected";
+    $cline .= ", $run_extra, $extra_expected";
   }
   print $file "    $cline },\n";
 }
@@ -289,7 +285,7 @@ sub parse_args {
 sub generate_testfile {
   my ($input, $output) = @_;
   my ($lasttext);
-  my (@args, $i, $str, $thisfct);
+  my (@args, $i);
 
   open INPUT, $input or die ("Can't open $input: $!");
   open OUTPUT, ">$output" or die ("Can't open $output: $!");
@@ -302,17 +298,18 @@ sub generate_testfile {
       my ($descr, $args);
       chop;
       ($descr, $args) = ($_ =~ /TEST_(\w+)\s*\((.*)\)/);
-      &parse_args (\*OUTPUT, $descr, $thisfct, $args);
+      &parse_args (\*OUTPUT, $descr, $args);
       next;
     }
     # START_DATA (function)
     if (/START_DATA/) {
-      ($thisfct) = ($_ =~ /START_DATA\s*\((.*)\)/);
       next;
     }
     # START (function)
     if (/START/) {
+      my ($thisfct);
       ($thisfct) = ($_ =~ /START\s*\((.*)\)/);
+      print OUTPUT "  const char *this_func = \"$thisfct\";\n";
       print OUTPUT "  init_max_error ();\n";
       next;
     }
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 3374ce99c0..5a02399460 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -920,21 +920,21 @@ check_longlong (const char *test_name, long long int computed,
 /* Structures for each kind of test.  */
 struct test_f_f_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg;
   FLOAT expected;
   int exceptions;
 };
 struct test_ff_f_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg1, arg2;
   FLOAT expected;
   int exceptions;
 };
 struct test_ff_f_data_nexttoward
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg1;
   long double arg2;
   FLOAT expected;
@@ -942,7 +942,7 @@ struct test_ff_f_data_nexttoward
 };
 struct test_fi_f_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg1;
   int arg2;
   FLOAT expected;
@@ -950,7 +950,7 @@ struct test_fi_f_data
 };
 struct test_fl_f_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg1;
   long int arg2;
   FLOAT expected;
@@ -958,7 +958,7 @@ struct test_fl_f_data
 };
 struct test_if_f_data
 {
-  const char *test_name;
+  const char *arg_str;
   int arg1;
   FLOAT arg2;
   FLOAT expected;
@@ -966,14 +966,14 @@ struct test_if_f_data
 };
 struct test_fff_f_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg1, arg2, arg3;
   FLOAT expected;
   int exceptions;
 };
 struct test_c_f_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT argr, argc;
   FLOAT expected;
   int exceptions;
@@ -981,44 +981,41 @@ struct test_c_f_data
 /* Used for both RUN_TEST_LOOP_f_f1 and RUN_TEST_LOOP_fI_f1.  */
 struct test_f_f1_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg;
   FLOAT expected;
   int exceptions;
-  const char *extra_name;
   int extra_test;
   int extra_expected;
 };
 struct test_fF_f1_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg;
   FLOAT expected;
   int exceptions;
-  const char *extra_name;
   int extra_test;
   FLOAT extra_expected;
 };
 struct test_ffI_f1_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg1, arg2;
   FLOAT expected;
   int exceptions;
-  const char *extra_name;
   int extra_test;
   int extra_expected;
 };
 struct test_c_c_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT argr, argc;
   FLOAT expr, expc;
   int exceptions;
 };
 struct test_cc_c_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg1r, arg1c, arg2r, arg2c;
   FLOAT expr, expc;
   int exceptions;
@@ -1027,41 +1024,39 @@ struct test_cc_c_data
    RUN_TEST_LOOP_f_b and RUN_TEST_LOOP_f_b_tg.  */
 struct test_f_i_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg;
   int expected;
   int exceptions;
 };
 struct test_ff_i_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg1, arg2;
   int expected;
   int exceptions;
 };
 struct test_f_l_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg;
   long int expected;
   int exceptions;
 };
 struct test_f_L_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg;
   long long int expected;
   int exceptions;
 };
 struct test_fFF_11_data
 {
-  const char *test_name;
+  const char *arg_str;
   FLOAT arg;
   int exceptions;
-  const char *extra1_name;
   int extra1_test;
   FLOAT extra1_expected;
-  const char *extra2_name;
   int extra2_test;
   FLOAT extra2_expected;
 };
@@ -1090,26 +1085,59 @@ struct test_fFF_11_data
 #define ROUND_RESTORE_FE_UPWARD			\
   fesetround (save_round_mode)
 
+/* Common setup for an individual test.  */
+#define COMMON_TEST_SETUP(ARG_STR)					\
+  char *test_name;							\
+  if (asprintf (&test_name, "%s (%s)", this_func, (ARG_STR)) == -1)	\
+    abort ()
+
+/* Setup for a test with an extra output.  */
+#define EXTRA_OUTPUT_TEST_SETUP(ARG_STR, N)			\
+  char *extra##N##_name;					\
+  if (asprintf (&extra##N##_name, "%s (%s) extra output " #N,	\
+		this_func, (ARG_STR)) == -1)			\
+    abort ()
+
+/* Common cleanup after an individual test.  */
+#define COMMON_TEST_CLEANUP			\
+  free (test_name)
+
+/* Cleanup for a test with an extra output.  */
+#define EXTRA_OUTPUT_TEST_CLEANUP(N)		\
+  free (extra##N##_name)
+
 /* Run an individual test, including any required setup and checking
    of results, or loop over all tests in an array.  */
-#define RUN_TEST_f_f(TEST_NAME, FUNC_NAME, ARG, EXPECTED,	\
+#define RUN_TEST_f_f(ARG_STR, FUNC_NAME, ARG, EXPECTED,	\
 		     EXCEPTIONS)				\
-  check_float (TEST_NAME, FUNC (FUNC_NAME) (ARG), EXPECTED,	\
-	       EXCEPTIONS)
+  do								\
+    {								\
+      COMMON_TEST_SETUP (ARG_STR);				\
+      check_float (test_name, FUNC (FUNC_NAME) (ARG), EXPECTED,	\
+		   EXCEPTIONS);					\
+      COMMON_TEST_CLEANUP;					\
+    }								\
+  while (0)
 #define RUN_TEST_LOOP_f_f(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_f_f ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
+      RUN_TEST_f_f ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
 		    (ARRAY)[i].expected, (ARRAY)[i].exceptions);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_2_f(TEST_NAME, FUNC_NAME, ARG1, ARG2, EXPECTED,	\
+#define RUN_TEST_2_f(ARG_STR, FUNC_NAME, ARG1, ARG2, EXPECTED,		\
 		     EXCEPTIONS)					\
-  check_float (TEST_NAME, FUNC (FUNC_NAME) (ARG1, ARG2), EXPECTED,	\
-	       EXCEPTIONS)
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_float (test_name, FUNC (FUNC_NAME) (ARG1, ARG2), EXPECTED,	\
+		   EXCEPTIONS);						\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_2_f(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_2_f ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg1,	\
+      RUN_TEST_2_f ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg1,	\
 		    (ARRAY)[i].arg2, (ARRAY)[i].expected,		\
 		    (ARRAY)[i].exceptions);				\
   ROUND_RESTORE_ ## ROUNDING_MODE
@@ -1121,230 +1149,314 @@ struct test_fFF_11_data
 #define RUN_TEST_LOOP_fl_f RUN_TEST_LOOP_2_f
 #define RUN_TEST_if_f RUN_TEST_2_f
 #define RUN_TEST_LOOP_if_f RUN_TEST_LOOP_2_f
-#define RUN_TEST_fff_f(TEST_NAME, FUNC_NAME, ARG1, ARG2, ARG3,	\
-		       EXPECTED, EXCEPTIONS)			\
-  check_float (TEST_NAME, FUNC (FUNC_NAME) (ARG1, ARG2, ARG3),	\
-	       EXPECTED, EXCEPTIONS)
+#define RUN_TEST_fff_f(ARG_STR, FUNC_NAME, ARG1, ARG2, ARG3,		\
+		       EXPECTED, EXCEPTIONS)				\
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_float (test_name, FUNC (FUNC_NAME) (ARG1, ARG2, ARG3),	\
+		   EXPECTED, EXCEPTIONS);				\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_fff_f(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_fff_f ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg1,	\
+      RUN_TEST_fff_f ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg1,	\
 		      (ARRAY)[i].arg2, (ARRAY)[i].arg3,			\
 		      (ARRAY)[i].expected, (ARRAY)[i].exceptions);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_c_f(TEST_NAME, FUNC_NAME, ARG1, ARG2, EXPECTED,	\
+#define RUN_TEST_c_f(ARG_STR, FUNC_NAME, ARG1, ARG2, EXPECTED,		\
 		     EXCEPTIONS)					\
-  check_float (TEST_NAME,						\
-	       FUNC (FUNC_NAME) (BUILD_COMPLEX (ARG1, ARG2)),		\
-	       EXPECTED, EXCEPTIONS)
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_float (test_name,						\
+		   FUNC (FUNC_NAME) (BUILD_COMPLEX (ARG1, ARG2)),	\
+		   EXPECTED, EXCEPTIONS);				\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_c_f(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_c_f ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].argr,	\
+      RUN_TEST_c_f ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].argr,	\
 		    (ARRAY)[i].argc, (ARRAY)[i].expected,		\
 		    (ARRAY)[i].exceptions);				\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_f_f1(TEST_NAME, FUNC_NAME, ARG, EXPECTED,	\
-		      EXCEPTIONS,				\
-		      EXTRA_NAME, EXTRA_VAR, EXTRA_TEST,	\
-		      EXTRA_EXPECTED)		\
+#define RUN_TEST_f_f1(ARG_STR, FUNC_NAME, ARG, EXPECTED,	\
+		      EXCEPTIONS, EXTRA_VAR, EXTRA_TEST,	\
+		      EXTRA_EXPECTED)				\
   do								\
     {								\
+      COMMON_TEST_SETUP (ARG_STR);				\
       (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0;		\
-      check_float (TEST_NAME, FUNC (FUNC_NAME) (ARG), EXPECTED,	\
+      check_float (test_name, FUNC (FUNC_NAME) (ARG), EXPECTED,	\
 		   EXCEPTIONS);					\
+      EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1);			\
       if (EXTRA_TEST)						\
-	check_int (EXTRA_NAME, EXTRA_VAR, EXTRA_EXPECTED, 0);	\
+	check_int (extra1_name, EXTRA_VAR, EXTRA_EXPECTED, 0);	\
+      EXTRA_OUTPUT_TEST_CLEANUP (1);				\
+      COMMON_TEST_CLEANUP;					\
     }								\
   while (0)
 #define RUN_TEST_LOOP_f_f1(FUNC_NAME, ARRAY, ROUNDING_MODE, EXTRA_VAR)	\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_f_f1 ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
-		     (ARRAY)[i].expected,				\
-		     (ARRAY)[i].exceptions, (ARRAY)[i].extra_name,	\
+      RUN_TEST_f_f1 ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
+		     (ARRAY)[i].expected, (ARRAY)[i].exceptions,	\
 		     EXTRA_VAR, (ARRAY)[i].extra_test,			\
 		     (ARRAY)[i].extra_expected);			\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_fF_f1(TEST_NAME, FUNC_NAME, ARG, EXPECTED,		\
-		       EXCEPTIONS,					\
-		       EXTRA_NAME, EXTRA_VAR, EXTRA_TEST,		\
+#define RUN_TEST_fF_f1(ARG_STR, FUNC_NAME, ARG, EXPECTED,		\
+		       EXCEPTIONS, EXTRA_VAR, EXTRA_TEST,		\
 		       EXTRA_EXPECTED)					\
   do									\
     {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
       (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0;			\
-      check_float (TEST_NAME, FUNC (FUNC_NAME) (ARG, &(EXTRA_VAR)),	\
+      check_float (test_name, FUNC (FUNC_NAME) (ARG, &(EXTRA_VAR)),	\
 		   EXPECTED, EXCEPTIONS);				\
+      EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1);				\
       if (EXTRA_TEST)							\
-	check_float (EXTRA_NAME, EXTRA_VAR, EXTRA_EXPECTED, 0);		\
+	check_float (extra1_name, EXTRA_VAR, EXTRA_EXPECTED, 0);	\
+      EXTRA_OUTPUT_TEST_CLEANUP (1);					\
+      COMMON_TEST_CLEANUP;						\
     }									\
   while (0)
 #define RUN_TEST_LOOP_fF_f1(FUNC_NAME, ARRAY, ROUNDING_MODE, EXTRA_VAR)	\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_fF_f1 ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
-		      (ARRAY)[i].expected,				\
-		      (ARRAY)[i].exceptions, (ARRAY)[i].extra_name,	\
+      RUN_TEST_fF_f1 ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
+		      (ARRAY)[i].expected, (ARRAY)[i].exceptions,	\
 		      EXTRA_VAR, (ARRAY)[i].extra_test,			\
 		      (ARRAY)[i].extra_expected);			\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_fI_f1(TEST_NAME, FUNC_NAME, ARG, EXPECTED,		\
-		       EXCEPTIONS,					\
-		       EXTRA_NAME, EXTRA_VAR, EXTRA_TEST,		\
+#define RUN_TEST_fI_f1(ARG_STR, FUNC_NAME, ARG, EXPECTED,		\
+		       EXCEPTIONS, EXTRA_VAR, EXTRA_TEST,		\
 		       EXTRA_EXPECTED)					\
   do									\
     {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
       (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0;			\
-      check_float (TEST_NAME, FUNC (FUNC_NAME) (ARG, &(EXTRA_VAR)),	\
+      check_float (test_name, FUNC (FUNC_NAME) (ARG, &(EXTRA_VAR)),	\
 		   EXPECTED, EXCEPTIONS);				\
+      EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1);				\
       if (EXTRA_TEST)							\
-	check_int (EXTRA_NAME, EXTRA_VAR, EXTRA_EXPECTED, 0);		\
+	check_int (extra1_name, EXTRA_VAR, EXTRA_EXPECTED, 0);		\
+      EXTRA_OUTPUT_TEST_CLEANUP (1);					\
+      COMMON_TEST_CLEANUP;						\
     }									\
   while (0)
 #define RUN_TEST_LOOP_fI_f1(FUNC_NAME, ARRAY, ROUNDING_MODE, EXTRA_VAR)	\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_fI_f1 ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
-		      (ARRAY)[i].expected,				\
-		      (ARRAY)[i].exceptions, (ARRAY)[i].extra_name,	\
+      RUN_TEST_fI_f1 ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
+		      (ARRAY)[i].expected, (ARRAY)[i].exceptions,	\
 		      EXTRA_VAR, (ARRAY)[i].extra_test,			\
 		      (ARRAY)[i].extra_expected);			\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_ffI_f1(TEST_NAME, FUNC_NAME, ARG1, ARG2, EXPECTED,	\
-			EXCEPTIONS,					\
-			EXTRA_NAME, EXTRA_VAR, EXTRA_TEST,		\
+#define RUN_TEST_ffI_f1(ARG_STR, FUNC_NAME, ARG1, ARG2, EXPECTED,	\
+			EXCEPTIONS, EXTRA_VAR, EXTRA_TEST,		\
 			EXTRA_EXPECTED)					\
   do									\
     {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
       (EXTRA_VAR) = (EXTRA_EXPECTED) == 0 ? 1 : 0;			\
-      check_float (TEST_NAME,						\
+      check_float (test_name,						\
 		   FUNC (FUNC_NAME) (ARG1, ARG2, &(EXTRA_VAR)),		\
 		   EXPECTED, EXCEPTIONS);				\
+      EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1);				\
       if (EXTRA_TEST)							\
-	check_int (EXTRA_NAME, EXTRA_VAR, EXTRA_EXPECTED, 0);		\
+	check_int (extra1_name, EXTRA_VAR, EXTRA_EXPECTED, 0);		\
+      EXTRA_OUTPUT_TEST_CLEANUP (1);					\
+      COMMON_TEST_CLEANUP;						\
     }									\
   while (0)
 #define RUN_TEST_LOOP_ffI_f1(FUNC_NAME, ARRAY, ROUNDING_MODE,		\
 			     EXTRA_VAR)					\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_ffI_f1 ((ARRAY)[i].test_name, FUNC_NAME,			\
+      RUN_TEST_ffI_f1 ((ARRAY)[i].arg_str, FUNC_NAME,			\
 		       (ARRAY)[i].arg1, (ARRAY)[i].arg2,		\
-		       (ARRAY)[i].expected,				\
-		       (ARRAY)[i].exceptions, (ARRAY)[i].extra_name,	\
+		       (ARRAY)[i].expected, (ARRAY)[i].exceptions,	\
 		       EXTRA_VAR, (ARRAY)[i].extra_test,		\
 		       (ARRAY)[i].extra_expected);			\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_c_c(TEST_NAME, FUNC_NAME, ARGR, ARGC, EXPR, EXPC,	\
+#define RUN_TEST_c_c(ARG_STR, FUNC_NAME, ARGR, ARGC, EXPR, EXPC,	\
 		     EXCEPTIONS)					\
-  check_complex (TEST_NAME,						\
-		 FUNC (FUNC_NAME) (BUILD_COMPLEX (ARGR, ARGC)),		\
-		 BUILD_COMPLEX (EXPR, EXPC), EXCEPTIONS)
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_complex (test_name,						\
+		     FUNC (FUNC_NAME) (BUILD_COMPLEX (ARGR, ARGC)),	\
+		     BUILD_COMPLEX (EXPR, EXPC), EXCEPTIONS);		\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_c_c(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_c_c ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].argr,	\
+      RUN_TEST_c_c ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].argr,	\
 		    (ARRAY)[i].argc, (ARRAY)[i].expr, (ARRAY)[i].expc,	\
 		    (ARRAY)[i].exceptions);				\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_cc_c(TEST_NAME, FUNC_NAME, ARG1R, ARG1C, ARG2R, ARG2C,	\
+#define RUN_TEST_cc_c(ARG_STR, FUNC_NAME, ARG1R, ARG1C, ARG2R, ARG2C,	\
 		      EXPR, EXPC, EXCEPTIONS)				\
-  check_complex (TEST_NAME,						\
-		 FUNC (FUNC_NAME) (BUILD_COMPLEX (ARG1R, ARG1C),	\
-				   BUILD_COMPLEX (ARG2R, ARG2C)),	\
-		 BUILD_COMPLEX (EXPR, EXPC), EXCEPTIONS)
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_complex (test_name,						\
+		     FUNC (FUNC_NAME) (BUILD_COMPLEX (ARG1R, ARG1C),	\
+				       BUILD_COMPLEX (ARG2R, ARG2C)),	\
+		     BUILD_COMPLEX (EXPR, EXPC), EXCEPTIONS);		\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_cc_c(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_cc_c ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg1r,	\
+      RUN_TEST_cc_c ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg1r,	\
 		     (ARRAY)[i].arg1c, (ARRAY)[i].arg2r,		\
 		     (ARRAY)[i].arg2c, (ARRAY)[i].expr,			\
 		     (ARRAY)[i].expc, (ARRAY)[i].exceptions);		\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_f_i(TEST_NAME, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS)	\
-  check_int (TEST_NAME, FUNC (FUNC_NAME) (ARG), EXPECTED, EXCEPTIONS)
+#define RUN_TEST_f_i(ARG_STR, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS)	\
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_int (test_name, FUNC (FUNC_NAME) (ARG), EXPECTED,		\
+		 EXCEPTIONS);						\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_f_i(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_f_i ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
+      RUN_TEST_f_i ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
 		    (ARRAY)[i].expected, (ARRAY)[i].exceptions);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_f_i_tg(TEST_NAME, FUNC_NAME, ARG, EXPECTED,	\
-			EXCEPTIONS)				\
-  check_int (TEST_NAME, FUNC_NAME (ARG), EXPECTED, EXCEPTIONS)
+#define RUN_TEST_f_i_tg(ARG_STR, FUNC_NAME, ARG, EXPECTED,		\
+			EXCEPTIONS)					\
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_int (test_name, FUNC_NAME (ARG), EXPECTED, EXCEPTIONS);	\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_f_i_tg(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_f_i_tg ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
+      RUN_TEST_f_i_tg ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
 		       (ARRAY)[i].expected, (ARRAY)[i].exceptions);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_ff_i_tg(TEST_NAME, FUNC_NAME, ARG1, ARG2, EXPECTED,	\
+#define RUN_TEST_ff_i_tg(ARG_STR, FUNC_NAME, ARG1, ARG2, EXPECTED,	\
 			 EXCEPTIONS)					\
-  check_int (TEST_NAME, FUNC_NAME (ARG1, ARG2), EXPECTED, EXCEPTIONS)
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_int (test_name, FUNC_NAME (ARG1, ARG2), EXPECTED,		\
+		 EXCEPTIONS);						\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_ff_i_tg(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_ff_i_tg ((ARRAY)[i].test_name, FUNC_NAME,		\
+      RUN_TEST_ff_i_tg ((ARRAY)[i].arg_str, FUNC_NAME,		\
 			(ARRAY)[i].arg1, (ARRAY)[i].arg2,		\
 			(ARRAY)[i].expected, (ARRAY)[i].exceptions);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_f_b(TEST_NAME, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS)	\
-  check_bool (TEST_NAME, FUNC (FUNC_NAME) (ARG), EXPECTED, EXCEPTIONS)
+#define RUN_TEST_f_b(ARG_STR, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS)	\
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_bool (test_name, FUNC (FUNC_NAME) (ARG), EXPECTED,		\
+		  EXCEPTIONS);						\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_f_b(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_f_b ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
+      RUN_TEST_f_b ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
 		    (ARRAY)[i].expected, (ARRAY)[i].exceptions);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_f_b_tg(TEST_NAME, FUNC_NAME, ARG, EXPECTED,	\
-			EXCEPTIONS)				\
-  check_bool (TEST_NAME, FUNC_NAME (ARG), EXPECTED, EXCEPTIONS)
+#define RUN_TEST_f_b_tg(ARG_STR, FUNC_NAME, ARG, EXPECTED,		\
+			EXCEPTIONS)					\
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_bool (test_name, FUNC_NAME (ARG), EXPECTED, EXCEPTIONS);	\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_f_b_tg(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_f_b_tg ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
+      RUN_TEST_f_b_tg ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
 		       (ARRAY)[i].expected, (ARRAY)[i].exceptions);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_f_l(TEST_NAME, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS)	\
-  check_long (TEST_NAME, FUNC (FUNC_NAME) (ARG), EXPECTED, EXCEPTIONS)
+#define RUN_TEST_f_l(ARG_STR, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS)	\
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_long (test_name, FUNC (FUNC_NAME) (ARG), EXPECTED,		\
+		  EXCEPTIONS);						\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_f_l(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_f_l ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
+      RUN_TEST_f_l ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
 		    (ARRAY)[i].expected, (ARRAY)[i].exceptions);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_f_L(TEST_NAME, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS)	\
-  check_longlong (TEST_NAME, FUNC (FUNC_NAME) (ARG), EXPECTED,		\
-		  EXCEPTIONS)
+#define RUN_TEST_f_L(ARG_STR, FUNC_NAME, ARG, EXPECTED, EXCEPTIONS)	\
+  do									\
+    {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
+      check_longlong (test_name, FUNC (FUNC_NAME) (ARG), EXPECTED,	\
+		      EXCEPTIONS);					\
+      COMMON_TEST_CLEANUP;						\
+    }									\
+  while (0)
 #define RUN_TEST_LOOP_f_L(FUNC_NAME, ARRAY, ROUNDING_MODE)		\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_f_L ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
+      RUN_TEST_f_L ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
 		    (ARRAY)[i].expected, (ARRAY)[i].exceptions);	\
   ROUND_RESTORE_ ## ROUNDING_MODE
-#define RUN_TEST_fFF_11(TEST_NAME, FUNC_NAME, ARG, EXCEPTIONS,		\
-			EXTRA1_NAME, EXTRA1_VAR, EXTRA1_TEST,		\
-			EXTRA1_EXPECTED, EXTRA2_NAME, EXTRA2_VAR,	\
+#define RUN_TEST_fFF_11(ARG_STR, FUNC_NAME, ARG, EXCEPTIONS,		\
+			EXTRA1_VAR, EXTRA1_TEST,			\
+			EXTRA1_EXPECTED, EXTRA2_VAR,			\
 			EXTRA2_TEST, EXTRA2_EXPECTED)			\
   do									\
     {									\
+      COMMON_TEST_SETUP (ARG_STR);					\
       FUNC (FUNC_NAME) (ARG, &(EXTRA1_VAR), &(EXTRA2_VAR));		\
+      EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 1);				\
       if (EXTRA1_TEST)							\
-	check_float (EXTRA1_NAME, EXTRA1_VAR, EXTRA1_EXPECTED,		\
+	check_float (extra1_name, EXTRA1_VAR, EXTRA1_EXPECTED,		\
 		     EXCEPTIONS);					\
+      EXTRA_OUTPUT_TEST_CLEANUP (1);					\
+      EXTRA_OUTPUT_TEST_SETUP (ARG_STR, 2);				\
       if (EXTRA2_TEST)							\
-	check_float (EXTRA2_NAME, EXTRA2_VAR, EXTRA2_EXPECTED, 0);	\
+	check_float (extra2_name, EXTRA2_VAR, EXTRA2_EXPECTED, 0);	\
+      EXTRA_OUTPUT_TEST_CLEANUP (2);					\
+      COMMON_TEST_CLEANUP;						\
     }									\
   while (0)
 #define RUN_TEST_LOOP_fFF_11(FUNC_NAME, ARRAY, ROUNDING_MODE,		\
 			     EXTRA1_VAR, EXTRA2_VAR)			\
   IF_ROUND_INIT_ ## ROUNDING_MODE					\
     for (size_t i = 0; i < sizeof (ARRAY) / sizeof (ARRAY)[0]; i++)	\
-      RUN_TEST_fFF_11 ((ARRAY)[i].test_name, FUNC_NAME, (ARRAY)[i].arg,	\
-		       (ARRAY)[i].exceptions, (ARRAY)[i].extra1_name,	\
+      RUN_TEST_fFF_11 ((ARRAY)[i].arg_str, FUNC_NAME, (ARRAY)[i].arg,	\
+		       (ARRAY)[i].exceptions,				\
 		       EXTRA1_VAR, (ARRAY)[i].extra1_test,		\
 		       (ARRAY)[i].extra1_expected,			\
-		       (ARRAY)[i].extra2_name, EXTRA2_VAR,		\
+		       EXTRA2_VAR,					\
 		       (ARRAY)[i].extra2_test,				\
 		       (ARRAY)[i].extra2_expected);			\
   ROUND_RESTORE_ ## ROUNDING_MODE