This is an automated email from the ASF dual-hosted git repository.
yuanz pushed a commit to branch no-std
in repository
https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git
The following commit(s) were added to refs/heads/no-std by this push:
new 8265917 Simplify test scripts
8265917 is described below
commit 8265917bf443d40c3690c6b92b6bc29bf93da654
Author: Yuan Zhuang <[email protected]>
AuthorDate: Thu May 9 09:57:13 2024 +0000
Simplify test scripts
- Use the OP-TEE 4.2.0 prebuilt images and avoid multiple downloads;
- Add `tests/setup.sh` for common operations;
- Add `error_handling` test in qemu ci;
- unify scripts' indentation.
Similar changes on master branch: [1].
[1]
https://github.com/apache/incubator-teaclave-trustzone-sdk/commit/b05173f3ad3274b361b089896d0f51aa74ee6dd4
Signed-off-by: Yuan Zhuang <[email protected]>
---
ci/ci.sh | 1 +
ci/qemu-check.exp | 13 ++++++
examples/error_handling-rs/host/src/main.rs | 2 +
ci/ci.sh => tests/cleanup_all.sh | 19 +--------
tests/optee-qemuv8.sh | 6 +--
tests/setup.sh | 62 +++++++++++++++++++++++++++++
tests/test_acipher.sh | 39 +++++++-----------
tests/test_aes.sh | 47 +++++++++-------------
tests/test_authentication.sh | 37 ++++++-----------
tests/test_big_int.sh | 51 ++++++++++--------------
tests/test_diffie_hellman.sh | 39 +++++++-----------
tests/test_digest.sh | 37 ++++++-----------
tests/test_error_handling.sh | 36 ++++++-----------
tests/test_hello_world.sh | 43 ++++++++------------
tests/test_hotp.sh | 33 +++++----------
tests/test_random.sh | 35 ++++++----------
tests/test_secure_storage.sh | 47 +++++++++-------------
tests/test_signature_verification.sh | 37 ++++++-----------
tests/test_supp_plugin.sh | 54 ++++++++++---------------
tests/test_time.sh | 43 ++++++++------------
20 files changed, 293 insertions(+), 388 deletions(-)
diff --git a/ci/ci.sh b/ci/ci.sh
index bcd076b..e530044 100755
--- a/ci/ci.sh
+++ b/ci/ci.sh
@@ -34,5 +34,6 @@ pushd ../tests
./test_time.sh
./test_signature_verification.sh
./test_supp_plugin.sh
+./test_error_handling.sh
popd
diff --git a/ci/qemu-check.exp b/ci/qemu-check.exp
index a76deb4..0d066c5 100644
--- a/ci/qemu-check.exp
+++ b/ci/qemu-check.exp
@@ -245,4 +245,17 @@ expect {
}
}
+expect "# "
+info "Running error_handling-rs...\n"
+send -- "error_handling-rs\r"
+expect {
+ "Test passed" {
+ info "Test success\n"
+ }
+ timeout {
+ info "!!! Timeout: Test failed\n"
+ exit 1
+ }
+}
+
info "Test Rust application finished\n"
diff --git a/examples/error_handling-rs/host/src/main.rs
b/examples/error_handling-rs/host/src/main.rs
index d4eac18..a16825f 100644
--- a/examples/error_handling-rs/host/src/main.rs
+++ b/examples/error_handling-rs/host/src/main.rs
@@ -40,4 +40,6 @@ fn test_error_handling() {
// Test repeated error invocation also returns the requested error.
let e = session.invoke_command(Command::ReturnGenericError as u32, &mut
operation).expect_err("generic error");
assert_eq!(e.kind(), ErrorKind::Generic);
+
+ println!("Test passed");
}
diff --git a/ci/ci.sh b/tests/cleanup_all.sh
similarity index 73%
copy from ci/ci.sh
copy to tests/cleanup_all.sh
index bcd076b..2305d4b 100755
--- a/ci/ci.sh
+++ b/tests/cleanup_all.sh
@@ -19,20 +19,5 @@
set -xe
-pushd ../tests
-
-./test_hello_world.sh
-./test_random.sh
-./test_secure_storage.sh
-./test_aes.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_signature_verification.sh
-./test_supp_plugin.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..95d10de 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 \
@@ -30,6 +30,4 @@ cd optee-qemuv8-3.20.0-ubuntu-20.04 && ./qemu-system-aarch64 \
-append 'console=ttyAMA0,38400 keep_bootcon root=/dev/vda2' \
-kernel Image -no-acpi \
-fsdev local,id=fsdev0,path=$(pwd)/../shared,security_model=none \
- -device virtio-9p-device,fsdev=fsdev0,mount_tag=host \
- -netdev user,id=vmnic,hostfwd=:127.0.0.1:54433-:4433 \
- -device virtio-net-device,netdev=vmnic
+ -device virtio-9p-device,fsdev=fsdev0,mount_tag=host
diff --git a/tests/setup.sh b/tests/setup.sh
new file mode 100755
index 0000000..e8a6a2a
--- /dev/null
+++ b/tests/setup.sh
@@ -0,0 +1,62 @@
+#!/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"
+# libteec.so.2 since OP-TEE 4.2.0, for legacy versions:
+run_in_qemu "[ ! -e /usr/lib/libteec.so.1 ] && ln -s /usr/lib/libteec.so
/usr/lib/libteec.so.1"
diff --git a/tests/test_acipher.sh b/tests/test_acipher.sh
index bba9af8..c04fe16 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-linux-gnu/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
diff --git a/tests/test_aes.sh b/tests/test_aes.sh
index 711573a..d423364 100755
--- a/tests/test_aes.sh
+++ b/tests/test_aes.sh
@@ -19,41 +19,30 @@
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-linux-gnu/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 &&
- grep -q "Reset ciphering operation in TA (provides the initial vector)"
screenlog.0 &&
- grep -q "Encode buffer from TA" screenlog.0 &&
- grep -q "Prepare decode operation" screenlog.0 &&
- grep -q "Clear text and decoded text match" screenlog.0
+ grep -q "Prepare encode operation" screenlog.0 &&
+ grep -q "Load key in TA" screenlog.0 &&
+ grep -q "Reset ciphering operation in TA (provides the initial vector)"
screenlog.0 &&
+ grep -q "Encode buffer from TA" screenlog.0 &&
+ grep -q "Prepare decode operation" screenlog.0 &&
+ grep -q "Clear text and decoded text match" 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_authentication.sh b/tests/test_authentication.sh
index 03fd0f1..33284a9 100755
--- a/tests/test_authentication.sh
+++ b/tests/test_authentication.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/authentication-rs/ta/target/aarch64-unknown-linux-gnu/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
+ grep -q "Clear text and decoded text match" screenlog.0 &&
+ grep -q "Success" screenlog.0
} || {
- cat -v screenlog.0
- cat -v /tmp/serial.log
+ 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_big_int.sh b/tests/test_big_int.sh
index c3836c5..8a1dc93 100755
--- a/tests/test_big_int.sh
+++ b/tests/test_big_int.sh
@@ -19,44 +19,33 @@
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-linux-gnu/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 &&
- grep -q "\[.*] in i32 is [0-9]*" /tmp/serial.log &&
- grep -q "\[.*] + \[.*] = \[.*]" /tmp/serial.log &&
- grep -q "\[.*] - \[.*] = \[.*]" /tmp/serial.log &&
- grep -q "\[.*] \* \[.*] = \[.*]" /tmp/serial.log &&
- grep -q "\[.*] / \[.*] = \[.*]" /tmp/serial.log &&
- grep -q "\[.*] % \[.*] = \[.*]" /tmp/serial.log &&
- grep -q "Success" screenlog.0
+ grep -q "\[.*] > \[.*]\|\[.*] < \[.*]\|\[.*] == \[.*]" /tmp/serial.log &&
+ grep -q "\[.*] in u8 array is \[.*]" /tmp/serial.log &&
+ grep -q "\[.*] in i32 is [0-9]*" /tmp/serial.log &&
+ grep -q "\[.*] + \[.*] = \[.*]" /tmp/serial.log &&
+ grep -q "\[.*] - \[.*] = \[.*]" /tmp/serial.log &&
+ grep -q "\[.*] \* \[.*] = \[.*]" /tmp/serial.log &&
+ grep -q "\[.*] / \[.*] = \[.*]" /tmp/serial.log &&
+ grep -q "\[.*] % \[.*] = \[.*]" /tmp/serial.log &&
+ grep -q "Success" screenlog.0
} || {
- cat -v screenlog.0
- cat -v /tmp/serial.log
+ 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_diffie_hellman.sh b/tests/test_diffie_hellman.sh
index bc5ae5f..2a9d3bf 100755
--- a/tests/test_diffie_hellman.sh
+++ b/tests/test_diffie_hellman.sh
@@ -19,38 +19,27 @@
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-linux-gnu/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 &&
- grep -q "Success" screenlog.0
+ grep -q "get key [0|1] pair as public: \[.*], private: \[.*]" screenlog.0
&&
+ grep -q "Derived share key as \[.*]" screenlog.0 &&
+ grep -q "Success" screenlog.0
} || {
- cat -v screenlog.0
- cat -v /tmp/serial.log
+ 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_digest.sh b/tests/test_digest.sh
index 2b4dbc1..21cd87d 100755
--- a/tests/test_digest.sh
+++ b/tests/test_digest.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/digest-rs/ta/target/aarch64-unknown-linux-gnu/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
+ grep -q "Get message hash as:" screenlog.0 &&
+ grep -q "Success" screenlog.0
} || {
- cat -v screenlog.0
- cat -v /tmp/serial.log
+ 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_error_handling.sh b/tests/test_error_handling.sh
index 3794a42..8abdf92 100755
--- a/tests/test_error_handling.sh
+++ b/tests/test_error_handling.sh
@@ -19,36 +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/error_handling-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta
shared
cp
../examples/error_handling-rs/host/target/aarch64-unknown-linux-gnu/release/error_handling-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 "./error_handling-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 "./error_handling-rs\n"
+run_in_qemu "^C"
+# Script specific checks
{
- grep -q -v "panicked" screenlog.0
+ grep -q -v "panicked" screenlog.0 &&
+ grep -q "Test passed" 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
diff --git a/tests/test_hello_world.sh b/tests/test_hello_world.sh
index ca42341..05847a8 100755
--- a/tests/test_hello_world.sh
+++ b/tests/test_hello_world.sh
@@ -19,39 +19,28 @@
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-linux-gnu/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 &&
- grep -q "dec value is 29" screenlog.0 &&
- grep -q "Success" screenlog.0
+ grep -q "original value is 29" screenlog.0 &&
+ grep -q "inc value is 129" screenlog.0 &&
+ grep -q "dec value is 29" screenlog.0 &&
+ grep -q "Success" 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_hotp.sh b/tests/test_hotp.sh
index 18641db..b2d9a0e 100755
--- a/tests/test_hotp.sh
+++ b/tests/test_hotp.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/hotp-rs/ta/target/aarch64-unknown-linux-gnu/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
+ grep -q "Get HOTP" screenlog.0 &&
+ grep -q "Success" screenlog.0
} || {
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
diff --git a/tests/test_random.sh b/tests/test_random.sh
index 863f678..a1e0fc0 100755
--- a/tests/test_random.sh
+++ b/tests/test_random.sh
@@ -19,38 +19,27 @@
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-linux-gnu/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 &&
- grep -q "Success" screenlog.0
+ 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 &&
+ grep -q "Success" screenlog.0
} || {
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_secure_storage.sh b/tests/test_secure_storage.sh
index 5a0ebd3..71d9b9c 100755
--- a/tests/test_secure_storage.sh
+++ b/tests/test_secure_storage.sh
@@ -19,46 +19,35 @@
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-linux-gnu/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 &&
- grep -q "\- Read back the object" screenlog.0 &&
- grep -q "\- Content read-out correctly" screenlog.0 &&
- grep -q "\- Delete the object" screenlog.0 &&
+ grep -q "Test on object \"object#1\"" screenlog.0 &&
+ grep -q "\- Create and load object in the TA secure storage" screenlog.0 &&
+ grep -q "\- Read back the object" screenlog.0 &&
+ grep -q "\- Content read-out correctly" screenlog.0 &&
+ grep -q "\- Delete the object" screenlog.0 &&
- grep -q "Test on object \"object#2\"" screenlog.0 &&
- #miss the read correctly output
- grep -Eq "\- Object not found in TA secure storage, create it|\- Object
found in TA secure storage, delete it" screenlog.0 &&
+ grep -q "Test on object \"object#2\"" screenlog.0 &&
+ #miss the read correctly output
+ grep -Eq "\- Object not found in TA secure storage, create it|\- Object
found in TA secure storage, delete it" screenlog.0 &&
- grep -q "We're done, close and release TEE resources" screenlog.0
+ grep -q "We're done, close and release TEE resources" screenlog.0
} || {
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_signature_verification.sh
b/tests/test_signature_verification.sh
index be7e3ae..5a30535 100755
--- a/tests/test_signature_verification.sh
+++ b/tests/test_signature_verification.sh
@@ -19,36 +19,25 @@
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-linux-gnu/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
+ grep -q "Success" 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_supp_plugin.sh b/tests/test_supp_plugin.sh
index 09e3f2f..7806cf4 100755
--- a/tests/test_supp_plugin.sh
+++ b/tests/test_supp_plugin.sh
@@ -19,47 +19,33 @@
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-linux-gnu/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 &&
- grep -q "receive value" screenlog.0 &&
- grep -q "invoke commmand finished" screenlog.0 &&
- grep -q "Success" screenlog.0
+ grep -q "send value" screenlog.0 &&
+ grep -q "invoke" screenlog.0 &&
+ grep -q "receive value" screenlog.0 &&
+ grep -q "invoke commmand finished" screenlog.0 &&
+ grep -q "Success" 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_time.sh b/tests/test_time.sh
index 2958b09..4184bb8 100755
--- a/tests/test_time.sh
+++ b/tests/test_time.sh
@@ -19,40 +19,29 @@
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-linux-gnu/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 &&
- grep -q "\[+] Now wait 1 second in TEE" /tmp/serial.log &&
- grep -q "\[+] Get system time (second: [0-9]*, millisecond: [0-9]*)"
/tmp/serial.log &&
- grep -q "\[+] After set the TA time 5 seconds ahead of system time, new
TA time (second: [0-9]*, millisecond: [0-9]*)" /tmp/serial.log
+ grep -q "Success" screenlog.0 &&
+ grep -q "\[+] Get REE time (second: [0-9]*, millisecond: [0-9]*)"
/tmp/serial.log &&
+ grep -q "\[+] Now wait 1 second in TEE" /tmp/serial.log &&
+ grep -q "\[+] Get system time (second: [0-9]*, millisecond: [0-9]*)"
/tmp/serial.log &&
+ grep -q "\[+] After set the TA time 5 seconds ahead of system time, new TA
time (second: [0-9]*, millisecond: [0-9]*)" /tmp/serial.log
} || {
- cat -v screenlog.0
- cat -v /tmp/serial.log
+ 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]