Cope better with errors in child processes
If a test needs to run in a child process, make it easier to cope if
that child process encounters a failure along the way.
- Add a stringly-typed `Error` to the `run_as` module, which can:
- be serialized and so emitted from child processes
- be constructed from an `anyhow::Error`.
- Add helper macros that construct and `return` an `Error` rather than
directly panicking.
- Add a `recv_or_die()` method that attempts to read a response message
from the child process, but copes with the channel being gone. This
happens if the child has already exited; in this case a final result
message is hopefully available on the `result_reader`.
- Migrate the auth-bound tests to use `Result<(), run_as::Error>`.
Test: keystore2_client_tests auth_bound
Change-Id: Ic306bb272f740a44c0e1d06c948f11435ac3b211
diff --git a/keystore2/tests/Android.bp b/keystore2/tests/Android.bp
index ff89493..0406a71 100644
--- a/keystore2/tests/Android.bp
+++ b/keystore2/tests/Android.bp
@@ -49,6 +49,7 @@
"libaconfig_android_hardware_biometrics_rust",
"libandroid_logger",
"libandroid_security_flags_rust",
+ "libanyhow",
"libbinder_rs",
"libkeystore2_test_utils",
"liblog_rust",