Merge pull request #660 from bjorn3/libtest

Libtest support
This commit is contained in:
bjorn3 2019-08-09 15:19:06 +02:00 committed by GitHub
commit 1b005eb92d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 114 additions and 5 deletions

1
.gitignore vendored
View File

@ -7,5 +7,6 @@ perf.data.old
/build_sysroot/sysroot
/build_sysroot/sysroot_src
/build_sysroot/Cargo.lock
/build_sysroot/test_target/Cargo.lock
/rust
/regex

View File

@ -7,7 +7,7 @@ version = "0.0.0"
core = { path = "./sysroot_src/src/libcore" }
compiler_builtins = "0.1"
alloc = { path = "./sysroot_src/src/liballoc" }
std = { path = "./sysroot_src/src/libstd" }
std = { path = "./sysroot_src/src/libstd", features = ["panic_unwind"] }
alloc_system = { path = "./alloc_system" }

View File

@ -12,7 +12,8 @@ popd >/dev/null
# Cleanup for previous run
# v Clean target dir except for build scripts and incremental cache
rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true
rm Cargo.lock 2>/dev/null || true
rm -r sysroot_src/src/{libcore,libtest}/target/$TARGET_TRIPLE/$sysroot_channel/ || true
rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true
rm -r sysroot 2>/dev/null || true
# Build libs
@ -28,3 +29,14 @@ fi
# Copy files to sysroot
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
if [[ "$1" == "--release" ]]; then
channel='release'
RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release --manifest-path ./sysroot_src/src/libtest/Cargo.toml
else
channel='debug'
cargo build --target $TARGET_TRIPLE --manifest-path ./sysroot_src/src/libtest/Cargo.toml
fi
# Copy files to sysroot
cp sysroot_src/src/libtest/target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/

View File

@ -0,0 +1,49 @@
From a25405f1fc4a168c9c370524be48aff8c8ebc529 Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Wed, 12 Jun 2019 18:07:23 +0200
Subject: [PATCH] Fix libtest compilation
---
src/libtest/lib.rs | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 810a98e..4fdde0e 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -1441,11 +1441,11 @@ pub fn run_test(
return;
}
- fn run_test_inner(
+ fn run_test_inner<F: FnOnce() + Send + 'static>(
desc: TestDesc,
monitor_ch: Sender<MonitorMsg>,
nocapture: bool,
- testfn: Box<dyn FnOnce() + Send>,
+ testfn: F,
concurrency: Concurrent,
) {
// Buffer for capturing standard I/O
@@ -1500,15 +1500,14 @@ pub fn run_test(
(benchfn.clone())(harness)
});
}
- DynTestFn(f) => {
- let cb = move || __rust_begin_short_backtrace(f);
- run_test_inner(desc, monitor_ch, opts.nocapture, Box::new(cb), concurrency)
+ DynTestFn(_f) => {
+ unimplemented!();
}
StaticTestFn(f) => run_test_inner(
desc,
monitor_ch,
opts.nocapture,
- Box::new(move || __rust_begin_short_backtrace(f)),
+ move || __rust_begin_short_backtrace(f),
concurrency,
),
}
--
2.11.0

View File

@ -0,0 +1,34 @@
From e275a6ac96bedda2d57296914f2bb736e1e4154c Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Fri, 9 Aug 2019 13:16:55 +0200
Subject: [PATCH] [test] Force single thread mode
---
src/libtest/lib.rs | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 8d74d9a..c7a3c23 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -1419,16 +1419,7 @@ pub fn run_test(
.unwrap();
};
- // If the platform is single-threaded we're just going to run
- // the test synchronously, regardless of the concurrency
- // level.
- let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_arch = "wasm32");
- if concurrency == Concurrent::Yes && supports_threads {
- let cfg = thread::Builder::new().name(name.as_slice().to_owned());
- cfg.spawn(runtest).unwrap();
- } else {
- runtest();
- }
+ runtest();
}
match testfn {
--
2.20.1

View File

@ -1011,6 +1011,20 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
simd_fmax, (c x, c y) {
simd_flt_binop!(fx, intrinsic, fmax(x, y) -> ret);
};
try, (v f, v data, v _local_ptr) {
// FIXME once unwinding is supported, change this to actually catch panics
let f_sig = fx.bcx.func.import_signature(Signature {
call_conv: cranelift::codegen::isa::CallConv::SystemV,
params: vec![AbiParam::new(fx.bcx.func.dfg.value_type(data))],
returns: vec![],
});
fx.bcx.ins().call_indirect(f_sig, f, &[data]);
let ret_val = CValue::const_val(fx, ret.layout().ty, 0);
ret.write_cvalue(fx, ret_val);
};
}
if let Some((_, dest)) = destination {

View File

@ -58,9 +58,8 @@ echo "[TEST] rust-lang/regex example shootout-regex-dna"
cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna > res.txt
diff -u res.txt examples/regexdna-output.txt
# FIXME compile libtest
# echo "[TEST] rust-lang/regex standalone tests"
# ../cargo.sh test
echo "[TEST] rust-lang/regex standalone tests"
../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options
popd
COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline"