]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Rework gen-libm-test.pl input/output handling.
authorJoseph Myers <joseph@codesourcery.com>
Mon, 6 Feb 2017 18:20:15 +0000 (18:20 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Mon, 6 Feb 2017 18:21:06 +0000 (18:21 +0000)
This patch reworks how input and output files are specified for
gen-libm-test.pl.

Previously, the script had names of various inputs and outputs
hardcoded, with a -o option to specify an output directory.  This
patch replaces this with all inputs and outputs being specified
explicitly as the arguments of options passed to the script.  Outputs
are only generated if the relevant option is passed, and only the
processing required for the indicated outputs is done.  The Makefile
is made to pass options for generating libm-test-ulps.h in a separate
invocation of gen-libm-test.pl from that generating libm-test.c.

This is all in preparation for splitting up libm-test.inc and
auto-libm-test-out and running tests separately for each function,
when gen-libm-test.pl will be run separately for each function to
generate the .c file but only once to generate libm-test-ulps.h (and
those runs will be able to be in parallel).

Tested for x86_64.  The generated libm-test.c and libm-test-ulps.h are
identical before and after the patch.  Also tested the "make
regen-ulps" case.

* math/gen-libm-test.pl ($output_dir): Remove variable.
($srcdir): Likewise.
($opt_a): New variable.
($opt_c): Likewise.
($opt_C): Likewise.
($opt_H): Likewise.
(-n): Make option take argument and use it as NewUlps output.
(-a): New option.  Use its argument for auto-libm-test-out input.
(-c): New option.  Use its argument for libm-test.inc input.
(-C): New option.  Use its argument for libm-test.c output.
(-H): New option.  Use its argument for libm-test-ulps.h output.
(top level): Only process inputs needed to generate outputs
specified by command-line options.  Only generate outputs
specified by command-line options.
* math/README.libm-test: Update example gen-libm-test.pl command.
* math/Makefile ($(objpfx)libm-test.stmp): Update gen-libm-test.pl
commands.
(regen-ulps): Likewise.

ChangeLog
math/Makefile
math/README.libm-test
math/gen-libm-test.pl

index d058211edb081fb4975c666d9b7c02c0d94f2e52..d5516f0e7917eaa3e80a4345c65626cf42efd7dd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2017-02-06  Joseph Myers  <joseph@codesourcery.com>
+
+       * math/gen-libm-test.pl ($output_dir): Remove variable.
+       ($srcdir): Likewise.
+       ($opt_a): New variable.
+       ($opt_c): Likewise.
+       ($opt_C): Likewise.
+       ($opt_H): Likewise.
+       (-n): Make option take argument and use it as NewUlps output.
+       (-a): New option.  Use its argument for auto-libm-test-out input.
+       (-c): New option.  Use its argument for libm-test.inc input.
+       (-C): New option.  Use its argument for libm-test.c output.
+       (-H): New option.  Use its argument for libm-test-ulps.h output.
+       (top level): Only process inputs needed to generate outputs
+       specified by command-line options.  Only generate outputs
+       specified by command-line options.
+       * math/README.libm-test: Update example gen-libm-test.pl command.
+       * math/Makefile ($(objpfx)libm-test.stmp): Update gen-libm-test.pl
+       commands.
+       (regen-ulps): Likewise.
+
 2017-02-06  Wilco Dijkstra  <wdijkstr@arm.com>
 
        * hurd/path-lookup.c (file_name_path_scan): Rename index to strchr.
index dd3b05ab48e173bca35edee3e6cc556cfd90eff1..bbee8f3c58720879238aff16aad3eb87ffc0ffb5 100644 (file)
@@ -217,7 +217,9 @@ $(addprefix $(objpfx), $(libm-tests-generated)): $(objpfx)libm-test.stmp
 $(objpfx)libm-test.stmp: $(ulps-file) libm-test.inc gen-libm-test.pl \
                         gen-libm-have-vector-test.sh auto-libm-test-out
        $(make-target-directory)
-       $(PERL) gen-libm-test.pl -u $< -o "$(objpfx)"
+       $(PERL) gen-libm-test.pl -u $< -H "$(objpfx)libm-test-ulps.h"
+       $(PERL) gen-libm-test.pl -c libm-test.inc -a auto-libm-test-out \
+                                -C "$(objpfx)libm-test.c"
        $(SHELL) gen-libm-have-vector-test.sh > $(objpfx)libm-have-vector-test.h
        @echo > $@
 endif
@@ -353,7 +355,8 @@ regen-ulps: $(addprefix $(objpfx),$(libm-tests))
          cat $(objpfx)ULPs >> $(objpfx)libm-test-ulps; \
          rm $(objpfx)ULPs; \
        done; \
-       $(PERL) gen-libm-test.pl -o $(objpfx) -n -u $(objpfx)libm-test-ulps; \
+       $(PERL) gen-libm-test.pl -n $(objpfx)NewUlps \
+                                -u $(objpfx)libm-test-ulps; \
        echo "Automatic regeneration of ULPs complete."; \
        echo "Difference between the current baseline and the new baseline is:";\
        diff -urN $(ulps-file) $(objpfx)NewUlps; \
index 69e2d3f1b6a13790204106ef5678363cb088ada7..d0a528ee3496af7fd9754904653645e982ca210b 100644 (file)
@@ -81,7 +81,7 @@ generate the ULPs for all other formats, the tests will be appending the
 data to the "ULPs" file.  As final step run "gen-libm-test.pl" with the
 file as input and ask to generate a pretty printed output in the file
 "NewUlps":
-  gen-libm-test.pl -u ULPs -n
+  gen-libm-test.pl -u ULPs -n NewUlps
 Copy "NewUlps" to "libm-test-ulps" in the appropriate machine sysdep
 directory.
 
index a58194dfd61a9c0ab3568b5825601cb25f962d76..a931bc542f1ba2c162547d2569a8523b26546aae 100755 (executable)
@@ -40,7 +40,7 @@ use strict;
 use vars qw ($input $output $auto_input);
 use vars qw (%results);
 use vars qw (%beautify @all_floats %all_floats_pfx);
-use vars qw ($output_dir $ulps_file $srcdir);
+use vars qw ($ulps_file);
 use vars qw (%auto_tests);
 
 # all_floats is sorted and contains all recognised float types
@@ -73,38 +73,41 @@ use vars qw (%auto_tests);
 
 # get Options
 # Options:
+# a: auto-libm-test-out input file
+# c: .inc input file
 # u: ulps-file
+# n: new ulps file
+# C: libm-test.c output file
+# H: libm-test-ulps.h output file
 # h: help
-# o: output-directory
-# n: generate new ulps file
-use vars qw($opt_u $opt_h $opt_o $opt_n);
-getopts('u:o:nh');
+use vars qw($opt_a $opt_c $opt_u $opt_n $opt_C $opt_H $opt_h);
+getopts('a:c:u:n:C:H:h');
 
 $ulps_file = 'libm-test-ulps';
-$output_dir = '';
-($srcdir = $0) =~ s{[^/]*$}{};
 
 if ($opt_h) {
   print "Usage: gen-libm-test.pl [OPTIONS]\n";
   print " -h         print this help, then exit\n";
-  print " -o DIR     directory where generated files will be placed\n";
-  print " -n         only generate sorted file NewUlps from libm-test-ulps\n";
+  print " -a FILE    input file with automatically generated tests\n";
+  print " -c FILE    input file .inc file with tests\n";
   print " -u FILE    input file with ulps\n";
+  print " -n FILE    generate sorted file FILE from libm-test-ulps\n";
+  print " -C FILE    generate output C file FILE from libm-test.inc\n";
+  print " -H FILE    generate output ulps header FILE from libm-test-ulps\n";
   exit 0;
 }
 
 $ulps_file = $opt_u if ($opt_u);
-$output_dir = $opt_o if ($opt_o);
 
-$input = "libm-test.inc";
-$auto_input = "${srcdir}auto-libm-test-out";
-$output = "${output_dir}libm-test.c";
+$input = $opt_c if ($opt_c);
+$auto_input = $opt_a if ($opt_a);
+$output = $opt_C if ($opt_C);
 
-&parse_ulps ($ulps_file);
-&parse_auto_input ($auto_input);
-&generate_testfile ($input, $output) unless ($opt_n);
-&output_ulps ("${output_dir}libm-test-ulps.h", $ulps_file) unless ($opt_n);
-&print_ulps_file ("${output_dir}NewUlps") if ($opt_n);
+&parse_ulps ($ulps_file) if ($opt_H || $opt_n);
+&parse_auto_input ($auto_input) if ($opt_C);
+&generate_testfile ($input, $output) if ($opt_C);
+&output_ulps ($opt_H, $ulps_file) if ($opt_H);
+&print_ulps_file ($opt_n) if ($opt_n);
 
 # Return a nicer representation
 sub beautify {