diff options
author | mattprost <matt.prost@ni.com> | 2021-06-09 14:17:58 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-06-10 07:28:25 -0500 |
commit | ea76face99e8628a1c4189fd2d02849ea58d0c06 (patch) | |
tree | 627de45e3182f4b24c49ef4a9ea260e51769723f /host/tests | |
parent | 4574063639a3aa5389005f646577d5644f72d5d3 (diff) | |
download | uhd-ea76face99e8628a1c4189fd2d02849ea58d0c06.tar.gz uhd-ea76face99e8628a1c4189fd2d02849ea58d0c06.tar.bz2 uhd-ea76face99e8628a1c4189fd2d02849ea58d0c06.zip |
devtest: benchmark_rate: Add support for rx and tx only tests
Fixes some minor reporting issues that occurred in devtest streaming
tests with only rx or only tx.
Signed-off-by: mattprost <matt.prost@ni.com>
Diffstat (limited to 'host/tests')
-rwxr-xr-x | host/tests/devtest/benchmark_rate_test.py | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/host/tests/devtest/benchmark_rate_test.py b/host/tests/devtest/benchmark_rate_test.py index 598fbc8f0..56761f974 100755 --- a/host/tests/devtest/benchmark_rate_test.py +++ b/host/tests/devtest/benchmark_rate_test.py @@ -31,15 +31,16 @@ class uhd_benchmark_rate_test(uhd_example_test_case): """ Runs benchmark_rate with the given parameters. Parses output and writes results to file. - - We always run both tx and rx. """ # rel_samp_err_threshold = 0.1 # 10% off is still quite generous samp_rate = test_args.get('rate', 1e6) duration = test_args.get('duration', 1) chan = test_args.get('chan', '0') n_chans = len(chan.split(",")) - expected_samples = n_chans * duration * samp_rate + expected_rx_samples = n_chans * duration * samp_rate \ + if 'rx' in test_args.get('direction', '') else 0 + expected_tx_samples = n_chans * duration * samp_rate \ + if 'tx' in test_args.get('direction', '') else 0 self.log.info('Running test {n}, Channel = {c}, Sample Rate = {r}'.format( n=test_name, c=chan, r=samp_rate, )) @@ -59,35 +60,43 @@ class uhd_benchmark_rate_test(uhd_example_test_case): if 'tx' in test_args.get('direction', ''): args.append('--tx_rate') args.append(str(samp_rate)) - if 'rx' in test_args.get('direction', ''): args.append('--rx_rate') args.append(str(samp_rate)) (app, run_results) = self.run_example('benchmark_rate', args) + match = re.search(r'(Num received samples):\s*(.*)', app.stdout) run_results['num_rx_samples'] = int(match.group(2)) if match else -1 - if run_results['num_rx_samples'] != -1: - run_results['rel_rx_samples_error'] = 1.0 * abs( - run_results['num_rx_samples'] - - test_args.get('rx_buffer', 0) - - expected_samples - ) / expected_samples + if expected_rx_samples != 0: + if run_results['num_rx_samples'] != -1: + run_results['rel_rx_samples_error'] = 1.0 * abs( + run_results['num_rx_samples'] + - test_args.get('rx_buffer', 0) + - expected_rx_samples + ) / expected_rx_samples + else: + run_results['rel_rx_samples_error'] = 100 else: - run_results['rel_rx_samples_error'] = 100 + run_results['rel_rx_samples_error'] = 0 \ + if run_results['num_rx_samples'] == 0 else 1 match = re.search(r'(Num dropped samples):\s*(.*)', app.stdout) run_results['num_rx_dropped'] = int(match.group(2)) if match else -1 match = re.search(r'(Num overruns detected):\s*(.*)', app.stdout) run_results['num_rx_overruns'] = int(match.group(2)) if match else -1 match = re.search(r'(Num transmitted samples):\s*(.*)', app.stdout) run_results['num_tx_samples'] = int(match.group(2)) if match else -1 - if run_results['num_tx_samples'] != -1: - run_results['rel_tx_samples_error'] = 1.0 * abs( - run_results['num_tx_samples'] - - test_args.get('tx_buffer', 0) - - expected_samples - ) / expected_samples + if expected_tx_samples != 0: + if run_results['num_tx_samples'] != -1: + run_results['rel_tx_samples_error'] = 1.0 * abs( + run_results['num_tx_samples'] + - test_args.get('tx_buffer', 0) + - expected_tx_samples + ) / expected_tx_samples + else: + run_results['rel_tx_samples_error'] = 100 else: - run_results['rel_tx_samples_error'] = 100 + run_results['rel_tx_samples_error'] = 0 \ + if run_results['num_tx_samples'] == 0 else 1 match = re.search(r'(Num sequence errors \(Tx\)):\s*(.*)', app.stdout) run_results['num_tx_seqerrs'] = int(match.group(2)) if match else -1 match = re.search(r'(Num underruns detected):\s*(.*)', app.stdout) @@ -107,4 +116,3 @@ class uhd_benchmark_rate_test(uhd_example_test_case): ]) self.report_example_results(test_name, run_results) return run_results - |