Skip to content

Commit 605dddc

Browse files
committed
QEMU Expect Script tested OK
1 parent 67faed9 commit 605dddc

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

nuttx.exp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/expect
2+
## Expect Script for Testing NuttX with QEMU Emulator
3+
4+
## Wait at most 300 seconds
5+
set timeout 300
6+
7+
## For every 1 character sent, wait 0.01 milliseconds
8+
set send_slow {1 0.01}
9+
10+
## Start the QEMU Emulator for 64-bit RISC-V
11+
spawn qemu-system-riscv64 \
12+
-semihosting \
13+
-M virt,aclint=on \
14+
-cpu rv64 \
15+
-bios none \
16+
-kernel nuttx \
17+
-nographic
18+
19+
## Wait for the prompt and enter `uname -a`
20+
expect "nsh> "
21+
send -s "uname -a\r"
22+
23+
## Wait for the prompt and enter `free`
24+
expect "nsh> "
25+
send -s "free\r"
26+
27+
## Wait for the prompt and enter `hello`
28+
expect "nsh> "
29+
send -s "hello\r"
30+
31+
## Wait for the prompt and enter `getprime`
32+
expect "nsh> "
33+
send -s "getprime\r"
34+
35+
## Wait for the prompt and enter `hello`
36+
expect "nsh> "
37+
send -s "hello\r"
38+
39+
## Wait for the prompt and enter `getprime`
40+
expect "nsh> "
41+
send -s "getprime\r"
42+
43+
## Wait for the prompt and enter `ostest`
44+
expect "nsh> "
45+
send -s "ostest\r"
46+
47+
## Check the response...
48+
expect {
49+
## If we see this message, exit normally
50+
"ostest_main: Exiting with status 0" {
51+
## Terminate the session: Ctrl-A x
52+
send "\x01x"
53+
puts "\n===== Test OK\n"
54+
exit 0
55+
}
56+
57+
## If timeout, exit with an error
58+
timeout {
59+
## Terminate the session: Ctrl-A x
60+
send "\x01x"
61+
puts "\n===== Error: Test Failed\n"
62+
exit 1
63+
}
64+
}

0 commit comments

Comments
 (0)