- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
BREAK command does not work when the LOOP is invoked as a thread
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-18-2009 04:18 AM
Hi team
I have a testcase scenario as below. I am trying to use parallel threading concepts and am stuck. Can anyone please help.
Test case:
- Login to the device twice with 2 different session handles
- Execute command1 on session_handle1 (wrapped inside a for loop) which is invoked as thread1
- Execute command1 on session_handle2 (wrapped inside a for loop) which is invoked as thread2
- To break out of the LOOP when a particular state of the device is achieved (which is found by parsing the command output).
Issue: though break command is used inside a FOR LOOP, I see an error message in Execution Issues window saying:
“Illegal action break; BREAK is only valid inside a loop: for, foreach, while.
Looks like, the command break is not supported when the for loop is invoked as a thread. Is there any way to step out of the loop on a certain condition of the response?
Code Snippet Used:
for i=0; i < 10; incr i
{
command SESSION_HANDLE command_name
analysis rule to check whether a certain part of the output is as EXPECTED
if $output != “expected”
then
sleep 2 (checks for the Recovery of the device every 2s and for a maximum of 20s)
else
break (On recovery of the device well within 20s, just step out of the loop)
}
The same successfully breaks out from the loop if the loop is not invoked as a thread. But, if I use that method, then I will not be able to run the next command parallely until the WAIT logic on the first thread completes.
Please let me know if there is any alternative way to go ahead with this kind of implementation.
Thanks
Ashwini
Re: BREAK command does not work when the LOOP is invoked as a thread
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-18-2009 08:19 AM
This seems like a bug. You could try the following:
create a comment step before the for loop. Select the for step and make it child step of the comment step. Then make the comment step asynchronous instead of the for step. If it works, you can use this as a workaround for now.
Re: BREAK command does not work when the LOOP is invoked as a thread
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-18-2009 08:36 AM
Or you could simply change the "break" to "return". In this example, there are no additional instructions to execute in this secondary thread anyway. So these should be equivalent.
