Keystore 2.0: Add run_as to keystore2_test_utils

The run_as function allows a test with sufficient privileges to run a
closure as different identity given by a tuple of UID, GID, and SELinux
context. This is infrastructure in preparation for the keystore2 vts
test.

Test: keystore2_test_utils_test
Bug: 182508302
Change-Id: Ic1923028e5bc4ca4b1112e34669d52687450fd14
diff --git a/keystore2/Android.bp b/keystore2/Android.bp
index 9c3ce6e..7c4f61b 100644
--- a/keystore2/Android.bp
+++ b/keystore2/Android.bp
@@ -74,8 +74,32 @@
     crate_name: "keystore2_test_utils",
     srcs: ["test_utils/lib.rs"],
     rustlibs: [
+        "libkeystore2_selinux",
         "liblog_rust",
+        "libnix",
         "librand",
+        "libserde",
+        "libserde_cbor",
+    ],
+}
+
+rust_test {
+    name: "keystore2_test_utils_test",
+    srcs: ["test_utils/lib.rs"],
+    test_suites: ["general-tests"],
+    // TODO Remove custom test_config and enable the following two lines when
+    //      b/200602232 was resolved.
+    // require_root: true,
+    // auto_gen_config: true,
+    test_config: "test_utils/AndroidTest.xml",
+    compile_multilib: "first",
+    rustlibs: [
+        "libkeystore2_selinux",
+        "liblog_rust",
+        "libnix",
+        "librand",
+        "libserde",
+        "libserde_cbor",
     ],
 }