File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments