From: Stephen Warren Date: Thu, 7 Jun 2018 17:21:19 -0600 Subject: [U-Boot] [PATCH v4 2/2] test/py: add test for whitelist of variables while importing environment In-Reply-To: References: <57820d3ba636810c2b6d03d0df4b2eeae35fbabd.1528105358.git-series.quentin.schulz@bootlin.com> Message-ID: <2c7e7a1a-401f-ae68-2dd5-1908ebf387f4@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 06/04/2018 03:47 AM, Quentin Schulz wrote: > This tests that the importing of an environment with a specified > whitelist works as intended. > > If there are variables passed as parameter to the env import command, > those only should be imported in the current environment. > > For each variable passed as parameter, if > - foo is bar in current env and bar2 in exported env, after importing > exported env, foo shall be bar2, > - foo does not exist in current env and foo is bar2 in exported env, > after importing exported env, foo shall be bar2, > - foo is bar in current env and does not exist in exported env (but is > passed as parameter), after importing exported env, foo shall be empty, > > Any variable not passed as parameter should be left untouched. > > Two other tests are made to test that size cannot be '-' if the checksum > protection is enabled. Reviewed-by: Stephen Warren > diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py > +def test_env_import_checksum_no_size(state_test_env): > + """Test that omitted ('-') size parameter with checksum validation fails the > + env import function. > + """ > + c = state_test_env.u_boot_console > + ram_base = u_boot_utils.find_ram_base(state_test_env.u_boot_console) > + addr = '%08x' % ram_base > + > + with c.disable_check('error_notification'): > + response = c.run_command('env import -c %s -' % addr) > + assert(response == '## Error: external checksum format must pass size') I could imagine all kinds of other useful tests here, e.g. completely missing the size parameter rather than passing it explicitly as - for example. But we can add that later if need be.