tests/inst: Add destructive test framework
This adds infrastructure to the Rust test suite for destructive tests, and adds a new `transactionality` test which runs rpm-ostree in a loop (along with `ostree-finalize-staged`) and repeatedly uses either `kill -9`, `reboot` and `reboot -ff`. The main goal here is to flush out any "logic errors". So far I've validated that this passes a lot of cycles using ``` $ kola run --qemu-image=fastbuild-fedora-coreos-ostree-qemu.qcow2 ext.ostree.destructive-rs.transactionality --debug --multiply 8 --parallel 4 ``` a number of times.
This commit is contained in:
1 parent
ab95c0264c
commit
1101c02c2a
15 files changed
+1079
-86
No files matched your search
@@ -9,18 +9,57 @@ use quote::quote;
|
||||
#[proc_macro_attribute]
|
||||
pub fn itest(attrs: TokenStream, input: TokenStream) -> TokenStream {
|
||||
let attrs = syn::parse_macro_input!(attrs as syn::AttributeArgs);
|
||||
if attrs.len() > 0 {
|
||||
return syn::Error::new_spanned(&attrs[0], "itest takes no attributes")
|
||||
if attrs.len() > 1 {
|
||||
return syn::Error::new_spanned(&attrs[1], "itest takes 0 or 1 attributes")
|
||||
.to_compile_error()
|
||||
.into();
|
||||
}
|
||||
let destructive = match attrs.get(0) {
|
||||
Some(syn::NestedMeta::Meta(syn::Meta::NameValue(namevalue))) => {
|
||||
if let Some(name) = namevalue.path.get_ident().map(|i| i.to_string()) {
|
||||
if name == "destructive" {
|
||||
match &namevalue.lit {
|
||||
syn::Lit::Bool(v) => v.value,
|
||||
_ => {
|
||||
return syn::Error::new_spanned(
|
||||
&attrs[1],
|
||||
format!("destructive must be bool {}", name),
|
||||
)
|
||||
.to_compile_error()
|
||||
.into();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return syn::Error::new_spanned(
|
||||
&attrs[1],
|
||||
format!("Unknown argument {}", name),
|
||||
)
|
||||
.to_compile_error()
|
||||
.into();
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
Some(v) => {
|
||||
return syn::Error::new_spanned(&v, "Unexpected argument")
|
||||
.to_compile_error()
|
||||
.into()
|
||||
}
|
||||
None => false,
|
||||
};
|
||||
let func = syn::parse_macro_input!(input as syn::ItemFn);
|
||||
let fident = func.sig.ident.clone();
|
||||
let varident = quote::format_ident!("ITEST_{}", fident);
|
||||
let fidentstrbuf = format!(r#"{}"#, fident);
|
||||
let fidentstr = syn::LitStr::new(&fidentstrbuf, Span::call_site());
|
||||
let testident = if destructive {
|
||||
quote::format_ident!("{}", "DESTRUCTIVE_TESTS")
|
||||
} else {
|
||||
quote::format_ident!("{}", "NONDESTRUCTIVE_TESTS")
|
||||
};
|
||||
let output = quote! {
|
||||
#[linkme::distributed_slice(TESTS)]
|
||||
#[linkme::distributed_slice(#testident)]
|
||||
#[allow(non_upper_case_globals)]
|
||||
static #varident : Test = Test {
|
||||
name: #fidentstr,
|
||||
|
||||
Reference in new issue
Block a user