Install python tests to testcases/ in soong-only

Needed for atest to work on python tests.

Bug: 391924360
Test: atest vts_vndk_dependency_test
Change-Id: Iabc05a58e4bbe958365a1027bcec25aa058ed1c9
diff --git a/python/test.go b/python/test.go
index 0f21771..5e70fc1 100644
--- a/python/test.go
+++ b/python/test.go
@@ -215,6 +215,22 @@
 	installedData := ctx.InstallTestData(installDir, p.data)
 	p.installedDest = ctx.InstallFile(installDir, p.installSource.Base(), p.installSource, installedData...)
 
+	// TODO: Remove the special case for kati
+	if !ctx.Config().KatiEnabled() {
+		// Install the test config in testcases/ directory for atest.
+		// Install configs in the root of $PRODUCT_OUT/testcases/$module
+		testCases := android.PathForModuleInPartitionInstall(ctx, "testcases", ctx.ModuleName())
+		if ctx.PrimaryArch() {
+			if p.testConfig != nil {
+				ctx.InstallFile(testCases, ctx.ModuleName()+".config", p.testConfig)
+			}
+		}
+		// Install tests and data in arch specific subdir $PRODUCT_OUT/testcases/$module/$arch
+		testCases = testCases.Join(ctx, ctx.Target().Arch.ArchType.String())
+		installedData := ctx.InstallTestData(testCases, p.data)
+		ctx.InstallFile(testCases, p.installSource.Base(), p.installSource, installedData...)
+	}
+
 	moduleInfoJSON := ctx.ModuleInfoJSON()
 	moduleInfoJSON.Class = []string{"NATIVE_TESTS"}
 	if len(p.binaryProperties.Test_suites) > 0 {