|
1 | | -#!/bin/sh |
| 1 | +#!/bin/bash |
2 | 2 | set -exuo pipefail |
3 | 3 |
|
4 | 4 | function build { |
5 | 5 | CRATE=enclave |
6 | 6 |
|
7 | | - mkdir -p $WORK_DIR |
8 | | - pushd $WORK_DIR |
9 | | - rm -rf $CRATE |
10 | | - cp -a $TEST_DIR/enclave . |
| 7 | + mkdir -p "${WORK_DIR}" |
| 8 | + pushd "${WORK_DIR}" |
| 9 | + rm -rf "${CRATE}" |
| 10 | + cp -a "${TEST_DIR}"/enclave . |
11 | 11 | pushd $CRATE |
12 | | - echo ${WORK_DIR} |
| 12 | + echo "${WORK_DIR}" |
13 | 13 | # HACK(eddyb) sets `RUSTC_BOOTSTRAP=1` so Cargo can accept nightly features. |
14 | 14 | # These come from the top-level Rust workspace, that this crate is not a |
15 | 15 | # member of, but Cargo tries to load the workspace `Cargo.toml` anyway. |
16 | 16 | env RUSTC_BOOTSTRAP=1 |
17 | | - cargo -v run --target $TARGET |
| 17 | + cargo -v run --target "${TARGET}" |
18 | 18 | popd |
19 | 19 | popd |
20 | 20 | } |
21 | 21 |
|
22 | 22 | function check { |
23 | 23 | local func_re="$1" |
24 | 24 | local checks="${TEST_DIR}/$2" |
25 | | - local asm=$(mktemp) |
| 25 | + local asm="" |
26 | 26 | local objdump="${LLVM_BIN_DIR}/llvm-objdump" |
27 | 27 | local filecheck="${LLVM_BIN_DIR}/FileCheck" |
28 | 28 | local enclave=${WORK_DIR}/enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave |
29 | 29 |
|
30 | | - func="$(${objdump} --syms --demangle ${enclave} | \ |
| 30 | + asm=$(mktemp) |
| 31 | + func="$(${objdump} --syms --demangle "${enclave}" | \ |
31 | 32 | grep --only-matching -E "[[:blank:]]+${func_re}\$" | \ |
32 | 33 | sed -e 's/^[[:space:]]*//' )" |
33 | 34 | ${objdump} --disassemble-symbols="${func}" --demangle \ |
34 | | - ${enclave} > ${asm} |
35 | | - ${filecheck} --input-file ${asm} ${checks} |
| 35 | + "${enclave}" > "${asm}" |
| 36 | + ${filecheck} --input-file "${asm}" "${checks}" |
36 | 37 |
|
37 | 38 | if [ "${func_re}" != "rust_plus_one_global_asm" && |
38 | 39 | "${func_re}" != "cmake_plus_one_c_global_asm" ]; then |
39 | 40 | # The assembler cannot avoid explicit `ret` instructions. Sequences |
40 | 41 | # of `shlq $0x0, (%rsp); lfence; retq` are used instead. |
41 | 42 | # https://www.intel.com/content/www/us/en/developer/articles/technical/ |
42 | 43 | # software-security-guidance/technical-documentation/load-value-injection.html |
43 | | - ${filecheck} --implicit-check-not ret --input-file ${asm} ${checks} |
| 44 | + ${filecheck} --implicit-check-not ret --input-file "${asm}" "${checks}" |
44 | 45 | fi |
45 | 46 | } |
46 | 47 |
|
|
0 commit comments