forked from bellard/quickjs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqemu.exp
executable file
·55 lines (43 loc) · 1.09 KB
/
qemu.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
#!/usr/bin/expect
## Expect Script for Testing NuttX with QEMU Emulator
## For every 1 character sent, wait 0.001 milliseconds
set send_slow {1 0.001}
## Start NuttX on QEMU Emulator
spawn qemu-system-riscv64 \
-semihosting \
-M virt,aclint=on \
-cpu rv64 \
-smp 8 \
-bios none \
-kernel nuttx \
-nographic
## Without REPL:
## Wait for the prompt and enter this command
# expect "nsh> "
# send -s "qjs -e console.log(123) \r"
# ## Check the response...
# expect {
# ## If we see this message, exit normally
# "nsh>" { exit 0 }
# ## If timeout, exit with an error
# timeout { exit 1 }
# }
## With REPL:
## Wait for the prompt and enter this command
expect "nsh> "
send -s "qjs \r"
expect "qjs > "
send -s "console.log(123) \r"
expect "qjs > "
send -s "os.open('/system/bin/init', os.O_RDONLY) \r"
## Wait at most 30 seconds
set timeout 30
## Check the response...
expect {
## If we see this message, exit normally
"qjs >" { exit 0 }
## If we see this message, exit with an error
## "EPC: 0000000080001faa" { exit 1 }
## If timeout, exit with an error
timeout { exit 1 }
}