在我的情况下,expect
与调试模式中的预期不符,我不明白为什么...
相关tcl的部分是这样的
...
set index 0
set p [lindex $propname $index]
send "prove -property {<embedded>::wrapper.$p}\r"
expect {
"*proven\r\n\[<embedded>\] % " {
incr index
if {$index == [llength $propname]} {
send "exit\r"
expect "*bash-4.2$ "
send "exit\r"
close
}
set p [lindex $propname $index]
send "prove -property {<embedded>::wrapper.$p}\r"
exp_continue
}
"*cex\r\n\[<embedded>\] % " {
send "visualize -violation -property <embedded>::wrapper.$p\r"
expect "*\[<embedded>\] % "
send "visualize -save -vcd cex.vcd -force\r"
}
}
...
从调试模式的输出中:
expect: does "prove -property {<embedded>::wrapper.x0_nouse}\r\nINFO (IPF031): Settings used for this proof:\r\n time_limit = 86400s\r\n per_property_time_limit = 1s * 10 ^ scan\r\n engine_mode = Hp Ht N B \r\n proofgrid_per_engine_max_jobs = 1\r\n proofgrid_mode = local\r\n proofgrid_restarts = 10\r\nINFO (IPF036): Starting proof on task: "<embedded>", 1 properties to prove with 0 already proven/unreachable\r\nINFO (IRS029): Starting reset analysis: phase 1 of 4.\r\nINFO (IRS030): Running reset analysis phase 2 of 4.\r\nINFO (IRS031): Running reset analysis phase 3 of 4.\r\nINFO (IRS020): Starting the reset analysis simulation with a limit of 100 iterations (phase 4 of 4).\r\nINFO (IRS024): Reset iterations 0 to 4 analyzed.\r\nINFO (IRS018): Reset analysis simulation executed for 3 iterations. Assigned values for 280 of 4626 design flops, 0 of 32 design latches, 136 of 2696 internal elements.\r\nUsing multistage preprocessing\r\nStarting reduce\r\nFinished reduce in 0.192s\r\n0.PRE: A proof was found: No trace exists. [0.00 s]\r\nINFO (IPF057): 0.PRE: The property "wrapper.x0_nouse" was proven in 0.00 s.\r\nFound proofs for 1 properties in preprocessing\r\nINFO (IPF059): Completed proof on task: <embedded>\r\nproven\r\n[<embedded>] % " (spawn_id exp4) match glob pattern "*proven\r\n[<embedded>] % "? no
"*cex\r\n[<embedded>] % "? no
抱歉,该行有点长,但是如果滚动到最右边,则会看到该行的末尾恰好是第一种情况下的期望值。
答案 0 :(得分:3)
您正在提供全局模式,并且正确地需要转义[]
,以便tcl不能将其作为命令来执行。您需要进一步转义[]
,以便[abc]
与文字字符串[abc]
匹配,而不仅仅是集合abc
中的字符。
但是,当用""
引用时,反斜杠也必须转义,因此您需要将其用作glob模式
"proven\r\n\\\[<embedded>\\\] % "
作为替代方案,您可以尝试完全匹配而不使用glob
-exact "proven\r\n\[<embedded>\] % "
您也可以使用{}
而不是""
,但是您的\r
等将不会转换。