Skip to content

Commit e240476

Browse files
committed
update fortanix run-make test
Make it more idiomatic with the new run-make infra
1 parent 6d488d4 commit e240476

File tree

1 file changed

+10
-23
lines changed
  • tests/run-make/x86_64-fortanix-unknown-sgx-lvi

1 file changed

+10
-23
lines changed

tests/run-make/x86_64-fortanix-unknown-sgx-lvi/rmake.rs

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,30 @@
1313

1414
//@ only-x86_64-fortanix-unknown-sgx
1515

16-
use run_make_support::{cmd, cwd, llvm_filecheck, llvm_objdump, regex, set_current_dir, target};
16+
use run_make_support::{
17+
cargo, cwd, llvm_filecheck, llvm_objdump, regex, run, set_current_dir, target,
18+
};
1719

1820
fn main() {
19-
let main_dir = cwd();
20-
set_current_dir("enclave");
21-
// HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features.
22-
// These come from the top-level Rust workspace, that this crate is not a
23-
// member of, but Cargo tries to load the workspace `Cargo.toml` anyway.
24-
cmd("cargo")
25-
.env("RUSTC_BOOTSTRAP", "1")
26-
.arg("-v")
27-
.arg("run")
28-
.arg("--target")
29-
.arg(target())
30-
.run();
31-
set_current_dir(&main_dir);
32-
// Rust has various ways of adding code to a binary:
33-
// - Rust code
34-
// - Inline assembly
35-
// - Global assembly
36-
// - C/C++ code compiled as part of Rust crates
37-
// For those different kinds, we do have very small code examples that should be
38-
// mitigated in some way. Mostly we check that ret instructions should no longer be present.
21+
cargo().arg("-v").arg("run").arg("--target").arg(target()).current_dir("enclave").run();
22+
23+
// Check that normal rust code has the right mitigations.
3924
check("unw_getcontext", "unw_getcontext.checks");
4025
check("__libunwind_Registers_x86_64_jumpto", "jumpto.checks");
4126

4227
check("std::io::stdio::_print::[[:alnum:]]+", "print.with_frame_pointers.checks");
4328

29+
// Check that rust global assembly has the right mitigations.
4430
check("rust_plus_one_global_asm", "rust_plus_one_global_asm.checks");
4531

32+
// Check that C code compiled using the `cc` crate has the right mitigations.
4633
check("cc_plus_one_c", "cc_plus_one_c.checks");
4734
check("cc_plus_one_c_asm", "cc_plus_one_c_asm.checks");
4835
check("cc_plus_one_cxx", "cc_plus_one_cxx.checks");
4936
check("cc_plus_one_cxx_asm", "cc_plus_one_cxx_asm.checks");
5037
check("cc_plus_one_asm", "cc_plus_one_asm.checks");
5138

39+
// Check that C++ code compiled using the `cc` crate has the right mitigations.
5240
check("cmake_plus_one_c", "cmake_plus_one_c.checks");
5341
check("cmake_plus_one_c_asm", "cmake_plus_one_c_asm.checks");
5442
check("cmake_plus_one_c_global_asm", "cmake_plus_one_c_global_asm.checks");
@@ -71,8 +59,7 @@ fn check(func_re: &str, mut checks: &str) {
7159
.input("enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave")
7260
.args(&["--demangle", &format!("--disassemble-symbols={func}")])
7361
.run()
74-
.stdout_utf8();
75-
let dump = dump.as_bytes();
62+
.stdout();
7663

7764
// Unique case, must succeed at one of two possible tests.
7865
// This is because frame pointers are optional, and them being enabled requires

0 commit comments

Comments
 (0)