about summary refs log tree commit diff
path: root/math/libm-test.inc
diff options
context:
space:
mode:
authorCarlos O'Donell <carlos@redhat.com>2013-04-06 16:22:47 -0400
committerCarlos O'Donell <carlos@redhat.com>2013-04-06 16:22:47 -0400
commit26510bdda1ab999041292737d1fad6aa25f9e06d (patch)
tree71297531eeb946e15b07748b7ad4fab6de816228 /math/libm-test.inc
parenta01f19c8fb12eef419d4112879bc715e2ab6f6d7 (diff)
downloadglibc-26510bdda1ab999041292737d1fad6aa25f9e06d.tar.gz
glibc-26510bdda1ab999041292737d1fad6aa25f9e06d.tar.xz
glibc-26510bdda1ab999041292737d1fad6aa25f9e06d.zip
New Makefile target `regen-ulps'.
The wiki "Regeneration" page has this to say about update ULPs.

"The libm-test-ulps files are semiautomatically updated. To
update an ulps baseline, run each of the failing tests (test-float,
 test-double, etc.) with -u; this will generate a file called ULPs;
concatenate each of those files with the existing libm-test-ulps
file, after removing any entries for particularly huge numbers of
ulps that you do not want to mark as expected. Then run
gen-libm-test.pl -n -u FILE where FILE is the concatenated file
produced in the previous step. This generates a file called
NewUlps which is the new sorted version of libm-test-ulps."

The same information is listed in math/README.libm-test, and is a
lot of manual work that you often want to run over-and-over again
while working on a particular test.

The `regen-ulps' convenience target does this automatically for
developers.

We strictly assume the source tree is readonly and add a
new --output-dir option to libm-test.inc to allow for writing
out ULPs to $(objpfx).

When run the new target does the following:
* Starts with the baseline ULPs file.
* Runs each of the libm math tests with -u.
* Adds new changes seen with -u to the baseline.
* Sorts and prepares the test output with gen-libm-test.pl.
* Leaves math/NewUlps in your build tree to copy to your source
  tree, cleanup, and checkin.

The math test documentation in math/README.libm-test is updated
document the new Makefile target.

---

2013-04-06  Carlos O'Donell  <carlos@redhat.com>

	* Makefile.in (regen-ulps): New target.
	* math/Makefile [ifneq (no,$(PERL)]: Declare regen-ulps with .PHONY.
	[ifneq (no,$(PERL)] (run-regen-ulps): New variable.
	[ifneq (no,$(PERL)] (regen-ulps): New target.
	[ifeq (no,$(PERL)] (regen-ulps): New target.
	* math/libm-test.inc (ulps_file_name): Define.
	(output_dir): New variable.
	(options): Add "output-dir" option.
	(parse_opt): Handle 'o' case.
	(main): If output_dir is non-NULL use it as a prefix
	otherwise use "".
	* math/README.libm-test: Update `How can I generate "libm-test-ulps"?'
Diffstat (limited to 'math/libm-test.inc')
-rw-r--r--math/libm-test.inc29
1 files changed, 26 insertions, 3 deletions
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 92fa6a201a..78d21074a6 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -210,8 +210,10 @@
 #define M_PI_LOG10El		M_PIl * M_LOG10El
 #define M_SQRT_2_2		0.70710678118654752440084436210484903L /* sqrt (2) / 2 */
 
-static FILE *ulps_file;	/* File to document difference.  */
-static int output_ulps;	/* Should ulps printed?  */
+#define ulps_file_name "ULPs"	/* Name of the ULPs file.  */
+static FILE *ulps_file;		/* File to document difference.  */
+static int output_ulps;		/* Should ulps printed?  */
+static char *output_dir;	/* Directory where generated files will be written.  */
 
 static int noErrors;	/* number of errors */
 static int noTests;	/* number of tests (without testing exceptions) */
@@ -12985,6 +12987,8 @@ static const struct argp_option options[] =
     "Don't output results of functions invocations"},
   { "ignore-max-ulp", 'i', "yes/no", 0,
     "Ignore given maximal errors"},
+  { "output-dir", 'o', "DIR", 0,
+    "Directory where generated files will be placed"},
   { NULL, 0, NULL, 0, NULL }
 };
 
@@ -13016,6 +13020,13 @@ parse_opt (int key, char *arg, struct argp_state *state)
       else if (strcmp (arg, "no") == 0)
 	ignore_max_ulp = 0;
       break;
+    case 'o':
+      output_dir = (char *) malloc (strlen (arg) + 1);
+      if (output_dir != NULL)
+	strcpy (output_dir, arg);
+      else
+        return errno;
+      break;
     case 'p':
       output_points = 0;
       break;
@@ -13065,11 +13076,14 @@ main (int argc, char **argv)
 {
 
   int remaining;
+  char *ulps_file_path;
+  size_t dir_len = 0;
 
   verbose = 1;
   output_ulps = 0;
   output_max_error = 1;
   output_points = 1;
+  output_dir = NULL;
   /* XXX set to 0 for releases.  */
   ignore_max_ulp = 0;
 
@@ -13085,7 +13099,16 @@ main (int argc, char **argv)
 
   if (output_ulps)
     {
-      ulps_file = fopen ("ULPs", "a");
+      if (output_dir != NULL)
+	dir_len = strlen (output_dir);
+      ulps_file_path = (char *) malloc (dir_len + strlen (ulps_file_name) + 1);
+      if (ulps_file_path == NULL)
+        {
+	  perror ("can't allocate path for `ULPs' file: ");
+	  exit (1);
+        }
+      sprintf (ulps_file_path, "%s%s", output_dir == NULL ? "" : output_dir, ulps_file_name);
+      ulps_file = fopen (ulps_file_path, "a");
       if (ulps_file == NULL)
 	{
 	  perror ("can't open file `ULPs' for writing: ");