This is an automated email from the ASF dual-hosted git repository. yuanz pushed a commit to branch update-to-optee-4.2 in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git
commit 0ff343182dd4b3bd69ac729232bec99c251ee92b Author: Yuan Zhuang <[email protected]> AuthorDate: Tue May 7 12:16:45 2024 +0000 Update to OP-TEE 4.2.0 - update to OP-TEE 4.2.0 - simplify test scripts - use new docker img based on Ubuntu 24.04 (required by qemu libslirp) --- .github/workflows/ci.yml | 11 +++--- Dockerfile | 28 +++------------ ci/ci.sh | 2 ++ environment | 1 + setup.sh | 2 +- ci/ci.sh => tests/cleanup_all.sh | 25 ++------------ tests/optee-qemuv8.sh | 2 +- tests/setup.sh | 60 +++++++++++++++++++++++++++++++++ tests/test_acipher.sh | 39 ++++++++------------- tests/test_aes.sh | 29 +++++----------- tests/test_authentication.sh | 29 +++++----------- tests/test_big_int.sh | 29 +++++----------- tests/test_diffie_hellman.sh | 29 +++++----------- tests/test_digest.sh | 29 +++++----------- tests/test_hello_world.sh | 29 +++++----------- tests/test_hotp.sh | 29 +++++----------- tests/test_message_passing_interface.sh | 29 +++++----------- tests/test_random.sh | 29 +++++----------- tests/test_secure_storage.sh | 29 +++++----------- tests/test_serde.sh | 29 +++++----------- tests/test_signature_verification.sh | 29 +++++----------- tests/test_supp_plugin.sh | 38 +++++++-------------- tests/test_tcp_client.sh | 29 +++++----------- tests/test_time.sh | 29 +++++----------- tests/test_tls_client.sh | 30 ++++++----------- tests/test_tls_server.sh | 34 +++++++------------ tests/test_udp_socket.sh | 29 +++++----------- 27 files changed, 259 insertions(+), 448 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 862575b..abaf9f7 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 1e1cd58..32a478e 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 <[email protected]> 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 50c72bc..d821c86 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 3216d09..5d141d2 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 50030b9..edb8a29 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/ci/ci.sh b/tests/cleanup_all.sh similarity index 65% copy from ci/ci.sh copy to tests/cleanup_all.sh index 50c72bc..2305d4b 100755 --- a/ci/ci.sh +++ b/tests/cleanup_all.sh @@ -19,26 +19,5 @@ set -xe -pushd ../tests - -./test_hello_world.sh -./test_random.sh -./test_secure_storage.sh -./test_aes.sh -./test_serde.sh -./test_hotp.sh -./test_acipher.sh -./test_big_int.sh -./test_diffie_hellman.sh -./test_digest.sh -./test_authentication.sh -./test_time.sh -./test_tcp_client.sh -./test_udp_socket.sh -./test_message_passing_interface.sh -./test_signature_verification.sh -./test_supp_plugin.sh -./test_tls_client.sh -./test_tls_server.sh - -popd +rm -rf screenlog.0 shared +rm -rf optee-qemuv8-* diff --git a/tests/optee-qemuv8.sh b/tests/optee-qemuv8.sh index 0d87044..2a44e21 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 0000000..55037fb --- /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 af39d02..dc4f88e 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 9ba9b59..9a15d85 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 337a089..f0d55f1 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 87b6a7a..df1b6fa 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 42f28eb..5d345de 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 5d0583a..82bcf4a 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 3074af1..bed9f97 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 9d41570..34ef4ef 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 8e80088..e126512 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 9700780..a5ced67 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 6b2995e..535f402 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 43b940c..c834592 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 8b7b7c8..950ca86 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 3fa30fd..975a25a 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 efb3d99..4409056 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 f49ece4..cd410b2 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 9df0409..9395899 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 d25909b..8212120 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 d91aa52..bee1e5a 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 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
