diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/Makefile | 1 | ||||
-rw-r--r-- | test/dm/bootcount.c | 30 | ||||
-rw-r--r-- | test/dm/regmap.c | 7 | ||||
-rw-r--r-- | test/dm/serial.c | 19 | ||||
-rw-r--r-- | test/lib/Makefile | 1 | ||||
-rw-r--r-- | test/lib/lmb.c | 601 | ||||
-rw-r--r-- | test/py/tests/test_avb.py | 14 | ||||
-rw-r--r-- | test/py/tests/test_bind.py | 143 | ||||
-rw-r--r-- | test/py/tests/test_dfu.py | 38 | ||||
-rw-r--r-- | test/py/tests/test_efi_loader.py | 12 | ||||
-rw-r--r-- | test/py/tests/test_fpga.py | 54 | ||||
-rw-r--r-- | test/py/tests/test_fs/conftest.py | 8 | ||||
-rw-r--r-- | test/py/tests/test_mmc_rd.py | 66 | ||||
-rw-r--r-- | test/py/tests/test_net.py | 22 | ||||
-rw-r--r-- | test/py/tests/test_ums.py | 24 |
15 files changed, 839 insertions, 201 deletions
diff --git a/test/dm/Makefile b/test/dm/Makefile index 7dc80be25e3..1b089960cbb 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -15,6 +15,7 @@ ifneq ($(CONFIG_SANDBOX),) obj-$(CONFIG_SOUND) += audio.o obj-$(CONFIG_BLK) += blk.o obj-$(CONFIG_BOARD) += board.o +obj-$(CONFIG_DM_BOOTCOUNT) += bootcount.o obj-$(CONFIG_CLK) += clk.o obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_FIRMWARE) += firmware.o diff --git a/test/dm/bootcount.c b/test/dm/bootcount.c new file mode 100644 index 00000000000..0817b7d3ec1 --- /dev/null +++ b/test/dm/bootcount.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) 2018 Theobroma Systems Design und Consulting GmbH + */ + +#include <common.h> +#include <dm.h> +#include <bootcount.h> +#include <asm/test.h> +#include <dm/test.h> +#include <test/ut.h> + +static int dm_test_bootcount(struct unit_test_state *uts) +{ + struct udevice *dev; + u32 val; + + ut_assertok(uclass_get_device(UCLASS_BOOTCOUNT, 0, &dev)); + ut_assertok(dm_bootcount_set(dev, 0)); + ut_assertok(dm_bootcount_get(dev, &val)); + ut_assert(val == 0); + ut_assertok(dm_bootcount_set(dev, 0xab)); + ut_assertok(dm_bootcount_get(dev, &val)); + ut_assert(val == 0xab); + + return 0; +} + +DM_TEST(dm_test_bootcount, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + diff --git a/test/dm/regmap.c b/test/dm/regmap.c index 9a70c159ddb..82de295cb8f 100644 --- a/test/dm/regmap.c +++ b/test/dm/regmap.c @@ -160,9 +160,10 @@ static int dm_test_regmap_poll(struct unit_test_state *uts) start = get_timer(0); ut_asserteq(-ETIMEDOUT, - regmap_read_poll_timeout(map, 0, reg, - (reg == 0xcacafafa), - 1, 5 * CONFIG_SYS_HZ)); + regmap_read_poll_timeout_test(map, 0, reg, + (reg == 0xcacafafa), + 1, 5 * CONFIG_SYS_HZ, + 5 * CONFIG_SYS_HZ)); ut_assert(get_timer(start) > (5 * CONFIG_SYS_HZ)); diff --git a/test/dm/serial.c b/test/dm/serial.c index 19a15d5d952..3d741a8c363 100644 --- a/test/dm/serial.c +++ b/test/dm/serial.c @@ -23,23 +23,24 @@ static int dm_test_serial(struct unit_test_state *uts) * test with default config which is the only one supported by * sandbox_serial driver */ - ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG)); - ut_assertok(serial_getconfig(&value_serial)); + ut_assertok(serial_setconfig(dev_serial, SERIAL_DEFAULT_CONFIG)); + ut_assertok(serial_getconfig(dev_serial, &value_serial)); ut_assert(value_serial == SERIAL_DEFAULT_CONFIG); - ut_assertok(serial_getinfo(&info_serial)); + ut_assertok(serial_getinfo(dev_serial, &info_serial)); ut_assert(info_serial.type == SERIAL_CHIP_UNKNOWN); ut_assert(info_serial.addr == SERIAL_DEFAULT_ADDRESS); /* * test with a parameter which is NULL pointer */ - ut_asserteq(-EINVAL, serial_getconfig(NULL)); - ut_asserteq(-EINVAL, serial_getinfo(NULL)); + ut_asserteq(-EINVAL, serial_getconfig(dev_serial, NULL)); + ut_asserteq(-EINVAL, serial_getinfo(dev_serial, NULL)); /* * test with a serial config which is not supported by * sandbox_serial driver: test with wrong parity */ ut_asserteq(-ENOTSUPP, - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_ODD, + serial_setconfig(dev_serial, + SERIAL_CONFIG(SERIAL_PAR_ODD, SERIAL_8_BITS, SERIAL_ONE_STOP))); /* @@ -47,7 +48,8 @@ static int dm_test_serial(struct unit_test_state *uts) * sandbox_serial driver: test with wrong bits number */ ut_asserteq(-ENOTSUPP, - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE, + serial_setconfig(dev_serial, + SERIAL_CONFIG(SERIAL_PAR_NONE, SERIAL_6_BITS, SERIAL_ONE_STOP))); @@ -56,7 +58,8 @@ static int dm_test_serial(struct unit_test_state *uts) * sandbox_serial driver: test with wrong stop bits number */ ut_asserteq(-ENOTSUPP, - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE, + serial_setconfig(dev_serial, + SERIAL_CONFIG(SERIAL_PAR_NONE, SERIAL_8_BITS, SERIAL_TWO_STOP))); diff --git a/test/lib/Makefile b/test/lib/Makefile index ea68fae566f..5a636aac740 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -3,3 +3,4 @@ # (C) Copyright 2018 # Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc obj-y += hexdump.o +obj-y += lmb.o diff --git a/test/lib/lmb.c b/test/lib/lmb.c new file mode 100644 index 00000000000..058d3c332be --- /dev/null +++ b/test/lib/lmb.c @@ -0,0 +1,601 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2018 Simon Goldschmidt + */ + +#include <common.h> +#include <lmb.h> +#include <dm/test.h> +#include <test/ut.h> + +static int check_lmb(struct unit_test_state *uts, struct lmb *lmb, + phys_addr_t ram_base, phys_size_t ram_size, + unsigned long num_reserved, + phys_addr_t base1, phys_size_t size1, + phys_addr_t base2, phys_size_t size2, + phys_addr_t base3, phys_size_t size3) +{ + ut_asserteq(lmb->memory.cnt, 1); + ut_asserteq(lmb->memory.region[0].base, ram_base); + ut_asserteq(lmb->memory.region[0].size, ram_size); + + ut_asserteq(lmb->reserved.cnt, num_reserved); + if (num_reserved > 0) { + ut_asserteq(lmb->reserved.region[0].base, base1); + ut_asserteq(lmb->reserved.region[0].size, size1); + } + if (num_reserved > 1) { + ut_asserteq(lmb->reserved.region[1].base, base2); + ut_asserteq(lmb->reserved.region[1].size, size2); + } + if (num_reserved > 2) { + ut_asserteq(lmb->reserved.region[2].base, base3); + ut_asserteq(lmb->reserved.region[2].size, size3); + } + return 0; +} + +#define ASSERT_LMB(lmb, ram_base, ram_size, num_reserved, base1, size1, \ + base2, size2, base3, size3) \ + ut_assert(!check_lmb(uts, lmb, ram_base, ram_size, \ + num_reserved, base1, size1, base2, size2, base3, \ + size3)) + +/* + * Test helper function that reserves 64 KiB somewhere in the simulated RAM and + * then does some alloc + free tests. + */ +static int test_multi_alloc(struct unit_test_state *uts, + const phys_addr_t ram, const phys_size_t ram_size, + const phys_addr_t alloc_64k_addr) +{ + const phys_addr_t ram_end = ram + ram_size; + const phys_addr_t alloc_64k_end = alloc_64k_addr + 0x10000; + + struct lmb lmb; + long ret; + phys_addr_t a, a2, b, b2, c, d; + + /* check for overflow */ + ut_assert(ram_end == 0 || ram_end > ram); + ut_assert(alloc_64k_end > alloc_64k_addr); + /* check input addresses + size */ + ut_assert(alloc_64k_addr >= ram + 8); + ut_assert(alloc_64k_end <= ram_end - 8); + + lmb_init(&lmb); + + ret = lmb_add(&lmb, ram, ram_size); + ut_asserteq(ret, 0); + + /* reserve 64KiB somewhere */ + ret = lmb_reserve(&lmb, alloc_64k_addr, 0x10000); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, alloc_64k_addr, 0x10000, + 0, 0, 0, 0); + + /* allocate somewhere, should be at the end of RAM */ + a = lmb_alloc(&lmb, 4, 1); + ut_asserteq(a, ram_end - 4); + ASSERT_LMB(&lmb, ram, ram_size, 2, alloc_64k_addr, 0x10000, + ram_end - 4, 4, 0, 0); + /* alloc below end of reserved region -> below reserved region */ + b = lmb_alloc_base(&lmb, 4, 1, alloc_64k_end); + ut_asserteq(b, alloc_64k_addr - 4); + ASSERT_LMB(&lmb, ram, ram_size, 2, + alloc_64k_addr - 4, 0x10000 + 4, ram_end - 4, 4, 0, 0); + + /* 2nd time */ + c = lmb_alloc(&lmb, 4, 1); + ut_asserteq(c, ram_end - 8); + ASSERT_LMB(&lmb, ram, ram_size, 2, + alloc_64k_addr - 4, 0x10000 + 4, ram_end - 8, 8, 0, 0); + d = lmb_alloc_base(&lmb, 4, 1, alloc_64k_end); + ut_asserteq(d, alloc_64k_addr - 8); + ASSERT_LMB(&lmb, ram, ram_size, 2, + alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 8, 0, 0); + + ret = lmb_free(&lmb, a, 4); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 2, + alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 4, 0, 0); + /* allocate again to ensure we get the same address */ + a2 = lmb_alloc(&lmb, 4, 1); + ut_asserteq(a, a2); + ASSERT_LMB(&lmb, ram, ram_size, 2, + alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 8, 0, 0); + ret = lmb_free(&lmb, a2, 4); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 2, + alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 4, 0, 0); + + ret = lmb_free(&lmb, b, 4); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 3, + alloc_64k_addr - 8, 4, alloc_64k_addr, 0x10000, + ram_end - 8, 4); + /* allocate again to ensure we get the same address */ + b2 = lmb_alloc_base(&lmb, 4, 1, alloc_64k_end); + ut_asserteq(b, b2); + ASSERT_LMB(&lmb, ram, ram_size, 2, + alloc_64k_addr - 8, 0x10000 + 8, ram_end - 8, 4, 0, 0); + ret = lmb_free(&lmb, b2, 4); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 3, + alloc_64k_addr - 8, 4, alloc_64k_addr, 0x10000, + ram_end - 8, 4); + + ret = lmb_free(&lmb, c, 4); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 2, + alloc_64k_addr - 8, 4, alloc_64k_addr, 0x10000, 0, 0); + ret = lmb_free(&lmb, d, 4); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, alloc_64k_addr, 0x10000, + 0, 0, 0, 0); + + return 0; +} + +static int test_multi_alloc_512mb(struct unit_test_state *uts, + const phys_addr_t ram) +{ + return test_multi_alloc(uts, ram, 0x20000000, ram + 0x10000000); +} + +/* Create a memory region with one reserved region and allocate */ +static int lib_test_lmb_simple(struct unit_test_state *uts) +{ + int ret; + + /* simulate 512 MiB RAM beginning at 1GiB */ + ret = test_multi_alloc_512mb(uts, 0x40000000); + if (ret) + return ret; + + /* simulate 512 MiB RAM beginning at 1.5GiB */ + return test_multi_alloc_512mb(uts, 0xE0000000); +} + +DM_TEST(lib_test_lmb_simple, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Simulate 512 MiB RAM, allocate some blocks that fit/don't fit */ +static int test_bigblock(struct unit_test_state *uts, const phys_addr_t ram) +{ + const phys_size_t ram_size = 0x20000000; + const phys_size_t big_block_size = 0x10000000; + const phys_addr_t ram_end = ram + ram_size; + const phys_addr_t alloc_64k_addr = ram + 0x10000000; + struct lmb lmb; + long ret; + phys_addr_t a, b; + + /* check for overflow */ + ut_assert(ram_end == 0 || ram_end > ram); + + lmb_init(&lmb); + + ret = lmb_add(&lmb, ram, ram_size); + ut_asserteq(ret, 0); + + /* reserve 64KiB in the middle of RAM */ + ret = lmb_reserve(&lmb, alloc_64k_addr, 0x10000); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, alloc_64k_addr, 0x10000, + 0, 0, 0, 0); + + /* allocate a big block, should be below reserved */ + a = lmb_alloc(&lmb, big_block_size, 1); + ut_asserteq(a, ram); + ASSERT_LMB(&lmb, ram, ram_size, 1, a, + big_block_size + 0x10000, 0, 0, 0, 0); + /* allocate 2nd big block */ + /* This should fail, printing an error */ + b = lmb_alloc(&lmb, big_block_size, 1); + ut_asserteq(b, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, a, + big_block_size + 0x10000, 0, 0, 0, 0); + + ret = lmb_free(&lmb, a, big_block_size); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, alloc_64k_addr, 0x10000, + 0, 0, 0, 0); + + /* allocate too big block */ + /* This should fail, printing an error */ + a = lmb_alloc(&lmb, ram_size, 1); + ut_asserteq(a, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, alloc_64k_addr, 0x10000, + 0, 0, 0, 0); + + return 0; +} + +static int lib_test_lmb_big(struct unit_test_state *uts) +{ + int ret; + + /* simulate 512 MiB RAM beginning at 1GiB */ + ret = test_bigblock(uts, 0x40000000); + if (ret) + return ret; + + /* simulate 512 MiB RAM beginning at 1.5GiB */ + return test_bigblock(uts, 0xE0000000); +} + +DM_TEST(lib_test_lmb_big, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Simulate 512 MiB RAM, allocate a block without previous reservation */ +static int test_noreserved(struct unit_test_state *uts, const phys_addr_t ram, + const phys_addr_t alloc_size, const ulong align) +{ + const phys_size_t ram_size = 0x20000000; + const phys_addr_t ram_end = ram + ram_size; + struct lmb lmb; + long ret; + phys_addr_t a, b; + const phys_addr_t alloc_size_aligned = (alloc_size + align - 1) & + ~(align - 1); + + /* check for overflow */ + ut_assert(ram_end == 0 || ram_end > ram); + + lmb_init(&lmb); + + ret = lmb_add(&lmb, ram, ram_size); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 0, 0, 0, 0, 0, 0, 0); + + /* allocate a block */ + a = lmb_alloc(&lmb, alloc_size, align); + ut_assert(a != 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram + ram_size - alloc_size_aligned, + alloc_size, 0, 0, 0, 0); + /* allocate another block */ + b = lmb_alloc(&lmb, alloc_size, align); + ut_assert(b != 0); + if (alloc_size == alloc_size_aligned) { + ASSERT_LMB(&lmb, ram, ram_size, 1, ram + ram_size - + (alloc_size_aligned * 2), alloc_size * 2, 0, 0, 0, + 0); + } else { + ASSERT_LMB(&lmb, ram, ram_size, 2, ram + ram_size - + (alloc_size_aligned * 2), alloc_size, ram + ram_size + - alloc_size_aligned, alloc_size, 0, 0); + } + /* and free them */ + ret = lmb_free(&lmb, b, alloc_size); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram + ram_size - alloc_size_aligned, + alloc_size, 0, 0, 0, 0); + ret = lmb_free(&lmb, a, alloc_size); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 0, 0, 0, 0, 0, 0, 0); + + /* allocate a block with base*/ + b = lmb_alloc_base(&lmb, alloc_size, align, ram_end); + ut_assert(a == b); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram + ram_size - alloc_size_aligned, + alloc_size, 0, 0, 0, 0); + /* and free it */ + ret = lmb_free(&lmb, b, alloc_size); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 0, 0, 0, 0, 0, 0, 0); + + return 0; +} + +static int lib_test_lmb_noreserved(struct unit_test_state *uts) +{ + int ret; + + /* simulate 512 MiB RAM beginning at 1GiB */ + ret = test_noreserved(uts, 0x40000000, 4, 1); + if (ret) + return ret; + + /* simulate 512 MiB RAM beginning at 1.5GiB */ + return test_noreserved(uts, 0xE0000000, 4, 1); +} + +DM_TEST(lib_test_lmb_noreserved, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +static int lib_test_lmb_unaligned_size(struct unit_test_state *uts) +{ + int ret; + + /* simulate 512 MiB RAM beginning at 1GiB */ + ret = test_noreserved(uts, 0x40000000, 5, 8); + if (ret) + return ret; + + /* simulate 512 MiB RAM beginning at 1.5GiB */ + return test_noreserved(uts, 0xE0000000, 5, 8); +} + +DM_TEST(lib_test_lmb_unaligned_size, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); +/* + * Simulate a RAM that starts at 0 and allocate down to address 0, which must + * fail as '0' means failure for the lmb_alloc functions. + */ +static int lib_test_lmb_at_0(struct unit_test_state *uts) +{ + const phys_addr_t ram = 0; + const phys_size_t ram_size = 0x20000000; + struct lmb lmb; + long ret; + phys_addr_t a, b; + + lmb_init(&lmb); + + ret = lmb_add(&lmb, ram, ram_size); + ut_asserteq(ret, 0); + + /* allocate nearly everything */ + a = lmb_alloc(&lmb, ram_size - 4, 1); + ut_asserteq(a, ram + 4); + ASSERT_LMB(&lmb, ram, ram_size, 1, a, ram_size - 4, + 0, 0, 0, 0); + /* allocate the rest */ + /* This should fail as the allocated address would be 0 */ + b = lmb_alloc(&lmb, 4, 1); + ut_asserteq(b, 0); + /* check that this was an error by checking lmb */ + ASSERT_LMB(&lmb, ram, ram_size, 1, a, ram_size - 4, + 0, 0, 0, 0); + /* check that this was an error by freeing b */ + ret = lmb_free(&lmb, b, 4); + ut_asserteq(ret, -1); + ASSERT_LMB(&lmb, ram, ram_size, 1, a, ram_size - 4, + 0, 0, 0, 0); + + ret = lmb_free(&lmb, a, ram_size - 4); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 0, 0, 0, 0, 0, 0, 0); + + return 0; +} + +DM_TEST(lib_test_lmb_at_0, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Check that calling lmb_reserve with overlapping regions fails. */ +static int lib_test_lmb_overlapping_reserve(struct unit_test_state *uts) +{ + const phys_addr_t ram = 0x40000000; + const phys_size_t ram_size = 0x20000000; + struct lmb lmb; + long ret; + + lmb_init(&lmb); + + ret = lmb_add(&lmb, ram, ram_size); + ut_asserteq(ret, 0); + + ret = lmb_reserve(&lmb, 0x40010000, 0x10000); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, 0x40010000, 0x10000, + 0, 0, 0, 0); + /* allocate overlapping region should fail */ + ret = lmb_reserve(&lmb, 0x40011000, 0x10000); + ut_asserteq(ret, -1); + ASSERT_LMB(&lmb, ram, ram_size, 1, 0x40010000, 0x10000, + 0, 0, 0, 0); + /* allocate 3nd region */ + ret = lmb_reserve(&lmb, 0x40030000, 0x10000); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 2, 0x40010000, 0x10000, + 0x40030000, 0x10000, 0, 0); + /* allocate 2nd region */ + ret = lmb_reserve(&lmb, 0x40020000, 0x10000); + ut_assert(ret >= 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, 0x40010000, 0x30000, + 0, 0, 0, 0); + + return 0; +} + +DM_TEST(lib_test_lmb_overlapping_reserve, + DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* + * Simulate 512 MiB RAM, reserve 3 blocks, allocate addresses in between. + * Expect addresses outside the memory range to fail. + */ +static int test_alloc_addr(struct unit_test_state *uts, const phys_addr_t ram) +{ + const phys_size_t ram_size = 0x20000000; + const phys_addr_t ram_end = ram + ram_size; + const phys_size_t alloc_addr_a = ram + 0x8000000; + const phys_size_t alloc_addr_b = ram + 0x8000000 * 2; + const phys_size_t alloc_addr_c = ram + 0x8000000 * 3; + struct lmb lmb; + long ret; + phys_addr_t a, b, c, d, e; + + /* check for overflow */ + ut_assert(ram_end == 0 || ram_end > ram); + + lmb_init(&lmb); + + ret = lmb_add(&lmb, ram, ram_size); + ut_asserteq(ret, 0); + + /* reserve 3 blocks */ + ret = lmb_reserve(&lmb, alloc_addr_a, 0x10000); + ut_asserteq(ret, 0); + ret = lmb_reserve(&lmb, alloc_addr_b, 0x10000); + ut_asserteq(ret, 0); + ret = lmb_reserve(&lmb, alloc_addr_c, 0x10000); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 3, alloc_addr_a, 0x10000, + alloc_addr_b, 0x10000, alloc_addr_c, 0x10000); + + /* allocate blocks */ + a = lmb_alloc_addr(&lmb, ram, alloc_addr_a - ram); + ut_asserteq(a, ram); + ASSERT_LMB(&lmb, ram, ram_size, 3, ram, 0x8010000, + alloc_addr_b, 0x10000, alloc_addr_c, 0x10000); + b = lmb_alloc_addr(&lmb, alloc_addr_a + 0x10000, + alloc_addr_b - alloc_addr_a - 0x10000); + ut_asserteq(b, alloc_addr_a + 0x10000); + ASSERT_LMB(&lmb, ram, ram_size, 2, ram, 0x10010000, + alloc_addr_c, 0x10000, 0, 0); + c = lmb_alloc_addr(&lmb, alloc_addr_b + 0x10000, + alloc_addr_c - alloc_addr_b - 0x10000); + ut_asserteq(c, alloc_addr_b + 0x10000); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram, 0x18010000, + 0, 0, 0, 0); + d = lmb_alloc_addr(&lmb, alloc_addr_c + 0x10000, + ram_end - alloc_addr_c - 0x10000); + ut_asserteq(d, alloc_addr_c + 0x10000); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram, ram_size, + 0, 0, 0, 0); + + /* allocating anything else should fail */ + e = lmb_alloc(&lmb, 1, 1); + ut_asserteq(e, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram, ram_size, + 0, 0, 0, 0); + + ret = lmb_free(&lmb, d, ram_end - alloc_addr_c - 0x10000); + ut_asserteq(ret, 0); + + /* allocate at 3 points in free range */ + + d = lmb_alloc_addr(&lmb, ram_end - 4, 4); + ut_asserteq(d, ram_end - 4); + ASSERT_LMB(&lmb, ram, ram_size, 2, ram, 0x18010000, + d, 4, 0, 0); + ret = lmb_free(&lmb, d, 4); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram, 0x18010000, + 0, 0, 0, 0); + + d = lmb_alloc_addr(&lmb, ram_end - 128, 4); + ut_asserteq(d, ram_end - 128); + ASSERT_LMB(&lmb, ram, ram_size, 2, ram, 0x18010000, + d, 4, 0, 0); + ret = lmb_free(&lmb, d, 4); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram, 0x18010000, + 0, 0, 0, 0); + + d = lmb_alloc_addr(&lmb, alloc_addr_c + 0x10000, 4); + ut_asserteq(d, alloc_addr_c + 0x10000); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram, 0x18010004, + 0, 0, 0, 0); + ret = lmb_free(&lmb, d, 4); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram, 0x18010000, + 0, 0, 0, 0); + + /* allocate at the bottom */ + ret = lmb_free(&lmb, a, alloc_addr_a - ram); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 1, ram + 0x8000000, 0x10010000, + 0, 0, 0, 0); + d = lmb_alloc_addr(&lmb, ram, 4); + ut_asserteq(d, ram); + ASSERT_LMB(&lmb, ram, ram_size, 2, d, 4, + ram + 0x8000000, 0x10010000, 0, 0); + + /* check that allocating outside memory fails */ + if (ram_end != 0) { + ret = lmb_alloc_addr(&lmb, ram_end, 1); + ut_asserteq(ret, 0); + } + if (ram != 0) { + ret = lmb_alloc_addr(&lmb, ram - 1, 1); + ut_asserteq(ret, 0); + } + + return 0; +} + +static int lib_test_lmb_alloc_addr(struct unit_test_state *uts) +{ + int ret; + + /* simulate 512 MiB RAM beginning at 1GiB */ + ret = test_alloc_addr(uts, 0x40000000); + if (ret) + return ret; + + /* simulate 512 MiB RAM beginning at 1.5GiB */ + return test_alloc_addr(uts, 0xE0000000); +} + +DM_TEST(lib_test_lmb_alloc_addr, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Simulate 512 MiB RAM, reserve 3 blocks, check addresses in between */ +static int test_get_unreserved_size(struct unit_test_state *uts, + const phys_addr_t ram) +{ + const phys_size_t ram_size = 0x20000000; + const phys_addr_t ram_end = ram + ram_size; + const phys_size_t alloc_addr_a = ram + 0x8000000; + const phys_size_t alloc_addr_b = ram + 0x8000000 * 2; + const phys_size_t alloc_addr_c = ram + 0x8000000 * 3; + struct lmb lmb; + long ret; + phys_size_t s; + + /* check for overflow */ + ut_assert(ram_end == 0 || ram_end > ram); + + lmb_init(&lmb); + + ret = lmb_add(&lmb, ram, ram_size); + ut_asserteq(ret, 0); + + /* reserve 3 blocks */ + ret = lmb_reserve(&lmb, alloc_addr_a, 0x10000); + ut_asserteq(ret, 0); + ret = lmb_reserve(&lmb, alloc_addr_b, 0x10000); + ut_asserteq(ret, 0); + ret = lmb_reserve(&lmb, alloc_addr_c, 0x10000); + ut_asserteq(ret, 0); + ASSERT_LMB(&lmb, ram, ram_size, 3, alloc_addr_a, 0x10000, + alloc_addr_b, 0x10000, alloc_addr_c, 0x10000); + + /* check addresses in between blocks */ + s = lmb_get_unreserved_size(&lmb, ram); + ut_asserteq(s, alloc_addr_a - ram); + s = lmb_get_unreserved_size(&lmb, ram + 0x10000); + ut_asserteq(s, alloc_addr_a - ram - 0x10000); + s = lmb_get_unreserved_size(&lmb, alloc_addr_a - 4); + ut_asserteq(s, 4); + + s = lmb_get_unreserved_size(&lmb, alloc_addr_a + 0x10000); + ut_asserteq(s, alloc_addr_b - alloc_addr_a - 0x10000); + s = lmb_get_unreserved_size(&lmb, alloc_addr_a + 0x20000); + ut_asserteq(s, alloc_addr_b - alloc_addr_a - 0x20000); + s = lmb_get_unreserved_size(&lmb, alloc_addr_b - 4); + ut_asserteq(s, 4); + + s = lmb_get_unreserved_size(&lmb, alloc_addr_c + 0x10000); + ut_asserteq(s, ram_end - alloc_addr_c - 0x10000); + s = lmb_get_unreserved_size(&lmb, alloc_addr_c + 0x20000); + ut_asserteq(s, ram_end - alloc_addr_c - 0x20000); + s = lmb_get_unreserved_size(&lmb, ram_end - 4); + ut_asserteq(s, 4); + + return 0; +} + +static int lib_test_lmb_get_unreserved_size(struct unit_test_state *uts) +{ + int ret; + + /* simulate 512 MiB RAM beginning at 1GiB */ + ret = test_get_unreserved_size(uts, 0x40000000); + if (ret) + return ret; + + /* simulate 512 MiB RAM beginning at 1.5GiB */ + return test_get_unreserved_size(uts, 0xE0000000); +} + +DM_TEST(lib_test_lmb_get_unreserved_size, + DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); diff --git a/test/py/tests/test_avb.py b/test/py/tests/test_avb.py index 9683fd80d07..e70a010c9ac 100644 --- a/test/py/tests/test_avb.py +++ b/test/py/tests/test_avb.py @@ -51,22 +51,22 @@ def test_avb_mmc_uuid(u_boot_console): part_lines = u_boot_console.run_command('mmc part').splitlines() part_list = {} - cur_partname = "" + cur_partname = '' for line in part_lines: - if "\"" in line: - start_pt = line.find("\"") - end_pt = line.find("\"", start_pt + 1) + if '"' in line: + start_pt = line.find('"') + end_pt = line.find('"', start_pt + 1) cur_partname = line[start_pt + 1: end_pt] - if "guid:" in line: - guid_to_check = line.split("guid:\t") + if 'guid:' in line: + guid_to_check = line.split('guid:\t') part_list[cur_partname] = guid_to_check[1] # lets check all guids with avb get_guid for part, guid in part_list.iteritems(): avb_guid_resp = u_boot_console.run_command('avb get_uuid %s' % part) - assert guid == avb_guid_resp.split("UUID: ")[1] + assert guid == avb_guid_resp.split('UUID: ')[1] @pytest.mark.buildconfigspec('cmd_avb') diff --git a/test/py/tests/test_bind.py b/test/py/tests/test_bind.py index dee3fee5661..ccf6d62ea8a 100644 --- a/test/py/tests/test_bind.py +++ b/test/py/tests/test_bind.py @@ -13,7 +13,8 @@ def in_tree(response, name, uclass, drv, depth, last_child): else: leaf = leaf + '`' leaf = leaf + '-- ' + name - line = ' *{:10.10} [0-9]* \[ [ +] \] {:20.20} {}$'.format(uclass, drv, leaf) + line = (' *{:10.10} [0-9]* \[ [ +] \] {:20.20} {}$' + .format(uclass, drv, leaf)) prog = re.compile(line) for l in lines: if prog.match(l): @@ -25,82 +26,82 @@ 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 generic_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-child1", "phy", "phy_sandbox", 1, False) - assert in_tree(tree, "bind-test-child2", "simple_bus", "generic_simple_bus", 1, True) + 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-child1', 'phy', 'phy_sandbox', 1, False) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_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") + 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 "bind-test-child1" not in tree - assert in_tree(tree, "bind-test-child2", "simple_bus", "generic_simple_bus", 1, True) + tree = u_boot_console.run_command('dm tree') + assert in_tree(tree, 'bind-test', 'simple_bus', 'generic_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) #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") + 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-child1", "phy", "phy_sandbox", 1, True) - assert in_tree(tree, "bind-test-child2", "simple_bus", "generic_simple_bus", 1, False) + 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-child1', 'phy', 'phy_sandbox', 1, True) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_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") + 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-child1", "phy", "phy_sandbox", 1, True) - assert "bind-test-child2" not in tree + 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-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 generic_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-child1", "phy", "phy_sandbox", 1, False) - assert in_tree(tree, "bind-test-child2", "simple_bus", "generic_simple_bus", 1, True) + 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-child1', 'phy', 'phy_sandbox', 1, False) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_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") + response = u_boot_console.run_command('unbind /bind-test') assert response == '' - tree = u_boot_console.run_command("dm tree") - assert "bind-test" not in tree - assert "bind-test-child1" not in tree - assert "bind-test-child2" not in tree + tree = u_boot_console.run_command('dm tree') + assert 'bind-test' not in tree + assert 'bind-test-child1' not in tree + 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 generic_simple_bus') assert response != '' - tree = u_boot_console.run_command("dm tree") - assert "not-a-valid-node" not in tree + tree = u_boot_console.run_command('dm tree') + assert 'not-a-valid-node' not in tree #try binding valid node with invalid driver - response = u_boot_console.run_command("bind /bind-test not_a_driver") + response = u_boot_console.run_command('bind /bind-test not_a_driver') assert response != '' - tree = u_boot_console.run_command("dm tree") - assert "bind-test" not in tree + tree = u_boot_console.run_command('dm tree') + 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 generic_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-child1", "phy", "phy_sandbox", 1, False) - assert in_tree(tree, "bind-test-child2", "simple_bus", "generic_simple_bus", 1, True) + 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-child1', 'phy', 'phy_sandbox', 1, False) + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_simple_bus', 1, True) - response = u_boot_console.run_command("unbind /bind-test") + response = u_boot_console.run_command('unbind /bind-test') assert response == '' def get_next_line(tree, name): treelines = [x.strip() for x in tree.splitlines() if x.strip()] - child_line = "" + child_line = '' for idx, line in enumerate(treelines): - if ("-- " + name) in line: + if ('-- ' + name) in line: try: child_line = treelines[idx+1] except: @@ -111,68 +112,68 @@ 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 generic_simple_bus') assert response == '' #make sure bind-test-child2 is there and get its uclass/index pair - tree = u_boot_console.run_command("dm tree") - child2_line = [x.strip() for x in tree.splitlines() if "-- bind-test-child2" in x] + tree = u_boot_console.run_command('dm tree') + child2_line = [x.strip() for x in tree.splitlines() if '-- bind-test-child2' in x] assert len(child2_line) == 1 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")) + response = u_boot_console.run_command('bind {} {} generic_simple_bus'.format(child2_uclass, child2_index, 'generic_simple_bus')) #check that the child is there and its uclass/index pair is right - tree = u_boot_console.run_command("dm tree") + tree = u_boot_console.run_command('dm tree') - child_of_child2_line = get_next_line(tree, "bind-test-child2") + 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, 'generic_simple_bus', 'simple_bus', 'generic_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)) + 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) - child_of_child2_line = get_next_line(tree, "bind-test-child2") - assert child_of_child2_line == "" + 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) + 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")) + response = u_boot_console.run_command('bind {} {} generic_simple_bus'.format(child2_uclass, child2_index, 'generic_simple_bus')) #check that the child is there and its uclass/index pair is right - tree = u_boot_console.run_command("dm tree") + tree = u_boot_console.run_command('dm tree') treelines = [x.strip() for x in tree.splitlines() if x.strip()] - child_of_child2_line = get_next_line(tree, "bind-test-child2") + 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, 'generic_simple_bus', 'simple_bus', 'generic_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 {} {} generic_simple_bus'.format(child2_uclass, child2_index, 'generic_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) + tree = u_boot_console.run_command('dm tree') + assert in_tree(tree, 'bind-test-child2', 'simple_bus', 'generic_simple_bus', 1, True) - child_of_child2_line = get_next_line(tree, "bind-test-child2") - assert child_of_child2_line == "" + 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")) - tree_new = u_boot_console.run_command("dm 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')) + tree_new = u_boot_console.run_command('dm tree') assert response == '' assert tree_old == tree_new - response = u_boot_console.run_command("unbind /bind-test") + response = u_boot_console.run_command('unbind /bind-test') assert response == '' diff --git a/test/py/tests/test_dfu.py b/test/py/tests/test_dfu.py index a24600376cb..5d87eb349bf 100644 --- a/test/py/tests/test_dfu.py +++ b/test/py/tests/test_dfu.py @@ -20,28 +20,28 @@ For example: env__usb_dev_ports = ( { - "fixture_id": "micro_b", - "tgt_usb_ctlr": "0", - "host_usb_dev_node": "/dev/usbdev-p2371-2180", + 'fixture_id': 'micro_b', + 'tgt_usb_ctlr': '0', + 'host_usb_dev_node': '/dev/usbdev-p2371-2180', # This parameter is optional /if/ you only have a single board # attached to your host at a time. - "host_usb_port_path": "3-13", + 'host_usb_port_path': '3-13', }, ) -# Optional entries (required only when "alt_id_test_file" and -# "alt_id_dummy_file" are specified). -test_file_name = "/dfu_test.bin" -dummy_file_name = "/dfu_dummy.bin" -# Above files are used to generate proper "alt_info" entry -"alt_info": "/%s ext4 0 2;/%s ext4 0 2" % (test_file_name, dummy_file_name), +# Optional entries (required only when 'alt_id_test_file' and +# 'alt_id_dummy_file' are specified). +test_file_name = '/dfu_test.bin' +dummy_file_name = '/dfu_dummy.bin' +# Above files are used to generate proper 'alt_info' entry +'alt_info': '/%s ext4 0 2;/%s ext4 0 2' % (test_file_name, dummy_file_name), env__dfu_configs = ( # eMMC, partition 1 { - "fixture_id": "emmc", - "alt_info": "/dfu_test.bin ext4 0 1;/dfu_dummy.bin ext4 0 1", - "cmd_params": "mmc 0", + 'fixture_id': 'emmc', + 'alt_info': '/dfu_test.bin ext4 0 1;/dfu_dummy.bin ext4 0 1', + 'cmd_params': 'mmc 0', # This value is optional. # If present, it specified the set of transfer sizes tested. # If missing, a default list of sizes will be used, which covers @@ -49,7 +49,7 @@ env__dfu_configs = ( # Manually specifying test sizes is useful if you wish to test 4 DFU # configurations, but don't want to test every single transfer size # on each, to avoid bloating the overall time taken by testing. - "test_sizes": (63, 64, 65), + 'test_sizes': (63, 64, 65), # This value is optional. # The name of the environment variable that the the dfu command reads # alt info from. If unspecified, this defaults to dfu_alt_info, which is @@ -57,17 +57,17 @@ env__dfu_configs = ( # One example is the Odroid XU3, which automatically generates # $dfu_alt_info, each time the dfu command is run, by concatenating # $dfu_alt_boot and $dfu_alt_system. - "alt_info_env_name": "dfu_alt_system", + 'alt_info_env_name': 'dfu_alt_system', # This value is optional. - # For boards which require the "test file" alt setting number other than + # For boards which require the 'test file' alt setting number other than # default (0) it is possible to specify exact file name to be used as # this parameter. - "alt_id_test_file": test_file_name, + 'alt_id_test_file': test_file_name, # This value is optional. - # For boards which require the "dummy file" alt setting number other + # For boards which require the 'dummy file' alt setting number other # than default (1) it is possible to specify exact file name to be used # as this parameter. - "alt_id_dummy_file": dummy_file_name, + 'alt_id_dummy_file': dummy_file_name, }, ) diff --git a/test/py/tests/test_efi_loader.py b/test/py/tests/test_efi_loader.py index a66c6e6f947..d6b214f8452 100644 --- a/test/py/tests/test_efi_loader.py +++ b/test/py/tests/test_efi_loader.py @@ -35,17 +35,17 @@ env__net_dhcp_server = True # static IP. If solely relying on DHCP, this variable may be omitted or set to # an empty list. env__net_static_env_vars = [ - ("ipaddr", "10.0.0.100"), - ("netmask", "255.255.255.0"), - ("serverip", "10.0.0.1"), + ('ipaddr', '10.0.0.100'), + ('netmask', '255.255.255.0'), + ('serverip', '10.0.0.1'), ] # Details regarding a file that may be read from a TFTP server. This variable # may be omitted or set to None if TFTP testing is not possible or desired. env__efi_loader_helloworld_file = { - "fn": "lib/efi_loader/helloworld.efi", - "size": 5058624, - "crc32": "c2244b26", + 'fn': 'lib/efi_loader/helloworld.efi', + 'size': 5058624, + 'crc32': 'c2244b26', } """ diff --git a/test/py/tests/test_fpga.py b/test/py/tests/test_fpga.py index 7459ce58674..798f6eed3dc 100644 --- a/test/py/tests/test_fpga.py +++ b/test/py/tests/test_fpga.py @@ -24,40 +24,40 @@ env__net_dhcp_server = True # static IP. In this test case we atleast need serverip for performing tftpb # to get required files. env__net_static_env_vars = [ - ("ipaddr", "10.0.0.100"), - ("netmask", "255.255.255.0"), - ("serverip", "10.0.0.1"), + ('ipaddr', '10.0.0.100'), + ('netmask', '255.255.255.0'), + ('serverip', '10.0.0.1'), ] # Details regarding the files that may be read from a TFTP server. . env__fpga_secure_readable_file = { - "fn": "auth_bhdr_ppk1_bit.bin", - "enckupfn": "auth_bhdr_enc_kup_load_bit.bin", - "addr": 0x1000000, - "keyaddr": 0x100000, - "keyfn": "key.txt", + 'fn': 'auth_bhdr_ppk1_bit.bin', + 'enckupfn': 'auth_bhdr_enc_kup_load_bit.bin', + 'addr': 0x1000000, + 'keyaddr': 0x100000, + 'keyfn': 'key.txt', } env__fpga_under_test = { - "dev": 0, - "addr" : 0x1000000, - "bitstream_load": "compress.bin", - "bitstream_load_size": 1831960, - "bitstream_loadp": "compress_pr.bin", - "bitstream_loadp_size": 423352, - "bitstream_loadb": "compress.bit", - "bitstream_loadb_size": 1832086, - "bitstream_loadbp": "compress_pr.bit", - "bitstream_loadbp_size": 423491, - "mkimage_legacy": "download.ub", - "mkimage_legacy_size": 13321468, - "mkimage_legacy_gz": "download.gz.ub", - "mkimage_legacy_gz_size": 53632, - "mkimage_fit": "download-fit.ub", - "mkimage_fit_size": 13322784, - "loadfs": "mmc 0 compress.bin", - "loadfs_size": 1831960, - "loadfs_block_size": 0x10000, + 'dev': 0, + 'addr' : 0x1000000, + 'bitstream_load': 'compress.bin', + 'bitstream_load_size': 1831960, + 'bitstream_loadp': 'compress_pr.bin', + 'bitstream_loadp_size': 423352, + 'bitstream_loadb': 'compress.bit', + 'bitstream_loadb_size': 1832086, + 'bitstream_loadbp': 'compress_pr.bit', + 'bitstream_loadbp_size': 423491, + 'mkimage_legacy': 'download.ub', + 'mkimage_legacy_size': 13321468, + 'mkimage_legacy_gz': 'download.gz.ub', + 'mkimage_legacy_gz_size': 53632, + 'mkimage_fit': 'download-fit.ub', + 'mkimage_fit_size': 13322784, + 'loadfs': 'mmc 0 compress.bin', + 'loadfs_size': 1831960, + 'loadfs_block_size': 0x10000, } """ diff --git a/test/py/tests/test_fs/conftest.py b/test/py/tests/test_fs/conftest.py index 60b4a2d737b..43eeb4be0ba 100644 --- a/test/py/tests/test_fs/conftest.py +++ b/test/py/tests/test_fs/conftest.py @@ -54,7 +54,7 @@ def pytest_configure(config): supported_fs = config.getoption('fs_type') if supported_fs: - print("*** FS TYPE modified: %s" % supported_fs) + print('*** FS TYPE modified: %s' % supported_fs) supported_fs_basic = intersect(supported_fs, supported_fs_basic) supported_fs_ext = intersect(supported_fs, supported_fs_ext) supported_fs_mkdir = intersect(supported_fs, supported_fs_mkdir) @@ -174,7 +174,7 @@ def tool_is_in_path(tool): Return: True if available, False if not. """ - for path in os.environ["PATH"].split(os.pathsep): + for path in os.environ['PATH'].split(os.pathsep): fn = os.path.join(path, tool) if os.path.isfile(fn) and os.access(fn, os.X_OK): return True @@ -202,9 +202,9 @@ def mount_fs(fs_type, device, mount_point): check_call('guestmount -a %s -m /dev/sda %s' % (device, mount_point), shell=True) else: - mount_opt = "loop,rw" + mount_opt = 'loop,rw' if re.match('fat', fs_type): - mount_opt += ",umask=0000" + mount_opt += ',umask=0000' check_call('sudo mount -o %s %s %s' % (mount_opt, device, mount_point), shell=True) diff --git a/test/py/tests/test_mmc_rd.py b/test/py/tests/test_mmc_rd.py index c5858cb0892..a13bc0a5f60 100644 --- a/test/py/tests/test_mmc_rd.py +++ b/test/py/tests/test_mmc_rd.py @@ -14,45 +14,45 @@ which MMC devices should be tested. For example: env__mmc_rd_configs = ( { - "fixture_id": "emmc-boot0", - "is_emmc": True, - "devid": 0, - "partid": 1, - "sector": 0x10, - "count": 1, + 'fixture_id': 'emmc-boot0', + 'is_emmc': True, + 'devid': 0, + 'partid': 1, + 'sector': 0x10, + 'count': 1, }, { - "fixture_id": "emmc-boot1", - "is_emmc": True, - "devid": 0, - "partid": 2, - "sector": 0x10, - "count": 1, + 'fixture_id': 'emmc-boot1', + 'is_emmc': True, + 'devid': 0, + 'partid': 2, + 'sector': 0x10, + 'count': 1, }, { - "fixture_id": "emmc-data", - "is_emmc": True, - "devid": 0, - "partid": 0, - "sector": 0x10, - "count": 0x1000, + 'fixture_id': 'emmc-data', + 'is_emmc': True, + 'devid': 0, + 'partid': 0, + 'sector': 0x10, + 'count': 0x1000, }, { - "fixture_id": "sd-mbr", - "is_emmc": False, - "devid": 1, - "partid": None, - "sector": 0, - "count": 1, - "crc32": "8f6ecf0d", + 'fixture_id': 'sd-mbr', + 'is_emmc': False, + 'devid': 1, + 'partid': None, + 'sector': 0, + 'count': 1, + 'crc32': '8f6ecf0d', }, { - "fixture_id": "sd-large", - "is_emmc": False, - "devid": 1, - "partid": None, - "sector": 0x10, - "count": 0x1000, + 'fixture_id': 'sd-large', + 'is_emmc': False, + 'devid': 1, + 'partid': None, + 'sector': 0x10, + 'count': 0x1000, }, ) """ @@ -92,9 +92,9 @@ def test_mmc_rd(u_boot_console, env__mmc_rd_config): response = u_boot_console.run_command(cmd) assert 'no card present' not in response if is_emmc: - partid_response = "(part %d)" % partid + partid_response = '(part %d)' % partid else: - partid_response = "" + partid_response = '' good_response = 'mmc%d%s is current device' % (devid, partid_response) assert good_response in response diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py index 2821ce65da8..9c395e69faf 100644 --- a/test/py/tests/test_net.py +++ b/test/py/tests/test_net.py @@ -33,27 +33,27 @@ env__net_dhcp_server = True # static IP. If solely relying on DHCP, this variable may be omitted or set to # an empty list. env__net_static_env_vars = [ - ("ipaddr", "10.0.0.100"), - ("netmask", "255.255.255.0"), - ("serverip", "10.0.0.1"), + ('ipaddr', '10.0.0.100'), + ('netmask', '255.255.255.0'), + ('serverip', '10.0.0.1'), ] # Details regarding a file that may be read from a TFTP server. This variable # may be omitted or set to None if TFTP testing is not possible or desired. env__net_tftp_readable_file = { - "fn": "ubtest-readable.bin", - "addr": 0x10000000, - "size": 5058624, - "crc32": "c2244b26", + 'fn': 'ubtest-readable.bin', + 'addr': 0x10000000, + 'size': 5058624, + 'crc32': 'c2244b26', } # Details regarding a file that may be read from a NFS server. This variable # may be omitted or set to None if NFS testing is not possible or desired. env__net_nfs_readable_file = { - "fn": "ubtest-readable.bin", - "addr": 0x10000000, - "size": 5058624, - "crc32": "c2244b26", + 'fn': 'ubtest-readable.bin', + 'addr': 0x10000000, + 'size': 5058624, + 'crc32': 'c2244b26', } """ diff --git a/test/py/tests/test_ums.py b/test/py/tests/test_ums.py index e8eb43c76b7..749b1606235 100644 --- a/test/py/tests/test_ums.py +++ b/test/py/tests/test_ums.py @@ -23,35 +23,35 @@ For example: # Leave this list empty if you have no block_devs below with writable # partitions defined. env__mount_points = ( - "/mnt/ubtest-mnt-p2371-2180-na", + '/mnt/ubtest-mnt-p2371-2180-na', ) env__usb_dev_ports = ( { - "fixture_id": "micro_b", - "tgt_usb_ctlr": "0", - "host_ums_dev_node": "/dev/disk/by-path/pci-0000:00:14.0-usb-0:13:1.0-scsi-0:0:0:0", + 'fixture_id': 'micro_b', + 'tgt_usb_ctlr': '0', + 'host_ums_dev_node': '/dev/disk/by-path/pci-0000:00:14.0-usb-0:13:1.0-scsi-0:0:0:0', }, ) env__block_devs = ( # eMMC; always present { - "fixture_id": "emmc", - "type": "mmc", - "id": "0", + 'fixture_id': 'emmc', + 'type': 'mmc', + 'id': '0', # The following two properties are optional. # If present, the partition will be mounted and a file written-to and # read-from it. If missing, only a simple block read test will be # performed. - "writable_fs_partition": 1, - "writable_fs_subdir": "tmp/", + 'writable_fs_partition': 1, + 'writable_fs_subdir': 'tmp/', }, # SD card; present since I plugged one in { - "fixture_id": "sd", - "type": "mmc", - "id": "1" + 'fixture_id': 'sd', + 'type': 'mmc', + 'id': '1' }, ) |