Repeat the execution of the test cases until terminated manually [message #1802219] |
Mon, 04 February 2019 09:11  |
Eclipse User |
|
|
|
Hi, guys,
I am currently trying to test a system "live". This requires a repeated execution of some test cases. As soon as one of these test cases fails, the execution is stopped, but it should also be possible to stop the execution manually. You can do this using the "Terminate" button in Eclipse, but this is not a clean solution because the "mctr_cli" instance still runs and therefore does not quit.
Is there a flag or something like that you could set manually and then query in a while loop?
I'm looking forward to your help!
LG Sean
|
|
|
|
|
Re: Repeat the execution of the test cases until terminated manually [message #1802586 is a reply to message #1802574] |
Tue, 12 February 2019 05:32  |
Eclipse User |
|
|
|
Hi Sean,
I had a similar demand for repeated test execution and counting the verdicts in an automated fashion. However, I assume stopping the execution on the occurrence of a failed test case should be also easily possible.
Rather than the Eclipse IDE, I used Titan with the CLI and python for the automation tasks.
Let me illustrate the concept with a few snippets of python code:
First, you would require a function which encapsulates the spawning of Titan and your test suite
def start_test_suite(test_suite, config):
"""
test_suite is the path to the binary test suite
config is the path to the configuration file
"""
args = ['ttcn3_start', test_suite, config]
child = subprocess.Popen(args, stdout=subprocess.PIPE)
return child
Now let's start the test suite and check for verdicts
child_process = start_test_suite(test_suite, config)
line = 'initialize line'
while line != '':
line = child_process.stdout.readline().decode("utf-8")
if 'finished. Verdict:' in line:
# here you should have lines like: "MTC@lx: Test case [TC] finished. Verdict: pass reason: [your reason]
# grab the verdict with regex: the verdict result is between the keyword 'Verdict:' and 'reason:'
# e.g. something like matches = re.finditer(r'Verdict:\s(.*)reason:')
Once you have found a fail verdict, you can simply terminate the child process. This should be similar to clicking the "Terminate" button within the IDE
child_process.terminate()
For clean manual termination, you will probably need to add a signal handler which listens for CTRL+C and terminates the child process gracefully.
Cheers,
Alex
|
|
|
Powered by
FUDForum. Page generated in 0.05425 seconds