From 9730ee8ebee199e70a52a64fe9fa5f1df44d2a60 Mon Sep 17 00:00:00 2001 From: Wosser1sProductions Date: Wed, 22 Feb 2017 19:18:59 +0100 Subject: [PATCH] Bugfix in XML test ~ Fixed the testing to properly create and destroy a tob_block so the correct spreading factor can be set. ~ Removed explicit expected-data-all and expected-hdr in xml file. This way the testing will only be done on the actual data and not the PHY HDR (since its currently unsure whate the correct HDR should be) --- examples/qa_BasicTest_Data.xml | 308 ++++++++++++++++----------------- python/qa_BasicTest_XML.py | 181 +++++++++---------- 2 files changed, 232 insertions(+), 257 deletions(-) diff --git a/examples/qa_BasicTest_Data.xml b/examples/qa_BasicTest_Data.xml index ec5833c..327d8a2 100644 --- a/examples/qa_BasicTest_Data.xml +++ b/examples/qa_BasicTest_Data.xml @@ -3,616 +3,616 @@ ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_000.cfile 7 - 80 0b 01 01 23 45 67 89 ab cd ef - 80 0b 01 + + 01 23 45 67 89 ab cd ef 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_000.cfile 8 - 80 0b 01 01 23 45 67 89 ab cd ef - 80 0b 01 + + 01 23 45 67 89 ab cd ef 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_000.cfile 12 - 80 0b 01 01 23 45 67 89 ab cd ef - 80 0b 01 + + 01 23 45 67 89 ab cd ef 10 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_000.cfile 6 - 80 0f 02 01 23 45 67 89 ab cd ef - 80 0f 02 + + 01 23 45 67 89 ab cd ef 10 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_000.cfile 7 - 80 0f 02 01 23 45 67 89 ab cd ef - 80 0f 02 + + 01 23 45 67 89 ab cd ef 10 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_000.cfile 6 - 80 0d 05 01 23 45 67 89 ab cd ef - 80 0d 05 + + 01 23 45 67 89 ab cd ef 10 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_000.cfile 7 - 80 0d 05 01 23 45 67 89 ab cd ef - 80 0d 05 + + 01 23 45 67 89 ab cd ef 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_001.cfile 7 - 30 0b 02 11 11 11 - 30 0b 02 + + 11 11 11 1 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_001.cfile 8 - 30 0b 02 11 11 11 - 30 0b 02 + + 11 11 11 1 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_001.cfile 12 - 30 0b 02 11 11 11 - 30 0b 02 + + 11 11 11 1 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_001.cfile 6 - 30 0f 01 11 11 11 - 30 0f 01 + + 11 11 11 1 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_001.cfile 7 - 30 0f 01 11 11 11 - 30 0f 01 + + 11 11 11 1 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_001.cfile 6 - 30 0d 06 11 11 11 - 30 0d 06 + + 11 11 11 1 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_001.cfile 7 - 30 0d 06 11 11 11 - 30 0d 06 + + 11 11 11 1 ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_002.cfile 7 - 30 0b 02 11 11 11 - 30 0b 02 + + 11 11 11 5 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_002.cfile 8 - 30 0b 02 11 11 11 - 30 0b 02 + + 11 11 11 5 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_002.cfile 12 - 30 0b 02 11 11 11 - 30 0b 02 + + 11 11 11 5 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_002.cfile 6 - 30 0f 01 11 11 11 - 30 0f 01 + + 11 11 11 5 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_002.cfile 7 - 30 0f 01 11 11 11 - 30 0f 01 + + 11 11 11 5 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_002.cfile 6 - 30 0d 06 11 11 11 - 30 0d 06 + + 11 11 11 5 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_002.cfile 7 - 30 0d 06 11 11 11 - 30 0d 06 + + 11 11 11 5 ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_003.cfile 7 - 40 0b 07 aa aa aa aa - 40 0b 07 + + aa aa aa aa 3 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_003.cfile 8 - 40 0b 07 aa aa aa aa - 40 0b 07 + + aa aa aa aa 3 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_003.cfile 12 - 40 0b 07 aa aa aa aa - 40 0b 07 + + aa aa aa aa 3 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_003.cfile 6 - 40 0f 04 aa aa aa aa - 40 0f 04 + + aa aa aa aa 3 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_003.cfile 7 - 40 0f 04 aa aa aa aa - 40 0f 04 + + aa aa aa aa 3 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_003.cfile 6 - 40 0d 03 aa aa aa aa - 40 0d 03 + + aa aa aa aa 3 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_003.cfile 7 - 40 0d 03 aa aa aa aa - 40 0d 03 + + aa aa aa aa 3 ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_004.cfile 7 - 40 0b 07 ff ff ff ff - 40 0b 07 + + ff ff ff ff 1 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_004.cfile 8 - 40 0b 07 ff ff ff ff - 40 0b 07 + + ff ff ff ff 1 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_004.cfile 12 - 40 0b 07 ff ff ff ff - 40 0b 07 + + ff ff ff ff 1 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_004.cfile 6 - 40 0f 04 ff ff ff ff - 40 0f 04 + + ff ff ff ff 1 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_004.cfile 7 - 40 0f 04 ff ff ff ff - 40 0f 04 + + ff ff ff ff 1 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_004.cfile 6 - 40 0d 03 ff ff ff ff - 40 0d 03 + + ff ff ff ff 1 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_004.cfile 7 - 40 0d 03 ff ff ff ff - 40 0d 03 + + ff ff ff ff 1 ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_005.cfile 7 - 40 0b 07 ff ff ff ff - 40 0b 07 + + ff ff ff ff 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_005.cfile 8 - 40 0b 07 ff ff ff ff - 40 0b 07 + + ff ff ff ff 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_005.cfile 12 - 40 0b 07 ff ff ff ff - 40 0b 07 + + ff ff ff ff 10 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_005.cfile 6 - 40 0f 04 ff ff ff ff - 40 0f 04 + + ff ff ff ff 10 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_005.cfile 7 - 40 0f 04 ff ff ff ff - 40 0f 04 + + ff ff ff ff 10 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_005.cfile 6 - 40 0d 03 ff ff ff ff - 40 0d 03 + + ff ff ff ff 10 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_005.cfile 7 - 40 0d 03 ff ff ff ff - 40 0d 03 + + ff ff ff ff 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_006.cfile 7 - 40 0b 07 55 55 55 55 - 40 0b 07 + + 55 55 55 55 3 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_006.cfile 8 - 40 0b 07 55 55 55 55 - 40 0b 07 + + 55 55 55 55 3 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_006.cfile 12 - 40 0b 07 55 55 55 55 - 40 0b 07 + + 55 55 55 55 3 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_006.cfile 6 - 40 0f 04 55 55 55 55 - 40 0f 04 + + 55 55 55 55 3 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_006.cfile 7 - 40 0f 04 55 55 55 55 - 40 0f 04 + + 55 55 55 55 3 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_006.cfile 6 - 40 0d 03 55 55 55 55 - 40 0d 03 + + 55 55 55 55 3 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_006.cfile 7 - 40 0d 03 55 55 55 55 - 40 0d 03 + + 55 55 55 55 3 ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_007.cfile 7 - 40 0b 07 55 55 55 55 - 40 0b 07 + + 55 55 55 55 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_007.cfile 8 - 40 0b 07 55 55 55 55 - 40 0b 07 + + 55 55 55 55 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_007.cfile 12 - 40 0b 07 55 55 55 55 - 40 0b 07 + + 55 55 55 55 10 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_007.cfile 6 - 40 0f 04 55 55 55 55 - 40 0f 04 + + 55 55 55 55 10 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_007.cfile 7 - 40 0f 04 55 55 55 55 - 40 0f 04 + + 55 55 55 55 10 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_007.cfile 6 - 40 0d 03 55 55 55 55 - 40 0d 03 + + 55 55 55 55 10 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_007.cfile 7 - 40 0d 03 55 55 55 55 - 40 0d 03 + + 55 55 55 55 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_008.cfile 7 - 40 0b 07 88 88 88 88 - 40 0b 07 + + 88 88 88 88 1 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_008.cfile 8 - 40 0b 07 88 88 88 88 - 40 0b 07 + + 88 88 88 88 1 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_008.cfile 12 - 40 0b 07 88 88 88 88 - 40 0b 07 + + 88 88 88 88 1 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_008.cfile 6 - 40 0f 04 88 88 88 88 - 40 0f 04 + + 88 88 88 88 1 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_008.cfile 7 - 40 0f 04 88 88 88 88 - 40 0f 04 + + 88 88 88 88 1 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_008.cfile 6 - 40 0d 03 88 88 88 88 - 40 0d 03 + + 88 88 88 88 1 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_008.cfile 7 - 40 0d 03 88 88 88 88 - 40 0d 03 + + 88 88 88 88 1 ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_009.cfile 7 - 40 0b 07 88 88 88 88 - 40 0b 07 + + 88 88 88 88 5 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_009.cfile 8 - 40 0b 07 88 88 88 88 - 40 0b 07 + + 88 88 88 88 5 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_009.cfile 12 - 40 0b 07 88 88 88 88 - 40 0b 07 + + 88 88 88 88 5 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_009.cfile 6 - 40 0f 04 88 88 88 88 - 40 0f 04 + + 88 88 88 88 5 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_009.cfile 7 - 40 0f 04 88 88 88 88 - 40 0f 04 + + 88 88 88 88 5 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_009.cfile 6 - 40 0d 03 88 88 88 88 - 40 0d 03 + + 88 88 88 88 5 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_009.cfile 7 - 40 0d 03 88 88 88 88 - 40 0d 03 + + 88 88 88 88 5 ./examples/lora-samples/hackrf_cr4-5_bw125_sf7_crc1_pwr1_010.cfile 7 - 40 0b 07 88 88 88 88 - 40 0b 07 + + 88 88 88 88 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf8_crc1_pwr1_010.cfile 8 - 40 0b 07 88 88 88 88 - 40 0b 07 + + 88 88 88 88 10 ./examples/lora-samples/hackrf_cr4-5_bw125_sf12_crc1_pwr1_010.cfile 12 - 40 0b 07 88 88 88 88 - 40 0b 07 + + 88 88 88 88 10 ./examples/lora-samples/hackrf_cr4-7_bw125_sf6_crc1_pwr1_010.cfile 6 - 40 0f 04 88 88 88 88 - 40 0f 04 + + 88 88 88 88 10 ./examples/lora-samples/hackrf_cr4-7_bw125_sf7_crc1_pwr1_010.cfile 7 - 40 0f 04 88 88 88 88 - 40 0f 04 + + 88 88 88 88 10 ./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_010.cfile 6 - 40 0d 03 88 88 88 88 - 40 0d 03 + + 88 88 88 88 10 ./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_010.cfile 7 - 40 0d 03 88 88 88 88 - 40 0d 03 + + 88 88 88 88 10 diff --git a/python/qa_BasicTest_XML.py b/python/qa_BasicTest_XML.py index dab9782..654bcf3 100644 --- a/python/qa_BasicTest_XML.py +++ b/python/qa_BasicTest_XML.py @@ -33,7 +33,7 @@ class qa_BasicTest_XML (gr_unittest.TestCase): # Print received data, expected data and if they match. # Also give feedback about successrate in the decoding (percentage correctly captured and decoded). # - def compareDataSets(self, total_data, expected_data, fromfile, cmpHDR): + def compareDataSets(self, total_data, expected_data, fromfile): global testResults total_passing = 0 @@ -45,7 +45,7 @@ class qa_BasicTest_XML (gr_unittest.TestCase): try: data_str = " ".join("{:02x}".format(ord(n)) for n in total_data[idx]) - self.assertEqual(val, data_str if cmpHDR else data_str[9:]) + self.assertEqual(val, data_str if self.hasHDR else data_str[9:]) except: passed = False @@ -59,29 +59,7 @@ class qa_BasicTest_XML (gr_unittest.TestCase): results = TestResultData(fromfile, total_passing, len(expected_data), float(total_passing) / len(expected_data) * 100.0) testResults[len(testResults) - 1].append(results) print ("\nPassed rate: {0:d} out of {1:d} ({2:.2f}%)\n" - .format(results[1], results[2], results[3])) - - # - # Connect a filesource with the given file and run the flowgraph. - # File is acquired from the file_sink block and saved as .cfile (complex IQ data). - # - def runWithFileSourceAndData(self, infile, SpreadingFactor, cmpHDR): - print "Starting test from data in: {0:s}\n".format(infile) - - if os.path.isfile(infile): - self.file_source.close() - self.file_source.open(infile, False) - self.sf = SpreadingFactor - self.lora_lora_receiver_0.set_sf(self.sf) - self.tb.run () - - total_data = self.gatherFromSocket(test_series[len(test_series) - 1][1]) - self.compareDataSets(total_data, - test_series[len(test_series) - 1][0] * test_series[len(test_series) - 1][1], - os.path.splitext(os.path.basename(infile))[0], - cmpHDR) - else: - raise Exception("Error file does not exists!") + .format(results.passing, results.total, results.rate)) # # Set up flowgraph before Unit Test. (Gets threrefore called before EVERY test) @@ -102,6 +80,9 @@ class qa_BasicTest_XML (gr_unittest.TestCase): #self.symbols_per_sec = self.bw / (2**self.sf) self.offset = -(self.capture_freq - self.target_freq) #self.bitrate = self.sf * (1 / (2**self.sf / self.bw )) + self.hasHDR = True + + self.inputFile = "./" # Socket connection for sink self.host = "127.0.0.1" @@ -112,8 +93,6 @@ class qa_BasicTest_XML (gr_unittest.TestCase): self.server.bind((self.host, self.port)) self.server.setblocking(0) ## or self.server.settimeout(0.5) ? - self.lastTestComplete = False - self.logFile = './examples/qa_BasicTest.log' self.xmlFile = './examples/qa_BasicTest_Data.xml' @@ -123,95 +102,64 @@ class qa_BasicTest_XML (gr_unittest.TestCase): self.xmlTests = xmltodict.parse(f.read())["lora-test-data"]["TEST"] f.close() else: - raise Exception("[BasicTest_XML] '" + self.xmlFile + "' does not exists!") - - self.prevData = "" - - ################################################## - # Blocks # - ################################################## - self.tb = gr.top_block () - - self.file_source = blocks.file_source(gr.sizeof_gr_complex*1, "./", False) # Repeat input: True/False - self.lora_lora_receiver_0 = lora.lora_receiver(self.samp_rate, self.capture_freq, self.offset, self.sf, self.samp_rate) - self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, self.samp_rate, True) - self.blocks_message_socket_sink_0 = lora.message_socket_sink() - - self.tb.connect( (self.file_source, 0), (self.blocks_throttle_0, 0)) - self.tb.connect( (self.blocks_throttle_0, 0), (self.lora_lora_receiver_0, 0)) - self.tb.msg_connect( (self.lora_lora_receiver_0, 'frames'), (self.blocks_message_socket_sink_0, 'in')) + raise Exception("[BasicTest_XML] '" + self.xmlFile + "' does not exist!") # # Clean-up flowgraph after Unit Test. (Gets threrefore called after EVERY test) # - # If last test was completed, report results. + # Because tests are completed, report results. # def tearDown (self): self.tb = None self.xmlTests = None self.server.close() + + flog = open(self.logFile, 'a') + passed_t_a = 0 + passed_t = 0 + total_t_a = 0 + total_t = 0 + stro = ("-" * 8) + " Test Results on " + str(datetime.datetime.now())[:19] + " " + ("-" * 9) + print(stro) + flog.write(stro + '\n') - if self.lastTestComplete: - flog = open(self.logFile, 'a') - passed_t_a = 0 - passed_t = 0 - total_t_a = 0 - total_t = 0 - stro = ("-" * 8) + " Test Results on " + str(datetime.datetime.now())[:19] + " " + ("-" * 9) + for j, serie in enumerate(testResults): + total_t = passed_t = 0 + + stro = ("Test serie {0: 3d}: {1:s} * {2:d}" + .format(j, test_series[j].data, test_series[j].times)) print(stro) flog.write(stro + '\n') - for j, serie in enumerate(testResults): - total_t = passed_t = 0 - - stro = ("Test serie {0: 3d}: {1:s} * {2:d}" - .format(j, test_series[j][0], test_series[j][1])) + for i, x in enumerate(serie): + passed_t += x[1] + total_t += x[2] + stro = (" Test {0: 3d} :: {1:5s} {2:5s} {3:4s} {4:4s} {5:4s} :: passed {6: 3d} out of {7: 3d} ({8:6.2f}%)" + .format(i, *(x[0].split('_')[1:-1] + [x[1]] + [x[2]] + [x[3]]))) print(stro) flog.write(stro + '\n') - for i, x in enumerate(serie): - passed_t += x[1] - total_t += x[2] - stro = (" Test {0: 3d} :: {1:5s} {2:5s} {3:4s} {4:4s} {5:4s} :: passed {6: 3d} out of {7: 3d} ({8:6.2f}%)" - .format(i, *(x[0].split('_')[1:-1] + [x[1]] + [x[2]] + [x[3]]))) - print(stro) - flog.write(stro + '\n') - - passed_t_a += passed_t - total_t_a += total_t - stro = (" => Total passed: {0:d} out of {1:d} ({2:.2f}%)\n" - .format(passed_t, total_t, float(passed_t) / (total_t if total_t else 1.0) * 100.0)) - print(stro) - flog.write(stro + '\n') - - stro = ("\n ====== Total passed: {0:d} out of {1:d} ({2:.2f}%) ======" - .format(passed_t_a, total_t_a, float(passed_t_a) / (total_t_a if total_t_a else 1.0) * 100.0)) + passed_t_a += passed_t + total_t_a += total_t + stro = (" => Total passed: {0:d} out of {1:d} ({2:.2f}%)\n" + .format(passed_t, total_t, float(passed_t) / (total_t if total_t else 1.0) * 100.0)) print(stro) - flog.write(stro + '\n\n') - flog.close() + flog.write(stro + '\n') - print ("Log appended to: " + self.logFile) + stro = ("\n ====== Total passed: {0:d} out of {1:d} ({2:.2f}%) ======" + .format(passed_t_a, total_t_a, float(passed_t_a) / (total_t_a if total_t_a else 1.0) * 100.0)) + print(stro) + flog.write(stro + '\n\n') + flog.close() - - -################################################################################################### -# Unit tests # -# These assume a directory "./examples/lora-samples" # -# with the specified .cfiles existing. # -################################################################################################### - # def test_032 (self): - # testResults.append( [] ) - # test_series.append( TestSerieSettings(["40 0d 03 88 88 88 88"] , 10) ) - # - # self.runWithFileSourceAndData('./examples/lora-samples/hackrf_cr4-6_bw125_sf6_crc1_pwr1_010.cfile', 6) - # self.runWithFileSourceAndData('./examples/lora-samples/hackrf_cr4-6_bw125_sf7_crc1_pwr1_010.cfile', 7) - # - # self.lastTestComplete = True + print ("Log appended to: " + self.logFile) ############################################################################################### # Unit tests series from qa_BasicTest_Data.xml # ############################################################################################### def test_000 (self): + prevData = "" + for test in self.xmlTests: # print (("Test {0: 3d}\n" # + " File: {1:s}\n" @@ -225,31 +173,58 @@ class qa_BasicTest_XML (gr_unittest.TestCase): # test['expected-data-only'], int(test['expected-times'])) # ) - data = test['expected-data-all'] - hasHDR = True + self.sf = int(test['spreading-factor']) + self.inputFile = str(test['file']) + self.hasHDR = True + data = test['expected-data-all'] if not data: data = test['expected-hdr'] if not data: - hasHDR = False + self.hasHDR = False data = test['expected-data-only'] else: data = data + " " + test['expected-data-only'] - infile = str(test['file']) - - if data and os.path.isfile(infile): - if data != self.prevData: + if data and os.path.isfile(self.inputFile): + if data != prevData: testResults.append( [] ) test_series.append( TestSerieSettings([data], int(test['expected-times'])) ) - self.prevData = data - self.runWithFileSourceAndData(infile, int(test['spreading-factor']), hasHDR) + prevData = data + + print "++++++++++ Starting test {0: 3d} from data in: \n {1:s}\n".format(int(test['@id']), self.inputFile) + + ################################################## + # Blocks # + ################################################## + self.tb = gr.top_block () + + self.file_source = blocks.file_source(gr.sizeof_gr_complex*1, self.inputFile, False) # Repeat input: True/False + self.lora_lora_receiver_0 = lora.lora_receiver(self.samp_rate, self.capture_freq, self.offset, self.sf, self.samp_rate) + self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, self.samp_rate, True) + self.blocks_message_socket_sink_0 = lora.message_socket_sink() + + self.tb.connect( (self.file_source, 0), (self.blocks_throttle_0, 0)) + self.tb.connect( (self.blocks_throttle_0, 0), (self.lora_lora_receiver_0, 0)) + self.tb.msg_connect( (self.lora_lora_receiver_0, 'frames'), (self.blocks_message_socket_sink_0, 'in')) + + self.tb.run () + + total_data = self.gatherFromSocket(test_series[len(test_series) - 1].times) + self.compareDataSets(total_data, + test_series[len(test_series) - 1].data * test_series[len(test_series) - 1].times, + os.path.splitext(os.path.basename(self.inputFile))[0]) + + self.tb = None else: print("No test data or file does not exist, skipping test {0: 3d}...".format(int(test['@id']))) - self.lastTestComplete = True - +################################################################################################### +# Unit tests # +# These assume a directory "./examples/lora-samples" # +# with the specified .cfiles existing. # +################################################################################################### if __name__ == '__main__': global testResults testResults = []