switch off rdroidtest
rdroidtest doesn't work correctly with on-device tests because they use
`panic = "abort"` and rdroidtest doesn't support `-Zpanic-abort-tests`
yet. The result is that all test failure look like a "native crash" and
the test infra cannot correctly track them via bugs or display them in
the UI.
The only `rdroidtest` specific feature we used was `ignore_if`. It is a
bit of a loss to have ignored tests reported as passing, but it is a
lesser evil in this case.
Bug: 291169704
Bug: 384438979
Test: atest libdm_rust.test
Change-Id: I23af380c79a87d246a1f50e163415021d7f5fa84
diff --git a/guest/apkdmverity/src/main.rs b/guest/apkdmverity/src/main.rs
index 2fc964b..167f5d4 100644
--- a/guest/apkdmverity/src/main.rs
+++ b/guest/apkdmverity/src/main.rs
@@ -160,12 +160,8 @@
}
#[cfg(test)]
-rdroidtest::test_main!();
-
-#[cfg(test)]
mod tests {
use crate::*;
- use rdroidtest::{ignore_if, rdroidtest};
use std::fs::{File, OpenOptions};
use std::io::Write;
use std::ops::Deref;
@@ -236,9 +232,11 @@
});
}
- #[rdroidtest]
- #[ignore_if(should_skip())]
+ #[test]
fn correct_inputs() {
+ if should_skip() {
+ return;
+ }
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
run_test(apk.as_ref(), idsig.as_ref(), "correct", |ctx| {
@@ -250,9 +248,11 @@
}
// A single byte change in the APK file causes an IO error
- #[rdroidtest]
- #[ignore_if(should_skip())]
+ #[test]
fn incorrect_apk() {
+ if should_skip() {
+ return;
+ }
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -268,9 +268,11 @@
}
// A single byte change in the merkle tree also causes an IO error
- #[rdroidtest]
- #[ignore_if(should_skip())]
+ #[test]
fn incorrect_merkle_tree() {
+ if should_skip() {
+ return;
+ }
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -293,9 +295,11 @@
// APK is not altered when the verity device is created, but later modified. IO error should
// occur when trying to read the data around the modified location. This is the main scenario
// that we'd like to protect.
- #[rdroidtest]
- #[ignore_if(should_skip())]
+ #[test]
fn tampered_apk() {
+ if should_skip() {
+ return;
+ }
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -315,9 +319,11 @@
// idsig file is not alread when the verity device is created, but later modified. Unlike to
// the APK case, this doesn't occur IO error because the merkle tree is already cached.
- #[rdroidtest]
- #[ignore_if(should_skip())]
+ #[test]
fn tampered_idsig() {
+ if should_skip() {
+ return;
+ }
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
run_test(apk.as_ref(), idsig.as_ref(), "tampered_idsig", |ctx| {
@@ -333,9 +339,11 @@
}
// test if both files are already block devices
- #[rdroidtest]
- #[ignore_if(should_skip())]
+ #[test]
fn inputs_are_block_devices() {
+ if should_skip() {
+ return;
+ }
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -383,9 +391,11 @@
}
// test with custom roothash
- #[rdroidtest]
- #[ignore_if(should_skip())]
+ #[test]
fn correct_custom_roothash() {
+ if should_skip() {
+ return;
+ }
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
let roothash = V4Signature::from_idsig_path("testdata/test.apk.idsig")
@@ -406,7 +416,7 @@
);
}
- #[rdroidtest]
+ #[test]
fn verify_command() {
// Check that the command parsing has been configured in a valid way.
clap_command().debug_assert();