#only-x86_64-fortanix-unknown-sgx
-OBJDUMP="${S}/build/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-objdump"
-FILECHECK="${S}/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck"
+# For cargo setting
+export RUSTC := $(RUSTC_ORIGINAL)
+export LD_LIBRARY_PATH := $(HOST_RPATH_DIR)
+# We need to be outside of 'src' dir in order to run cargo
+export WORK_DIR := $(TMPDIR)
+export TEST_DIR := $(shell pwd)
-all:
- $(RUSTC) --target ${TARGET} enclave.rs
-
- #TODO: re-enable check when newly compiled libunwind is used
- #${OBJDUMP} --disassemble-symbols=unw_getcontext --demangle $(TMPDIR)/enclave > $(TMPDIR)/unw_getcontext.asm
- #${FILECHECK} --input-file $(TMPDIR)/unw_getcontext.asm unw_getcontext.checks
+## clean up unused env variables which might cause harm.
+unexport RUSTC_LINKER
+unexport RUSTC_BOOTSTRAP
+unexport RUST_BUILD_STAGE
+unexport RUST_TEST_THREADS
+unexport RUST_TEST_TMPDIR
+unexport AR
+unexport CC
+unexport CXX
- #TODO: re-enable check when newly compiled libunwind is used
- ${OBJDUMP} --disassemble-symbols="libunwind::Registers_x86_64::jumpto()" --demangle $(TMPDIR)/enclave > $(TMPDIR)/jumpto.asm
- ${FILECHECK} --input-file $(TMPDIR)/jumpto.asm jumpto.checks
+all:
+ bash script.sh
+++ /dev/null
-
-pub fn main() {
- println!("Hello, World!");
-}
-
--- /dev/null
+[package]
+name = "enclave"
+version = "0.1.0"
+authors = ["Raoul Strackx <raoul.strackx@fortanix.com>"]
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
--- /dev/null
+fn main() {
+ println!("Hello, world!");
+}
--- /dev/null
+CHECK: print
+CHECK: lfence
+CHECK: lfence
+CHECK: lfence
+CHECK: popq
+CHECK: callq 0x{{[[:xdigit:]]*}} <_Unwind_Resume>
+CHECK-NEXT: ud2
--- /dev/null
+set -exuo pipefail
+
+function build {
+ CRATE=enclave
+
+ mkdir -p $WORK_DIR
+ pushd $WORK_DIR
+ rm -rf $CRATE
+ cp -a $TEST_DIR/enclave .
+ pushd $CRATE
+ echo ${WORK_DIR}
+ # HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features.
+ # These come from the top-level Rust workspace, that this crate is not a
+ # member of, but Cargo tries to load the workspace `Cargo.toml` anyway.
+ env RUSTC_BOOTSTRAP=1 \
+ cargo -v run --target $TARGET
+ env RUSTC_BOOTSTRAP=1 \
+ cargo -v run --target $TARGET --release
+ popd
+ popd
+}
+
+function check {
+ local func=$1
+ local checks="${TEST_DIR}/$2"
+ local asm=$(mktemp)
+ local objdump="${BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/build/bin/llvm-objdump"
+ local filecheck="${BUILD_DIR}/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck"
+
+ ${objdump} --disassemble-symbols=${func} --demangle ${WORK_DIR}/enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave > ${asm}
+ ${filecheck} --input-file ${asm} ${checks}
+}
+
+build
+
+#TODO: re-enable check when newly compiled libunwind is used
+#check unw_getcontext unw_getcontext.checks
+
+#TODO: re-enable check when newly compiled libunwind is used
+#check "libunwind::Registers_x86_64::jumpto()" jumpto.checks
+
+check "std::io::stdio::_print::h87f0c238421c45bc" print.checks