mirror of
https://github.com/lupyuen/nuttx-riscv64.git
synced 2025-01-12 15:18:29 +08:00
72 lines
1.5 KiB
Text
Executable file
72 lines
1.5 KiB
Text
Executable file
#!/usr/bin/expect
|
|
## Expect Script for Testing NuttX with QEMU Emulator
|
|
|
|
## Wait at most 300 seconds
|
|
set timeout 300
|
|
|
|
## For every 1 character sent, wait 0.01 milliseconds
|
|
set send_slow {1 0.01}
|
|
|
|
## Start the QEMU Emulator for 32-bit RISC-V with OpenSBI
|
|
spawn qemu-system-riscv32 \
|
|
-semihosting \
|
|
-M virt,aclint=on \
|
|
-cpu rv32 \
|
|
-kernel nuttx \
|
|
-bios opensbi-1.5-rv-bin/share/opensbi/ilp32/generic/firmware/fw_dynamic.bin \
|
|
-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 `ps`
|
|
expect "nsh> "
|
|
send -s "ps\r"
|
|
|
|
## Wait for the prompt and enter `ls -l /dev`
|
|
expect "nsh> "
|
|
send -s "ls -l /dev\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 `ostest`
|
|
expect "nsh> "
|
|
send -s "ostest\r"
|
|
|
|
## Check the response...
|
|
expect {
|
|
## If we see this message, exit normally
|
|
"ostest_main: Exiting with status 0" {
|
|
## Terminate the session: Ctrl-A x
|
|
send "\x01x"
|
|
puts "\n===== Test OK\n"
|
|
exit 0
|
|
}
|
|
|
|
## If timeout, exit with an error
|
|
timeout {
|
|
## Terminate the session: Ctrl-A x
|
|
send "\x01x"
|
|
puts "\n===== Error: Test Failed\n"
|
|
exit 1
|
|
}
|
|
}
|