diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/adc.c | 16 | ||||
-rw-r--r-- | test/dm/pci.c | 49 | ||||
-rw-r--r-- | test/dm/usb.c | 2 | ||||
-rw-r--r-- | test/py/tests/test_ofplatdata.py | 28 |
4 files changed, 86 insertions, 9 deletions
diff --git a/test/dm/adc.c b/test/dm/adc.c index 1f82304f41..da7bd4bf1f 100644 --- a/test/dm/adc.c +++ b/test/dm/adc.c @@ -24,7 +24,7 @@ static int dm_test_adc_bind(struct unit_test_state *uts) struct udevice *dev; unsigned int channel_mask; - ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); + ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc@0", &dev)); ut_asserteq_str(SANDBOX_ADC_DEVNAME, dev->name); ut_assertok(adc_channel_mask(dev, &channel_mask)); @@ -38,7 +38,7 @@ static int dm_test_adc_wrong_channel_selection(struct unit_test_state *uts) { struct udevice *dev; - ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); + ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc@0", &dev)); ut_asserteq(-EINVAL, adc_start_channel(dev, SANDBOX_ADC_CHANNELS)); return 0; @@ -51,7 +51,7 @@ static int dm_test_adc_supply(struct unit_test_state *uts) struct udevice *dev; int uV; - ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); + ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc@0", &dev)); /* Test Vss value - predefined 0 uV */ ut_assertok(adc_vss_value(dev, &uV)); @@ -94,7 +94,7 @@ static int dm_test_adc_single_channel_conversion(struct unit_test_state *uts) unsigned int i, data; struct udevice *dev; - ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); + ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc@0", &dev)); /* Test each ADC channel's value */ for (i = 0; i < SANDBOX_ADC_CHANNELS; i++, tdata++) { ut_assertok(adc_start_channel(dev, tdata->id)); @@ -117,7 +117,7 @@ static int dm_test_adc_multi_channel_conversion(struct unit_test_state *uts) ADC_CHANNEL(2) | ADC_CHANNEL(3); /* Start multi channel conversion */ - ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); + ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc@0", &dev)); ut_assertok(adc_start_channels(dev, channel_mask)); ut_assertok(adc_channels_data(dev, channel_mask, channels)); @@ -136,7 +136,7 @@ static int dm_test_adc_single_channel_shot(struct unit_test_state *uts) for (i = 0; i < SANDBOX_ADC_CHANNELS; i++, tdata++) { /* Start single channel conversion */ - ut_assertok(adc_channel_single_shot("adc", tdata->id, &data)); + ut_assertok(adc_channel_single_shot("adc@0", tdata->id, &data)); /* Compare the expected and returned conversion data. */ ut_asserteq(tdata->data, data); } @@ -155,7 +155,7 @@ static int dm_test_adc_multi_channel_shot(struct unit_test_state *uts) ADC_CHANNEL(2) | ADC_CHANNEL(3); /* Start single call and multi channel conversion */ - ut_assertok(adc_channels_single_shot("adc", channel_mask, channels)); + ut_assertok(adc_channels_single_shot("adc@0", channel_mask, channels)); /* Compare the expected and returned conversion data. */ for (i = 0; i < SANDBOX_ADC_CHANNELS; i++, tdata++) @@ -183,7 +183,7 @@ static int dm_test_adc_raw_to_uV(struct unit_test_state *uts) struct udevice *dev; int uV; - ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc", &dev)); + ut_assertok(uclass_get_device_by_name(UCLASS_ADC, "adc@0", &dev)); /* Test each ADC channel's value in microvolts */ for (i = 0; i < SANDBOX_ADC_CHANNELS; i++, tdata++) { ut_assertok(adc_start_channel(dev, tdata->id)); diff --git a/test/dm/pci.c b/test/dm/pci.c index a1febd54b7..c325f6600e 100644 --- a/test/dm/pci.c +++ b/test/dm/pci.c @@ -245,3 +245,52 @@ static int dm_test_pci_cap(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_pci_cap, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test looking up BARs in EA capability structure */ +static int dm_test_pci_ea(struct unit_test_state *uts) +{ + struct udevice *bus, *swap; + void *bar; + int cap; + + /* + * use emulated device mapping function, we're not using real physical + * addresses in this test + */ + sandbox_set_enable_pci_map(true); + + ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 0, &bus)); + ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(0, 0x01, 0), &swap)); + + /* look up PCI_CAP_ID_EA */ + cap = dm_pci_find_capability(swap, PCI_CAP_ID_EA); + ut_asserteq(PCI_CAP_ID_EA_OFFSET, cap); + + /* test swap case in BAR 1 */ + bar = dm_pci_map_bar(swap, PCI_BASE_ADDRESS_0, 0); + ut_assertnonnull(bar); + *(int *)bar = 2; /* swap upper/lower */ + + bar = dm_pci_map_bar(swap, PCI_BASE_ADDRESS_1, 0); + ut_assertnonnull(bar); + strcpy(bar, "ea TEST"); + unmap_sysmem(bar); + bar = dm_pci_map_bar(swap, PCI_BASE_ADDRESS_1, 0); + ut_assertnonnull(bar); + ut_asserteq_str("EA test", bar); + + /* test magic values in BARs2, 4; BAR 3 is n/a */ + bar = dm_pci_map_bar(swap, PCI_BASE_ADDRESS_2, 0); + ut_assertnonnull(bar); + ut_asserteq(PCI_EA_BAR2_MAGIC, *(u32 *)bar); + + bar = dm_pci_map_bar(swap, PCI_BASE_ADDRESS_3, 0); + ut_assertnull(bar); + + bar = dm_pci_map_bar(swap, PCI_BASE_ADDRESS_4, 0); + ut_assertnonnull(bar); + ut_asserteq(PCI_EA_BAR4_MAGIC, *(u32 *)bar); + + return 0; +} +DM_TEST(dm_test_pci_ea, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); diff --git a/test/dm/usb.c b/test/dm/usb.c index 3493617544..ef454b0ae5 100644 --- a/test/dm/usb.c +++ b/test/dm/usb.c @@ -125,7 +125,7 @@ static int dm_test_usb_keyb(struct unit_test_state *uts) /* Initially there should be no characters */ ut_asserteq(0, tstc()); - ut_assertok(uclass_get_device_by_name(UCLASS_USB_EMUL, "keyb", + ut_assertok(uclass_get_device_by_name(UCLASS_USB_EMUL, "keyb@3", &dev)); /* diff --git a/test/py/tests/test_ofplatdata.py b/test/py/tests/test_ofplatdata.py index 98103ee71a..263334b074 100644 --- a/test/py/tests/test_ofplatdata.py +++ b/test/py/tests/test_ofplatdata.py @@ -2,6 +2,7 @@ # Copyright (c) 2016 Google, Inc import pytest +import u_boot_utils as util OF_PLATDATA_OUTPUT = ''' of-platdata probe: @@ -31,6 +32,15 @@ intarray 0 0 0 0 longbytearray 00 00 00 00 00 00 00 00 00 string <NULL> stringarray "one" "" "" +of-platdata probe: +bool 0 +byte 00 +bytearray 00 00 00 +int 0 +intarray 0 0 0 0 +longbytearray 00 00 00 00 00 00 00 00 00 +string <NULL> +stringarray "spl" "" "" ''' @pytest.mark.buildconfigspec('spl_of_platdata') @@ -40,3 +50,21 @@ def test_ofplatdata(u_boot_console): cons.restart_uboot_with_flags(['--show_of_platdata']) output = cons.get_spawn_output().replace('\r', '') assert OF_PLATDATA_OUTPUT in output + +@pytest.mark.buildconfigspec('spl_of_platdata') +def test_spl_devicetree(u_boot_console): + """Test content of spl device-tree""" + cons = u_boot_console + dtb = cons.config.build_dir + '/spl/u-boot-spl.dtb' + fdtgrep = cons.config.build_dir + '/tools/fdtgrep' + output = util.run_and_log(cons, [fdtgrep, '-l', dtb]) + + assert "u-boot,dm-pre-reloc" not in output + assert "u-boot,dm-pre-proper" not in output + assert "u-boot,dm-spl" not in output + assert "u-boot,dm-tpl" not in output + + assert "spl-test4" in output + assert "spl-test5" not in output + assert "spl-test6" not in output + assert "spl-test7" in output |