Message ID | 20170910065451.31902-2-alison@peloton-tech.com |
---|---|
State | Accepted |
Commit | c5772188ede914b0e67c2a58ae179039a582afe0 |
Delegated to: | Tom Rini |
Headers | show |
Series | [U-Boot,1/1] add pytests for 'gpt rename' and 'gpt swap' | expand |
On 10 September 2017 at 00:54, <alison@peloton-tech.com> wrote: > From: Alison Chaiken <alison@peloton-tech.com> > > Add unit tests for the 'gpt rename' and 'gpt swap' commands that > rely on the block device created by test/py/make_test_disk.py. > Add CONFIG_CMD_GPT_RENAME to the sandbox_defconfig. Remove the > testdisk.raw test device at the end of the tests. > > Signed-off-by: Alison Chaiken <alison@peloton-tech.com> > --- > configs/sandbox_defconfig | 1 + > test/py/tests/test_gpt.py | 31 +++++++++++++++++++++++++++++++ > 2 files changed, 32 insertions(+) Reviewed-by: Simon Glass <sjg@chromium.org>
On Sat, Sep 09, 2017 at 11:54:51PM -0700, alison@peloton-tech.com wrote: > From: Alison Chaiken <alison@peloton-tech.com> > > Add unit tests for the 'gpt rename' and 'gpt swap' commands that > rely on the block device created by test/py/make_test_disk.py. > Add CONFIG_CMD_GPT_RENAME to the sandbox_defconfig. Remove the > testdisk.raw test device at the end of the tests. > > Signed-off-by: Alison Chaiken <alison@peloton-tech.com> > Reviewed-by: Simon Glass <sjg@chromium.org> Applied to u-boot/master, thanks!
On 09/15/2017 06:29 AM, Tom Rini wrote: > On Sat, Sep 09, 2017 at 11:54:51PM -0700, alison@peloton-tech.com wrote: >> From: Alison Chaiken <alison@peloton-tech.com> >> >> Add unit tests for the 'gpt rename' and 'gpt swap' commands that >> rely on the block device created by test/py/make_test_disk.py. >> Add CONFIG_CMD_GPT_RENAME to the sandbox_defconfig. Remove the >> testdisk.raw test device at the end of the tests. >> >> Signed-off-by: Alison Chaiken <alison@peloton-tech.com> >> Reviewed-by: Simon Glass <sjg@chromium.org> > > Applied to u-boot/master, thanks! As of commit cd3e8a72a6fb "test/py: u_boot_console_base.py: fix typo", in u-boot/master, test/py is failing test_gpt_*, with the log below. I assume that's due to this commit, since it relates to GPT, but I haven't bisected. => host bind 0 testdisk.raw Failed to access host backing file 'testdisk.raw' exit not allowed from main input shell. => gpt guid host 0 do_gpt: host dev 0 NOT available => FAILED: u_boot_console = <u_boot_console_sandbox.ConsoleSandbox object at 0x7f60875a7e10> @pytest.mark.buildconfigspec('cmd_gpt') def test_gpt_guid(u_boot_console): """Test the gpt guid command.""" if u_boot_console.config.buildconfig.get('config_cmd_gpt', 'n') != 'y': pytest.skip('gpt command not supported') make_test_disk.makeDisk() u_boot_console.run_command('host bind 0 testdisk.raw') output = u_boot_console.run_command('gpt guid host 0') > assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output E assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in 'do_gpt: host dev 0 NOT available' src/u-boot/test/py/tests/test_gpt.py:26: AssertionError
On Fri, Sep 15, 2017 at 09:40:29AM -0600, Stephen Warren wrote: > On 09/15/2017 06:29 AM, Tom Rini wrote: > >On Sat, Sep 09, 2017 at 11:54:51PM -0700, alison@peloton-tech.com wrote: > >>From: Alison Chaiken <alison@peloton-tech.com> > >> > >>Add unit tests for the 'gpt rename' and 'gpt swap' commands that > >>rely on the block device created by test/py/make_test_disk.py. > >>Add CONFIG_CMD_GPT_RENAME to the sandbox_defconfig. Remove the > >>testdisk.raw test device at the end of the tests. > >> > >>Signed-off-by: Alison Chaiken <alison@peloton-tech.com> > >>Reviewed-by: Simon Glass <sjg@chromium.org> > > > >Applied to u-boot/master, thanks! > > As of commit cd3e8a72a6fb "test/py: u_boot_console_base.py: fix > typo", in u-boot/master, test/py is failing test_gpt_*, with the log > below. I assume that's due to this commit, since it relates to GPT, > but I haven't bisected. > > => host bind 0 testdisk.raw > Failed to access host backing file 'testdisk.raw' > exit not allowed from main input shell. > => gpt guid host 0 > do_gpt: host dev 0 NOT available > => > > FAILED: > u_boot_console = <u_boot_console_sandbox.ConsoleSandbox object at > 0x7f60875a7e10> > > @pytest.mark.buildconfigspec('cmd_gpt') > def test_gpt_guid(u_boot_console): > """Test the gpt guid command.""" > > if u_boot_console.config.buildconfig.get('config_cmd_gpt', > 'n') != 'y': > pytest.skip('gpt command not supported') > make_test_disk.makeDisk() > u_boot_console.run_command('host bind 0 testdisk.raw') > output = u_boot_console.run_command('gpt guid host 0') > > assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output > E assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in 'do_gpt: > host dev 0 NOT available' > > src/u-boot/test/py/tests/test_gpt.py:26: AssertionError The "good" news is that it's not something blatantly wrong in the test, it runs for me and in travis as well.
On 09/15/2017 10:16 AM, Tom Rini wrote: > On Fri, Sep 15, 2017 at 09:40:29AM -0600, Stephen Warren wrote: >> On 09/15/2017 06:29 AM, Tom Rini wrote: >>> On Sat, Sep 09, 2017 at 11:54:51PM -0700, alison@peloton-tech.com wrote: >>>> From: Alison Chaiken <alison@peloton-tech.com> >>>> >>>> Add unit tests for the 'gpt rename' and 'gpt swap' commands that >>>> rely on the block device created by test/py/make_test_disk.py. >>>> Add CONFIG_CMD_GPT_RENAME to the sandbox_defconfig. Remove the >>>> testdisk.raw test device at the end of the tests. >>>> >>>> Signed-off-by: Alison Chaiken <alison@peloton-tech.com> >>>> Reviewed-by: Simon Glass <sjg@chromium.org> >>> >>> Applied to u-boot/master, thanks! >> >> As of commit cd3e8a72a6fb "test/py: u_boot_console_base.py: fix >> typo", in u-boot/master, test/py is failing test_gpt_*, with the log >> below. I assume that's due to this commit, since it relates to GPT, >> but I haven't bisected. >> >> => host bind 0 testdisk.raw >> Failed to access host backing file 'testdisk.raw' >> exit not allowed from main input shell. >> => gpt guid host 0 >> do_gpt: host dev 0 NOT available >> => >> >> FAILED: >> u_boot_console = <u_boot_console_sandbox.ConsoleSandbox object at >> 0x7f60875a7e10> >> >> @pytest.mark.buildconfigspec('cmd_gpt') >> def test_gpt_guid(u_boot_console): >> """Test the gpt guid command.""" >> >> if u_boot_console.config.buildconfig.get('config_cmd_gpt', >> 'n') != 'y': >> pytest.skip('gpt command not supported') >> make_test_disk.makeDisk() >> u_boot_console.run_command('host bind 0 testdisk.raw') >> output = u_boot_console.run_command('gpt guid host 0') >>> assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output >> E assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in 'do_gpt: >> host dev 0 NOT available' >> >> src/u-boot/test/py/tests/test_gpt.py:26: AssertionError > > The "good" news is that it's not something blatantly wrong in the test, > it runs for me and in travis as well. Ah. The issue happens when the current working directory isn't the root of the U-Boot source tree. It looks like make_test_disk.py creates the disk image in the current working directory rather than putting it into the correct test/py runtime data directory and referencing that path explicitly within the U-Boot console. I'll see if it's an easy fix or not.
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 4c4e4809be..e7a61bd61a 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -34,6 +34,7 @@ CONFIG_CMD_MX_CYCLIC=y CONFIG_CMD_DEMO=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y +CONFIG_CMD_GPT_RENAME=y CONFIG_CMD_IDE=y CONFIG_CMD_I2C=y CONFIG_CMD_PCI=y diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py index 73f5c50f6c..06f24b66ce 100644 --- a/test/py/tests/test_gpt.py +++ b/test/py/tests/test_gpt.py @@ -35,4 +35,35 @@ def test_gpt_save_guid(u_boot_console): output = u_boot_console.run_command('gpt guid host 0 newguid') output = u_boot_console.run_command('printenv newguid') assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output + +@pytest.mark.buildconfigspec('cmd_gpt') +def test_gpt_rename_partition(u_boot_console): + """Test the gpt rename command to write partition names.""" + + if u_boot_console.config.buildconfig.get('config_cmd_gpt_rename', 'n') != 'y': + pytest.skip('gpt rename command not supported') + u_boot_console.run_command('host bind 0 testdisk.raw') + u_boot_console.run_command('gpt rename host 0 1 first') + output = u_boot_console.run_command('gpt read host 0') + assert 'name first' in output + u_boot_console.run_command('gpt rename host 0 2 second') + output = u_boot_console.run_command('gpt read host 0') + assert 'name second' in output + +@pytest.mark.buildconfigspec('cmd_gpt') +def test_gpt_swap_partitions(u_boot_console): + """Test the gpt swap command to exchange two partition names.""" + + if u_boot_console.config.buildconfig.get('config_cmd_gpt_rename', 'n') != 'y': + pytest.skip('gpt rename command not supported') + if u_boot_console.config.buildconfig.get('config_cmd_part', 'n') != 'y': + pytest.skip('gpt swap test needs CMD_PART') + u_boot_console.run_command('host bind 0 testdisk.raw') + output = u_boot_console.run_command('part list host 0') + assert '0x000007ff "first"' in output + assert '0x000017ff "second"' in output + u_boot_console.run_command('gpt swap host 0 first second') + output = u_boot_console.run_command('part list host 0') + assert '0x000007ff "second"' in output + assert '0x000017ff "first"' in output os.remove('testdisk.raw')