Revert "Build System: Solve dependency problem for test"

This reverts commit 224e103308a80fa6440bddb3798ccafdffb14bd7.

Reason for revert: Build Breakage in git_pi-dev-plus-aosp/docs @5366136
make -j110 docs showcommands dist DIST_DIR=/buildbot/dist_dirs/git_pi-dev-plus-aosp-linux-docs/5366136 checkbuild
FAILED:
 Dependencies in out found with no rule to create them:
 out/target/product/generic/data/app/CtsVerifierTester/CtsVerifierTester.apk
 out/target/product/generic/data/app/TradeFedTestApp/TradeFedTestApp.apk
 out/target/product/generic/data/app/TradeFedUiTestApp/TradeFedUiTestApp.apk
 15:53:46 stopping
and
make -j50 showcommands dist TARGET_PRODUCT=cf_x86_phone DIST_DIR=/buildbot/dist_dirs/git_master-linux-ndk_translation_all/5366149 ndk_translation_all
FAILED: ninja: 'out/target/product/vsoc_x86/data/nativetest/arm/arm_insn_tests_arm_static/arm_insn_tests_arm_static', needed by 'out/target/product/vsoc_x86/obj/PACKAGING/ndk_translation_tests_intermediates/arm_insn_tests_arm_static_result.xml', missing and no known rule to make it
15:55:38 ninja failed with: exit status 1
make: *** [run_soong_ui] Error 1
Return Code: 2

Change-Id: Idf95ef2e06526a0a31690420c923207db627605f
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 51139ed..21034ad 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -603,13 +603,6 @@
 
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*)
 
-# Clean up old testcase files
-$(call add-clean-step, rm -rf $(TARGET_OUT_TESTCASES)/*)
-$(call add-clean-step, rm -rf $(HOST_OUT_TESTCASES)/*)
-$(call add-clean-step, rm -rf $(HOST_CROSS_OUT_TESTCASES)/*)
-$(call add-clean-step, rm -rf $(TARGET_OUT_DATA)/*)
-$(call add-clean-step, rm -rf $(HOST_OUT)/vts/*)
-$(call add-clean-step, rm -rf $(HOST_OUT)/framework/vts-tradefed.jar)
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/base_rules.mk b/core/base_rules.mk
index b2bbe46..2fbf524 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -242,33 +242,6 @@
   partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA)
 endif
 endif
-# For test modules that lack a suite tag, set null-suite as the default.
-# We only support adding a default suite to native tests, native benchmarks, and instrumentation tests.
-# This is because they are the only tests we currently auto-generate test configs for.
-ifndef LOCAL_COMPATIBILITY_SUITE
-  ifneq ($(filter NATIVE_TESTS NATIVE_BENCHMARK, $(LOCAL_MODULE_CLASS)),)
-    LOCAL_COMPATIBILITY_SUITE := null-suite
-  endif
-  ifneq ($(filter APPS, $(LOCAL_MODULE_CLASS)),)
-    ifneq ($(filter $(my_module_tags),tests),)
-      LOCAL_COMPATIBILITY_SUITE := null-suite
-    endif
-  endif
-endif
-
-use_testcase_folder :=
-ifdef ENABLE_DEFAULT_TEST_LOCATION
-  ifeq ($(my_module_path),)
-    ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(DEFAULT_DATA_OUT_MODULES)))
-      ifdef LOCAL_COMPATIBILITY_SUITE
-        ifneq (true, $(LOCAL_IS_HOST_MODULE))
-          use_testcase_folder := true
-        endif
-      endif
-    endif
-  endif
-endif
-
 ifeq ($(my_module_path),)
   install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
   ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
@@ -276,16 +249,6 @@
   endif
 
   my_module_path := $($(install_path_var))
-
-  # If use_testcase_folder be set, and LOCAL_MODULE_PATH not set,
-  # overwrite the default path under testcase.
-  ifeq ($(use_testcase_folder),true)
-    arch_dir := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
-    testcase_folder := $($(my_prefix)OUT_TESTCASES)/$(LOCAL_MODULE)/$(arch_dir)
-    my_module_path := $(testcase_folder)
-    arch_dir :=
-  endif
-
   ifeq ($(strip $(my_module_path)),)
     $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)")
   endif
@@ -361,9 +324,7 @@
   # Neither do Runtime Resource Overlay apks, which contain just the overlaid resources.
   else ifeq ($(LOCAL_IS_RUNTIME_RESOURCE_OVERLAY),true)
   else
-    ifneq ($(use_testcase_folder),true)
-      my_module_path := $(my_module_path)/$(LOCAL_MODULE)
-    endif
+    my_module_path := $(my_module_path)/$(LOCAL_MODULE)
   endif
   endif
   LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem)
@@ -468,23 +429,12 @@
 my_init_rc_installed :=
 my_init_rc_pairs :=
 my_installed_symlinks :=
-my_default_test_module :=
-ifeq ($(use_testcase_folder),true)
-arch_dir := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
-my_default_test_module := $($(my_prefix)OUT_TESTCASES)/$(LOCAL_MODULE)/$(arch_dir)/$(my_installed_module_stem)
-arch_dir :=
-endif
-
 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
-ifneq ($(LOCAL_INSTALLED_MODULE),$(my_default_test_module))
-# Install into the testcase folder
-$(LOCAL_INSTALLED_MODULE) : $(my_default_test_module)
 $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
 	@echo "Install: $@"
 	$(copy-file-to-new-target)
 	$(PRIVATE_POST_INSTALL_CMD)
-endif
 
 ifndef LOCAL_IS_HOST_MODULE
 # Rule to install the module's companion init.rc.
@@ -594,6 +544,20 @@
 endif
 endif
 
+# For test modules that lack a suite tag, set null-suite as the default.
+# We only support adding a default suite to native tests, native benchmarks, and instrumentation tests.
+# This is because they are the only tests we currently auto-generate test configs for.
+ifndef LOCAL_COMPATIBILITY_SUITE
+ifneq ($(filter NATIVE_TESTS NATIVE_BENCHMARK, $(LOCAL_MODULE_CLASS)),)
+LOCAL_COMPATIBILITY_SUITE := null-suite
+endif
+ifneq ($(filter APPS, $(LOCAL_MODULE_CLASS)),)
+ifneq ($(filter $(my_module_tags),tests),)
+LOCAL_COMPATIBILITY_SUITE := null-suite
+endif
+endif
+endif
+
 ###########################################################
 ## Compatibility suite files.
 ###########################################################
@@ -611,15 +575,9 @@
 ifdef LOCAL_MULTILIB
   multi_arch := true
 endif
-
 ifdef multi_arch
-arch_dir := /$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
-else
-ifeq ($(use_testcase_folder),true)
   arch_dir := /$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
 endif
-endif
-
 multi_arch :=
 
 # The module itself.
@@ -713,17 +671,6 @@
 endif
 
 
-ifeq ($(use_testcase_folder),true)
-ifneq ($(my_test_data_file_pairs),)
-$(foreach pair, $(my_test_data_file_pairs), \
-  $(eval parts := $(subst :,$(space),$(pair))) \
-  $(eval src_path := $(word 1,$(parts))) \
-  $(eval file := $(word 2,$(parts))) \
-  $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
-    $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \
-      $(call filter-copy-pair,$(src_path),$(call append-path,$(dir),$(file)),$(my_installed_test_data))))))
-endif
-else
 ifneq ($(my_test_data_file_pairs),)
 $(foreach pair, $(my_test_data_file_pairs), \
   $(eval parts := $(subst :,$(space),$(pair))) \
@@ -733,9 +680,6 @@
     $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \
       $(src_path):$(call append-path,$(dir),$(file))))))
 endif
-endif
-
-
 
 arch_dir :=
 is_native :=
diff --git a/core/config.mk b/core/config.mk
index 0bc460e..242558e 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -1174,12 +1174,4 @@
 include $(BUILD_SYSTEM)/soong_config.mk
 endif
 
-# If ENABLE_DEFAULT_TEST_LOCATION is true, move default install path from
-# $(my_prefix)OUT_DATA to $(my_prefix)OUT_TESTCASES
-ENABLE_DEFAULT_TEST_LOCATION := true
--include external/linux-kselftest/android/kselftest_test_list.mk
--include external/ltp/android/ltp_package_list.mk
-DEFAULT_DATA_OUT_MODULES := ltp $(ltp_packages) $(kselftest_modules)
-.KATI_READONLY := ENABLE_DEFAULT_TEST_LOCATION DEFAULT_DATA_OUT_MODULES
-
 include $(BUILD_SYSTEM)/dumpvar.mk
diff --git a/core/definitions.mk b/core/definitions.mk
index e880fa5..c46a873 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2478,25 +2478,6 @@
 	$$(align-package)
 endef
 
-# Create copy pair for compatibility suite
-# Filter out $(LOCAL_INSTALLED_MODULE) to prevent overriding target
-# $(1): source path
-# $(2): destination path
-# The format of copy pair is src:dst
-define compat-copy-pair
-$(if $(filter-out $(2), $(LOCAL_INSTALLED_MODULE)), $(1):$(2))
-endef
-
-# Create copy pair for $(1) $(2)
-# If $(2) is substring of $(3) do nothing.
-# $(1): source path
-# $(2): destination path
-# $(3): filter-out target
-# The format of copy pair is src:dst
-define filter-copy-pair
-$(if $(findstring $(2), $(3)),,$(1):$(2))
-endef
-
 # Copies many files.
 # $(1): The files to copy.  Each entry is a ':' separated src:dst pair
 # $(2): An optional directory to prepend to the destination
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 1704daf..506ec4d 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -523,11 +523,6 @@
   $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS_PRIVILEGED \
   $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_TESTCASES
 
-MODULE_CLASS_APPS := app
-MODULE_CLASS_EXECUTABLES := bin
-MODULE_CLASS_JAVA_LIBRARIES := framework
-MODULE_CLASS_NATIVE_TESTS := nativetest
-MODULE_CLASS_METRIC_TESTS := benchmarktest
 TARGET_OUT_DATA := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)
 TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
 TARGET_OUT_DATA_SHARED_LIBRARIES := $(TARGET_OUT_SHARED_LIBRARIES)
@@ -547,7 +542,6 @@
 TARGET_OUT_VENDOR_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest$(TARGET_VENDOR_TEST_SUFFIX)
 TARGET_OUT_VENDOR_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest$(TARGET_VENDOR_TEST_SUFFIX)
 endif
-MODULE_CLASS_FAKE := fake_packages
 TARGET_OUT_DATA_FAKE := $(TARGET_OUT_DATA)/fake_packages
 .KATI_READONLY := \
   TARGET_OUT_DATA \
@@ -562,13 +556,7 @@
   TARGET_OUT_DATA_METRIC_TESTS \
   TARGET_OUT_VENDOR_NATIVE_TESTS \
   TARGET_OUT_VENDOR_METRIC_TESTS \
-  TARGET_OUT_DATA_FAKE \
-  MODULE_CLASS_APPS \
-  MODULE_CLASS_EXECUTABLES \
-  MODULE_CLASS_JAVA_LIBRARIES \
-  MODULE_CLASS_NATIVE_TESTS \
-  MODULE_CLASS_METRIC_TESTS \
-  MODULE_CLASS_FAKE
+  TARGET_OUT_DATA_FAKE
 
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_DATA_EXECUTABLES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_SHARED_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
diff --git a/core/native_benchmark.mk b/core/native_benchmark.mk
index 4750649..e73bcad 100644
--- a/core/native_benchmark.mk
+++ b/core/native_benchmark.mk
@@ -6,10 +6,8 @@
 
 LOCAL_STATIC_LIBRARIES += libgoogle-benchmark
 
-ifndef ENABLE_DEFAULT_TEST_LOCATION
 LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_METRIC_TESTS)/$(LOCAL_MODULE)
 LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_METRIC_TESTS)/$(LOCAL_MODULE)
-endif
 
 ifndef LOCAL_MULTILIB
 ifndef LOCAL_32_BIT_ONLY
diff --git a/core/package_internal.mk b/core/package_internal.mk
index 3be4635..9043710 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -768,17 +768,10 @@
 
 ifdef LOCAL_COMPATIBILITY_SUITE
 
-ifndef ENABLE_DEFAULT_TEST_LOCATION
 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
   $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
     $(foreach s,$(my_split_suffixes),\
       $(intermediates)/package_$(s).apk:$(dir)/$(LOCAL_MODULE)_$(s).apk))))
-else
-$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
-  $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
-    $(foreach s,$(my_split_suffixes),\
-      $(call compat-copy-pair,$(intermediates)/package_$(s).apk,$(dir)/$(LOCAL_MODULE)_$(s).apk)))))
-endif
 
 $(call create-suite-dependencies)
 
diff --git a/core/target_test_internal.mk b/core/target_test_internal.mk
index 1ed1195..b5c3a7c 100644
--- a/core/target_test_internal.mk
+++ b/core/target_test_internal.mk
@@ -29,15 +29,6 @@
 $(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE))
 endif
 
-use_testcase_folder := false
-ifdef ENABLE_DEFAULT_TEST_LOCATION
-  ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(DEFAULT_DATA_OUT_MODULES)))
-    use_testcase_folder := true
-  endif
-endif
-
-ifneq ($(use_testcase_folder),true)
 ifndef LOCAL_MODULE_RELATIVE_PATH
 LOCAL_MODULE_RELATIVE_PATH := $(LOCAL_MODULE)
 endif
-endif
diff --git a/core/tasks/tools/package-modules.mk b/core/tasks/tools/package-modules.mk
index 82b4c6a..629a9b2 100644
--- a/core/tasks/tools/package-modules.mk
+++ b/core/tasks/tools/package-modules.mk
@@ -40,8 +40,6 @@
     $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).PICKUP_FILES)))\
   $(eval _built_files := $(strip $(ALL_MODULES.$(m).BUILT_INSTALLED)\
     $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT_INSTALLED)))\
-  $(eval _module_class_folder := $($(strip MODULE_CLASS_$(word 1, $(strip $(ALL_MODULES.$(m).CLASS)\
-    $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS))))))\
   $(if $(_pickup_files)$(_built_files),,\
     $(call my_missing_files,$(m)))\
   $(eval my_pickup_files += $(_pickup_files))\
@@ -51,15 +49,9 @@
     $(if $(filter $(TARGET_OUT_ROOT)/%,$(ins)),\
       $(eval bui := $(word 1,$(bui_ins)))\
       $(eval my_built_modules += $(bui))\
-      $(if $(filter $(_module_class_folder), nativetest benchmarktest),\
-        $(eval module_class_folder_stem := $(_module_class_folder)$(findstring 64, $(patsubst $(PRODUCT_OUT)/%,%,$(ins)))),\
-        $(eval module_class_folder_stem := $(_module_class_folder)))\
       $(eval my_copy_dest := $(patsubst data/%,DATA/%,\
-                               $(patsubst testcases/%,DATA/$(module_class_folder_stem)/%,\
-                                 $(patsubst testcases/$(m)/$(TARGET_ARCH)/%,DATA/$(module_class_folder_stem)/$(m)/%,\
-                                   $(patsubst testcases/$(m)/$(TARGET_2ND_ARCH)/%,DATA/$(module_class_folder_stem)/$(m)/%,\
-                                     $(patsubst system/%,DATA/%,\
-                                       $(patsubst $(PRODUCT_OUT)/%,%,$(ins))))))))\
+                               $(patsubst system/%,DATA/%,\
+                                 $(patsubst $(PRODUCT_OUT)/%,%,$(ins)))))\
       $(eval my_copy_pairs += $(bui):$(my_staging_dir)/$(my_copy_dest)))\
   ))