Skip to content

Commit 6db0590

Browse files
committed
LVI test std lib
1 parent 947d723 commit 6db0590

File tree

6 files changed

+78
-16
lines changed

6 files changed

+78
-16
lines changed

src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22

33
#only-x86_64-fortanix-unknown-sgx
44

5-
OBJDUMP="${S}/build/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-objdump"
6-
FILECHECK="${S}/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck"
5+
# For cargo setting
6+
export RUSTC := $(RUSTC_ORIGINAL)
7+
export LD_LIBRARY_PATH := $(HOST_RPATH_DIR)
8+
# We need to be outside of 'src' dir in order to run cargo
9+
export WORK_DIR := $(TMPDIR)
10+
export TEST_DIR := $(shell pwd)
711

8-
all:
9-
$(RUSTC) --target ${TARGET} enclave.rs
10-
11-
#TODO: re-enable check when newly compiled libunwind is used
12-
#${OBJDUMP} --disassemble-symbols=unw_getcontext --demangle $(TMPDIR)/enclave > $(TMPDIR)/unw_getcontext.asm
13-
#${FILECHECK} --input-file $(TMPDIR)/unw_getcontext.asm unw_getcontext.checks
12+
## clean up unused env variables which might cause harm.
13+
unexport RUSTC_LINKER
14+
unexport RUSTC_BOOTSTRAP
15+
unexport RUST_BUILD_STAGE
16+
unexport RUST_TEST_THREADS
17+
unexport RUST_TEST_TMPDIR
18+
unexport AR
19+
unexport CC
20+
unexport CXX
1421

15-
#TODO: re-enable check when newly compiled libunwind is used
16-
${OBJDUMP} --disassemble-symbols="libunwind::Registers_x86_64::jumpto()" --demangle $(TMPDIR)/enclave > $(TMPDIR)/jumpto.asm
17-
${FILECHECK} --input-file $(TMPDIR)/jumpto.asm jumpto.checks
22+
all:
23+
bash script.sh

src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "enclave"
3+
version = "0.1.0"
4+
authors = ["Raoul Strackx <raoul.strackx@fortanix.com>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CHECK: print
2+
CHECK: lfence
3+
CHECK: lfence
4+
CHECK: lfence
5+
CHECK: popq
6+
CHECK: callq 0x{{[[:xdigit:]]*}} <_Unwind_Resume>
7+
CHECK-NEXT: ud2
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
set -exuo pipefail
2+
3+
function build {
4+
CRATE=enclave
5+
6+
mkdir -p $WORK_DIR
7+
pushd $WORK_DIR
8+
rm -rf $CRATE
9+
cp -a $TEST_DIR/enclave .
10+
pushd $CRATE
11+
echo ${WORK_DIR}
12+
# HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features.
13+
# These come from the top-level Rust workspace, that this crate is not a
14+
# member of, but Cargo tries to load the workspace `Cargo.toml` anyway.
15+
env RUSTC_BOOTSTRAP=1 \
16+
cargo -v run --target $TARGET
17+
env RUSTC_BOOTSTRAP=1 \
18+
cargo -v run --target $TARGET --release
19+
popd
20+
popd
21+
}
22+
23+
function check {
24+
local func=$1
25+
local checks="${TEST_DIR}/$2"
26+
local asm=$(mktemp)
27+
local objdump="${BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-objdump"
28+
local filecheck="${BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck"
29+
30+
${objdump} --disassemble-symbols=${func} --demangle ${WORK_DIR}/enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave > ${asm}
31+
${filecheck} --input-file ${asm} ${checks}
32+
}
33+
34+
build
35+
36+
#TODO: re-enable check when newly compiled libunwind is used
37+
#check unw_getcontext unw_getcontext.checks
38+
39+
#TODO: re-enable check when newly compiled libunwind is used
40+
#check "libunwind::Registers_x86_64::jumpto()" jumpto.checks
41+
42+
check "std::io::stdio::_print::h87f0c238421c45bc" print.checks

0 commit comments

Comments
 (0)