env: ext4: add test for env in ext4
cover env: ext4: add test for env in ext4
Hi,
[RESEND] with correct serie title (sorry)
In this serie, I add sandbox test with CONFIG_ENV_IS_NOWHERE activated with other location: at least one CONFIG_ENV_IS_IN_... is defined and ENV_IS_IN_DEVICE is automatically defined.
To test this feature, I activate and test ENV_IS_IN_EXT4 in sandbox; I add a new command "env_loc" to change this ENV location.
This serie depends on previous env test introduced in:
"cmd: env: add option for quiet output on env info"
http://patchwork.ozlabs.org/project/uboot/list/?series=158105
To be able to test invalid file (bad CRC), I also add the support of the command "env erase" for EXT4 env location.
Regards
Patrick
Patrick Delaunay (10):
env: add absolute path at CONFIG_ENV_EXT4_FILE
env: ext4: set gd->env_valid
env: correctly handle result in env_init
sandbox: activate env in ext4 support
sandbox: support the change of env location
test: environment in ext4
env: ext4: fix possible compilation issue
env: ext4: introduce new function env_ext4_save_buffer
env: ext4: add support of command env erase
test: sandbox: add test for erase command
board/sandbox/sandbox.c | 50 ++++++++++++++ configs/sandbox64_defconfig | 5 ++ configs/sandbox_defconfig | 5 ++ configs/sandbox_flattree_defconfig | 5 ++ configs/sandbox_spl_defconfig | 5 ++ env/Kconfig | 2 +- env/env.c | 5 +- env/ext4.c | 63 +++++++++++++++--- test/py/tests/test_env.py | 103 +++++++++++++++++++++++++++++ 9 files changed, 232 insertions(+), 11 deletions(-)
Signature · 1 line
2.17.1
PATCH RESEND 1/10 env: add absolute path at CONFIG_ENV_EXT4_FILE
Add the absolute path to the default value ofCONFIG_ENV_EXT4_FILE = "/uboot.env".
This patch avoid the error :
Saving Environment to EXT4... File System is consistent Please supply Absolute path
---
For information, it is the value used today by all the boards:
dragonboard820c_defconfig:29:CONFIG_ENV_EXT4_FILE="/uboot.env" hikey960_defconfig:25:CONFIG_ENV_EXT4_FILE="/uboot.env" stm32mp15_basic_defconfig:64:CONFIG_ENV_EXT4_FILE="/uboot.env" stm32mp15_optee_defconfig:51:CONFIG_ENV_EXT4_FILE="/uboot.env" stm32mp15_trusted_defconfig:50:CONFIG_ENV_EXT4_FILE="/uboot.env"
env/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
env/Kconfig +1 -1
@@ -467,7 +467,7 @@ config ENV_EXT4_DEVICE_AND_PART config ENV_EXT4_FILE string "Name of the EXT4 file to use for the environment" depends on ENV_IS_IN_EXT4 - default "uboot.env" + default "/uboot.env" help It's a string of the EXT4 file name. This file use to store the environment (explicit path to the file)
Signature · 1 line
2.17.1
PATCH RESEND 2/10 env: ext4: set gd->env_valid
In reply to Patrick DelaunayAdd a missing initialization of gd->env_valid in env_ext4_load as it is already done in some other env device.
Set gd->env_valid = ENV_VALID in env_ext4_save() and env_ext4_load().
This patch allows to have a correct information in 'env info' command.
---
env/ext4.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
env/ext4.c +8 -1
@@ -31,6 +31,8 @@#include <ext4fs.h> #include <mmc.h> +DECLARE_GLOBAL_DATA_PTR ; +__weak const char *env_ext4_get_intf (void ) {return (const char *)CONFIG_ENV_EXT4_INTERFACE ;
@@ -79,6 +81,7 @@ static int env_ext4_save(void) CONFIG_ENV_EXT4_FILE, ifname, dev, part);return 1 ; } + gd->env_valid =ENV_VALID ;puts ("done\n" );return 0 ;
@@ -125,7 +128,11 @@ static int env_ext4_load(void) goto err_env_relocate; } -return env_import (buf,1 ); + err =env_import (buf,1 ); +if (!err) + gd->env_valid =ENV_VALID ; + +return err; err_env_relocate:env_set_default (NULL ,0 );
Signature · 1 line
2.17.1
PATCH RESEND 3/10 env: correctly handle result in env_init
In reply to Patrick DelaunayDon't return error with ret=-ENOENT when the optional ops drv->init is absent but only if env_driver_lookup don't found driver.
This patch correct an issue for the code
if (!env_init())
env_load()
When only ext4 is supported (CONFIG_ENV_IS_IN_EXT4), as the backend env/ext4.c doesn't define an ops .init
---
env/env.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
env/env.c +4 -1
@@ -292,7 +292,10 @@ int env_init(void)int prio;for (prio =0 ; (drv =env_driver_lookup (ENVOP_INIT , prio)); prio++) { -if (!drv->init || !(ret = drv->init ())) + ret =0 ; +if (drv->init) + ret = drv->init (); +if (!ret)env_set_inited (drv->location); debug("%s: Environment %s init done (ret=%d)\n", __func__,
Signature · 1 line
2.17.1
PATCH RESEND 4/10 sandbox: activate env in ext4 support
In reply to Patrick DelaunayThe default environment is still used with "ENVL_NOWHERE" indicated by the weak function env_get_location() and activated by CONFIG_ENV_IS_NOWHERE.
---
board/sandbox/sandbox.c | 12 ++++++++++++ configs/sandbox64_defconfig | 4 ++++ configs/sandbox_defconfig | 4 ++++ configs/sandbox_flattree_defconfig | 4 ++++ configs/sandbox_spl_defconfig | 4 ++++ 5 files changed, 28 insertions(+)
board/sandbox/sandbox.c +12 -0
@@ -7,6 +7,7 @@#include <cpu_func.h> #include <cros_ec.h> #include <dm.h> +#include <env_internal.h> #include <init.h> #include <led.h> #include <os.h>
@@ -44,6 +45,17 @@ unsigned long timer_read_counter(void) }#endif +enum env_location env_get_location (enum env_operation op,int prio) +{ +/* only one location supported */ +if (prio !=0 ) +return ENVL_UNKNOWN ; + + gd->env_load_prio =0 ; + +return ENVL_NOWHERE ; +} +int dram_init (void ) { gd->ram_size =CONFIG_SYS_SDRAM_SIZE ;
configs/sandbox64_defconfig +4 -0
@@ -75,6 +75,10 @@ CONFIG_OF_CONTROL=y CONFIG_OF_LIVE=y CONFIG_OF_HOSTFILE=y CONFIG_DEFAULT_DEVICE_TREE="sandbox64" +CONFIG_ENV_IS_NOWHERE=y +CONFIG_ENV_IS_IN_EXT4=y +CONFIG_ENV_EXT4_INTERFACE="host" +CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0" CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y
configs/sandbox_defconfig +4 -0
@@ -84,6 +84,10 @@ CONFIG_OF_CONTROL=y CONFIG_OF_LIVE=y CONFIG_OF_HOSTFILE=y CONFIG_DEFAULT_DEVICE_TREE="sandbox" +CONFIG_ENV_IS_NOWHERE=y +CONFIG_ENV_IS_IN_EXT4=y +CONFIG_ENV_EXT4_INTERFACE="host" +CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0" CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y
configs/sandbox_flattree_defconfig +4 -0
@@ -59,6 +59,10 @@ CONFIG_AMIGA_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_OF_HOSTFILE=y CONFIG_DEFAULT_DEVICE_TREE="sandbox" +CONFIG_ENV_IS_NOWHERE=y +CONFIG_ENV_IS_IN_EXT4=y +CONFIG_ENV_EXT4_INTERFACE="host" +CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0" CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y
configs/sandbox_spl_defconfig +4 -0
@@ -76,6 +76,10 @@ CONFIG_SPL_OF_CONTROL=y CONFIG_OF_HOSTFILE=y CONFIG_DEFAULT_DEVICE_TREE="sandbox" CONFIG_SPL_OF_PLATDATA=y +CONFIG_ENV_IS_NOWHERE=y +CONFIG_ENV_IS_IN_EXT4=y +CONFIG_ENV_EXT4_INTERFACE="host" +CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0" CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y
Signature · 1 line
2.17.1
PATCH RESEND 4/10 sandbox: activate env in ext4 support
Quoted 6 lines · Patrick Delaunay
The default environment is still used with "
ENVL_NOWHERE" indicated by the weak functionenv_get_location()and activated byCONFIG_ENV_IS_NOWHERE.Signed-off-by Patrick Delaunay <[email protected]>
Quoted 8 lines
---
board/sandbox/sandbox.c | 12 ++++++++++++ configs/sandbox64_defconfig | 4 ++++ configs/sandbox_defconfig | 4 ++++ configs/sandbox_flattree_defconfig | 4 ++++ configs/sandbox_spl_defconfig | 4 ++++ 5 files changed, 28 insertions(+)
At some point I'd really like the environment device/info to be in the device tree.
PATCH RESEND 5/10 sandbox: support the change of env location
In reply to Patrick DelaunayAdd support of environment location with a new sandbox command 'env_loc'.
When the user change the environment location with the command 'env_loc <location>' the env is reinitialized and saved; the GD_FLG_ENV_DEFAULT flag is also updated.
When the user set the same env location, the environment is re-loaded.
---
board/sandbox/sandbox.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-)
board/sandbox/sandbox.c +39 -1
@@ -21,6 +21,9 @@*/ gd_t *gd; +/* env location: current location used during test */ +static enum env_location sandbox_env_location =ENVL_NOWHERE ; +/* Add a simple GPIO device */ U_BOOT_DEVICE (gpio_sandbox) = { .name ="gpio_sandbox" ,
@@ -53,9 +56,44 @@ enum env_location env_get_location(enum env_operation op, int prio) gd->env_load_prio =0 ; -return ENVL_NOWHERE ; +return sandbox_env_location; } +static int do_env_loc (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +enum env_location loc; + +if (argc <2 ) +return CMD_RET_USAGE ; + + loc = (enum env_location )simple_strtoul (argv[1 ],NULL ,10 ); +if (loc >=ENVL_COUNT ) +return CMD_RET_FAILURE ; + +if (sandbox_env_location != loc) { + sandbox_env_location = loc; +if (loc ==ENVL_NOWHERE ) { + gd->flags |=GD_FLG_ENV_DEFAULT ; + gd->env_valid =ENV_VALID ; + }else { +if (gd->flags &GD_FLG_ENV_DEFAULT ) { + gd->flags &= ~GD_FLG_ENV_DEFAULT ; +if (!env_init ()) +env_save (); + } + } + }else { +if (!env_init ()) +env_load (); + } + +return CMD_RET_SUCCESS ; +} + +U_BOOT_CMD (env_loc,2 ,1 , do_env_loc, +"set the environment location" ,"[loc]" +); +int dram_init (void ) { gd->ram_size =CONFIG_SYS_SDRAM_SIZE ;
Signature · 1 line
2.17.1
PATCH RESEND 5/10 sandbox: support the change of env location
Hi Patrick,
Quoted 32 lines · Patrick Delaunay
Add support of environment location with a new sandbox command '
env_loc'.When the user change the environment location with the command '
env_loc<location>' the env is reinitialized and saved; theGD_FLG_ENV_DEFAULTflag is also updated.When the user set the same env location, the environment is re-loaded.
Signed-off-by Patrick Delaunay <[email protected]>---
board/sandbox/sandbox.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-)board/sandbox/sandbox.c +3
-0@@ -21,6 +21,9 @@*/ gd_t *gd; +/* env location: current location used during test */ +static enum env_location sandbox_env_location =ENVL_NOWHERE ; +/* Add a simple GPIO device */ U_BOOT_DEVICE (gpio_sandbox) = { .name ="gpio_sandbox" ,
board/sandbox/sandbox.c enum env_location env_get_location(enum env_operation op, int prio) · line 62
Quoted 8 lines
board/sandbox/sandbox.c +2
-1@@ -53,9 +56,44 @@ enum env_location env_get_location(enum env_operation op, int prio) gd->env_load_prio =0 ; -return ENVL_NOWHERE ; +return sandbox_env_location; } +static int do_env_loc (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[])
This should be a sub-command of 'env' I think.
Regards,
Simon
PATCH RESEND 6/10 test: environment in ext4
In reply to Patrick DelaunayAdd basic test to persistent environment in ext4:
save and load in host ext4 file 'uboot.env'.
On first execution a empty EXT4 file system is created in persistent data dir: env.ext4.img.
---
test/py/tests/test_env.py | 87 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+)
test/py/tests/test_env.py +87 -0
@@ -4,6 +4,10 @@ # Test operation of shell commands relating to environment variables. +import os +import os.path +from subprocess import call, check_call + import pytest import u_boot_utils
@@ -380,3 +384,86 @@ def test_env_info_quiet(state_test_env): assert response == "" response = c.run_command('echo $?') assert response == "1" + +def mk_env_ext4(state_test_env): + c = state_test_env.u_boot_console + + """Create a empty ext4 file system volume. + """ + filename = 'env.ext4.img' + persistent = c.config.persistent_data_dir + '/' + filename + fs_img = c.config.result_dir + '/' + filename + + if os.path.exists(persistent): + c.log.action('Disk image file ' + persistent + ' already exists') + else: + try: + check_call('rm -f %s' % persistent, shell=True) + check_call('dd if=/dev/zero of=%s bs=1M count=16' + % persistent, shell=True) + check_call('mkfs.ext4 -O ^metadata_csum %s' % persistent, shell=True) + except CalledProcessError: + call('rm -f %s' % persistent, shell=True) + raise + + call('cp -f %s %s' % (persistent, fs_img), shell=True) + return fs_img + + at pytest.mark.boardspec('sandbox') + at pytest.mark.buildconfigspec('cmd_nvedit_info') + at pytest.mark.buildconfigspec('cmd_echo') + at pytest.mark.buildconfigspec('env_is_in_ext4') +def test_env_ext4(state_test_env): + + c = state_test_env.u_boot_console + + fs_img = mk_env_ext4(state_test_env) + c.run_command('host bind 0 %s' % fs_img) + + response = c.run_command('ext4ls host 0:0') + assert 'uboot.env' not in response + + """ env_location: ENVL_EXT4 (2) + """ + response = c.run_command('env_loc 2') + assert 'Saving Environment to EXT4' in response + + response = c.run_command('env_loc 2') + assert 'Loading Environment from EXT4... OK' in response + + response = c.run_command('ext4ls host 0:0') + assert '8192 uboot.env' in response + + response = c.run_command('env info') + assert 'env_valid = valid' in response + assert 'env_ready = true' in response + assert 'env_use_default = false' in response + + response = c.run_command('env info -p -d') + assert 'Environment was loaded from persistent storage' in response + assert 'Environment can be persisted' in response + + response = c.run_command('env info -d -q') + assert response == "" + response = c.run_command('echo $?') + assert response == "1" + + response = c.run_command('env info -p -q') + assert response == "" + response = c.run_command('echo $?') + assert response == "0" + + """ restore env_location: ENVL_NOWHERE (12) + """ + c.run_command('env_loc 12') + + response = c.run_command('env info') + assert 'env_valid = valid' in response + assert 'env_ready = true' in response + assert 'env_use_default = true' in response + + response = c.run_command('env info -p -d') + assert 'Default environment is used' in response + assert 'Environment cannot be persisted' in response + + call('rm -f %s' % fs_img, shell=True)
Signature · 1 line
2.17.1
PATCH RESEND 6/10 test: environment in ext4
Quoted 7 lines · Patrick Delaunay
Add basic test to persistent environment in ext4:
save and load in host ext4 file 'uboot.env'.On first execution a empty EXT4 file system is created in persistent data dir: env.ext4.img.
test/py/tests/test_env.py def test_env_info_quiet(state_test_env): · line 394
Quoted 8 lines
test/py/tests/test_env.py +7
-0+def mk_env_ext4(state_test_env): + c = state_test_env.u_boot_console + + """Create a empty ext4 file system volume. + """ + filename = 'env.ext4.img' + persistent = c.config.persistent_data_dir + '/' + filename
The test seems to want to delete this file at the end, and re-create it each time. Why store it in the persistent data directory in that case?
test/py/tests/test_env.py def test_env_info_quiet(state_test_env): · line 398
Quoted 2 lines
test/py/tests/test_env.py +2
-0+ if os.path.exists(persistent): + c.log.action('Disk image file ' + persistent + ' already exists')
... and why just delete it and re-create it if a stale copy exists?
test/py/tests/test_env.py def test_env_info_quiet(state_test_env): · line 401
Quoted 3 lines
test/py/tests/test_env.py +3
-0+ else: + try: + check_call('rm -f %s' % persistent, shell=True)
why not:
check_call('rm -f ' + persistent)
That has simpler string operations, and I don't think any of these commands need shell=True, since they don't contain any shell metacharacters? Same comment for most of the other commands.
test/py/tests/test_env.py def test_env_info_quiet(state_test_env): · line 427
Quoted 4 lines
test/py/tests/test_env.py +3
-0+def test_env_ext4(state_test_env): + """ env_location: ENVL_EXT4 (2) + """
I think that'd be better as a regular comment:
# env_location: ENVL_EXT4 (2)
If there's a reason to make it a docstring, lets put the trailing """ on the same line since it's a short piece of text.
test/py/tests/test_env.py def test_env_info_quiet(state_test_env): · line 432
Quoted 5 lines
test/py/tests/test_env.py +5
-0+ response = c.run_command('env_loc 2') + assert 'Saving Environment to EXT4' in response + + response = c.run_command('env_loc 2') + assert 'Loading Environment from EXT4... OK' in response
Can't both assert invocations run on the same response? Or, does the env_loc command do different things based on some other state; that would feel pretty nasty.
PATCH RESEND 7/10 env: ext4: fix possible compilation issue
In reply to Patrick DelaunayFix possible compilation issue in env ext4 support when CONFIG_CMD_SAVEENV is not activated.
---
env/ext4.c | 2 ++ 1 file changed, 2 insertions(+)
env/ext4.c +2 -0
@@ -144,5 +144,7 @@ U_BOOT_ENV_LOCATION(ext4) = { .location = ENVL_EXT4, ENV_NAME("EXT4") .load = env_ext4_load, +#ifdef CONFIG_CMD_SAVEENV .save = env_save_ptr(env_ext4_save), +#endif };
Signature · 1 line
2.17.1
PATCH RESEND 8/10 env: ext4: introduce new function env_ext4_save_buffer
In reply to Patrick DelaunaySplit the function env_ext4_save to prepare the erase support
---
env/ext4.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-)
env/ext4.c +23 -9
@@ -43,10 +43,9 @@ __weak const char *env_ext4_get_dev_part(void)return (const char *)CONFIG_ENV_EXT4_DEVICE_AND_PART ; } -#ifdef CONFIG_CMD_SAVEENV -static int env_ext4_save (void ) +#if defined(CONFIG_CMD_SAVEENV ) +static int env_ext4_save_buffer (env_t *env_new) { -env_t env_new;struct blk_desc *dev_desc =NULL ;disk_partition_t info;int dev, part;
@@ -54,10 +53,6 @@ static int env_ext4_save(void)const char *ifname =env_ext4_get_intf ();const char *dev_and_part =env_ext4_get_dev_part (); - err =env_export (&env_new); -if (err) -return err; - part =blk_get_device_part_str (ifname, dev_and_part, &dev_desc, &info,1 );if (part <0 )
@@ -72,7 +67,7 @@ static int env_ext4_save(void)return 1 ; } - err =ext4fs_write (CONFIG_ENV_EXT4_FILE , (void *)&env_new, + err =ext4fs_write (CONFIG_ENV_EXT4_FILE , (void *)env_new,sizeof (env_t),FILETYPE_REG );ext4fs_close ();
@@ -81,9 +76,28 @@ static int env_ext4_save(void) CONFIG_ENV_EXT4_FILE, ifname, dev, part); return 1; } - gd->env_valid =ENV_VALID ; +return 0 ; +} +#endif + +#ifdef CONFIG_CMD_SAVEENV +static int env_ext4_save (void ) +{ +env_t env_new; +int err; + + err =env_export (&env_new); +if (err) +return err; + + err =env_ext4_save_buffer (&env_new); +if (err) +return err; + + gd->env_valid =ENV_VALID ;puts ("done\n" ); +return 0 ; }#endif /* CONFIG_CMD_SAVEENV */
Signature · 1 line
2.17.1
PATCH RESEND 9/10 env: ext4: add support of command env erase
In reply to Patrick DelaunayAdd support of opts erase for env in ext4,
this opts is used by command 'env erase'.
This command only fill the env file (CONFIG_ENV_EXT4_FILE) with 0, the CRC and the saved environment becomes invalid.
---
env/ext4.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
env/ext4.c +23 -1
@@ -43,7 +43,7 @@ __weak const char *env_ext4_get_dev_part(void)return (const char *)CONFIG_ENV_EXT4_DEVICE_AND_PART ; } -#if defined(CONFIG_CMD_SAVEENV ) +#if defined(CONFIG_CMD_SAVEENV ) || defined(CONFIG_CMD_ERASEENV )static int env_ext4_save_buffer (env_t *env_new) {struct blk_desc *dev_desc =NULL ;
@@ -102,6 +102,25 @@ static int env_ext4_save(void) }#endif /* CONFIG_CMD_SAVEENV */ +#if defined(CONFIG_CMD_ERASEENV ) +static int env_ext4_erase (void ) +{ +env_t env_new; +int err; + +memset (&env_new,0 ,sizeof (env_t)); + + err =env_ext4_save_buffer (&env_new); +if (err) +return err; + + gd->env_valid =ENV_INVALID ; +puts ("done\n" ); + +return 0 ; +} +#endif +static int env_ext4_load (void ) {ALLOC_CACHE_ALIGN_BUFFER (char, buf,CONFIG_ENV_SIZE );
@@ -161,4 +180,7 @@ U_BOOT_ENV_LOCATION(ext4) = {#ifdef CONFIG_CMD_SAVEENV .save = env_save_ptr(env_ext4_save),#endif +#if defined(CONFIG_CMD_ERASEENV ) + .erase = env_ext4_erase, +#endif };
Signature · 1 line
2.17.1
PATCH RESEND 10/10 test: sandbox: add test for erase command
In reply to Patrick DelaunayAdd test for the erase command tested on ENV in EXT4.
---
configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + configs/sandbox_spl_defconfig | 1 + test/py/tests/test_env.py | 20 ++++++++++++++++++-- 5 files changed, 22 insertions(+), 2 deletions(-)
configs/sandbox64_defconfig +1 -0
@@ -25,6 +25,7 @@ CONFIG_CMD_BOOTZ=y # CONFIG_CMD_ELF is not set CONFIG_CMD_ASKENV=y CONFIG_CMD_GREPENV=y +CONFIG_CMD_ERASEENV=y CONFIG_CMD_ENV_CALLBACK=y CONFIG_CMD_ENV_FLAGS=y CONFIG_CMD_NVEDIT_INFO=y
configs/sandbox_defconfig +1 -0
@@ -29,6 +29,7 @@ CONFIG_CMD_ABOOTIMG=y # CONFIG_CMD_ELF is not set CONFIG_CMD_ASKENV=y CONFIG_CMD_GREPENV=y +CONFIG_CMD_ERASEENV=y CONFIG_CMD_ENV_CALLBACK=y CONFIG_CMD_ENV_FLAGS=y CONFIG_CMD_NVEDIT_INFO=y
configs/sandbox_flattree_defconfig +1 -0
@@ -22,6 +22,7 @@ CONFIG_CMD_BOOTZ=y # CONFIG_CMD_ELF is not set CONFIG_CMD_ASKENV=y CONFIG_CMD_GREPENV=y +CONFIG_CMD_ERASEENV=y CONFIG_CMD_NVEDIT_INFO=y CONFIG_LOOPW=y CONFIG_CMD_MD5SUM=y
configs/sandbox_spl_defconfig +1 -0
@@ -31,6 +31,7 @@ CONFIG_CMD_BOOTZ=y # CONFIG_CMD_ELF is not set CONFIG_CMD_ASKENV=y CONFIG_CMD_GREPENV=y +CONFIG_CMD_ERASEENV=y CONFIG_CMD_ENV_CALLBACK=y CONFIG_CMD_ENV_FLAGS=y CONFIG_CMD_NVEDIT_INFO=y
test/py/tests/test_env.py +18 -2
@@ -423,7 +423,7 @@ def test_env_ext4(state_test_env): response = c.run_command('ext4ls host 0:0') assert 'uboot.env' not in response - """ env_location: ENVL_EXT4 (2) + """ env location: ENVL_EXT4 (2) """ response = c.run_command('env_loc 2') assert 'Saving Environment to EXT4' in response
@@ -453,7 +453,23 @@ def test_env_ext4(state_test_env): response = c.run_command('echo $?') assert response == "0" - """ restore env_location: ENVL_NOWHERE (12) + response = c.run_command('env erase') + assert 'OK' in response + + response = c.run_command('env_loc 2') + assert 'Loading Environment from EXT4... ' in response + assert 'bad CRC, using default environment' in response + + response = c.run_command('env info') + assert 'env_valid = invalid' in response + assert 'env_ready = true' in response + assert 'env_use_default = true' in response + + response = c.run_command('env info -p -d') + assert 'Default environment is used' in response + assert 'Environment can be persisted' in response + + """ restore env location: ENVL_NOWHERE (12) """ c.run_command('env_loc 12')
Signature · 1 line
2.17.1
PATCH RESEND 10/10 test: sandbox: add test for erase command
Hi Patrick,
Quoted 4 lines · Patrick Delaunay
Add test for the erase command tested on ENV in EXT4.
Signed-off-by Patrick Delaunay <[email protected]>
Quoted 8 lines
---
configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + configs/sandbox_spl_defconfig | 1 + test/py/tests/test_env.py | 20 ++++++++++++++++++-- 5 files changed, 22 insertions(+), 2 deletions(-)
Can you write this test in C?
See ut_check_console_line() in mainline which should help if you need to check console output.
Regards,
Simon
PATCH RESEND 10/10 test: sandbox: add test for erase command
In reply to Patrick Delaunaytest/py/tests/test_env.py def test_env_ext4(state_test_env): · line 472
Quoted 7 lines · Patrick Delaunay
Add test for the erase command tested on ENV in EXT4.
test/py/tests/test_env.py +2
-2- """ env_location: ENVL_EXT4 (2) + """ env location: ENVL_EXT4 (2) - """ restore env_location: ENVL_NOWHERE (12) + """ restore env location: ENVL_NOWHERE (12)
Was there a whitespace mistake in the earlier path or something? I can't see a diff here...