kopia lustrzana https://github.com/rpp0/gr-lora
Added test suite functionality
- Switch to disable file export - Allow controller to be specified - Clamp value of CR in event of decoding errorpull/61/head
rodzic
994f80ce53
commit
2f28b1ba9e
|
@ -19,7 +19,7 @@ from lora.loraconfig import LoRaConfig
|
|||
Test = collections.namedtuple('Test', ['payload', 'times'])
|
||||
|
||||
class TestSuite():
|
||||
def __init__(self, name, args, config_set, test_set):
|
||||
def __init__(self, lc, name, args, config_set, test_set):
|
||||
self.name = name
|
||||
self.config_set = config_set
|
||||
self.test_set = test_set
|
||||
|
@ -32,7 +32,7 @@ class TestSuite():
|
|||
self.pre_delay = 0.150
|
||||
self.post_delay = 1.0
|
||||
self.intra_delay = 0.1
|
||||
self.lc = RN2483Controller("/dev/lora")
|
||||
self.lc = lc
|
||||
self.test_count = 0
|
||||
|
||||
# Prepare SigMF global metadata (identical for all tests)
|
||||
|
@ -96,6 +96,7 @@ class TestSuite():
|
|||
exit(1)
|
||||
|
||||
# Build GNU Radio flowgraph
|
||||
gr.enable_realtime_scheduling()
|
||||
tb = gr.top_block()
|
||||
osmosdr_source = osmosdr.source(args="numchan=" + str(1) + " " + '' )
|
||||
osmosdr_source.set_sample_rate(self.sample_rate)
|
||||
|
@ -162,7 +163,7 @@ if __name__ == '__main__':
|
|||
]
|
||||
|
||||
decode_long_test_set = [Test(payload="000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfe", times=1),]
|
||||
TestSuite(name='decode_long', args=args, config_set=decode_long_config_set, test_set=decode_long_test_set).run()
|
||||
TestSuite(lc=RN2483Controller("/dev/lora"), name='decode_long', args=args, config_set=decode_long_config_set, test_set=decode_long_test_set).run()
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Test suite: short
|
||||
|
@ -199,4 +200,4 @@ if __name__ == '__main__':
|
|||
Test(payload="88", times=1),
|
||||
Test(payload="ffff", times=10),
|
||||
]
|
||||
TestSuite(name='short', args=args, config_set=short_config_set, test_set=short_test_set).run()
|
||||
TestSuite(lc=RN2483Controller("/dev/lora"), name='short_rn', args=args, config_set=short_config_set, test_set=short_test_set).run()
|
||||
|
|
|
@ -797,6 +797,8 @@ namespace gr {
|
|||
decode(true);
|
||||
gr::lora::print_vector_hex(std::cout, &d_decoded[0], d_decoded.size(), false);
|
||||
memcpy(&d_phdr, &d_decoded[0], sizeof(loraphy_header_t));
|
||||
if (d_phdr.cr > 4)
|
||||
d_phdr.cr = 4;
|
||||
d_decoded.clear();
|
||||
|
||||
d_payload_length = d_phdr.length + MAC_CRC_SIZE * d_phdr.has_mac_crc;
|
||||
|
|
|
@ -53,7 +53,7 @@ class TestSummary():
|
|||
else:
|
||||
raise Exception("Test result must be of type TestResult")
|
||||
|
||||
def export_summary(self, path, print_output=True):
|
||||
def export_summary(self, path, print_output=True, write_output=True):
|
||||
self._summary_text += "\nRan a total of {:n} tests, together containing {:n} payloads.\n".format(
|
||||
self._num_tests,
|
||||
self._num_total_payloads
|
||||
|
@ -147,7 +147,7 @@ class TestSummary():
|
|||
|
||||
|
||||
class qa_testsuite():
|
||||
def __init__(self):
|
||||
def __init__(self, path=None):
|
||||
"""
|
||||
Determine installed test suites and setup socket server for receiving payloads decoded by gr-lora.
|
||||
"""
|
||||
|
@ -159,12 +159,17 @@ class qa_testsuite():
|
|||
self.server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
self.server.bind((self.host, self.port))
|
||||
self.server.settimeout(3)
|
||||
self.server.settimeout(10)
|
||||
|
||||
# Determine test suites directory if needed
|
||||
if path is None:
|
||||
current_dir = os.path.dirname(os.path.realpath(__file__)) + "/"
|
||||
self.test_suites_directory = os.path.abspath(current_dir + '../apps/test-suites')
|
||||
self.reports_directory = os.path.abspath(current_dir + '../docs/test-results')
|
||||
else:
|
||||
self.test_suites_directory = os.path.abspath(path)
|
||||
self.reports_directory = os.path.abspath(path + '/../test-results')
|
||||
|
||||
# Determine test suites directory
|
||||
current_dir = os.path.dirname(os.path.realpath(__file__)) + "/"
|
||||
self.test_suites_directory = os.path.abspath(current_dir + '../apps/test-suites')
|
||||
self.reports_directory = os.path.abspath(current_dir + '../docs/test-results')
|
||||
|
||||
# List test suites
|
||||
self.test_suites = []
|
||||
|
@ -194,7 +199,7 @@ class qa_testsuite():
|
|||
|
||||
return total_data
|
||||
|
||||
def run(self, suites_to_run, pause=False):
|
||||
def run(self, suites_to_run, pause=False, write_output=True):
|
||||
for test_suite in self.test_suites:
|
||||
# Skip test suites that we don't want to run
|
||||
if suites_to_run != [] and (not test_suite in suites_to_run):
|
||||
|
@ -262,20 +267,22 @@ class qa_testsuite():
|
|||
decoded_data = self.get_payloads(times) # Output from the flowgraph
|
||||
summary.add(TestResult(decoded_data=decoded_data, lora_config=lora_config, test=test), print_intermediate=True)
|
||||
# Finally, export the result for the suite
|
||||
summary.export_summary(path=self.reports_directory)
|
||||
summary.export_summary(path=self.reports_directory, write_output=write_output)
|
||||
|
||||
if __name__ == '__main__':
|
||||
"""
|
||||
Tool to evaluate decoding test suites in apps/test-suites/
|
||||
Tool to evaluate decoding test suites
|
||||
"""
|
||||
# Parse args
|
||||
parser = argparse.ArgumentParser(description="Tool to evaluate decoding test suites for gr-lora.")
|
||||
parser.add_argument('suites', type=str, nargs="*", help='Names of the test suites to execute.')
|
||||
parser.add_argument('--pause', action="store_true", default=False, help='Pause upon encountering an error.')
|
||||
parser.add_argument('--path', type=str, default=None, help='Path of the test suites')
|
||||
parser.add_argument('--nowrite', action="store_true", default=False, help='Do not write anything.')
|
||||
args = parser.parse_args()
|
||||
|
||||
# Make sure CTRL+C exits the whole test suite instead of only the current GNU Radio top block
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
|
||||
suite = qa_testsuite()
|
||||
suite.run(args.suites, args.pause)
|
||||
suite = qa_testsuite(args.path)
|
||||
suite.run(args.suites, args.pause, not args.nowrite)
|
||||
|
|
Ładowanie…
Reference in New Issue