diff options
author | Tom Rini <trini@konsulko.com> | 2020-07-10 16:22:57 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-07-10 16:22:57 -0400 |
commit | 4a9146c29573dbfa661918280d9522a01f6ca919 (patch) | |
tree | b1b135237dcfee94a27e8df7ce2208230c28b894 /test | |
parent | f30924739975b4f60c0862b539790fdcdb7da20c (diff) | |
parent | 6c3fc50ee59366df62e8345ea9fd86c3ace0c3f1 (diff) | |
download | u-boot-4a9146c29573dbfa661918280d9522a01f6ca919.tar.gz u-boot-4a9146c29573dbfa661918280d9522a01f6ca919.tar.xz u-boot-4a9146c29573dbfa661918280d9522a01f6ca919.zip |
Merge tag 'dm-pull-10jul20' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
of-platdata: better phandle and compatible-string support
patman support for Python3 on Ubuntu 14.04
new checkpatch check to avoid #ifdefs
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/fdtdec.c | 73 | ||||
-rw-r--r-- | test/dm/gpio.c | 2 | ||||
-rw-r--r-- | test/dm/spi.c | 6 | ||||
-rw-r--r-- | test/log/syslog_test.c | 20 | ||||
-rw-r--r-- | test/py/tests/test_bind.py | 54 | ||||
-rw-r--r-- | test/py/tests/test_log.py | 2 |
6 files changed, 119 insertions, 38 deletions
diff --git a/test/dm/fdtdec.c b/test/dm/fdtdec.c index b2f75b5843..56f6f4f6cc 100644 --- a/test/dm/fdtdec.c +++ b/test/dm/fdtdec.c @@ -9,6 +9,8 @@ #include <dm/test.h> #include <test/ut.h> +DECLARE_GLOBAL_DATA_PTR; + static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts) { struct fdt_memory resv; @@ -20,7 +22,7 @@ static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts) blob = malloc(blob_sz); ut_assertnonnull(blob); - /* Make a writtable copy of the fdt blob */ + /* Make a writable copy of the fdt blob */ ut_assertok(fdt_open_into(gd->fdt_blob, blob, blob_sz)); resv.start = 0x1000; @@ -57,3 +59,72 @@ static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts) } DM_TEST(dm_test_fdtdec_set_carveout, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE); + +static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts) +{ + struct fdt_memory resv; + fdt_addr_t addr; + fdt_size_t size; + void *blob; + int blob_sz, parent, subnode; + uint32_t phandle, phandle1; + + blob_sz = fdt_totalsize(gd->fdt_blob) + 128; + blob = malloc(blob_sz); + ut_assertnonnull(blob); + + /* Make a writable copy of the fdt blob */ + ut_assertok(fdt_open_into(gd->fdt_blob, blob, blob_sz)); + + /* Insert a memory region in /reserved-memory node */ + resv.start = 0x1000; + resv.end = 0x1fff; + ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region", + &resv, &phandle)); + + /* Test /reserve-memory and its subnode should exist */ + parent = fdt_path_offset(blob, "/reserved-memory"); + ut_assert(parent > 0); + subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region"); + ut_assert(subnode > 0); + + /* Test reg property of /reserved-memory/rsvd_region node */ + addr = fdtdec_get_addr_size_auto_parent(blob, parent, subnode, + "reg", 0, &size, false); + ut_assert(addr == resv.start); + ut_assert(size == resv.end - resv.start + 1); + + /* Insert another memory region in /reserved-memory node */ + subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region1"); + ut_assert(subnode < 0); + + resv.start = 0x2000; + resv.end = 0x2fff; + ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region1", + &resv, &phandle1)); + subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region1"); + ut_assert(subnode > 0); + + /* phandles must be different */ + ut_assert(phandle != phandle1); + + /* + * Insert a 3rd memory region with the same addr/size as the 1st one, + * but a new node should not be inserted due to the same addr/size. + */ + resv.start = 0x1000; + resv.end = 0x1fff; + ut_assertok(fdtdec_add_reserved_memory(blob, "rsvd_region2", + &resv, &phandle1)); + subnode = fdt_path_offset(blob, "/reserved-memory/rsvd_region2"); + ut_assert(subnode < 0); + + /* phandle must be same as the 1st one */ + ut_assert(phandle == phandle1); + + free(blob); + + return 0; +} +DM_TEST(dm_test_fdtdec_add_reserved_memory, + DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT | DM_TESTF_FLAT_TREE); diff --git a/test/dm/gpio.c b/test/dm/gpio.c index fcee1fe598..e3be57b602 100644 --- a/test/dm/gpio.c +++ b/test/dm/gpio.c @@ -244,7 +244,7 @@ static int dm_test_gpio_anon(struct unit_test_state *uts) /* And the anonymous bank */ ut_assertok(gpio_lookup_name("14", &dev, &offset, &gpio)); - ut_asserteq_str(dev->name, "gpio_sandbox"); + ut_asserteq_str(dev->name, "sandbox_gpio"); ut_asserteq(14, offset); ut_asserteq(14, gpio); diff --git a/test/dm/spi.c b/test/dm/spi.c index 474008cde0..ff2cddd245 100644 --- a/test/dm/spi.c +++ b/test/dm/spi.c @@ -58,7 +58,7 @@ static int dm_test_spi_find(struct unit_test_state *uts) */ ut_asserteq(-ENODEV, spi_find_bus_and_cs(busnum, cs, &bus, &dev)); ut_asserteq(-ENOENT, spi_get_bus_and_cs(busnum, cs, speed, mode, - "spi_flash_std", "name", &bus, + "jedec_spi_nor", "name", &bus, &slave)); sandbox_sf_unbind_emul(state_get_current(), busnum, cs); ut_assertok(spi_cs_info(bus, cs, &info)); @@ -69,7 +69,7 @@ static int dm_test_spi_find(struct unit_test_state *uts) "name")); ut_assertok(spi_find_bus_and_cs(busnum, cs, &bus, &dev)); ut_assertok(spi_get_bus_and_cs(busnum, cs, speed, mode, - "spi_flash_std", "name", &bus, &slave)); + "jedec_spi_nor", "name", &bus, &slave)); ut_assertok(spi_cs_info(bus, cs, &info)); ut_asserteq_ptr(info.dev, slave->dev); @@ -78,7 +78,7 @@ static int dm_test_spi_find(struct unit_test_state *uts) ut_assertok(sandbox_sf_bind_emul(state, busnum, cs_b, bus, node, "name")); ut_asserteq(-EINVAL, spi_get_bus_and_cs(busnum, cs_b, speed, mode, - "spi_flash_std", "name", &bus, &slave)); + "jedec_spi_nor", "name", &bus, &slave)); ut_asserteq(-EINVAL, spi_cs_info(bus, cs_b, &info)); ut_asserteq_ptr(NULL, info.dev); diff --git a/test/log/syslog_test.c b/test/log/syslog_test.c index 26536ebca7..120a8b2537 100644 --- a/test/log/syslog_test.c +++ b/test/log/syslog_test.c @@ -21,6 +21,8 @@ DECLARE_GLOBAL_DATA_PTR; +#define LOGF_TEST (BIT(LOGF_FUNC) | BIT(LOGF_MSG)) + /** * struct sb_log_env - private data for sandbox ethernet driver * @@ -102,7 +104,7 @@ static int log_test_syslog_err(struct unit_test_state *uts) int old_log_level = gd->default_log_level; struct sb_log_env env; - gd->log_fmt = LOGF_DEFAULT; + gd->log_fmt = LOGF_TEST; gd->default_log_level = LOGL_INFO; env_set("ethact", "eth@10002000"); env_set("log_hostname", "sandbox"); @@ -116,6 +118,7 @@ static int log_test_syslog_err(struct unit_test_state *uts) /* Check that the callback function was called */ sandbox_eth_set_tx_handler(0, NULL); gd->default_log_level = old_log_level; + gd->log_fmt = log_get_default_format(); return 0; } @@ -132,7 +135,7 @@ static int log_test_syslog_warning(struct unit_test_state *uts) int old_log_level = gd->default_log_level; struct sb_log_env env; - gd->log_fmt = LOGF_DEFAULT; + gd->log_fmt = LOGF_TEST; gd->default_log_level = LOGL_INFO; env_set("ethact", "eth@10002000"); env_set("log_hostname", "sandbox"); @@ -147,6 +150,7 @@ static int log_test_syslog_warning(struct unit_test_state *uts) /* Check that the callback function was called */ ut_assertnull(env.expected); gd->default_log_level = old_log_level; + gd->log_fmt = log_get_default_format(); return 0; } @@ -163,7 +167,7 @@ static int log_test_syslog_notice(struct unit_test_state *uts) int old_log_level = gd->default_log_level; struct sb_log_env env; - gd->log_fmt = LOGF_DEFAULT; + gd->log_fmt = LOGF_TEST; gd->default_log_level = LOGL_INFO; env_set("ethact", "eth@10002000"); env_set("log_hostname", "sandbox"); @@ -178,6 +182,7 @@ static int log_test_syslog_notice(struct unit_test_state *uts) /* Check that the callback function was called */ ut_assertnull(env.expected); gd->default_log_level = old_log_level; + gd->log_fmt = log_get_default_format(); return 0; } @@ -194,7 +199,7 @@ static int log_test_syslog_info(struct unit_test_state *uts) int old_log_level = gd->default_log_level; struct sb_log_env env; - gd->log_fmt = LOGF_DEFAULT; + gd->log_fmt = LOGF_TEST; gd->default_log_level = LOGL_INFO; env_set("ethact", "eth@10002000"); env_set("log_hostname", "sandbox"); @@ -209,6 +214,7 @@ static int log_test_syslog_info(struct unit_test_state *uts) /* Check that the callback function was called */ ut_assertnull(env.expected); gd->default_log_level = old_log_level; + gd->log_fmt = log_get_default_format(); return 0; } @@ -225,7 +231,7 @@ static int log_test_syslog_debug(struct unit_test_state *uts) int old_log_level = gd->default_log_level; struct sb_log_env env; - gd->log_fmt = LOGF_DEFAULT; + gd->log_fmt = LOGF_TEST; gd->default_log_level = LOGL_DEBUG; env_set("ethact", "eth@10002000"); env_set("log_hostname", "sandbox"); @@ -240,6 +246,7 @@ static int log_test_syslog_debug(struct unit_test_state *uts) /* Check that the callback function was called */ ut_assertnull(env.expected); gd->default_log_level = old_log_level; + gd->log_fmt = log_get_default_format(); return 0; } @@ -259,7 +266,7 @@ static int log_test_syslog_nodebug(struct unit_test_state *uts) int old_log_level = gd->default_log_level; struct sb_log_env env; - gd->log_fmt = LOGF_DEFAULT; + gd->log_fmt = LOGF_TEST; gd->default_log_level = LOGL_INFO; env_set("ethact", "eth@10002000"); env_set("log_hostname", "sandbox"); @@ -274,6 +281,7 @@ static int log_test_syslog_nodebug(struct unit_test_state *uts) /* Check that the callback function was not called */ ut_assertnonnull(env.expected); gd->default_log_level = old_log_level; + gd->log_fmt = log_get_default_format(); return 0; } diff --git a/test/py/tests/test_bind.py b/test/py/tests/test_bind.py index 20c6050342..e9681c69c5 100644 --- a/test/py/tests/test_bind.py +++ b/test/py/tests/test_bind.py @@ -26,45 +26,45 @@ def in_tree(response, name, uclass, drv, depth, last_child): def test_bind_unbind_with_node(u_boot_console): #bind /bind-test. Device should come up as well as its children - response = u_boot_console.run_command('bind /bind-test generic_simple_bus') + response = u_boot_console.run_command('bind /bind-test simple_bus') assert response == '' tree = u_boot_console.run_command('dm tree') - assert in_tree(tree, 'bind-test', 'simple_bus', 'generic_simple_bus', 0, True) + assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True) assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, False) - assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_simple_bus', 1, True) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, True) #Unbind child #1. No error expected and all devices should be there except for bind-test-child1 response = u_boot_console.run_command('unbind /bind-test/bind-test-child1') assert response == '' tree = u_boot_console.run_command('dm tree') - assert in_tree(tree, 'bind-test', 'simple_bus', 'generic_simple_bus', 0, True) + assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True) assert 'bind-test-child1' not in tree - assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_simple_bus', 1, True) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, True) #bind child #1. No error expected and all devices should be there response = u_boot_console.run_command('bind /bind-test/bind-test-child1 phy_sandbox') assert response == '' tree = u_boot_console.run_command('dm tree') - assert in_tree(tree, 'bind-test', 'simple_bus', 'generic_simple_bus', 0, True) + assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True) assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, True) - assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_simple_bus', 1, False) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, False) #Unbind child #2. No error expected and all devices should be there except for bind-test-child2 response = u_boot_console.run_command('unbind /bind-test/bind-test-child2') assert response == '' tree = u_boot_console.run_command('dm tree') - assert in_tree(tree, 'bind-test', 'simple_bus', 'generic_simple_bus', 0, True) + assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True) assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, True) assert 'bind-test-child2' not in tree #Bind child #2. No error expected and all devices should be there - response = u_boot_console.run_command('bind /bind-test/bind-test-child2 generic_simple_bus') + response = u_boot_console.run_command('bind /bind-test/bind-test-child2 simple_bus') assert response == '' tree = u_boot_console.run_command('dm tree') - assert in_tree(tree, 'bind-test', 'simple_bus', 'generic_simple_bus', 0, True) + assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True) assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, False) - assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_simple_bus', 1, True) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, True) #Unbind parent. No error expected. All devices should be removed and unbound response = u_boot_console.run_command('unbind /bind-test') @@ -75,7 +75,7 @@ def test_bind_unbind_with_node(u_boot_console): assert 'bind-test-child2' not in tree #try binding invalid node with valid driver - response = u_boot_console.run_command('bind /not-a-valid-node generic_simple_bus') + response = u_boot_console.run_command('bind /not-a-valid-node simple_bus') assert response != '' tree = u_boot_console.run_command('dm tree') assert 'not-a-valid-node' not in tree @@ -87,12 +87,12 @@ def test_bind_unbind_with_node(u_boot_console): assert 'bind-test' not in tree #bind /bind-test. Device should come up as well as its children - response = u_boot_console.run_command('bind /bind-test generic_simple_bus') + response = u_boot_console.run_command('bind /bind-test simple_bus') assert response == '' tree = u_boot_console.run_command('dm tree') - assert in_tree(tree, 'bind-test', 'simple_bus', 'generic_simple_bus', 0, True) + assert in_tree(tree, 'bind-test', 'simple_bus', 'simple_bus', 0, True) assert in_tree(tree, 'bind-test-child1', 'phy', 'phy_sandbox', 1, False) - assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_simple_bus', 1, True) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, True) response = u_boot_console.run_command('unbind /bind-test') assert response == '' @@ -112,7 +112,7 @@ def get_next_line(tree, name): @pytest.mark.buildconfigspec('cmd_bind') def test_bind_unbind_with_uclass(u_boot_console): #bind /bind-test - response = u_boot_console.run_command('bind /bind-test generic_simple_bus') + response = u_boot_console.run_command('bind /bind-test simple_bus') assert response == '' #make sure bind-test-child2 is there and get its uclass/index pair @@ -123,8 +123,8 @@ def test_bind_unbind_with_uclass(u_boot_console): child2_uclass = child2_line[0].split()[0] child2_index = int(child2_line[0].split()[1]) - #bind generic_simple_bus as a child of bind-test-child2 - response = u_boot_console.run_command('bind {} {} generic_simple_bus'.format(child2_uclass, child2_index, 'generic_simple_bus')) + #bind simple_bus as a child of bind-test-child2 + response = u_boot_console.run_command('bind {} {} simple_bus'.format(child2_uclass, child2_index, 'simple_bus')) #check that the child is there and its uclass/index pair is right tree = u_boot_console.run_command('dm tree') @@ -132,20 +132,20 @@ def test_bind_unbind_with_uclass(u_boot_console): child_of_child2_line = get_next_line(tree, 'bind-test-child2') assert child_of_child2_line child_of_child2_index = int(child_of_child2_line.split()[1]) - assert in_tree(tree, 'generic_simple_bus', 'simple_bus', 'generic_simple_bus', 2, True) + assert in_tree(tree, 'simple_bus', 'simple_bus', 'simple_bus', 2, True) assert child_of_child2_index == child2_index + 1 #unbind the child and check it has been removed response = u_boot_console.run_command('unbind simple_bus {}'.format(child_of_child2_index)) assert response == '' tree = u_boot_console.run_command('dm tree') - assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_simple_bus', 1, True) - assert not in_tree(tree, 'generic_simple_bus', 'simple_bus', 'generic_simple_bus', 2, True) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, True) + assert not in_tree(tree, 'simple_bus', 'simple_bus', 'simple_bus', 2, True) child_of_child2_line = get_next_line(tree, 'bind-test-child2') assert child_of_child2_line == '' - #bind generic_simple_bus as a child of bind-test-child2 - response = u_boot_console.run_command('bind {} {} generic_simple_bus'.format(child2_uclass, child2_index, 'generic_simple_bus')) + #bind simple_bus as a child of bind-test-child2 + response = u_boot_console.run_command('bind {} {} simple_bus'.format(child2_uclass, child2_index, 'simple_bus')) #check that the child is there and its uclass/index pair is right tree = u_boot_console.run_command('dm tree') @@ -154,22 +154,22 @@ def test_bind_unbind_with_uclass(u_boot_console): child_of_child2_line = get_next_line(tree, 'bind-test-child2') assert child_of_child2_line child_of_child2_index = int(child_of_child2_line.split()[1]) - assert in_tree(tree, 'generic_simple_bus', 'simple_bus', 'generic_simple_bus', 2, True) + assert in_tree(tree, 'simple_bus', 'simple_bus', 'simple_bus', 2, True) assert child_of_child2_index == child2_index + 1 #unbind the child and check it has been removed - response = u_boot_console.run_command('unbind {} {} generic_simple_bus'.format(child2_uclass, child2_index, 'generic_simple_bus')) + response = u_boot_console.run_command('unbind {} {} simple_bus'.format(child2_uclass, child2_index, 'simple_bus')) assert response == '' tree = u_boot_console.run_command('dm tree') - assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_simple_bus', 1, True) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'simple_bus', 1, True) child_of_child2_line = get_next_line(tree, 'bind-test-child2') assert child_of_child2_line == '' #unbind the child again and check it doesn't change the tree tree_old = u_boot_console.run_command('dm tree') - response = u_boot_console.run_command('unbind {} {} generic_simple_bus'.format(child2_uclass, child2_index, 'generic_simple_bus')) + response = u_boot_console.run_command('unbind {} {} simple_bus'.format(child2_uclass, child2_index, 'simple_bus')) tree_new = u_boot_console.run_command('dm tree') assert response == '' diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py index 75325fad61..ddc28f19ee 100644 --- a/test/py/tests/test_log.py +++ b/test/py/tests/test_log.py @@ -39,6 +39,8 @@ def test_log(u_boot_console): Returns: iterator containing the lines output from the command """ + output = u_boot_console.run_command('log format fm') + assert output == '' with cons.log.section('basic'): output = u_boot_console.run_command('log test %d' % testnum) split = output.replace('\r', '').splitlines() |