Use compile_multilib: "both" with "32"/"64" suffixes by default for ART
native tests.

It cannot be used for shared testing libraries since the suffixes
aren't picked up by DT_NEEDED or dlopen calls. They need to continue to
be installed into different directories, just like before.

Test: gtests and run tests in the buildbot-build.sh chroot
Test: art/libnativebridge/tests/runtests.sh
Test: atest art_standalone_dex2oat_tests
Bug: 233550842
Change-Id: Idd576f9de34ab63d70e63b8701373767f0bd78ae
diff --git a/libdexfile/Android.bp b/libdexfile/Android.bp
index fdc57d0..f7afe85 100644
--- a/libdexfile/Android.bp
+++ b/libdexfile/Android.bp
@@ -398,19 +398,6 @@
         "art_libdexfile_external_tests_defaults",
     ],
 
-    // Support multilib variants (using different suffix per sub-architecture), which is needed on
-    // build targets with secondary architectures, as the CTS test suite packaging logic flattens
-    // all test artifacts into a single `testcases` directory.
-    compile_multilib: "both",
-    multilib: {
-        lib32: {
-            suffix: "32",
-        },
-        lib64: {
-            suffix: "64",
-        },
-    },
-
     test_config_template: ":art-gtests-target-standalone-cts-template",
     test_suites: ["cts"], // For backed-by API coverage.
 }
@@ -495,20 +482,6 @@
         "art_standalone_test_defaults",
         "art_libdexfile_support_tests_defaults",
     ],
-
-    // Support multilib variants (using different suffix per sub-architecture), which is needed on
-    // build targets with secondary architectures, as the MTS test suite packaging logic flattens
-    // all test artifacts into a single `testcases` directory.
-    compile_multilib: "both",
-    multilib: {
-        lib32: {
-            suffix: "32",
-        },
-        lib64: {
-            suffix: "64",
-        },
-    },
-
     test_suites: [
         "mts-art",
     ],
diff --git a/libnativebridge/tests/Android.bp b/libnativebridge/tests/Android.bp
index b787fba..a42f3d9 100644
--- a/libnativebridge/tests/Android.bp
+++ b/libnativebridge/tests/Android.bp
@@ -172,20 +172,6 @@
     ],
     header_libs: ["libbase_headers"],
 
-    // Support multilib variants (using different suffix per sub-architecture),
-    // which is needed on build targets with secondary architectures, as the CTS
-    // test suite packaging logic flattens all test artifacts into a single
-    // `testcases` directory.
-    compile_multilib: "both",
-    multilib: {
-        lib32: {
-            suffix: "32",
-        },
-        lib64: {
-            suffix: "64",
-        },
-    },
-
     test_config_template: ":art-gtests-target-standalone-cts-template",
     test_suites: [
         "cts",
diff --git a/libnativebridge/tests/NativeBridgeTest.h b/libnativebridge/tests/NativeBridgeTest.h
index 62509b8..6b445d0 100644
--- a/libnativebridge/tests/NativeBridgeTest.h
+++ b/libnativebridge/tests/NativeBridgeTest.h
@@ -22,12 +22,18 @@
 #include <nativebridge/native_bridge.h>
 #include <gtest/gtest.h>
 
-constexpr const char* kNativeBridgeLibrary = "libnativebridge-test-case.so";
+#if defined(__LP64__)
+#define LIB_SUFFIX "64"
+#else
+#define LIB_SUFFIX "32"
+#endif
+
+constexpr const char* kNativeBridgeLibrary = "libnativebridge-test-case" LIB_SUFFIX ".so";
 constexpr const char* kCodeCache = "./code_cache";
 constexpr const char* kCodeCacheStatFail = "./code_cache/temp";
-constexpr const char* kNativeBridgeLibrary2 = "libnativebridge2-test-case.so";
-constexpr const char* kNativeBridgeLibrary3 = "libnativebridge3-test-case.so";
-constexpr const char* kNativeBridgeLibrary6 = "libnativebridge6-test-case.so";
+constexpr const char* kNativeBridgeLibrary2 = "libnativebridge2-test-case" LIB_SUFFIX ".so";
+constexpr const char* kNativeBridgeLibrary3 = "libnativebridge3-test-case" LIB_SUFFIX ".so";
+constexpr const char* kNativeBridgeLibrary6 = "libnativebridge6-test-case" LIB_SUFFIX ".so";
 
 namespace android {
 
diff --git a/libnativeloader/Android.bp b/libnativeloader/Android.bp
index e14aea2..f30a3ac 100644
--- a/libnativeloader/Android.bp
+++ b/libnativeloader/Android.bp
@@ -164,19 +164,6 @@
         "libnativeloader",
     ],
 
-    // Support multilib variants (using different suffix per sub-architecture), which is needed on
-    // build targets with secondary architectures, as the CTS test suite packaging logic flattens
-    // all test artifacts into a single `testcases` directory.
-    compile_multilib: "both",
-    multilib: {
-        lib32: {
-            suffix: "32",
-        },
-        lib64: {
-            suffix: "64",
-        },
-    },
-
     // Added to CTS for API coverage of libnativeloader which is backed by the
     // ART module.
     test_config_template: ":art-gtests-target-standalone-cts-template",
diff --git a/test/Android.bp b/test/Android.bp
index c0a363e..db8383c 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -47,6 +47,21 @@
         "-Wno-deprecated-dynamic-exception-spec",
     ],
 
+    // Support multilib variants (using different suffix per sub-architecture),
+    // which is needed on build targets with secondary architectures, as the
+    // CTS/MTS/etc test suite packaging logic flattens all test artifacts into a
+    // single `testcases` directory. Also, there is CI testing that expects
+    // 64-bit multilib test suites to work for 32-bit devices (b/233550842).
+    compile_multilib: "both",
+    multilib: {
+        lib32: {
+            suffix: "32",
+        },
+        lib64: {
+            suffix: "64",
+        },
+    },
+
     target: {
         darwin: {
             enabled: false,
@@ -104,16 +119,30 @@
     ],
 }
 
-// Variant of art_test_defaults that installs the library in a location which
-// will be added to the default namespace, and hence also the com_android_art
-// namespace. That allows the library to have shared_libs dependencies on all
-// ART internal libraries.
+// Variant of art_test_defaults for test libraries that installs them in a
+// location which will be added to the default namespace, and hence also the
+// com_android_art namespace. That allows them to have shared_libs
+// dependencies on all ART internal libraries.
 //
 // Currently this only works for run tests where run-test-jar sets
 // LD_LIBRARY_PATH and NATIVELOADER_DEFAULT_NAMESPACE_LIBS.
 art_cc_defaults {
     name: "art_test_internal_library_defaults",
     defaults: ["art_test_defaults"],
+
+    // Undo multilib settings inherited from art_test_common_defaults - we
+    // cannot add suffixes to shared libraries or else they won't be found at
+    // runtime.
+    compile_multilib: "",
+    multilib: {
+        lib32: {
+            suffix: "",
+        },
+        lib64: {
+            suffix: "",
+        },
+    },
+
     target: {
         android_arm: {
             relative_install_path: "com.android.art/lib",