Use rdroidtest proc macro.
Test: atest apkdmverity.test libdm_rust.test
Change-Id: I4e52f71a81e539a386fd37bada36d1c4daed9822
diff --git a/apkdmverity/src/main.rs b/apkdmverity/src/main.rs
index 0ecb0ea..d2f88ae 100644
--- a/apkdmverity/src/main.rs
+++ b/apkdmverity/src/main.rs
@@ -161,7 +161,7 @@
#[cfg(test)]
mod tests {
use crate::*;
- use rdroidtest::test;
+ use rdroidtest::{ignore_if, rdroidtest};
use std::fs::{File, OpenOptions};
use std::io::Write;
use std::ops::Deref;
@@ -232,7 +232,8 @@
});
}
- test!(correct_inputs, ignore_if: should_skip());
+ #[rdroidtest]
+ #[ignore_if(should_skip())]
fn correct_inputs() {
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -245,7 +246,8 @@
}
// A single byte change in the APK file causes an IO error
- test!(incorrect_apk, ignore_if: should_skip());
+ #[rdroidtest]
+ #[ignore_if(should_skip())]
fn incorrect_apk() {
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -262,7 +264,8 @@
}
// A single byte change in the merkle tree also causes an IO error
- test!(incorrect_merkle_tree, ignore_if: should_skip());
+ #[rdroidtest]
+ #[ignore_if(should_skip())]
fn incorrect_merkle_tree() {
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -286,7 +289,8 @@
// 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.
- test!(tampered_apk, ignore_if: should_skip());
+ #[rdroidtest]
+ #[ignore_if(should_skip())]
fn tampered_apk() {
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -307,7 +311,8 @@
// 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.
- test!(tampered_idsig, ignore_if: should_skip());
+ #[rdroidtest]
+ #[ignore_if(should_skip())]
fn tampered_idsig() {
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -324,7 +329,8 @@
}
// test if both files are already block devices
- test!(inputs_are_block_devices, ignore_if: should_skip());
+ #[rdroidtest]
+ #[ignore_if(should_skip())]
fn inputs_are_block_devices() {
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -374,7 +380,8 @@
}
// test with custom roothash
- test!(correct_custom_roothash, ignore_if: should_skip());
+ #[rdroidtest]
+ #[ignore_if(should_skip())]
fn correct_custom_roothash() {
let apk = include_bytes!("../testdata/test.apk");
let idsig = include_bytes!("../testdata/test.apk.idsig");
@@ -396,7 +403,7 @@
);
}
- test!(verify_command);
+ #[rdroidtest]
fn verify_command() {
// Check that the command parsing has been configured in a valid way.
clap_command().debug_assert();
diff --git a/libs/devicemapper/src/lib.rs b/libs/devicemapper/src/lib.rs
index 8d004f9..5656743 100644
--- a/libs/devicemapper/src/lib.rs
+++ b/libs/devicemapper/src/lib.rs
@@ -235,7 +235,7 @@
mod tests {
use super::*;
use crypt::{CipherType, DmCryptTargetBuilder};
- use rdroidtest::test;
+ use rdroidtest::{ignore_if, rdroidtest};
use rustutils::system_properties;
use std::fs::{read, File, OpenOptions};
use std::io::Write;
@@ -292,22 +292,24 @@
}
}
- test!(mapping_again_keeps_data_xts);
+ #[rdroidtest]
fn mapping_again_keeps_data_xts() {
mapping_again_keeps_data(&KEY_SET_XTS, "name1");
}
- test!(mapping_again_keeps_data_hctr2, ignore_if: !is_hctr2_supported());
+ #[rdroidtest]
+ #[ignore_if(!is_hctr2_supported())]
fn mapping_again_keeps_data_hctr2() {
mapping_again_keeps_data(&KEY_SET_HCTR2, "name2");
}
- test!(data_inaccessible_with_diff_key_xts);
+ #[rdroidtest]
fn data_inaccessible_with_diff_key_xts() {
data_inaccessible_with_diff_key(&KEY_SET_XTS, "name3");
}
- test!(data_inaccessible_with_diff_key_hctr2, ignore_if: !is_hctr2_supported());
+ #[rdroidtest]
+ #[ignore_if(!is_hctr2_supported())]
fn data_inaccessible_with_diff_key_hctr2() {
data_inaccessible_with_diff_key(&KEY_SET_HCTR2, "name4");
}
@@ -325,8 +327,8 @@
backing_file,
0,
sz,
- /*direct_io*/ true,
- /*writable*/ true,
+ /* direct_io */ true,
+ /* writable */ true,
)
.unwrap();
let device_diff = device.to_owned() + "_diff";
@@ -357,7 +359,8 @@
fn data_inaccessible_with_diff_key(keyset: &KeySet, device: &str) {
// This test creates 2 different crypt devices using different keys backed
- // by same data_device -> Write data on dev1 -> Check the data is visible but not the same on dev2
+ // by same data_device -> Write data on dev1 -> Check the data is visible but not the same
+ // on dev2
let dm = DeviceMapper::new().unwrap();
let inputimg = include_bytes!("../testdata/rand8k");
let sz = inputimg.len() as u64;
@@ -368,8 +371,8 @@
backing_file,
0,
sz,
- /*direct_io*/ true,
- /*writable*/ true,
+ /* direct_io */ true,
+ /* writable */ true,
)
.unwrap();
let device_diff = device.to_owned() + "_diff";