Editing Guided Tutorial GNU Radio in C++

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 702: Line 702:
 
== Step 6: Quality Assurance (Unit Testing) ==
 
== Step 6: Quality Assurance (Unit Testing) ==
  
In the previous steps of writing the OOT module, we produced the QPSK demodulator, but it doesn't guarantee the correct working of our block. In this situation, it becomes significant to write a unit test for our module that certifies the clean implementation of the QPSK demodulator.
+
https://raw.githubusercontent.com/gnuradio/gr-tutorial/master/examples/tutorial4/figs/Constellation_diagram.png
  
Below is the source of code of the <code>qa_qpsk_demod.py</code> can be found under <code>python/</code>
+
Figure above represents the constellation diagram (displayed in accordance to the Qt GUI Constellation Sink) of the QPSK modulated input fed to out OOT module. The task of our QPSK demodulator is to demodulate this complex valued input stream and to produce stream of quaternary alphabets (0,1,2,3) or simply bytes as output.
 +
 
 +
By following the steps of writing the OOT module, we did manage to produce the byte stream at the output of QPSK demodulator, still, it doesn't guarantee the correct working of our block. In this situation, it becomes significant to write unit test for our module that certifies the clean implementation of the QPSK demodulator.
 +
 
 +
Below we see the source of code of the <code>qa_qpsk_demod.py</code> can be found under <code>python/</code>
  
 
Full QA code
 
Full QA code
Line 777: Line 781:
  
  
Obviously the <code>qa_qpsk_demod</code> is implemented in python, in spite of we opted C++ in the first case for writing our blocks. This is because GNU Radio inherits the [https://docs.python.org/2/library/unittest.html python unittest framework] to support quality assurance. And, if you remember it correctly from previous tutorials, swig as part of GNU Radio framework, provides python bindings for the C++ code. Hence, we are able to write the unit test for our block <code>qa_qpsk_demod</code> in Python.
+
It can be easily noticed that the <code>qa_qpsk_demod</code> is implemented in python, in spite of we opted C++ in the first case for writing our blocks. This is because, GNU Radio inherits the [https://docs.python.org/2/library/unittest.html python unittest framework] to support quality assurance. And, if you remember it correctly from previous tutorials, swig as part of GNU Radio framework, provides python bindings for the C++ code. Hence, we are able to write the unit test for our block <code>qa_qpsk_demod</code> in python.
  
 
So lets gather a bit of know how on how to write test cases for the block. Okay, lets consider the header part first:
 
So lets gather a bit of know how on how to write test cases for the block. Okay, lets consider the header part first:
Line 803: Line 807:
 
self.assertEqual(len(expected_result), len(result_data))
 
self.assertEqual(len(expected_result), len(result_data))
 
</syntaxhighlight>
 
</syntaxhighlight>
determine the result of test cases as passed or failed. The test cases are executed before installation of the module by running <code>make test</code> yielding the following output:
+
determine the result of test cases as passed or failed. The test cases are executed before installation of the module by running <code>make test</code>:<br />
 +
Output
 
<pre>
 
<pre>
barry@barry:~/gr-tutorial/build$ make test
+
xyz@comp:mydir/gr-tutorial/build$ make test
Running tests...
+
Running tests...
Test project /home/barry/gr-tutorial/build
+
Test project /home/kaushik/src/gr-tutorial/build
    Start 1: test_tutorial
+
    Start 1: test_tutorial
1/2 Test #1: test_tutorial ....................  Passed    0.02 sec
+
1/3 Test #1: test_tutorial ....................  Passed    0.11 sec
    Start 2: qa_my_qpsk_demod_cb
+
    Start 2: qa_chat_sanitizer
2/2 Test #2: qa_my_qpsk_demod_cb ..............  Passed    1.01 sec
+
2/3 Test #2: qa_chat_sanitizer ................***Failed    0.04 sec
 
+
    Start 3: qa_qpsk_demod
100% tests passed, 0 tests failed out of 2
+
3/3 Test #3: qa_qpsk_demod ....................  Passed    2.00 sec
 
+
Total Test time (real) =  1.04 sec
+
67% tests passed, 1 tests failed out of 3
 +
 +
Total Test time (real) =  2.34 sec
 +
 +
The following tests FAILED:
 +
      2 - qa_chat_sanitizer (Failed)
 +
Errors while running CTest
 +
make: *** [test] Fehler 8
 
</pre>
 
</pre>
  
 +
In the output above, one of the test failed, however, Test 3 belonging to the <code>qa_qpsk_demod</code>, claims to have passed the test cases.<br />
 
Congratulations, we have just finished writing our OOT module <code>gr-tutorial</code> and a C++ block <code>my_qpsk_demodulator</code>.
 
Congratulations, we have just finished writing our OOT module <code>gr-tutorial</code> and a C++ block <code>my_qpsk_demodulator</code>.
  

Please note that all contributions to GNU Radio are considered to be released under the Creative Commons Attribution-ShareAlike (see GNU Radio:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)