Only allow LOCAL_IS_UNIT_TEST set to ALL_MODULES if defined.

To prevent the argument be cleaned if the same module name with
different unit_test value, treat it as unit test if one of the module is
treated as unit tests.

Bug: 176096135
Test: m out/target/product/generic/module-info.json
Change-Id: Iee4ee1063d47dcba1aaf915ec9e4e56f8c7df787
diff --git a/core/base_rules.mk b/core/base_rules.mk
index c973997..a42d702 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -1005,7 +1005,9 @@
 ifndef LOCAL_IS_HOST_MODULE
 ALL_MODULES.$(my_register_name).FILE_CONTEXTS := $(LOCAL_FILE_CONTEXTS)
 endif
+ifdef LOCAL_IS_UNIT_TEST
 ALL_MODULES.$(my_register_name).IS_UNIT_TEST := $(LOCAL_IS_UNIT_TEST)
+endif
 test_config :=
 
 INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name)