Split up CommonTest into CommonRuntimeTest and CommonCompilerTest

Change-Id: I8dcf6b29a5aecd445f1a3ddb06386cf81dbc9c70
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 67f09f9..2ddd09e 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -16,21 +16,7 @@
 
 LOCAL_PATH := art
 
-TEST_COMMON_SRC_FILES := \
-	compiler/dex/local_value_numbering_test.cc \
-	compiler/driver/compiler_driver_test.cc \
-	compiler/elf_writer_test.cc \
-	compiler/image_test.cc \
-	compiler/jni/jni_compiler_test.cc \
-	compiler/leb128_encoder_test.cc \
-	compiler/oat_test.cc \
-	compiler/optimizing/dominator_test.cc \
-	compiler/optimizing/pretty_printer_test.cc \
-	compiler/output_stream_test.cc \
-	compiler/utils/arena_allocator_test.cc \
-	compiler/utils/dedupe_set_test.cc \
-	compiler/utils/arm/managed_register_arm_test.cc \
-	compiler/utils/x86/managed_register_x86_test.cc \
+RUNTIME_GTEST_COMMON_SRC_FILES := \
 	runtime/barrier_test.cc \
 	runtime/base/bit_vector_test.cc \
 	runtime/base/hex_dump_test.cc \
@@ -57,7 +43,7 @@
 	runtime/indenter_test.cc \
 	runtime/indirect_reference_table_test.cc \
 	runtime/intern_table_test.cc \
-	runtime/jni_internal_test.cc \
+	runtime/leb128_test.cc \
 	runtime/mem_map_test.cc \
 	runtime/mirror/dex_cache_test.cc \
 	runtime/mirror/object_test.cc \
@@ -68,28 +54,50 @@
 	runtime/utils_test.cc \
 	runtime/verifier/method_verifier_test.cc \
 	runtime/verifier/reg_type_test.cc \
-	runtime/zip_archive_test.cc
+	runtime/zip_archive_test.cc \
+
+COMPILER_GTEST_COMMON_SRC_FILES := \
+	runtime/jni_internal_test.cc \
+	compiler/dex/local_value_numbering_test.cc \
+	compiler/driver/compiler_driver_test.cc \
+	compiler/elf_writer_test.cc \
+	compiler/image_test.cc \
+	compiler/jni/jni_compiler_test.cc \
+	compiler/oat_test.cc \
+	compiler/optimizing/dominator_test.cc \
+	compiler/optimizing/pretty_printer_test.cc \
+	compiler/output_stream_test.cc \
+	compiler/utils/arena_allocator_test.cc \
+	compiler/utils/dedupe_set_test.cc \
+	compiler/utils/arm/managed_register_arm_test.cc \
+	compiler/utils/x86/managed_register_x86_test.cc \
 
 ifeq ($(ART_SEA_IR_MODE),true)
-TEST_COMMON_SRC_FILES += \
+COMPILER_GTEST_COMMON_SRC_FILES += \
 	compiler/utils/scoped_hashtable_test.cc \
 	compiler/sea_ir/types/type_data_test.cc \
 	compiler/sea_ir/types/type_inference_visitor_test.cc \
 	compiler/sea_ir/ir/regions_test.cc
 endif
 
-TEST_TARGET_SRC_FILES := \
-	$(TEST_COMMON_SRC_FILES)
+RUNTIME_GTEST_TARGET_SRC_FILES := \
+	$(RUNTIME_GTEST_COMMON_SRC_FILES)
 
-TEST_HOST_SRC_FILES := \
-	$(TEST_COMMON_SRC_FILES) \
+RUNTIME_GTEST_HOST_SRC_FILES := \
+	$(RUNTIME_GTEST_COMMON_SRC_FILES)
+
+COMPILER_GTEST_TARGET_SRC_FILES := \
+	$(COMPILER_GTEST_COMMON_SRC_FILES)
+
+COMPILER_GTEST_HOST_SRC_FILES := \
+	$(COMPILER_GTEST_COMMON_SRC_FILES) \
 	compiler/utils/x86/assembler_x86_test.cc
 
-ART_HOST_TEST_EXECUTABLES :=
-ART_TARGET_TEST_EXECUTABLES :=
-ART_HOST_TEST_TARGETS :=
-ART_HOST_VALGRIND_TEST_TARGETS :=
-ART_TARGET_TEST_TARGETS :=
+ART_HOST_GTEST_EXECUTABLES :=
+ART_TARGET_GTEST_EXECUTABLES :=
+ART_HOST_GTEST_TARGETS :=
+ART_HOST_VALGRIND_GTEST_TARGETS :=
+ART_TARGET_GTEST_TARGETS :=
 
 ART_TEST_CFLAGS :=
 ifeq ($(ART_USE_PORTABLE_COMPILER),true)
@@ -98,6 +106,8 @@
 
 # $(1): target or host
 # $(2): file name
+# $(3): extra C includes
+# $(4): extra shared libraries
 define build-art-test
   ifneq ($(1),target)
     ifneq ($(1),host)
@@ -107,6 +117,8 @@
 
   art_target_or_host := $(1)
   art_gtest_filename := $(2)
+  art_gtest_extra_c_includes := $(3)
+  art_gtest_extra_shared_libraries := $(4)
 
   art_gtest_name := $$(notdir $$(basename $$(art_gtest_filename)))
 
@@ -120,10 +132,10 @@
   ifeq ($$(art_target_or_host),target)
     LOCAL_MODULE_TAGS := tests
   endif
-  LOCAL_SRC_FILES := $$(art_gtest_filename) runtime/common_test.cc
-  LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime art/compiler
-  LOCAL_SHARED_LIBRARIES += libartd-compiler libartd
-  # dex2oatd is needed to go libartd-compiler and libartd
+  LOCAL_SRC_FILES := $$(art_gtest_filename) runtime/common_runtime_test.cc
+  LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime $(3)
+  LOCAL_SHARED_LIBRARIES += libartd $(4)
+  # dex2oatd is needed to go with libartd
   LOCAL_REQUIRED_MODULES := dex2oatd
 
   LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk
@@ -146,7 +158,7 @@
     include $(LLVM_DEVICE_BUILD_MK)
     include $(BUILD_EXECUTABLE)
     art_gtest_exe := $$(LOCAL_MODULE_PATH)/$$(LOCAL_MODULE)
-    ART_TARGET_TEST_EXECUTABLES += $$(art_gtest_exe)
+    ART_TARGET_GTEST_EXECUTABLES += $$(art_gtest_exe)
   else # host
     LOCAL_CLANG := $(ART_HOST_CLANG)
     LOCAL_CFLAGS += $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
@@ -159,7 +171,7 @@
     include $(LLVM_HOST_BUILD_MK)
     include $(BUILD_HOST_EXECUTABLE)
     art_gtest_exe := $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
-    ART_HOST_TEST_EXECUTABLES += $$(art_gtest_exe)
+    ART_HOST_GTEST_EXECUTABLES += $$(art_gtest_exe)
   endif
 art_gtest_target := test-art-$$(art_target_or_host)-gtest-$$(art_gtest_name)
 ifeq ($$(art_target_or_host),target)
@@ -172,29 +184,31 @@
 	$(hide) (adb pull $(ART_TEST_DIR)/$$@ /tmp/ && echo $$@ PASSED) || (echo $$@ FAILED && exit 1)
 	$(hide) rm /tmp/$$@
 
-ART_TARGET_TEST_TARGETS += $$(art_gtest_target)
+ART_TARGET_GTEST_TARGETS += $$(art_gtest_target)
 else
 .PHONY: $$(art_gtest_target)
 $$(art_gtest_target): $$(art_gtest_exe) test-art-host-dependencies
 	$$<
 	@echo $$@ PASSED
 
-ART_HOST_TEST_TARGETS += $$(art_gtest_target)
+ART_HOST_GTEST_TARGETS += $$(art_gtest_target)
 
 .PHONY: valgrind-$$(art_gtest_target)
 valgrind-$$(art_gtest_target): $$(art_gtest_exe) test-art-host-dependencies
 	valgrind --leak-check=full --error-exitcode=1 $$<
 	@echo $$@ PASSED
 
-ART_HOST_VALGRIND_TEST_TARGETS += valgrind-$$(art_gtest_target)
+ART_HOST_VALGRIND_GTEST_TARGETS += valgrind-$$(art_gtest_target)
 endif
 endef
 
 ifeq ($(ART_BUILD_TARGET),true)
-  $(foreach file,$(TEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file))))
+  $(foreach file,$(RUNTIME_GTEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file),,)))
+  $(foreach file,$(COMPILER_GTEST_TARGET_SRC_FILES), $(eval $(call build-art-test,target,$(file),art/compiler,libartd-compiler)))
 endif
 ifeq ($(WITH_HOST_DALVIK),true)
   ifeq ($(ART_BUILD_HOST),true)
-    $(foreach file,$(TEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file))))
+    $(foreach file,$(RUNTIME_GTEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file),,)))
+    $(foreach file,$(COMPILER_GTEST_HOST_SRC_FILES), $(eval $(call build-art-test,host,$(file),art/compiler,libartd-compiler)))
   endif
 endif