Expect 脚本非常适合编写基本上“确保运行此命令会打印这些日志”的测试。Expect 可以让您跳过不相关的输出并查找日志中的特定行。
有没有办法确保我们不会遇到特定的消息?
例如,一个简单的 Expect 脚本可能如下所示:
spawn ./my_launcher.sh
expect "System booted."
Run Code Online (Sandbox Code Playgroud)
有什么方法可以确保我们在“系统启动”之前不会得到某个字符串。线出现?
传达我的目标的虚构语法:
spawn ./my_launcher.sh
expect-not "license activation error"
expect "System booted."
Run Code Online (Sandbox Code Playgroud)
har*_*ymc 10
您可以期待多种事情:
expect {
"license activation error" {
... mark that this happened ...
}
"System booted" {
... check if the above error didn't happen and do something ...
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1143 次 |
| 最近记录: |