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.14.0-ubuntu-20.04 24rm -rf shared 25 26curl http://mesalock-linux.org/assets/optee-qemuv8-3.14.0-ubuntu-20.04.tar.gz | tar zxv 27mkdir shared 28cp ../examples/big_int-rs/ta/target/aarch64-unknown-optee-trustzone/release/*.ta shared 29cp ../examples/big_int-rs/host/target/aarch64-unknown-linux-gnu/release/big_int-rs shared 30 31screen -L -d -m -S qemu_screen ./optee-qemuv8.sh 32sleep 30 33screen -S qemu_screen -p 0 -X stuff "root\n" 34sleep 5 35screen -S qemu_screen -p 0 -X stuff "mkdir shared && mount -t 9p -o trans=virtio host shared && cd shared\n" 36sleep 5 37screen -S qemu_screen -p 0 -X stuff "cp *.ta /lib/optee_armtz/\n" 38sleep 5 39screen -S qemu_screen -p 0 -X stuff "./big_int-rs\n" 40sleep 5 41screen -S qemu_screen -p 0 -X stuff "^C" 42sleep 5 43 44{ 45 grep -q "\[.*] > \[.*]\|\[.*] < \[.*]\|\[.*] == \[.*]" /tmp/serial.log && 46 grep -q "\[.*] in u8 array is \[.*]" /tmp/serial.log && 47 grep -q "\[.*] in i32 is [0-9]*" /tmp/serial.log && 48 grep -q "\[.*] + \[.*] = \[.*]" /tmp/serial.log && 49 grep -q "\[.*] - \[.*] = \[.*]" /tmp/serial.log && 50 grep -q "\[.*] \* \[.*] = \[.*]" /tmp/serial.log && 51 grep -q "\[.*] / \[.*] = \[.*]" /tmp/serial.log && 52 grep -q "\[.*] % \[.*] = \[.*]" /tmp/serial.log && 53 grep -q "Success" screenlog.0 54} || { 55 cat -v screenlog.0 56 cat -v /tmp/serial.log 57 false 58} 59 60rm -rf screenlog.0 61rm -rf optee-qemuv8-3.14.0-ubuntu-20.04 62rm -rf shared 63