Merge "[RESTRICT AUTOMERGE] Exclude mcts tests from cts based on the env config, a similar change to aosp/3081046." into android12-tests-dev
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 1b7a279..4014b49 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -686,6 +686,14 @@
 ifdef LOCAL_COMPATIBILITY_SUITE
 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
 
+ifeq ($(EXCLUDE_MCTS),true)
+  ifneq (,$(test_config))
+    ifneq (,$(filter mcts-%,$(LOCAL_COMPATIBILITY_SUITE)))
+      LOCAL_COMPATIBILITY_SUITE := $(filter-out cts,$(LOCAL_COMPATIBILITY_SUITE))
+    endif
+  endif
+endif
+
 # If we are building a native test or benchmark and its stem variants are not defined,
 # separate the multiple architectures into subdirectories of the testcase folder.
 arch_dir :=