Add tests for Rust VM Payload
Make sure we exercise the Rust wrapper by having a test payload using
it.
API tweaks in the process:
- Add a module for restricted functions to make them more obvious.
- Remove a bogus generic parameter.
Test tweaks in the process:
- Test retrieving VM secrets in more places, it's not a restricted
operation unlike CDIs etc.
Note that attestation-related APIs are exercised by
VmAttestationTestApp, so aren't covered here.
Bug: 340857915
Test: atest MicrodroidTests
Change-Id: I8f4166ffea5db17381875c83119c592d6be48296
diff --git a/tests/testapk/Android.bp b/tests/testapk/Android.bp
index 471aea7..e32ff88 100644
--- a/tests/testapk/Android.bp
+++ b/tests/testapk/Android.bp
@@ -55,6 +55,7 @@
"MicrodroidExitNativeLib",
"MicrodroidPrivateLinkingNativeLib",
"MicrodroidCrashNativeLib",
+ "libmicrodroid_testlib_rust",
"libvm_attestation_test_payload",
],
min_sdk_version: "33",
@@ -166,3 +167,22 @@
header_libs: ["vm_payload_headers"],
stl: "libc++_static",
}
+
+// A payload written in Rust, using the Rust wrapper for the VM payload API.
+rust_ffi_shared {
+ name: "libmicrodroid_testlib_rust",
+ crate_name: "microdroid_testlib_rust",
+ defaults: ["avf_build_flags_rust"],
+ prefer_rlib: true,
+ srcs: ["src/native/testbinary.rs"],
+ compile_multilib: "both",
+ rustlibs: [
+ "com.android.microdroid.testservice-rust",
+ "libandroid_logger",
+ "libanyhow",
+ "libavflog",
+ "libcstr",
+ "liblog_rust",
+ "libvm_payload_rs",
+ ],
+}