-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qemu-riscv-leds64-rust.exp
executable file
·100 lines (81 loc) · 1.95 KB
/
qemu-riscv-leds64-rust.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
#!/usr/bin/expect
## Expect Script for Testing NuttX with QEMU Emulator
## Wait at most 10 seconds
set timeout 10
## For every 1 character sent, wait 0.01 milliseconds
set send_slow {1 0.01}
## Start the QEMU Emulator for 64-bit RISC-V
spawn qemu-system-riscv64 \
-semihosting \
-M virt,aclint=on \
-cpu rv64 \
-bios none \
-kernel nuttx \
-nographic
## Wait for the prompt and enter `uname -a`
expect "nsh> "
send -s "uname -a\r"
## Wait for the prompt and enter `free`
expect "nsh> "
send -s "free\r"
## Wait for the prompt and enter `hello`
expect "nsh> "
send -s "hello\r"
## Wait for the prompt and enter `getprime`
expect "nsh> "
send -s "getprime\r"
## Wait for the prompt and enter `hello`
expect "nsh> "
send -s "hello\r"
## Wait for the prompt and enter `getprime`
expect "nsh> "
send -s "getprime\r"
## Wait for the prompt and enter `ls -l /dev`
expect "nsh> "
send -s "ls -l /dev\r"
## Wait for the prompt and enter `ps`
expect "nsh> "
send -s "ps\r"
## Wait for the prompt and enter `leds_rust`
expect "nsh> "
send -s "leds_rust\r"
## Check the response...
expect {
## If we see this message, continue normally
"board_userled: LED 1 set to 0" {}
## If timeout, exit with an error
timeout {
## Terminate the session: Ctrl-A x
send "\x01x"
puts "\n===== Error: Test Failed\n"
exit 1
}
}
## Check the response...
expect {
## If we see this message, continue normally
"board_userled: LED 2 set to 0" {}
## If timeout, exit with an error
timeout {
## Terminate the session: Ctrl-A x
send "\x01x"
puts "\n===== Error: Test Failed\n"
exit 1
}
}
## Check the response...
expect {
## If we see this message, continue normally
"board_userled: LED 3 set to 0" {}
## If timeout, exit with an error
timeout {
## Terminate the session: Ctrl-A x
send "\x01x"
puts "\n===== Error: Test Failed\n"
exit 1
}
}
## Terminate the session: Ctrl-A x
send "\x01x"
puts "\n===== Test OK\n"
exit 0