forked from OP-TEE/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqemu-check.exp
112 lines (106 loc) · 3.24 KB
/
qemu-check.exp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/expect -f
#
# This scripts starts QEMU, loads and boots Linux/OP-TEE, then runs
# xtest in the guest. The return code is 0 for success, >0 for error.
#
# Options:
# --bios Path to the binary to be run [../out/bios-qemu/bios.bin]
# -q Suppress output to stdout (quiet)
# --timeout Timeout for each test (sub)case, in seconds [480]
set bios "../out/bios-qemu/bios.bin"
set cmd "xtest"
set quiet 0
# The time required to run some tests (e.g., key generation tests [4007.*])
# can be significant and vary widely -- typically, from about one minute to
# several minutes depending on the host machine.
set timeout 480
# Parse command line
set myargs $argv
while {[llength $myargs]} {
set myargs [lassign $myargs arg]
switch -exact -- $arg {
"--bios" {set myargs [lassign $myargs ::bios]}
"--timeout" {set myargs [lassign $myargs ::timeout]}
"-q" {set ::quiet 1}
}
}
proc info arg {
if {$::quiet==1} { return }
puts -nonewline $arg
flush stdout
}
# Disable echoing of guest output
log_user 0
# Save guest console output to a file
log_file -a -noappend "serial0.log"
info "Starting QEMU..."
open "serial1.log" "w+"
spawn -open [open "|tail -f serial1.log"]
set teecore $spawn_id
if {[string first "aarch64" $::env(QEMU)] != -1} {
spawn $::env(QEMU) -nographic -serial mon:stdio -serial file:serial1.log -smp $::env(QEMU_SMP) -machine virt,secure=on -cpu cortex-a57 -d unimp -semihosting-config enable,target=native -m 1057 -bios bl1.bin -initrd rootfs.cpio.gz -kernel Image -no-acpi -append "console=ttyAMA0,38400 keep_bootcon root=/dev/vda2"
} else {
spawn $::env(QEMU) -nographic -monitor none -machine virt -machine secure=on -cpu cortex-a15 -smp $::env(QEMU_SMP) -d unimp -semihosting-config enable,target=native -m 1057 -serial stdio -serial file:serial1.log -bios $bios
}
expect {
"Kernel panic" {
info "!!! Kernel panic\n"
exit 1
}
timeout {
info "!!! Timeout\n"
exit 1
}
"ogin:"
}
send -- "root\r\r"
expect "# "
info " done, guest is booted.\n"
# Toolchain libraries might be here or there
send -- "export LD_LIBRARY_PATH=/lib:/lib/arm-linux-gnueabihf\r"
expect "# "
info "Running: $cmd...\n"
send -- "$cmd\r"
set casenum "none"
expect {
# Exit with error status as soon as a test fails
-re { regression_([^ ]+) FAIL} {
info " $expect_out(1,string) FAIL\n"
exit 1
}
-re {rcu_sched detected stalls} {
info " Kernel error: '$expect_out(0,string)'\n"
exit 1
}
# Crude progress indicator: print one # when each test [sub]case starts
-re {([\*o]) regression_([^ ]+) } {
set casenum $expect_out(2,string)
if {$expect_out(1,string) == "o"} {
if {$star == 1} {
# Do not count first subcase ('o') since start
# of test ('*') was counted already
set star 0
exp_continue
}
} else {
set star 1
}
info "#"
incr ncases
if {$ncases % 50 == 0} { info "\n" }
exp_continue
}
# Exit when result separator is seen
"+-----------------------------------------------------\r\r" {}
# Handle errors in TEE core output
-i $teecore -re {(assertion.*failed at.*)\n} {
info "!!! TEE core assertion failed: '$expect_out(1,string)'\n"
exit 1
}
timeout {
info "!!! Timeout\n"
info "TIMEOUT - test case too long or hung? (last test started: $casenum)\n"
exit 2
}
}
info "\nStatus: PASS ($ncases test cases)\n"