diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 862575b5..abaf9f7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,8 @@ defaults: jobs: build-and-run-examples: - runs-on: ubuntu-20.04 - container: teaclave/teaclave-trustzone-sdk-build:0.3.0 + runs-on: ubuntu-24.04 + container: yuanz0/teaclave-trustzone-sdk:ubuntu-24.04 steps: - name: Checkout repository uses: actions/checkout@v2 @@ -37,7 +37,6 @@ jobs: ln -sf /root/.cargo ~/.cargo - name: Building run: | - apt update && apt install libslirp-dev -y export CARGO_NET_GIT_FETCH_WITH_CLI=true && ./setup.sh && source environment && @@ -48,8 +47,8 @@ jobs: run: | cd ci && ./ci.sh build-utee-teec: - runs-on: ubuntu-20.04 - container: teaclave/teaclave-trustzone-sdk-build:0.3.0 + runs-on: ubuntu-24.04 + container: yuanz0/teaclave-trustzone-sdk:ubuntu-24.04 steps: - name: Checkout repository uses: actions/checkout@v2 @@ -70,7 +69,7 @@ jobs: (cd optee-utee && xargo build --target aarch64-unknown-optee-trustzone -vv) && (cd optee-teec && cargo build --target aarch64-unknown-linux-gnu -vv) license: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v2 - name: Check License Header diff --git a/Dockerfile b/Dockerfile index 1e1cd580..32a478ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -FROM ubuntu:20.04 +FROM ubuntu:24.04 MAINTAINER Teaclave Contributors ENV DEBIAN_FRONTEND=noninteractive @@ -53,15 +53,12 @@ RUN apt-get update && \ libtool \ make \ mtools \ - netcat \ ninja-build \ - python \ - python-crypto \ - python3-crypto \ - python-pyelftools \ + python3 \ python3-pycryptodome \ python3-pyelftools \ python3-serial \ + python3-cryptography \ rsync \ unzip \ uuid-dev \ @@ -72,26 +69,9 @@ RUN apt-get update && \ wget \ cpio \ libcap-ng-dev \ + libslirp-dev \ screen \ libvdeplug-dev \ libsdl2-dev \ pip \ ca-certificates - -RUN pip install cryptography - -RUN apt-get install -y software-properties-common && \ - add-apt-repository ppa:linuxuprising/libpng12 && \ - apt-get update && \ - apt-get install libpng12-0 - -# Install Rust -RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \ - . $HOME/.cargo/env && \ - rustup default nightly-2021-09-20 && \ - rustup component add rust-src && \ - rustup target install aarch64-unknown-linux-gnu && \ - rustup default 1.44.0 && cargo +1.44.0 install xargo && \ - rustup default nightly-2021-09-20 - -ENV PATH="/root/.cargo/bin:$PATH" diff --git a/ci/ci.sh b/ci/ci.sh index 50c72bcc..d821c865 100755 --- a/ci/ci.sh +++ b/ci/ci.sh @@ -40,5 +40,7 @@ pushd ../tests ./test_supp_plugin.sh ./test_tls_client.sh ./test_tls_server.sh +echo "All tests passed!" +./cleanup_all.sh popd diff --git a/environment b/environment index 3216d099..5d141d2f 100644 --- a/environment +++ b/environment @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +export PATH=$PATH:$HOME/.cargo/bin export RUST_TARGET_PATH="$(pwd)" export RUST_COMPILER_RT_ROOT=$RUST_TARGET_PATH/rust/rust/src/llvm-project/compiler-rt if [ -z "$OPTEE_DIR" ] diff --git a/setup.sh b/setup.sh index 50030b9e..edb8a294 100755 --- a/setup.sh +++ b/setup.sh @@ -44,7 +44,7 @@ cargo +stable install xargo ######################################################## # initialize submodules: optee_os / optee_client / build -OPTEE_RELEASE_VERSION=3.20.0 +OPTEE_RELEASE_VERSION=4.2.0 if [[ -z "$OPTEE_DIR" ]] || [[ "$OPTEE_DIR" == "$(pwd)/optee" ]] then diff --git a/tests/cleanup_all.sh b/tests/cleanup_all.sh new file mode 100755 index 00000000..2305d4bc --- /dev/null +++ b/tests/cleanup_all.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -xe + +rm -rf screenlog.0 shared +rm -rf optee-qemuv8-* diff --git a/tests/optee-qemuv8.sh b/tests/optee-qemuv8.sh index 0d870446..2a44e218 100755 --- a/tests/optee-qemuv8.sh +++ b/tests/optee-qemuv8.sh @@ -17,7 +17,7 @@ # specific language governing permissions and limitations # under the License. -cd optee-qemuv8-3.20.0-ubuntu-20.04 && ./qemu-system-aarch64 \ +cd $1 && ./qemu-system-aarch64 \ -nodefaults \ -nographic \ -serial stdio -serial file:/tmp/serial.log \ diff --git a/tests/setup.sh b/tests/setup.sh new file mode 100755 index 00000000..55037fb6 --- /dev/null +++ b/tests/setup.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -xe + +# Default value for NEED_EXPANDED_MEM +: ${NEED_EXPANDED_MEM:=false} + +# Define IMG_VERSION +IMG_VERSION="optee-qemuv8-4.2.0-ubuntu-24.04" + +# Set IMG based on NEED_EXPANDED_MEM +if [ "$NEED_EXPANDED_MEM" = true ]; then + IMG="${IMG_VERSION}-expand-ta-memory" +else + IMG="$IMG_VERSION" +fi + +# Function to download image +download_image() { + curl "https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/${IMG}.tar.gz" | tar zxv +} + +# Functions for running commands in QEMU screen +run_in_qemu() { + screen -S qemu_screen -p 0 -X stuff "$1\n" + sleep 5 +} + +# Check if the image file exists locally +if [ ! -d "${IMG}" ]; then + echo "Image file '${IMG}' not found locally. Downloading from network." + download_image +else + echo "Image file '${IMG}' found locally." +fi + +mkdir -p shared + +# Start QEMU screen +screen -L -d -m -S qemu_screen ./optee-qemuv8.sh $IMG +sleep 30 +run_in_qemu "root" +run_in_qemu "mkdir -p shared && mount -t 9p -o trans=virtio host shared && cd shared" diff --git a/tests/test_acipher.sh b/tests/test_acipher.sh index af39d02f..dc4f88e6 100755 --- a/tests/test_acipher.sh +++ b/tests/test_acipher.sh @@ -19,37 +19,26 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/acipher-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/acipher-rs/host/target/aarch64-unknown-linux-gnu/release/acipher-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./acipher-rs 256 teststring\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./acipher-rs 256 teststring\n" +run_in_qemu "^C" +# Script specific checks { - grep -q "Success encrypt input text \".*\" as [0-9]* bytes cipher text:" screenlog.0 && - grep -q "Success decrypt the above ciphertext as [0-9]* bytes plain text:" screenlog.0 + grep -q "Success encrypt input text \".*\" as [0-9]* bytes cipher text:" screenlog.0 && + grep -q "Success decrypt the above ciphertext as [0-9]* bytes plain text:" screenlog.0 } || { - cat -v screenlog.0 - cat -v /tmp/serial.log - false + cat -v screenlog.0 + cat -v /tmp/serial.log + false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_aes.sh b/tests/test_aes.sh index 9ba9b59c..9a15d851 100755 --- a/tests/test_aes.sh +++ b/tests/test_aes.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/aes-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/aes-rs/host/target/aarch64-unknown-linux-gnu/release/aes-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./aes-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./aes-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Prepare encode operation" screenlog.0 && grep -q "Load key in TA" screenlog.0 && @@ -54,6 +45,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_authentication.sh b/tests/test_authentication.sh index 337a0892..f0d55f1c 100755 --- a/tests/test_authentication.sh +++ b/tests/test_authentication.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/authentication-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/authentication-rs/host/target/aarch64-unknown-linux-gnu/release/authentication-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./authentication-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./authentication-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Clear text and decoded text match" screenlog.0 && grep -q "Success" screenlog.0 @@ -50,6 +41,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_big_int.sh b/tests/test_big_int.sh index 87b6a7ac..df1b6faf 100755 --- a/tests/test_big_int.sh +++ b/tests/test_big_int.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/big_int-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/big_int-rs/host/target/aarch64-unknown-linux-gnu/release/big_int-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./big_int-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./big_int-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "\[.*] > \[.*]\|\[.*] < \[.*]\|\[.*] == \[.*]" /tmp/serial.log && grep -q "\[.*] in u8 array is \[.*]" /tmp/serial.log && @@ -57,6 +48,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_diffie_hellman.sh b/tests/test_diffie_hellman.sh index 42f28eb5..5d345de2 100755 --- a/tests/test_diffie_hellman.sh +++ b/tests/test_diffie_hellman.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/diffie_hellman-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/diffie_hellman-rs/host/target/aarch64-unknown-linux-gnu/release/diffie_hellman-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./diffie_hellman-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./diffie_hellman-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "get key [0|1] pair as public: \[.*], private: \[.*]" screenlog.0 && grep -q "Derived share key as \[.*]" screenlog.0 && @@ -51,6 +42,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_digest.sh b/tests/test_digest.sh index 5d0583a1..82bcf4af 100755 --- a/tests/test_digest.sh +++ b/tests/test_digest.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/digest-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/digest-rs/host/target/aarch64-unknown-linux-gnu/release/digest-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./digest-rs message1 message2\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./digest-rs message1 message2\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Get message hash as:" screenlog.0 && grep -q "Success" screenlog.0 @@ -50,6 +41,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_hello_world.sh b/tests/test_hello_world.sh index 3074af10..bed9f979 100755 --- a/tests/test_hello_world.sh +++ b/tests/test_hello_world.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/hello_world-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/hello_world-rs/host/target/aarch64-unknown-linux-gnu/release/hello_world-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./hello_world-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./hello_world-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "original value is 29" screenlog.0 && grep -q "inc value is 129" screenlog.0 && @@ -52,6 +43,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_hotp.sh b/tests/test_hotp.sh index 9d415705..34ef4ef6 100755 --- a/tests/test_hotp.sh +++ b/tests/test_hotp.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/hotp-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/hotp-rs/host/target/aarch64-unknown-linux-gnu/release/hotp-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./hotp-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./hotp-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Get HOTP" screenlog.0 && grep -q "Success" screenlog.0 @@ -50,6 +41,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 diff --git a/tests/test_message_passing_interface.sh b/tests/test_message_passing_interface.sh index 8e800886..e1265127 100755 --- a/tests/test_message_passing_interface.sh +++ b/tests/test_message_passing_interface.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/message_passing_interface-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/message_passing_interface-rs/host/target/aarch64-unknown-linux-gnu/release/message_passing_interface-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./message_passing_interface-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./message_passing_interface-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Hello, World" screenlog.0 } || { @@ -49,6 +40,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_random.sh b/tests/test_random.sh index 97007803..a5ced675 100755 --- a/tests/test_random.sh +++ b/tests/test_random.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/random-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/random-rs/host/target/aarch64-unknown-linux-gnu/release/random-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./random-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./random-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Invoking TA to generate random UUID" screenlog.0 && grep -q "Generate random UUID: [a-z0-9]*-[a-z0-9]*-[a-z0-9]*-[a-z0-9]*" screenlog.0 && @@ -51,6 +42,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_secure_storage.sh b/tests/test_secure_storage.sh index 6b2995eb..535f4021 100755 --- a/tests/test_secure_storage.sh +++ b/tests/test_secure_storage.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/secure_storage-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/secure_storage-rs/host/target/aarch64-unknown-linux-gnu/release/secure_storage-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./secure_storage-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./secure_storage-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Test on object \"object#1\"" screenlog.0 && grep -q "\- Create and load object in the TA secure storage" screenlog.0 && @@ -59,6 +50,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_serde.sh b/tests/test_serde.sh index 43b940c4..c834592b 100755 --- a/tests/test_serde.sh +++ b/tests/test_serde.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/serde-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/serde-rs/host/target/aarch64-unknown-linux-gnu/release/serde-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./serde-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./serde-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Success" screenlog.0 && grep -q "Point { x: 1, y: 2 }" screenlog.0 && @@ -52,6 +43,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_signature_verification.sh b/tests/test_signature_verification.sh index 8b7b7c81..950ca86f 100755 --- a/tests/test_signature_verification.sh +++ b/tests/test_signature_verification.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/signature_verification-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/signature_verification-rs/host/target/aarch64-unknown-linux-gnu/release/signature_verification-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./signature_verification-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./signature_verification-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Success" screenlog.0 } || { @@ -49,6 +40,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_supp_plugin.sh b/tests/test_supp_plugin.sh index 3fa30fd3..975a25a7 100755 --- a/tests/test_supp_plugin.sh +++ b/tests/test_supp_plugin.sh @@ -19,35 +19,23 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/supp_plugin-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/supp_plugin-rs/host/target/aarch64-unknown-linux-gnu/release/supp_plugin-rs shared cp ../examples/supp_plugin-rs/plugin/target/aarch64-unknown-linux-gnu/release/*.plugin.so shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.plugin.so /usr/lib/tee-supplicant/plugins/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "kill \$(pidof tee-supplicant)\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "/usr/sbin/tee-supplicant &\n\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./supp_plugin-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "cp *.plugin.so /usr/lib/tee-supplicant/plugins/\n" +run_in_qemu "kill \$(pidof tee-supplicant)\n" +run_in_qemu "/usr/sbin/tee-supplicant &\n\n" +run_in_qemu "./supp_plugin-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "send value" screenlog.0 && grep -q "invoke" screenlog.0 && @@ -60,6 +48,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_tcp_client.sh b/tests/test_tcp_client.sh index efb3d998..44090563 100755 --- a/tests/test_tcp_client.sh +++ b/tests/test_tcp_client.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/tcp_client-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/tcp_client-rs/host/target/aarch64-unknown-linux-gnu/release/tcp_client-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./tcp_client-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./tcp_client-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Success" screenlog.0 } || { @@ -49,6 +40,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_time.sh b/tests/test_time.sh index f49ece4e..cd410b2c 100755 --- a/tests/test_time.sh +++ b/tests/test_time.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/time-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/time-rs/host/target/aarch64-unknown-linux-gnu/release/time-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./time-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./time-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Success" screenlog.0 && grep -q "\[+] Get REE time (second: [0-9]*, millisecond: [0-9]*)" /tmp/serial.log && @@ -53,6 +44,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file diff --git a/tests/test_tls_client.sh b/tests/test_tls_client.sh index 9df0409e..93958995 100755 --- a/tests/test_tls_client.sh +++ b/tests/test_tls_client.sh @@ -19,28 +19,20 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +NEED_EXPANDED_MEM=true +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04-expand-ta-memory.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/tls_client-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/tls_client-rs/host/target/aarch64-unknown-linux-gnu/release/tls_client-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./tls_client-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./tls_client-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Success" screenlog.0 } || { @@ -49,6 +41,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 diff --git a/tests/test_tls_server.sh b/tests/test_tls_server.sh index d25909b8..82121200 100755 --- a/tests/test_tls_server.sh +++ b/tests/test_tls_server.sh @@ -19,30 +19,21 @@ set -xe -rm -rf screenlog.0 -rm -rf openssl.log -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +NEED_EXPANDED_MEM=true +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04-expand-ta-memory.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/tls_server-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/tls_server-rs/host/target/aarch64-unknown-linux-gnu/release/tls_server-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./tls_server-rs\n" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./tls_server-rs\n" echo "Q" | openssl s_client -connect 127.0.0.1:54433 -debug > openssl.log 2>&1 -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" +run_in_qemu "^C" +# Script specific checks { grep -q "DONE" openssl.log } || { @@ -52,7 +43,6 @@ screen -S qemu_screen -p 0 -X stuff "^C" false } -rm -rf screenlog.0 -rm -rf openssl.log -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 + +rm -rf openssl.log \ No newline at end of file diff --git a/tests/test_udp_socket.sh b/tests/test_udp_socket.sh index d91aa526..bee1e5a9 100755 --- a/tests/test_udp_socket.sh +++ b/tests/test_udp_socket.sh @@ -19,28 +19,19 @@ set -xe -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +# Include base script +source setup.sh -curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv -mkdir shared +# Copy TA and host binary cp ../examples/udp_socket-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared cp ../examples/udp_socket-rs/host/target/aarch64-unknown-linux-gnu/release/udp_socket-rs shared -screen -L -d -m -S qemu_screen ./optee-qemuv8.sh -sleep 30 -screen -S qemu_screen -p 0 -X stuff "root\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "./udp_socket-rs\n" -sleep 5 -screen -S qemu_screen -p 0 -X stuff "^C" -sleep 5 +# Run script specific commands in QEMU +run_in_qemu "cp *.ta /lib/optee_armtz/\n" +run_in_qemu "./udp_socket-rs\n" +run_in_qemu "^C" +# Script specific checks { grep -q "Success" screenlog.0 } || { @@ -49,6 +40,4 @@ sleep 5 false } -rm -rf screenlog.0 -rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 -rm -rf shared +rm screenlog.0 \ No newline at end of file