Install both test variants in testcases

https://r.android.com/3462694 installed only the primary variant of
device in $PRODUCT_OUT/testcases and host in $HOST_OUT/testcases.

```
Soong only
$PRODUCT_OUT/testcases/$module/$bin
...
```

```
Make
$PRODUCT_OUT/testcases/$module/x86/$bin
...
$PRODUCT_OUT/testcases/$module/x86_64/$bin
...

This means that only the primary variant will be under test in m
--soong-only. To test both variants as well as to match make
installation rules, copy both the variants.

Config files will continue to be copied once, and they will be copied to
the arch-agnostic root $PRODUCT_OUT/testcases/$module/

Test: Set PRODUCT_SOONG_ONLY locally
Test: atest bionic-unit-tests
Test: verified that $PRODUCT_OUT/testcases/bionic-unit-tests has same no
of files as in make+soong builds
Bug: 391924360

Change-Id: I3dac751b6ea97cdfaca26ff61fb5e3cfd6e52840
diff --git a/cc/test.go b/cc/test.go
index ec20cb0..dad4afa 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -397,20 +397,24 @@
 		test.Properties.Test_options.Unit_test = proptools.BoolPtr(true)
 	}
 
-	if ctx.PrimaryArch() && !ctx.Config().KatiEnabled() { // TODO(spandandas): Remove the special case for kati
+	if !ctx.Config().KatiEnabled() { // TODO(spandandas): Remove the special case for kati
 		// Install the test config in testcases/ directory for atest.
-		// Use PrimaryArch and SubName to prevent duplicate installation rules
 		c, ok := ctx.Module().(*Module)
 		if !ok {
 			ctx.ModuleErrorf("Not a cc_test module")
 		}
+		// Install configs in the root of $PRODUCT_OUT/testcases/$module
 		testCases := android.PathForModuleInPartitionInstall(ctx, "testcases", ctx.ModuleName()+c.SubName())
-		if test.testConfig != nil {
-			ctx.InstallFile(testCases, ctx.ModuleName()+".config", test.testConfig)
+		if ctx.PrimaryArch() {
+			if test.testConfig != nil {
+				ctx.InstallFile(testCases, ctx.ModuleName()+".config", test.testConfig)
+			}
+			for _, extraTestConfig := range test.extraTestConfigs {
+				ctx.InstallFile(testCases, extraTestConfig.Base(), extraTestConfig)
+			}
 		}
-		for _, extraTestConfig := range test.extraTestConfigs {
-			ctx.InstallFile(testCases, extraTestConfig.Base(), extraTestConfig)
-		}
+		// Install tests and data in arch specific subdir $PRODUCT_OUT/testcases/$module/$arch
+		testCases = testCases.Join(ctx, ctx.Target().Arch.ArchType.String())
 		ctx.InstallTestData(testCases, test.data)
 		ctx.InstallFile(testCases, file.Base(), file)
 	}