Makefile: Introduce TEST_LISTS and its single rule

Create a single "display test list" rule expecting a target-specific
Make variable, LISTED_TESTS, in order to have the implementation in a
single location.

Introduce the TEST_LISTS variable holding all targets to which the rule
described above applies. New test-list-* targets will be expected to add
themselves to that variable. By doing so, they will also be marked as
dependencies of the test-list target.

Fix the bug in the existing test-list-{boot,crosvm-helloworld} recipes
(now in a single location) where the shell variable was not properly
escaped with a double-$.

Bug: 195395681
Test: make test-list
Change-Id: Ibe1da9bfc1c43e9214d5e3afea9f1b29c5e71ff6
diff --git a/Makefile b/Makefile
index 3863926..97c6c42 100644
--- a/Makefile
+++ b/Makefile
@@ -394,14 +394,12 @@
 endef
 
 test: test-boot
-test-list: test-list-boot
 
 .PHONY: test-boot
 test-boot: $(BOOT_TESTS)
 
-.PHONY: test-list-boot
-test-list-boot:
-	@ for x in $(BOOT_TESTS); do echo $x; done
+TEST_LISTS += test-list-boot
+test-list-boot: LISTED_TESTS = $(BOOT_TESTS)
 
 .PHONY: $(BOOT_TESTS)
 $(BOOT_TESTS): $(KERNEL_IMAGE)
@@ -429,15 +427,16 @@
 endef
 
 test: test-crosvm-helloworld
-test-list: test-list-crosvm-helloworld
-
 .PHONY: test-crosvm-helloworld
 test-crosvm-helloworld: $(CROSVM_HELLOWORLD_TESTS)
 
-.PHONY: test-list-crosvm-helloworld
-test-list-crosvm-helloworld:
-	@ for x in $(CROSVM_HELLOWORLD_TESTS); do echo $x; done
+TEST_LISTS += test-list-crosvm-helloworld
+test-list-crosvm-helloworld: LISTED_TESTS = $(CROSVM_HELLOWORLD_TESTS)
 
 .PHONY: $(CROSVM_HELLOWORLD_TESTS)
 $(CROSVM_HELLOWORLD_TESTS): $(KERNEL_IMAGE) $(UBOOT_BIN)
 	@ $(call gen_crosvm_helloworld_test,$@,$(call hyphensuffix,$@))
+
+.PHONY test-list: $(TEST_LISTS)
+$(TEST_LISTS):
+	@ for x in $(LISTED_TESTS); do echo $$x; done