blob: cff9ba50e1b3c1f2c9a4ec946a75141f302035dc [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..."
Jerome Forissier7950f2b2015-09-03 10:35:29 +020041spawn ../qemu/arm-softmmu/qemu-system-arm -nographic -monitor none -machine virt -cpu cortex-a15 -m 1057 -serial stdio -serial file:serial1.log -bios $bios
42expect {
43 "Kernel panic" {
44 info "!!! Kernel panic\n"
45 exit 1
46 }
47 timeout {
48 info "!!! Timeout\n"
49 exit 1
50 }
51 "Please press Enter to activate this console. "
52}
Jerome Forissierf080b5a2015-08-07 16:18:57 +020053send -- "\r"
54expect "root@Vexpress:/ "
55info " done, guest is booted.\nLoading OP-TEE driver and tee-supplicant..."
Jerome Forissier7950f2b2015-09-03 10:35:29 +020056# Toolchain libraries might be here or there
57send -- "export LD_LIBRARY_PATH=/lib:/lib/arm-linux-gnueabihf\r"
58expect "root@Vexpress:/ "
Jerome Forissierf080b5a2015-08-07 16:18:57 +020059send -- "modprobe optee_armtz\r"
60expect "root@Vexpress:/ "
61sleep 1
62send -- "tee-supplicant&\r"
63expect "root@Vexpress:/ "
64sleep 1
65info " done.\nRunning: $cmd...\n"
66send -- "$cmd\r"
Jerome Forissier7950f2b2015-09-03 10:35:29 +020067set casenum "none"
Jerome Forissierf080b5a2015-08-07 16:18:57 +020068expect {
69 # Exit with error status as soon as a test fails
70 -re { XTEST_TEE_([^ ]+) FAIL} {
Jerome Forissier7950f2b2015-09-03 10:35:29 +020071 info " $expect_out(1,string) FAIL\n"
72 exit 1
73 }
74 -re {rcu_sched detected stalls} {
75 info " Kernel error: '$expect_out(0,string)'\n"
Jerome Forissierf080b5a2015-08-07 16:18:57 +020076 exit 1
77 }
78 # Crude progress indicator: print one # when each test [sub]case starts
79 -re {([\*o]) XTEST_TEE_([^ ]+) } {
80 set casenum $expect_out(2,string)
81 if {$expect_out(1,string) == "o"} {
82 if {$star == 1} {
83 # Do not count first subcase ('o') since start
84 # of test ('*') was counted already
85 set star 0
86 exp_continue
87 }
88 } else {
89 set star 1
90 }
91 info "#"
92 incr ncases
Jerome Forissier7950f2b2015-09-03 10:35:29 +020093 if {$ncases % 50 == 0} { info "\n" }
Jerome Forissierf080b5a2015-08-07 16:18:57 +020094 exp_continue
95 }
96 # Exit when result separator is seen
97 "+-----------------------------------------------------\r\r" {}
98 timeout {
99 info "!!! Timeout\n"
Jerome Forissier7950f2b2015-09-03 10:35:29 +0200100 info "TIMEOUT - test case too long or hung? (last test started: $casenum)\n"
Jerome Forissierf080b5a2015-08-07 16:18:57 +0200101 exit 2
102 }
103}
104info "\nStatus: PASS ($ncases test cases)\n"
105