1#!/bin/bash 2 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19 20set -xe 21 22rm -rf screenlog.0 23rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 24rm -rf shared 25 26curl https://nightlies.apache.org/teaclave/teaclave-trustzone-sdk/optee-qemuv8-3.20.0-ubuntu-20.04.tar.gz | tar zxv 27mkdir shared 28cp ../examples/supp_plugin-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared 29cp ../examples/supp_plugin-rs/host/target/aarch64-unknown-linux-gnu/release/supp_plugin-rs shared 30cp ../examples/supp_plugin-rs/plugin/target/aarch64-unknown-linux-gnu/release/*.plugin.so shared 31 32screen -L -d -m -S qemu_screen ./optee-qemuv8.sh 33sleep 30 34screen -S qemu_screen -p 0 -X stuff "root\n" 35sleep 5 36screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" 37sleep 5 38screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" 39sleep 5 40screen -S qemu_screen -p 0 -X stuff "cp *.plugin.so /usr/lib/tee-supplicant/plugins/\n" 41sleep 5 42screen -S qemu_screen -p 0 -X stuff "kill \$(pidof tee-supplicant)\n" 43sleep 5 44screen -S qemu_screen -p 0 -X stuff "/usr/sbin/tee-supplicant &\n\n" 45sleep 5 46screen -S qemu_screen -p 0 -X stuff "./supp_plugin-rs\n" 47sleep 5 48screen -S qemu_screen -p 0 -X stuff "^C" 49sleep 5 50 51{ 52 grep -q "send value" screenlog.0 && 53 grep -q "invoke" screenlog.0 && 54 grep -q "receive value" screenlog.0 && 55 grep -q "invoke commmand finished" screenlog.0 && 56 grep -q "Success" screenlog.0 57} || { 58 cat -v screenlog.0 59 cat -v /tmp/serial.log 60 false 61} 62 63rm -rf screenlog.0 64rm -rf optee-qemuv8-3.20.0-ubuntu-20.04 65rm -rf shared 66