Fix tests-clean Makefile target (bug 30545)
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
Thu, 15 Jun 2023 15:25:47 +0000 (15:25 +0000)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 26 Jun 2023 13:37:25 +0000 (10:37 -0300)
This patch improves tests-clean Makefile target to reliably clean
test artifacts from a build directory.  Before this patch tests-clean
missed around 3k (out of total 9k) .out and .test-result files.

Signed-off-by: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Makefile
Makerules

index 523efd42c161c1bf0c8d6be1dc290a3abce4c464..f324df7a1fa60c394ff1155aaded2e3554f27764 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -518,7 +518,10 @@ mostlyclean: parent-mostlyclean
        @$(MAKE) subdir_mostlyclean no_deps=t
        -rm -f $(postclean)
 
-tests-clean:
+# Remove test artifacts from the whole glibc build.
+# do-tests-clean removes test artifacts from top-level directory, and
+# subdir_testclean removes them from individual sub-directories.
+tests-clean: do-tests-clean
        @$(MAKE) subdir_testclean no_deps=t
 
 ifneq (,$(CXX))
index 2ccf26d32008a1fe4270aa91ae5c3afc3950df7a..018780c818cab0d4626e31308f013582114fca4f 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -1334,18 +1334,13 @@ echo-headers:
 clean: common-clean
 mostlyclean: common-mostlyclean
 
+# Remove test artifacts from a given directory
 do-tests-clean:
-       -rm -f $(addprefix $(objpfx),$(addsuffix .out,$(tests) \
-                                                     $(tests-internal) \
-                                                     $(xtests) \
-                                                     $(test-srcs)) \
-                                    $(addsuffix .test-result,$(tests) \
-                                                             $(tests-internal) \
-                                                             $(xtests) \
-                                                             $(test-srcs)))
+       -find $(objpfx) -name '*.out' -delete
+       -find $(objpfx) -name '*.test-result' -delete
 
 # Remove the object files.
-common-mostlyclean:
+common-mostlyclean: do-tests-clean
        -rm -f $(addprefix $(objpfx),$(tests) $(tests-internal) $(xtests) \
                                     $(test-srcs) \
                                     $(others) $(sysdep-others) stubs \
@@ -1354,15 +1349,7 @@ common-mostlyclean:
                                                    $(xtests) \
                                                    $(test-srcs) \
                                                    $(others) \
-                                                   $(sysdep-others)) \
-                                    $(addsuffix .out,$(tests) \
-                                                     $(tests-internal) \
-                                                     $(xtests) \
-                                                     $(test-srcs)) \
-                                    $(addsuffix .test-result,$(tests) \
-                                                             $(tests-internal) \
-                                                             $(xtests) \
-                                                             $(test-srcs)))
+                                                   $(sysdep-others)))
        -rm -f $(addprefix $(objpfx),$(extra-objs) $(extra-test-objs) \
                                     $(install-lib) $(install-lib.so) \
                                     $(install-lib.so:%.so=%_pic.a))