Change test skipping logic a little, separate feature-based and function-based skipping
This commit is contained in:
committed by
Amanieu d'Antras
parent
cc6855e1e9
commit
b3a7ba4607
@@ -8,4 +8,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \
|
||||
CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -cpu power10 -L /usr/powerpc64-linux-gnu" \
|
||||
CC=powerpc64-linux-gnu-gcc \
|
||||
OBJDUMP=powerpc64-linux-gnu-objdump
|
||||
OBJDUMP=powerpc64-linux-gnu-objdump \
|
||||
# These 2 tests have erratic behaviour with qemu, see https://gitlab.com/qemu-project/qemu/-/issues/1623#note_2449012173
|
||||
STDARCH_TEST_SKIP_FUNCTION=vec_lde_u16,vec_lde_u32
|
||||
|
||||
@@ -56,10 +56,11 @@ case ${TARGET} in
|
||||
esac
|
||||
|
||||
echo "RUSTFLAGS=${RUSTFLAGS}"
|
||||
echo "FEATURES=${FEATURES}"
|
||||
echo "OBJDUMP=${OBJDUMP}"
|
||||
echo "STDARCH_DISABLE_ASSERT_INSTR=${STDARCH_DISABLE_ASSERT_INSTR}"
|
||||
echo "STDARCH_TEST_EVERYTHING=${STDARCH_TEST_EVERYTHING}"
|
||||
echo "STDARCH_TEST_SKIP_FEATURE=${STDARCH_TEST_SKIP_FEATURE}"
|
||||
echo "STDARCH_TEST_SKIP_FUNCTION=${STDARCH_TEST_SKIP_FUNCTION}"
|
||||
echo "PROFILE=${PROFILE}"
|
||||
|
||||
cargo_test() {
|
||||
@@ -78,15 +79,7 @@ cargo_test() {
|
||||
wasm32*)
|
||||
cmd="$cmd --nocapture"
|
||||
;;
|
||||
# qemu has an erratic behavior on those tests
|
||||
powerpc64-unknown-linux-gnu)
|
||||
cmd="$cmd --skip test_vec_lde_u16 --skip test_vec_lde_u32"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$SKIP_TESTS" != "" ]; then
|
||||
cmd="$cmd --skip "$SKIP_TESTS
|
||||
fi
|
||||
$cmd
|
||||
}
|
||||
|
||||
|
||||
@@ -12,3 +12,6 @@ test = false
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
syn = { version = "2.0", features = ["full"] }
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = {level = "warn", check-cfg = ['cfg(optimized)'] }
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo::rustc-check-cfg=cfg(optimized)");
|
||||
let opt_level = env::var("OPT_LEVEL")
|
||||
.ok()
|
||||
.and_then(|s| s.parse().ok())
|
||||
|
||||
@@ -51,7 +51,6 @@ pub fn simd_test(
|
||||
let target = env::var("TARGET").expect(
|
||||
"TARGET environment variable should be set for rustc (e.g. TARGET=x86_64-apple-darwin cargo test)"
|
||||
);
|
||||
let mut force_test = false;
|
||||
let macro_test = match target
|
||||
.split('-')
|
||||
.next()
|
||||
@@ -63,27 +62,29 @@ pub fn simd_test(
|
||||
maybe_riscv if maybe_riscv.starts_with("riscv") => "is_riscv_feature_detected",
|
||||
"powerpc" | "powerpcle" => "is_powerpc_feature_detected",
|
||||
"powerpc64" | "powerpc64le" => "is_powerpc64_feature_detected",
|
||||
"mips" | "mipsel" | "mipsisa32r6" | "mipsisa32r6el" => {
|
||||
// FIXME:
|
||||
// On MIPS CI run-time feature detection always returns false due
|
||||
// to this qemu bug: https://bugs.launchpad.net/qemu/+bug/1754372
|
||||
//
|
||||
// This is a workaround to force the MIPS tests to always run on
|
||||
// CI.
|
||||
force_test = true;
|
||||
"is_mips_feature_detected"
|
||||
}
|
||||
"mips64" | "mips64el" | "mipsisa64r6" | "mipsisa64r6el" => {
|
||||
// FIXME: see above
|
||||
force_test = true;
|
||||
"is_mips64_feature_detected"
|
||||
}
|
||||
"loongarch64" => "is_loongarch_feature_detected",
|
||||
"s390x" => "is_s390x_feature_detected",
|
||||
t => panic!("unknown target: {t}"),
|
||||
};
|
||||
let macro_test = Ident::new(macro_test, Span::call_site());
|
||||
|
||||
let skipped_functions = env::var("STDARCH_TEST_SKIP_FUNCTION").unwrap_or_default();
|
||||
let skipped_features = env::var("STDARCH_TEST_SKIP_FEATURE").unwrap_or_default();
|
||||
|
||||
let mut name_str = &*name.to_string();
|
||||
if name_str.starts_with("test_") {
|
||||
name_str = &name_str[5..];
|
||||
}
|
||||
|
||||
let skip_this = skipped_functions
|
||||
.split(',')
|
||||
.map(str::trim)
|
||||
.any(|s| s == name_str)
|
||||
|| skipped_features
|
||||
.split(',')
|
||||
.map(str::trim)
|
||||
.any(|s| target_features.iter().any(|feature| s == feature));
|
||||
|
||||
let mut detect_missing_features = TokenStream::new();
|
||||
for feature in target_features {
|
||||
let q = quote_spanned! {
|
||||
@@ -95,8 +96,7 @@ pub fn simd_test(
|
||||
q.to_tokens(&mut detect_missing_features);
|
||||
}
|
||||
|
||||
let test_norun = std::env::var("STDSIMD_TEST_NORUN").is_ok();
|
||||
let maybe_ignore = if test_norun {
|
||||
let maybe_ignore = if skip_this {
|
||||
quote! { #[ignore] }
|
||||
} else {
|
||||
TokenStream::new()
|
||||
@@ -111,7 +111,7 @@ pub fn simd_test(
|
||||
fn #name() {
|
||||
let mut missing_features = ::std::vec::Vec::new();
|
||||
#detect_missing_features
|
||||
if #force_test || missing_features.is_empty() {
|
||||
if missing_features.is_empty() {
|
||||
let v = unsafe { #name() };
|
||||
return v;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user