diff options
author | Lane Kolbly <lane.kolbly@ni.com> | 2021-10-29 15:08:45 -0500 |
---|---|---|
committer | Lane Kolbly <lane@rscheme.org> | 2022-03-23 21:09:39 -0500 |
commit | 24eddf75febfb56f4f6184a5e80f2817c86269e6 (patch) | |
tree | 840c37f878c87bfb0700f00b56596f1c175862af /host | |
parent | 897384aabf121383c259457313b09744c16fb55f (diff) | |
download | uhd-24eddf75febfb56f4f6184a5e80f2817c86269e6.tar.gz uhd-24eddf75febfb56f4f6184a5e80f2817c86269e6.tar.bz2 uhd-24eddf75febfb56f4f6184a5e80f2817c86269e6.zip |
test: x410: Add GPIO tests to X410 devtest
Diffstat (limited to 'host')
-rwxr-xr-x | host/tests/devtest/bitbang_test.py | 6 | ||||
-rw-r--r-- | host/tests/devtest/devtest_x4x0.py | 26 | ||||
-rwxr-xr-x | host/tests/devtest/gpio_test.py | 58 |
3 files changed, 84 insertions, 6 deletions
diff --git a/host/tests/devtest/bitbang_test.py b/host/tests/devtest/bitbang_test.py index 8f6ea7598..5e4eb6e37 100755 --- a/host/tests/devtest/bitbang_test.py +++ b/host/tests/devtest/bitbang_test.py @@ -11,7 +11,9 @@ from uhd_test_base import uhd_example_test_case class bitbang_test(uhd_example_test_case): """ Run gpio --bitbang. """ - tests = {'default': {},} + tests = {'default': { + 'addl_args': [], + },} def setup_example(self): """ @@ -27,6 +29,7 @@ class bitbang_test(uhd_example_test_case): self.create_addr_args_str(), '--bitbang', ] + args += test_args['addl_args'] (app, run_results) = self.run_example('gpio', args) # Evaluate pass/fail: run_results['passed'] = all([ @@ -35,4 +38,3 @@ class bitbang_test(uhd_example_test_case): ]) self.report_example_results(test_name, run_results) return run_results - diff --git a/host/tests/devtest/devtest_x4x0.py b/host/tests/devtest/devtest_x4x0.py index d1add6a66..8a23e9a41 100644 --- a/host/tests/devtest/devtest_x4x0.py +++ b/host/tests/devtest/devtest_x4x0.py @@ -67,9 +67,29 @@ from rx_samples_to_file_test import rx_samples_to_file_test from tx_bursts_test import uhd_tx_bursts_test from test_pps_test import uhd_test_pps_test -# Enable these when GPIO API is enabled -# from gpio_test import gpio_test -# from bitbang_test import bitbang_test +from gpio_test import gpio_test +gpio_test.tests = {} +for port in ["GPIO0", "GPIO1"]: + for bank,driver in [("GPIOA", "DB0_RF0")]: + gpio_test.tests[f"{port}_{driver}"] = { + "addl_args": ["--src", " ".join([driver]*12), "--bank", bank, "--port", port, "--bits", "12"], + } + +from gpio_test import gpio_x410_set_get_source_test +gpio_x410_set_get_source_test.test_params = { + "possible_sources": ["PS", "MPM", "USER_APP", "DB0_RF0", "DB0_RF1", "DB0_SPI", "DB1_RF0", "DB1_RF1", "DB1_SPI"], + "num_pins": 12, +} + +from gpio_test import x410_gpio_power_test + +from bitbang_test import bitbang_test +bitbang_test.tests = {} +for port in ["GPIO0", "GPIO1"]: + for bank,driver in [("GPIOA", "DB0_RF0"), ("GPIOB", "DB1_RF0")]: + bitbang_test.tests[f"{port}_{driver}"] = { + "addl_args": ["--bank", bank, "--port", port, "--src", " ".join([driver]*12)] + } from gpio_test import gpio_atr_readback_test gpio_atr_readback_test.test_params = [ diff --git a/host/tests/devtest/gpio_test.py b/host/tests/devtest/gpio_test.py index 179ace5b3..517f0bf5b 100755 --- a/host/tests/devtest/gpio_test.py +++ b/host/tests/devtest/gpio_test.py @@ -8,10 +8,13 @@ import re from uhd_test_base import uhd_example_test_case, uhd_test_case, UHDPythonTestCase +import random class gpio_test(uhd_example_test_case): """ Run gpio. """ - tests = {'default': {},} + tests = {'default': { + 'addl_args': [], + },} def setup_example(self): """ @@ -26,6 +29,7 @@ class gpio_test(uhd_example_test_case): args = [ self.create_addr_args_str(), ] + args += test_args['addl_args'] (app, run_results) = self.run_example('gpio', args) # Evaluate pass/fail: run_results['passed'] = all([ @@ -58,3 +62,55 @@ class gpio_atr_readback_test(UHDPythonTestCase): assert usrp.get_gpio_attr(gpio, "ATR_RX") == 0xCAB assert usrp.get_gpio_attr(gpio, "ATR_TX") == 0xABA assert usrp.get_gpio_attr(gpio, "ATR_XX") == 0xBAB + + +class gpio_x410_set_get_source_test(UHDPythonTestCase): + test_params = { + "possible_sources": [], + "num_pins": 0, + } + + def test_all(self): + import uhd + usrp = uhd.usrp.MultiUSRP(self.args_str) + + POSSIBLE_SOURCES = self.test_params["possible_sources"] + + # Assemble two lists which have at least one of each of the 7 sources, + # with the remaining 12-7=5 entries containing random sources. + sources_0 = [x for x in POSSIBLE_SOURCES] + sources_1 = [x for x in POSSIBLE_SOURCES] + for _ in range(self.test_params["num_pins"] - len(POSSIBLE_SOURCES)): + sources_0.append(random.choice(POSSIBLE_SOURCES)) + sources_1.append(random.choice(POSSIBLE_SOURCES)) + random.shuffle(sources_0) + random.shuffle(sources_1) + + usrp.set_gpio_src("GPIO0", sources_0) + usrp.set_gpio_src("GPIO1", sources_1) + + assert sources_0 == list(usrp.get_gpio_src("GPIO0")) + assert sources_1 == list(usrp.get_gpio_src("GPIO1")) + + +class x410_gpio_power_test(UHDPythonTestCase): + """ Run gpio_power_test """ + test_name = "x410_gpio_power_test" + + def run_test(self, test_name, test_args): + """ + Run test and report results. + """ + import uhd + usrp = uhd.usrp.MultiUSRP(self.args_str) + + gpio_power = usrp.get_mb_controller().get_gpio_power() + assert usrp.get_mb_controller().get_gpio_power().get_supported_voltages("GPIO0") == ['OFF', '1V8', '2V5', '3V3'] + + for port in ["GPIO0", "GPIO1"]: + assert gpio_power.get_port_voltage(port) == "3V3" + for voltage in gpio_power.get_supported_voltages(port): + gpio_power.set_port_voltage(port, voltage) + assert gpio_power.get_port_voltage(port) == voltage + + return {"passed": True} |