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]

Split up rules for tests that compare output with baselines


This patch splits makefile rules that generate a file then run cmp to
check the contents of that file into separate rules to generate and
compare the file.  This simplifies making those tests generate PASS /
FAIL results, by removing the need to insert && between commands in
the test so that a $(evaluate-test) call is reached.  It also avoids
the oddity of the .out file being an intermediate file rather than the
final result generated, as noted for some of these tests in
<https://sourceware.org/ml/libc-alpha/2012-10/msg00894.html>.

In many cases, the rule to run the program was no longer needed
because the default rules for running test programs on the host to
generate a .out file sufficed.  (I'm not asserting the commands run
after this patch are *exactly* the same as before, simply that the
rules did nothing special that appeared deliberate or relevant to
anything about what the tests were testing.  In cases where the rules
redirected stderr as well as stdout, I left the existing rule's
redirection in place to avoid changing what gets compared with the
expected results.)

It's clear there is a lot in common between the various -cmp.out rules
and it might be possible in future to refactor them into more generic
support for the case of comparing test output against a baseline.
(Some baselines are *.exp, some *.expect, some directly embedded in
the makefiles, and nptl/tst-cleanupx0.expect appears unused.)  I
propose to leave this as a possible future cleanup on the wiki todo
list rather than implementing it as part of the present series of
cleanups.

Tested x86_64.

2014-02-13  Joseph Myers  <joseph@codesourcery.com>

	* elf/Makefile ($(objpfx)order.out): Remove rule.
	[$(run-built-tests) = yes] (tests): Depend on
	$(objpfx)order-cmp.out.
	($(objpfx)order-cmp.out): New rule.
	[$(run-built-tests) = yes] (tests): Depend on
	$(objpfx)tst-array1-cmp.out, $(objpfx)tst-array1-static-cmp.out,
	$(objpfx)tst-array2-cmp.out, $(objpfx)tst-array3-cmp.out,
	$(objpfx)tst-array4-cmp.out, $(objpfx)tst-array5-cmp.out and
	$(objpfx)tst-array5-static-cmp.out.
	($(objpfx)tst-array1.out): Remove rule.
	($(objpfx)tst-array1-cmp.out): New rule.
	($(objpfx)tst-array1-static.out): Remove rule.
	($(objpfx)tst-array1-static-cmp.out): New rule.
	($(objpfx)tst-array2.out): Remove rule.
	($(objpfx)tst-array2-cmp.out): New rule.
	($(objpfx)tst-array3.out): Remove rule.
	($(objpfx)tst-array3-cmp.out): New rule.
	($(objpfx)tst-array4.out): Remove rule.
	($(objpfx)tst-array4-cmp.out): New rule.
	($(objpfx)tst-array5.out): Remove rule.
	($(objpfx)tst-array5-cmp.out): New rule.
	($(objpfx)tst-array5-static.out): Remove rule.
	($(objpfx)tst-array5-static-cmp.out): New rule.
	[$(run-built-tests) = yes] (tests): Depend on
	$(objpfx)order2-cmp.out.
	($(objpfx)order2.out): Remove rule.
	($(objpfx)order2-cmp.out): New rule.
	($(objpfx)tst-initorder.out): Remove rule.
	[$(run-built-tests) = yes] (tests): Depend on
	$(objpfx)tst-initorder-cmp.out.
	($(objpfx)tst-initorder-cmp.out): New rule.
	($(objpfx)tst-initorder2.out): Remove rule.
	[$(run-built-tests) = yes] (tests): Depend on
	$(objpfx)tst-initorder2-cmp.out.
	($(objpfx)tst-initorder2-cmp.out): New rule.
	[$(run-built-tests) = yes] (tests): Depend on
	$(objpfx)tst-unused-dep-cmp.out.
	($(objpfx)tst-unused-dep-cmp.out): Do not run cmp.
	($(objpfx)tst-unused-dep-cmp.out): New rule.
	* stdio-common/Makefile [$(run-built-tests) = yes] (tests): Depend
	on $(objpfx)tst-setvbuf1-cmp.out.
	($(objpfx)tst-setvbuf1.out): Do not run cmp.
	($(objpfx)tst-setvbuf1-cmp.out): New rule.
	* string/Makefile [$(run-built-tests) = yes] (tests): Depend
	$(objpfx)tst-svc-cmp.out instead of $(objpfx)tst-svc.out.
	($(objpfx)tst-svc.out): Remove rule.
	($(objpfx)tst-svc-cmp.out): New rule.

nptl:
2014-02-13  Joseph Myers  <joseph@codesourcery.com>

	* Makefile ($(objpfx)tst-cleanup0.out): Do not run cmp.
	[$(run-built-tests) = yes] (tests): Depend on
	$(objpfx)tst-cleanup0-cmp.out.
	($(objpfx)tst-cleanup0-cmp.out): New rule.

diff --git a/elf/Makefile b/elf/Makefile
index a684b6b..6f4f2f8 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -637,10 +637,11 @@ $(objpfx)circlemod2a.so: $(objpfx)circlemod3a.so
 
 $(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
 
-$(objpfx)order.out: $(objpfx)order
-	$(test-program-prefix) \
-	  $(objpfx)order > $@
-	(echo "0123456789" | cmp $@ -) > /dev/null
+ifeq ($(run-built-tests),yes)
+tests: $(objpfx)order-cmp.out
+endif
+$(objpfx)order-cmp.out: $(objpfx)order.out
+	(echo "0123456789" | cmp $< -) > $@
 
 $(objpfx)vismain: $(addprefix $(objpfx),vismod1.so vismod2.so)
 $(objpfx)vismain.out: $(addprefix $(objpfx),vismod3.so)
@@ -848,38 +849,39 @@ endif
 LDFLAGS-tst-array2 = $(no-as-needed)
 LDFLAGS-tst-array5 = $(no-as-needed)
 
-$(objpfx)tst-array1.out: tst-array1.exp $(objpfx)tst-array1
-	$(test-program-cmd) > $@
-	cmp $@ tst-array1.exp > /dev/null
+ifeq ($(run-built-tests),yes)
+tests: $(objpfx)tst-array1-cmp.out $(objpfx)tst-array1-static-cmp.out \
+       $(objpfx)tst-array2-cmp.out $(objpfx)tst-array3-cmp.out \
+       $(objpfx)tst-array4-cmp.out $(objpfx)tst-array5-cmp.out \
+       $(objpfx)tst-array5-static-cmp.out
+endif
 
-$(objpfx)tst-array1-static.out: tst-array1.exp $(objpfx)tst-array1-static
-	$(test-program-cmd) > $@
-	cmp $@ tst-array1.exp > /dev/null
+$(objpfx)tst-array1-cmp.out: tst-array1.exp $(objpfx)tst-array1.out
+	cmp $^ > $@
+
+$(objpfx)tst-array1-static-cmp.out: tst-array1.exp \
+				    $(objpfx)tst-array1-static.out
+	cmp $^ > $@
 
 $(objpfx)tst-array2: $(objpfx)tst-array2dep.so
-$(objpfx)tst-array2.out: tst-array2.exp $(objpfx)tst-array2
-	$(test-program-cmd) > $@
-	cmp $@ tst-array2.exp > /dev/null
+$(objpfx)tst-array2-cmp.out: tst-array2.exp $(objpfx)tst-array2.out
+	cmp $^ > $@
 
-$(objpfx)tst-array3.out: tst-array1.exp $(objpfx)tst-array3
-	$(test-program-cmd) > $@
-	cmp $@ tst-array1.exp > /dev/null
+$(objpfx)tst-array3-cmp.out: tst-array1.exp $(objpfx)tst-array3.out
+	cmp $^ > $@
 
 $(objpfx)tst-array4: $(libdl)
-$(objpfx)tst-array4.out: tst-array4.exp $(objpfx)tst-array4 \
-			 $(objpfx)tst-array2dep.so
-	$(test-program-cmd) > $@
-	cmp $@ tst-array4.exp > /dev/null
+$(objpfx)tst-array4.out: $(objpfx)tst-array2dep.so
+$(objpfx)tst-array4-cmp.out: tst-array4.exp $(objpfx)tst-array4.out
+	cmp $^ > $@
 
 $(objpfx)tst-array5: $(objpfx)tst-array5dep.so
-$(objpfx)tst-array5.out: tst-array5.exp $(objpfx)tst-array5
-	$(test-program-cmd) > $@
-	cmp $@ tst-array5.exp > /dev/null
+$(objpfx)tst-array5-cmp.out: tst-array5.exp $(objpfx)tst-array5.out
+	cmp $^ > $@
 
-$(objpfx)tst-array5-static.out: tst-array5-static.exp \
-				$(objpfx)tst-array5-static
-	$(test-program-cmd) > $@
-	cmp $@ tst-array5-static.exp > /dev/null
+$(objpfx)tst-array5-static-cmp.out: tst-array5-static.exp \
+				$(objpfx)tst-array5-static.out
+	cmp $^ > $@
 
 CFLAGS-tst-pie1.c += $(pie-ccflag)
 
@@ -1003,12 +1005,13 @@ tst-audit8-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
 $(objpfx)tst-global1: $(libdl)
 $(objpfx)tst-global1.out: $(objpfx)testobj6.so $(objpfx)testobj2.so
 
+ifeq ($(run-built-tests),yes)
+tests: $(objpfx)order2-cmp.out
+endif
 $(objpfx)order2: $(libdl)
-$(objpfx)order2.out: $(objpfx)order2 $(objpfx)order2mod1.so \
-		     $(objpfx)order2mod2.so
-	$(test-program-prefix) \
-	  $(objpfx)order2 > $@
-	(echo "12345" | cmp $@ -) > /dev/null
+$(objpfx)order2.out: $(objpfx)order2mod1.so $(objpfx)order2mod2.so
+$(objpfx)order2-cmp.out: $(objpfx)order2.out
+	(echo "12345" | cmp $< -) > $@
 $(objpfx)order2mod1.so: $(objpfx)order2mod4.so
 $(objpfx)order2mod4.so: $(objpfx)order2mod3.so
 $(objpfx)order2mod2.so: $(objpfx)order2mod3.so
@@ -1104,10 +1107,11 @@ $(objpfx)tst-unique3.out: $(objpfx)tst-unique3lib2.so
 
 $(objpfx)tst-unique4: $(objpfx)tst-unique4lib.so
 
-$(objpfx)tst-initorder.out: $(objpfx)tst-initorder
-	$(test-program-prefix) \
-	  $< > $@
-	cmp $@ tst-initorder.exp > /dev/null
+ifeq ($(run-built-tests),yes)
+tests: $(objpfx)tst-initorder-cmp.out
+endif
+$(objpfx)tst-initorder-cmp.out: tst-initorder.exp $(objpfx)tst-initorder.out
+	cmp $^ > $@
 
 $(objpfx)tst-initorder2: $(objpfx)tst-initorder2a.so $(objpfx)tst-initorder2d.so $(objpfx)tst-initorder2c.so
 $(objpfx)tst-initorder2a.so: $(objpfx)tst-initorder2b.so
@@ -1124,10 +1128,11 @@ endef
 object-suffixes-left := a b c d
 include $(o-iterator)
 
-$(objpfx)tst-initorder2.out: $(objpfx)tst-initorder2
-	$(test-program-prefix) \
-	  $< > $@
-	cmp $@ tst-initorder2.exp > /dev/null
+ifeq ($(run-built-tests),yes)
+tests: $(objpfx)tst-initorder2-cmp.out
+endif
+$(objpfx)tst-initorder2-cmp.out: tst-initorder2.exp $(objpfx)tst-initorder2.out
+	cmp $^ > $@
 
 $(objpfx)tst-relsort1: $(libdl)
 $(objpfx)tst-relsort1mod1.so: $(libm) $(objpfx)tst-relsort1mod2.so
@@ -1136,7 +1141,7 @@ $(objpfx)tst-relsort1.out: $(objpfx)tst-relsort1mod1.so \
 			   $(objpfx)tst-relsort1mod2.so
 
 ifeq ($(run-built-tests),yes)
-tests: $(objpfx)tst-unused-dep.out
+tests: $(objpfx)tst-unused-dep.out $(objpfx)tst-unused-dep-cmp.out
 endif
 
 $(objpfx)tst-unused-dep.out: $(objpfx)testobj1.so
@@ -1147,4 +1152,6 @@ $(objpfx)tst-unused-dep.out: $(objpfx)testobj1.so
 	$(elf-objpfx)${rtld-installed-name} \
 	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
 	  $< > $@
-	cmp $@ /dev/null > /dev/null
+
+$(objpfx)tst-unused-dep-cmp.out: $(objpfx)tst-unused-dep.out
+	cmp $< /dev/null > $@
diff --git a/nptl/Makefile b/nptl/Makefile
index 57cc8c6..889552f 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -542,7 +542,13 @@ endif
 ifeq ($(build-shared),yes)
 
 $(objpfx)tst-cleanup0.out: /dev/null $(objpfx)tst-cleanup0
-	$(make-test-out) 2>&1 | cmp - tst-cleanup0.expect > $@
+	$(make-test-out) > $@ 2>&1
+
+ifeq ($(run-built-tests),yes)
+tests: $(objpfx)tst-cleanup0-cmp.out
+endif
+$(objpfx)tst-cleanup0-cmp.out: tst-cleanup0.expect $(objpfx)tst-cleanup0.out
+	cmp $^ > $@
 
 $(objpfx)crti.o: $(objpfx)pt-crti.o
 	ln -f $< $@
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index fb35f43..c0fd973 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -124,9 +124,15 @@ tst-grouping-ENV = LOCPATH=$(common-objpfx)localedata
 
 CPPFLAGS += $(libio-mtsafe)
 
-$(objpfx)tst-setvbuf1.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1
+ifeq ($(run-built-tests),yes)
+tests: $(objpfx)tst-setvbuf1-cmp.out
+endif
+
+$(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
 	$(test-program-cmd) > $@ 2>&1
-	cmp tst-setvbuf1.expect $@
+
+$(objpfx)tst-setvbuf1-cmp.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1.out
+	cmp $^ > $@
 
 ifeq ($(build-shared),yes)
 link-libm = $(common-objpfx)math/libm.so
diff --git a/string/Makefile b/string/Makefile
index ffc02ef..af0eece 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -74,9 +74,7 @@ CFLAGS-test-ffs.c = -fno-builtin
 CFLAGS-tst-inlcall.c = -fno-builtin
 
 ifeq ($(run-built-tests),yes)
-tests: $(objpfx)tst-svc.out
-$(objpfx)tst-svc.out: tst-svc.input $(objpfx)tst-svc
-	GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
-	  $(test-program-cmd) < $(word 1,$^) > $@
-	@cmp tst-svc.expect $(objpfx)tst-svc.out
+tests: $(objpfx)tst-svc-cmp.out
+$(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out
+	cmp $^ > $@
 endif

-- 
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]