[libbacktrace] Don't assign check_PROGRAMS to TESTS

In automake files, the check_PROGRAMS variable lists programs that need to be
build for testing, and TESTS lists the programs that need to be run.

The libbacktrace/Makefile.am uses a shortcut:
...
TESTS = $(check_PROGRAMS)
...
to make sure that each program added with:
...
check_PROGRAMS += foo
...
is both build and run.

However, for the allocfail.sh test, we need allocfail to be build and
allocfail.sh to be run:
...
check_PROGRAMS += allocfail
TESTS += allocfail.sh
...
but the shortcut causes allocfail also to be run, which is not required.

Fix this by removing the short-cut, allowing check_PROGRAMS to retain its
original semantics, and introducing a variable BUILDTESTS for programs that
need to be both build and run.

2019-01-28  Tom de Vries  <tdevries@suse.de>

	* Makefile.am: Replace check_PROGRAMS with BUILDTESTS, except for
	allocfail.
	(TESTS): Don't add check_PROGRAMS. Add BUILDTESTS.
	(check_PROGRAMS): Add BUILDTESTS.
	* Makefile.in: Regenerate.

---
 libbacktrace/Makefile.am |  49 +++++++++++---------
 libbacktrace/Makefile.in | 113 +++++++++++++++++++++++------------------------
 2 files changed, 85 insertions(+), 77 deletions(-)

diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 997a535dff4..a038234897a 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -84,9 +84,14 @@ libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
 
 # Testsuite.
 
+# Add test to this variable, if you want it to be build.
 check_PROGRAMS =
 
-TESTS = $(check_PROGRAMS)
+# Add test to this variable, if you want it to be run.
+TESTS =
+
+# Add test to this variable, if you want it to be build and run.
+BUILDTESTS =
 
 if NATIVE
 check_LTLIBRARIES = libbacktrace_alloc.la
@@ -114,37 +119,37 @@ xcoff_%.c: xcoff.c
 test_elf_SOURCES = test_format.c testlib.c
 test_elf_LDADD = libbacktrace_noformat.la elf.lo
 
-check_PROGRAMS += test_elf
+BUILDTESTS += test_elf
 
 test_xcoff_32_SOURCES = test_format.c testlib.c
 test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
 
-check_PROGRAMS += test_xcoff_32
+BUILDTESTS += test_xcoff_32
 
 test_xcoff_64_SOURCES = test_format.c testlib.c
 test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
 
-check_PROGRAMS += test_xcoff_64
+BUILDTESTS += test_xcoff_64
 
 test_pecoff_SOURCES = test_format.c testlib.c
 test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
 
-check_PROGRAMS += test_pecoff
+BUILDTESTS += test_pecoff
 
 test_unknown_SOURCES = test_format.c testlib.c
 test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
 
-check_PROGRAMS += test_unknown
+BUILDTESTS += test_unknown
 
 unittest_SOURCES = unittest.c testlib.c
 unittest_LDADD = libbacktrace.la
 
-check_PROGRAMS += unittest
+BUILDTESTS += unittest
 
 unittest_alloc_SOURCES = $(unittest_SOURCES)
 unittest_alloc_LDADD = libbacktrace_alloc.la
 
-check_PROGRAMS += unittest_alloc
+BUILDTESTS += unittest_alloc
 
 check_LTLIBRARIES += libbacktrace_instrumented_alloc.la
 
@@ -170,13 +175,13 @@ btest_SOURCES = btest.c testlib.c
 btest_CFLAGS = $(AM_CFLAGS) -g -O
 btest_LDADD = libbacktrace.la
 
-check_PROGRAMS += btest
+BUILDTESTS += btest
 
 btest_alloc_SOURCES = $(btest_SOURCES)
 btest_alloc_CFLAGS = $(btest_CFLAGS)
 btest_alloc_LDADD = libbacktrace_alloc.la
 
-check_PROGRAMS += btest_alloc
+BUILDTESTS += btest_alloc
 
 if HAVE_DWZ
 
@@ -201,12 +206,12 @@ endif HAVE_DWZ
 stest_SOURCES = stest.c
 stest_LDADD = libbacktrace.la
 
-check_PROGRAMS += stest
+BUILDTESTS += stest
 
 stest_alloc_SOURCES = $(stest_SOURCES)
 stest_alloc_LDADD = libbacktrace_alloc.la
 
-check_PROGRAMS += stest_alloc
+BUILDTESTS += stest_alloc
 
 ztest_SOURCES = ztest.c testlib.c
 ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
@@ -220,22 +225,22 @@ endif
 ztest_LDADD += $(CLOCK_GETTIME_LINK)
 ztest_alloc_LDADD += $(CLOCK_GETTIME_LINK)
 
-check_PROGRAMS += ztest
+BUILDTESTS += ztest
 
 ztest_alloc_SOURCES = $(ztest_SOURCES)
 ztest_alloc_CFLAGS = $(ztest_CFLAGS)
 
-check_PROGRAMS += ztest_alloc
+BUILDTESTS += ztest_alloc
 
 edtest_SOURCES = edtest.c edtest2_build.c testlib.c
 edtest_LDADD = libbacktrace.la
 
-check_PROGRAMS += edtest
+BUILDTESTS += edtest
 
 edtest_alloc_SOURCES = $(edtest_SOURCES)
 edtest_alloc_LDADD = libbacktrace_alloc.la
 
-check_PROGRAMS += edtest_alloc
+BUILDTESTS += edtest_alloc
 
 edtest2_build.c: gen_edtest2_build; @true
 gen_edtest2_build: $(srcdir)/edtest2.c
@@ -245,13 +250,13 @@ gen_edtest2_build: $(srcdir)/edtest2.c
 
 if HAVE_PTHREAD
 
-check_PROGRAMS += ttest
+BUILDTESTS += ttest
 
 ttest_SOURCES = ttest.c testlib.c
 ttest_CFLAGS = $(AM_CFLAGS) -pthread
 ttest_LDADD = libbacktrace.la
 
-check_PROGRAMS += ttest_alloc
+BUILDTESTS += ttest_alloc
 
 ttest_alloc_SOURCES = $(ttest_SOURCES)
 ttest_alloc_CFLAGS = $(ttest_CFLAGS)
@@ -281,7 +286,7 @@ ctesta_CFLAGS = $(AM_CFLAGS) -g
 ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
 ctesta_LDADD = libbacktrace.la
 
-check_PROGRAMS += ctestg ctesta
+BUILDTESTS += ctestg ctesta
 
 ctestg_alloc_SOURCES = $(ctestg_SOURCES)
 ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
@@ -293,12 +298,16 @@ ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
 ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS)
 ctesta_alloc_LDADD = libbacktrace_alloc.la
 
-check_PROGRAMS += ctestg_alloc ctesta_alloc
+BUILDTESTS += ctestg_alloc ctesta_alloc
 
 endif
 
 endif NATIVE
 
+check_PROGRAMS += $(BUILDTESTS)
+
+TESTS += $(BUILDTESTS)
+
 # We can't use automake's automatic dependency tracking, because it
 # breaks when using bootstrap-lean.  Automatic dependency tracking
 # with GCC bootstrap will cause some of the objects to depend on
diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index f04577066f8..378e06e9498 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -120,19 +120,22 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3)
+check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_5)
+TESTS = $(am__append_3) $(am__append_4) $(am__append_5) \
+	$(am__append_9) $(am__EXEEXT_5)
 @NATIVE_TRUE@am__append_1 = test_elf test_xcoff_32 test_xcoff_64 \
 @NATIVE_TRUE@	test_pecoff test_unknown unittest unittest_alloc \
-@NATIVE_TRUE@	allocfail btest btest_alloc stest stest_alloc \
-@NATIVE_TRUE@	ztest ztest_alloc edtest edtest_alloc
-@NATIVE_TRUE@am__append_2 = allocfail.sh
-@HAVE_DWZ_TRUE@@NATIVE_TRUE@am__append_3 = btest_dwz
-@HAVE_DWZ_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_4 = btest_dwz_gnudebuglink
-@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_5 = -lz
+@NATIVE_TRUE@	btest btest_alloc stest stest_alloc ztest \
+@NATIVE_TRUE@	ztest_alloc edtest edtest_alloc
+@NATIVE_TRUE@am__append_2 = allocfail
+@NATIVE_TRUE@am__append_3 = allocfail.sh
+@HAVE_DWZ_TRUE@@NATIVE_TRUE@am__append_4 = btest_dwz
+@HAVE_DWZ_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_5 = btest_dwz_gnudebuglink
 @HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_6 = -lz
-@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_7 = ttest ttest_alloc
-@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_8 = btest_gnudebuglink
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_9 = ctestg ctesta \
+@HAVE_ZLIB_TRUE@@NATIVE_TRUE@am__append_7 = -lz
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__append_8 = ttest ttest_alloc
+@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@am__append_9 = btest_gnudebuglink
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__append_10 = ctestg ctesta \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctestg_alloc \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctesta_alloc
 subdir = .
@@ -181,21 +184,23 @@ libbacktrace_instrumented_alloc_la_OBJECTS =  \
 libbacktrace_noformat_la_OBJECTS =  \
 	$(am_libbacktrace_noformat_la_OBJECTS)
 @NATIVE_TRUE@am_libbacktrace_noformat_la_rpath =
-@NATIVE_TRUE@am__EXEEXT_1 = test_elf$(EXEEXT) test_xcoff_32$(EXEEXT) \
+@NATIVE_TRUE@am__EXEEXT_1 = allocfail$(EXEEXT)
+@NATIVE_TRUE@am__EXEEXT_2 = test_elf$(EXEEXT) test_xcoff_32$(EXEEXT) \
 @NATIVE_TRUE@	test_xcoff_64$(EXEEXT) test_pecoff$(EXEEXT) \
 @NATIVE_TRUE@	test_unknown$(EXEEXT) unittest$(EXEEXT) \
-@NATIVE_TRUE@	unittest_alloc$(EXEEXT) allocfail$(EXEEXT) \
-@NATIVE_TRUE@	btest$(EXEEXT) btest_alloc$(EXEEXT) \
-@NATIVE_TRUE@	stest$(EXEEXT) stest_alloc$(EXEEXT) \
-@NATIVE_TRUE@	ztest$(EXEEXT) ztest_alloc$(EXEEXT) \
-@NATIVE_TRUE@	edtest$(EXEEXT) edtest_alloc$(EXEEXT)
-@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_2 = ttest$(EXEEXT) \
+@NATIVE_TRUE@	unittest_alloc$(EXEEXT) btest$(EXEEXT) \
+@NATIVE_TRUE@	btest_alloc$(EXEEXT) stest$(EXEEXT) \
+@NATIVE_TRUE@	stest_alloc$(EXEEXT) ztest$(EXEEXT) \
+@NATIVE_TRUE@	ztest_alloc$(EXEEXT) edtest$(EXEEXT) \
+@NATIVE_TRUE@	edtest_alloc$(EXEEXT)
+@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@am__EXEEXT_3 = ttest$(EXEEXT) \
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@	ttest_alloc$(EXEEXT)
-@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_3 =  \
+@HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@am__EXEEXT_4 =  \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctestg$(EXEEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctesta$(EXEEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctestg_alloc$(EXEEXT) \
 @HAVE_COMPRESSED_DEBUG_TRUE@@NATIVE_TRUE@	ctesta_alloc$(EXEEXT)
+am__EXEEXT_5 = $(am__EXEEXT_2) $(am__EXEEXT_3) $(am__EXEEXT_4)
 @NATIVE_TRUE@am_allocfail_OBJECTS = allocfail.$(OBJEXT) \
 @NATIVE_TRUE@	testlib.$(OBJEXT)
 allocfail_OBJECTS = $(am_allocfail_OBJECTS)
@@ -789,8 +794,9 @@ libbacktrace_la_LIBADD = \
 	$(ALLOC_FILE)
 
 libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
-TESTS = $(check_PROGRAMS) $(am__append_2) $(am__append_3) \
-	$(am__append_4) $(am__append_8)
+
+# Add test to this variable, if you want it to be build and run.
+BUILDTESTS = $(am__append_1) $(am__append_8) $(am__append_10)
 @NATIVE_TRUE@check_LTLIBRARIES = libbacktrace_alloc.la \
 @NATIVE_TRUE@	libbacktrace_noformat.la \
 @NATIVE_TRUE@	libbacktrace_instrumented_alloc.la
@@ -835,9 +841,9 @@ TESTS = $(check_PROGRAMS) $(am__append_2) $(am__append_3) \
 @NATIVE_TRUE@stest_alloc_LDADD = libbacktrace_alloc.la
 @NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c
 @NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
-@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_5) \
+@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_6) \
 @NATIVE_TRUE@	$(CLOCK_GETTIME_LINK)
-@NATIVE_TRUE@ztest_alloc_LDADD = libbacktrace_alloc.la $(am__append_6) \
+@NATIVE_TRUE@ztest_alloc_LDADD = libbacktrace_alloc.la $(am__append_7) \
 @NATIVE_TRUE@	$(CLOCK_GETTIME_LINK)
 @NATIVE_TRUE@ztest_alloc_SOURCES = $(ztest_SOURCES)
 @NATIVE_TRUE@ztest_alloc_CFLAGS = $(ztest_CFLAGS)
@@ -1418,6 +1424,34 @@ recheck: all $(check_LTLIBRARIES) $(check_PROGRAMS)
 	        am__force_recheck=am--force-recheck \
 	        TEST_LOGS="$$log_list"; \
 	exit $$?
+allocfail.sh.log: allocfail.sh
+	@p='allocfail.sh'; \
+	b='allocfail.sh'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+btest_dwz.log: btest_dwz
+	@p='btest_dwz'; \
+	b='btest_dwz'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+btest_dwz_gnudebuglink.log: btest_dwz_gnudebuglink
+	@p='btest_dwz_gnudebuglink'; \
+	b='btest_dwz_gnudebuglink'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
+btest_gnudebuglink.log: btest_gnudebuglink
+	@p='btest_gnudebuglink'; \
+	b='btest_gnudebuglink'; \
+	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+	--log-file $$b.log --trs-file $$b.trs \
+	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+	"$$tst" $(AM_TESTS_FD_REDIRECT)
 test_elf.log: test_elf$(EXEEXT)
 	@p='test_elf$(EXEEXT)'; \
 	b='test_elf'; \
@@ -1467,13 +1501,6 @@ unittest_alloc.log: unittest_alloc$(EXEEXT)
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
-allocfail.log: allocfail$(EXEEXT)
-	@p='allocfail$(EXEEXT)'; \
-	b='allocfail'; \
-	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
-	--log-file $$b.log --trs-file $$b.trs \
-	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
-	"$$tst" $(AM_TESTS_FD_REDIRECT)
 btest.log: btest$(EXEEXT)
 	@p='btest$(EXEEXT)'; \
 	b='btest'; \
@@ -1572,34 +1599,6 @@ ctesta_alloc.log: ctesta_alloc$(EXEEXT)
 	--log-file $$b.log --trs-file $$b.trs \
 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
 	"$$tst" $(AM_TESTS_FD_REDIRECT)
-allocfail.sh.log: allocfail.sh
-	@p='allocfail.sh'; \
-	b='allocfail.sh'; \
-	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
-	--log-file $$b.log --trs-file $$b.trs \
-	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
-	"$$tst" $(AM_TESTS_FD_REDIRECT)
-btest_dwz.log: btest_dwz
-	@p='btest_dwz'; \
-	b='btest_dwz'; \
-	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
-	--log-file $$b.log --trs-file $$b.trs \
-	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
-	"$$tst" $(AM_TESTS_FD_REDIRECT)
-btest_dwz_gnudebuglink.log: btest_dwz_gnudebuglink
-	@p='btest_dwz_gnudebuglink'; \
-	b='btest_dwz_gnudebuglink'; \
-	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
-	--log-file $$b.log --trs-file $$b.trs \
-	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
-	"$$tst" $(AM_TESTS_FD_REDIRECT)
-btest_gnudebuglink.log: btest_gnudebuglink
-	@p='btest_gnudebuglink'; \
-	b='btest_gnudebuglink'; \
-	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
-	--log-file $$b.log --trs-file $$b.trs \
-	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
-	"$$tst" $(AM_TESTS_FD_REDIRECT)
 .test.log:
 	@p='$<'; \
 	$(am__set_b); \
