question

dclaar avatar image
dclaar Suspended asked dclaar Suspended posted

Close on error?

Is there some way to close tclsh on an error from an analysis rule? i.e.

open tclsh application://com.fnfr.svt.applications.tclsh command tclsh puts foo analyze contains foo When True close tclsh

 

Right now, because iTest hates goto, I do something like

 

open tclsh application://com.fnfr.svt.applications.tclsh foreach i {1} command tclsh puts foo analyze contains foo When True break ... close tclsh

 

 

Which is ugly, but gets the job done. I guess I could callProcedure closeit "tclsh", and have that procedure close it, but that's ugly, too.

 

iTest
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
PaulD avatar image
PaulD answered PaulD posted

I'm not exactly sure what the big picture is here.  (The foreach i {1} seems odd to me.) 

 

Is there some need to aggressively close the Tclsh session?  What's the rush?  In any case, CallProcedure actions (either from analysis or events) looks like the answer.  

 

We'd really like to be able to put any kind of executable steps inside analysis rule actions.  But that is going to take some major surgery -- as it means that call stacks need to traverse through analysis rules, which requires some re-engineering.  So CallProcedure is the wildcard action that lets you get this kind of thing done.  

4 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dclaar avatar image dclaar commented ·

The "rush" is that, if I bail out of this tclsh, then the next open tclsh fails, because it was left open.

 

open tclsh

do stuff

   if bad_stuff, then goto end

 

end: close tclsh

 

But, of course, iTest bought into the whole "goto is evil" thing. So the above is rewritten:

 

open tclsh

for i {1}

   do stuff

      if bad_stuff, break

 

close tclsh

 

In otherwords, it is a "blessed" goto. Which is to say, iTest doesn't complain.

 

0 Likes 0 ·
PaulD avatar image PaulD dclaar commented ·

Ahh.  I see, the "for" is simply so that you can use a "break" to skip over a bunch of steps.  Right?

 

It sounds like what you would really like is a "try/catch/finally" capability.  Then you could use a "throw" action that will pop out of the context.  Right?  We've been talking about adding structured exception handling to iTest for exactly these scenarios.

0 Likes 0 ·
KumarS avatar image KumarS PaulD commented ·
In my opinion though - analysis rule->When true, When False is kind of equivalent of "if then else". You can definitely close the tclsh using "if then else" syntax. So it would be nice to have try-catch or ability to execute steps in analysis rules (other than call procedure), but you can do that currently in pretty much the same way.
0 Likes 0 ·
dclaar avatar image dclaar PaulD commented ·
Yep, that would work!
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.