diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/cache.c | 20 | ||||
-rw-r--r-- | test/dm/clk.c | 21 | ||||
-rw-r--r-- | test/dm/reset.c | 23 | ||||
-rw-r--r-- | test/dm/video.c | 8 | ||||
-rw-r--r-- | test/print_ut.c | 39 | ||||
-rw-r--r-- | test/py/tests/test_mmc_rd.py | 85 |
6 files changed, 163 insertions, 33 deletions
diff --git a/test/dm/cache.c b/test/dm/cache.c new file mode 100644 index 00000000000..d4144aab76f --- /dev/null +++ b/test/dm/cache.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 Intel Corporation <www.intel.com> + */ + +#include <common.h> +#include <dm.h> +#include <dm/test.h> + +static int dm_test_reset(struct unit_test_state *uts) +{ + struct udevice *dev_cache; + struct cache_info; + + ut_assertok(uclass_get_device(UCLASS_CACHE, 0, &dev_cache)); + ut_assertok(cache_get_info(dev, &info)); + + return 0; +} +DM_TEST(dm_test_reset, DM_TESTF_SCAN_FDT); diff --git a/test/dm/clk.c b/test/dm/clk.c index 112d5cbbc91..f301ecbb459 100644 --- a/test/dm/clk.c +++ b/test/dm/clk.c @@ -4,12 +4,33 @@ */ #include <common.h> +#include <clk.h> #include <dm.h> #include <asm/clk.h> #include <dm/test.h> #include <linux/err.h> #include <test/ut.h> +/* Base test of the clk uclass */ +static int dm_test_clk_base(struct unit_test_state *uts) +{ + struct udevice *dev; + struct clk clk_method1; + struct clk clk_method2; + + /* Get the device using the clk device */ + ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test", &dev)); + + /* Get the same clk port in 2 different ways and compare */ + ut_assertok(clk_get_by_index(dev, 1, &clk_method1)); + ut_assertok(clk_get_by_index_nodev(dev_ofnode(dev), 1, &clk_method2)); + ut_asserteq(clk_method1.id, clk_method2.id); + + return 0; +} + +DM_TEST(dm_test_clk_base, DM_TESTF_SCAN_FDT); + static int dm_test_clk(struct unit_test_state *uts) { struct udevice *dev_fixed, *dev_fixed_factor, *dev_clk, *dev_test; diff --git a/test/dm/reset.c b/test/dm/reset.c index c02866a2f0a..c61daed4903 100644 --- a/test/dm/reset.c +++ b/test/dm/reset.c @@ -5,6 +5,7 @@ #include <common.h> #include <dm.h> +#include <reset.h> #include <dm/test.h> #include <asm/reset.h> #include <test/ut.h> @@ -15,6 +16,28 @@ /* This is the other reset phandle specifier handled by bulk */ #define OTHER_RESET_ID 2 +/* Base test of the reset uclass */ +static int dm_test_reset_base(struct unit_test_state *uts) +{ + struct udevice *dev; + struct reset_ctl reset_method1; + struct reset_ctl reset_method2; + + /* Get the device using the reset device */ + ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "reset-ctl-test", + &dev)); + + /* Get the same reset port in 2 different ways and compare */ + ut_assertok(reset_get_by_index(dev, 1, &reset_method1)); + ut_assertok(reset_get_by_index_nodev(dev_ofnode(dev), 1, + &reset_method2)); + ut_asserteq(reset_method1.id, reset_method2.id); + + return 0; +} + +DM_TEST(dm_test_reset_base, DM_TESTF_SCAN_FDT); + static int dm_test_reset(struct unit_test_state *uts) { struct udevice *dev_reset; diff --git a/test/dm/video.c b/test/dm/video.c index 6be5defc53c..3151ebb73fc 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -97,14 +97,6 @@ static int select_vidconsole(struct unit_test_state *uts, const char *drv_name) return 0; } -static void vidconsole_put_string(struct udevice *dev, const char *str) -{ - const char *s; - - for (s = str; *s; s++) - vidconsole_put_char(dev, *s); -} - /* Test text output works on the video console */ static int dm_test_video_text(struct unit_test_state *uts) { diff --git a/test/print_ut.c b/test/print_ut.c index f0f1d6010a1..a3b9974ad26 100644 --- a/test/print_ut.c +++ b/test/print_ut.c @@ -15,6 +15,26 @@ #define FAKE_BUILD_TAG "jenkins-u-boot-denx_uboot_dm-master-build-aarch64" \ "and a lot more text to come" +/* Test printing GUIDs */ +static void guid_ut_print(void) +{ +#if CONFIG_IS_ENABLED(LIB_UUID) + unsigned char guid[16] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 + }; + char str[40]; + + sprintf(str, "%pUb", guid); + assert(!strcmp("01020304-0506-0708-090a-0b0c0d0e0f10", str)); + sprintf(str, "%pUB", guid); + assert(!strcmp("01020304-0506-0708-090A-0B0C0D0E0F10", str)); + sprintf(str, "%pUl", guid); + assert(!strcmp("04030201-0605-0807-090a-0b0c0d0e0f10", str)); + sprintf(str, "%pUL", guid); + assert(!strcmp("04030201-0605-0807-090A-0B0C0D0E0F10", str)); +#endif +} + /* Test efi_loader specific printing */ static void efi_ut_print(void) { @@ -79,14 +99,18 @@ static int do_ut_print(cmd_tbl_t *cmdtp, int flag, int argc, assert(s == str); assert(!strcmp("\n\nU-Boo\n\n", s)); - s = display_options_get_banner(true, str, 1); - assert(s == str); - assert(!strcmp("", s)); + /* Assert that we do not overwrite memory before the buffer */ + str[0] = '`'; + s = display_options_get_banner(true, str + 1, 1); + assert(s == str + 1); + assert(!strcmp("`", str)); - s = display_options_get_banner(true, str, 2); - assert(s == str); - assert(!strcmp("\n", s)); + str[0] = '~'; + s = display_options_get_banner(true, str + 1, 2); + assert(s == str + 1); + assert(!strcmp("~\n", str)); + /* The last two characters are set to \n\n for all buffer sizes > 2 */ s = display_options_get_banner(false, str, sizeof(str)); assert(s == str); assert(!strcmp("U-Boot \n\n", s)); @@ -113,6 +137,9 @@ static int do_ut_print(cmd_tbl_t *cmdtp, int flag, int argc, /* Test efi_loader specific printing */ efi_ut_print(); + /* Test printing GUIDs */ + guid_ut_print(); + printf("%s: Everything went swimmingly\n", __func__); return 0; } diff --git a/test/py/tests/test_mmc_rd.py b/test/py/tests/test_mmc_rd.py index 2dc715bb510..a25aa5f6f78 100644 --- a/test/py/tests/test_mmc_rd.py +++ b/test/py/tests/test_mmc_rd.py @@ -13,6 +13,53 @@ import u_boot_utils This test relies on boardenv_* to containing configuration values to define which MMC devices should be tested. For example: +# Configuration data for test_mmc_dev, test_mmc_rescan, test_mmc_info; defines +# whole MMC devices that mmc dev/rescan/info commands may operate upon. +env__mmc_dev_configs = ( + { + 'fixture_id': 'emmc-boot0', + 'is_emmc': True, + 'devid': 0, + 'partid': 1, + 'info_device': ???, + 'info_speed': ???, + 'info_mode': ???, + 'info_buswidth': ???. + }, + { + 'fixture_id': 'emmc-boot1', + 'is_emmc': True, + 'devid': 0, + 'partid': 2, + 'info_device': ???, + 'info_speed': ???, + 'info_mode': ???, + 'info_buswidth': ???. + }, + { + 'fixture_id': 'emmc-data', + 'is_emmc': True, + 'devid': 0, + 'partid': 0, + 'info_device': ???, + 'info_speed': ???, + 'info_mode': ???, + 'info_buswidth': ???. + }, + { + 'fixture_id': 'sd', + 'is_emmc': False, + 'devid': 1, + 'partid': None, + 'info_device': ???, + 'info_speed': ???, + 'info_mode': ???, + 'info_buswidth': ???. + }, +} + +# Configuration data for test_mmc_rd; defines regions of the MMC (entire +# devices, or ranges of sectors) which can be read: env__mmc_rd_configs = ( { 'fixture_id': 'emmc-boot0', @@ -85,12 +132,12 @@ def mmc_dev(u_boot_console, is_emmc, devid, partid): assert good_response in response @pytest.mark.buildconfigspec('cmd_mmc') -def test_mmc_dev(u_boot_console, env__mmc_rd_config): +def test_mmc_dev(u_boot_console, env__mmc_dev_config): """Test the "mmc dev" command. Args: u_boot_console: A U-Boot console connection. - env__mmc_rd_config: The single MMC configuration on which + env__mmc_dev_config: The single MMC configuration on which to run the test. See the file-level comment above for details of the format. @@ -98,20 +145,20 @@ def test_mmc_dev(u_boot_console, env__mmc_rd_config): Nothing. """ - is_emmc = env__mmc_rd_config['is_emmc'] - devid = env__mmc_rd_config['devid'] - partid = env__mmc_rd_config.get('partid', 0) + is_emmc = env__mmc_dev_config['is_emmc'] + devid = env__mmc_dev_config['devid'] + partid = env__mmc_dev_config.get('partid', 0) # Select MMC device mmc_dev(u_boot_console, is_emmc, devid, partid) @pytest.mark.buildconfigspec('cmd_mmc') -def test_mmc_rescan(u_boot_console, env__mmc_rd_config): +def test_mmc_rescan(u_boot_console, env__mmc_dev_config): """Test the "mmc rescan" command. Args: u_boot_console: A U-Boot console connection. - env__mmc_rd_config: The single MMC configuration on which + env__mmc_dev_config: The single MMC configuration on which to run the test. See the file-level comment above for details of the format. @@ -119,9 +166,9 @@ def test_mmc_rescan(u_boot_console, env__mmc_rd_config): Nothing. """ - is_emmc = env__mmc_rd_config['is_emmc'] - devid = env__mmc_rd_config['devid'] - partid = env__mmc_rd_config.get('partid', 0) + is_emmc = env__mmc_dev_config['is_emmc'] + devid = env__mmc_dev_config['devid'] + partid = env__mmc_dev_config.get('partid', 0) # Select MMC device mmc_dev(u_boot_console, is_emmc, devid, partid) @@ -132,12 +179,12 @@ def test_mmc_rescan(u_boot_console, env__mmc_rd_config): assert 'no card present' not in response @pytest.mark.buildconfigspec('cmd_mmc') -def test_mmc_info(u_boot_console, env__mmc_rd_config): +def test_mmc_info(u_boot_console, env__mmc_dev_config): """Test the "mmc info" command. Args: u_boot_console: A U-Boot console connection. - env__mmc_rd_config: The single MMC configuration on which + env__mmc_dev_config: The single MMC configuration on which to run the test. See the file-level comment above for details of the format. @@ -145,13 +192,13 @@ def test_mmc_info(u_boot_console, env__mmc_rd_config): Nothing. """ - is_emmc = env__mmc_rd_config['is_emmc'] - devid = env__mmc_rd_config['devid'] - partid = env__mmc_rd_config.get('partid', 0) - info_device = env__mmc_rd_config['info_device'] - info_speed = env__mmc_rd_config['info_speed'] - info_mode = env__mmc_rd_config['info_mode'] - info_buswidth = env__mmc_rd_config['info_buswidth'] + is_emmc = env__mmc_dev_config['is_emmc'] + devid = env__mmc_dev_config['devid'] + partid = env__mmc_dev_config.get('partid', 0) + info_device = env__mmc_dev_config['info_device'] + info_speed = env__mmc_dev_config['info_speed'] + info_mode = env__mmc_dev_config['info_mode'] + info_buswidth = env__mmc_dev_config['info_buswidth'] # Select MMC device mmc_dev(u_boot_console, is_emmc, devid, partid) |