diff options
author | Maximilian Stiefel <stiefel.maximilian@online.de> | 2018-03-14 15:25:09 +0100 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2018-03-22 23:35:40 +0100 |
commit | 38b6d3216652fcf329babfe81bdd5bfde1c4afef (patch) | |
tree | 29981ca157006ba54d2a5d3fb96d6c408db72018 /gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py | |
parent | 6ab59c7528384cae182d59dfb3ae35899cac179d (diff) |
Throwing a std::invalid_argument instead of letting SIGFPE happen for wrong input in case of the OFDM carrier allocator.
Fixes #1648
Diffstat (limited to 'gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py')
-rwxr-xr-x | gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py b/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py index befb15ac4a..bd1dfb0915 100755 --- a/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py +++ b/gr-digital/python/digital/qa_ofdm_carrier_allocator_cvc.py @@ -1,23 +1,23 @@ #!/usr/bin/env python -# Copyright 2012-2014 Free Software Foundation, Inc. -# +# Copyright 2012-2018 Free Software Foundation, Inc. +# # This file is part of GNU Radio -# +# # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. -# +# # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -# +# from gnuradio import gr, gr_unittest, digital, blocks import pmt @@ -208,6 +208,32 @@ class qa_digital_carrier_allocator_cvc (gr_unittest.TestCase): self.assertEqual(correct_offsets[key], tag.offset) self.assertTrue(all(tags_found.values())) + @gr_unittest.unittest.skip("Skipping test with wrong input (caused SIGFPE earlier, now throws a simple std::invalid_argument with useful message)") + def test_004_t (self): + """ + Provoking exception (earlier SIGFPE). + """ + fft_len = 6 + tx_symbols = (1, 2, 3) + pilot_symbols = () + occupied_carriers = ((-1, 1, 2),) + pilot_carriers = () + expected_result = (0, 0, 1, 0, 2, 3) + src = blocks.vector_source_c(tx_symbols, False, 1) + alloc = digital.ofdm_carrier_allocator_cvc(fft_len, + occupied_carriers, + pilot_carriers, + pilot_symbols, (), + self.tsb_key) + sink = blocks.tsb_vector_sink_c(fft_len) + self.tb.connect( + src, + blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_symbols), self.tsb_key), + alloc, + sink + ) + self.tb.run () + self.assertEqual(sink.data()[0], expected_result) if __name__ == '__main__': gr_unittest.run(qa_digital_carrier_allocator_cvc, "qa_digital_carrier_allocator_cvc.xml") |