blob: eb7865056b954e34646db758858795a5104dcd4a [file] [log] [blame]
Jerome Forissierf080b5a2015-08-07 16:18:57 +02001#!/usr/bin/expect -f
2#
3# This scripts starts QEMU, loads and boots Linux/OP-TEE, then runs
4# xtest in the guest. The return code is 0 for success, >0 for error.
5#
6# Options:
7# --bios Path to the binary to be run [../out/bios-qemu/bios.bin]
8# -q Suppress output to stdout (quiet)
9
10set bios "../out/bios-qemu/bios.bin"
11set cmd "xtest"
12set quiet 0
13
14# The time required to run some tests (e.g., key generation tests [4007.*])
15# can be significant and vary widely -- typically, from about one minute to
16# several minutes depending on the host machine.
17# So, set an infinite timeout.
18set timeout -1
19
20# Parse command line
21set myargs $argv
22while {[llength $myargs]} {
23 set myargs [lassign $myargs arg]
24 switch -exact -- $arg {
25 "--bios" {set myargs [lassign $myargs ::bios]}
26 "-q" {set ::quiet 1}
27 }
28}
29
30proc info arg {
31 if {$::quiet==1} { return }
32 puts -nonewline $arg
33 flush stdout
34}
35
36# Disable echoing of guest output
37log_user 0
38# Save guest console output to a file
39log_file -a -noappend "serial0.log"
40info "Starting QEMU..."
41spawn ../qemu/arm-softmmu/qemu-system-arm -machine virt -cpu cortex-a15 -m 1057 -serial stdio -serial file:serial1.log -bios $bios
42expect "*Please press Enter to activate this console. "
43send -- "\r"
44expect "root@Vexpress:/ "
45info " done, guest is booted.\nLoading OP-TEE driver and tee-supplicant..."
46send -- "modprobe optee_armtz\r"
47expect "root@Vexpress:/ "
48sleep 1
49send -- "tee-supplicant&\r"
50expect "root@Vexpress:/ "
51sleep 1
52info " done.\nRunning: $cmd...\n"
53send -- "$cmd\r"
54expect {
55 # Exit with error status as soon as a test fails
56 -re { XTEST_TEE_([^ ]+) FAIL} {
57 info "$expect_out(1,string) FAIL"
58 exit 1
59 }
60 # Crude progress indicator: print one # when each test [sub]case starts
61 -re {([\*o]) XTEST_TEE_([^ ]+) } {
62 set casenum $expect_out(2,string)
63 if {$expect_out(1,string) == "o"} {
64 if {$star == 1} {
65 # Do not count first subcase ('o') since start
66 # of test ('*') was counted already
67 set star 0
68 exp_continue
69 }
70 } else {
71 set star 1
72 }
73 info "#"
74 incr ncases
75 exp_continue
76 }
77 # Exit when result separator is seen
78 "+-----------------------------------------------------\r\r" {}
79 timeout {
80 info "!!! Timeout\n"
81 info "TIMEOUT - test case too long or hung? ($casenum)\n"
82 exit 2
83 }
84}
85info "\nStatus: PASS ($ncases test cases)\n"
86