Add tests for multiton issue

Test accessing a singleton from two libraries, the second of which
depends on the first but is dlopen'd after the first is already
loaded.

Bug: 35674422
Test: out/host/linux-x86/nativetest64/libutils_tests/libutils_tests
Change-Id: I975ba933a19b941a52bdb6e9c221a6910ffb8081
diff --git a/libutils/tests/Android.bp b/libutils/tests/Android.bp
index 70ada72..ea606a1 100644
--- a/libutils/tests/Android.bp
+++ b/libutils/tests/Android.bp
@@ -23,6 +23,7 @@
     srcs: [
         "BitSet_test.cpp",
         "LruCache_test.cpp",
+        "Singleton_test.cpp",
         "String8_test.cpp",
         "StrongPointer_test.cpp",
         "Unicode_test.cpp",
@@ -42,6 +43,8 @@
                 "liblog",
                 "libcutils",
                 "libutils",
+                "libbase",
+                "libdl",
             ],
         },
         linux: {
@@ -54,13 +57,35 @@
             static_libs: [
                 "libutils",
                 "liblog",
+                "libbase",
             ],
+            host_ldlibs: ["-ldl"],
         },
     },
 
+    required: [
+        "libutils_tests_singleton1",
+        "libutils_tests_singleton2",
+    ],
+
     cflags: [
         "-Wall",
         "-Wextra",
         "-Werror",
     ],
 }
+
+cc_test_library {
+    name: "libutils_tests_singleton1",
+    host_supported: true,
+    relative_install_path: "libutils_tests",
+    srcs: ["Singleton_test1.cpp"],
+}
+
+cc_test_library {
+    name: "libutils_tests_singleton2",
+    host_supported: true,
+    relative_install_path: "libutils_tests",
+    srcs: ["Singleton_test2.cpp"],
+    shared_libs: ["libutils_tests_singleton1"],
+}