Forum: GNU Radio test runs twice

Posted by Nemanja Savic (Guest)
on 2013-02-26 13:18
(Received via mailing list)
Hi GNURADIOers,

I wanted to tell you that test for my block runs twice.
Namely, I designed block based on tagged_file_sink, which is able to 
store
some
additional samples before true tag.
I designed also test, but when I run it, it simply executes twice.

at the bottom of my qa file you can find this:

      self.tb.run ()
      print "\nAfter run!\n"
      result_data = (0, 1, 1, 0, 0, 1, 1)
      expected_result = (0, 1, 1, 0, 0, 1, 1)
      self.assertEqual (expected_result, result_data, 6)

and I am able to see in terminal twice "After run", and there are also 
two
files produced by the block itself.

I discovered that at very end of my qa file, there is:

if __name__ == '__main__':
    gr_unittest.run(qa_file_sink_history, "qa_file_sink_history.xml")

but in some older test one can find this:

if __name__ == '__main__':
  gr_unittest.main ()

When change first one with the second one, test executes once as it 
should
be.
Can anybody explain me this behaviour?

Best
Posted by Tom Rondeau (Guest)
on 2013-02-26 15:47
(Received via mailing list)
On Tue, Feb 26, 2013 at 7:17 AM, Nemanja Savic <vlasinac@gmail.com> 
wrote:
>       self.tb.run ()
> if __name__ == '__main__':
>
> Best
>
> --
> Nemanja Savić


It has to do with how we run the test in the gr_unittest.py suite.
Specifically, if you give it an XML file to save the results, it has
to run the test twice: once to output to the XML file and once to
output to the screen for feedback. If you don't provide the XML file
to output to, it will only run the test once.

Their is actually a FIXME in the gr_unittest.py file about this.

Tom
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.