Re: [PATCH v5 2/3] test: Add PStore command tests
On Fri, Mar 20, 2020 at 10:59:23AM +0100, Frédéric Danis wrote: > Add PStore command to sandbox and sandbox64 defconfigs. > Add test checking: > - 'pstore display' of all records > - 'pstore display' only the 2nd dump record > - 'pstore save' of all records > > Signed-off-by: Frédéric Danis > Cc: Tom Rini > Cc: Heinrich Schuchardt > Cc: Wolfgang Denk > Cc: Heiko Schocher With the test files supplied off-list and some minor changes to ensure it works reliably with separate source/build/run directories: Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [PATCH v5 2/3] test: Add PStore command tests
On Tue, Oct 13, 2020 at 02:03:46PM -0400, Tom Rini wrote: > On Tue, Oct 13, 2020 at 06:35:51PM +0200, Frédéric Danis wrote: > > Hi Tom, > > > > On 13/10/2020 17:48, Tom Rini wrote: > > > On Fri, Mar 20, 2020 at 10:59:23AM +0100, Frédéric Danis wrote: > > > > > > > Add PStore command to sandbox and sandbox64 defconfigs. > > > > Add test checking: > > > > - 'pstore display' of all records > > > > - 'pstore display' only the 2nd dump record > > > > - 'pstore save' of all records > > > > > > > > Signed-off-by: Frédéric Danis > > > > Cc: Tom Rini > > > > Cc: Heinrich Schuchardt > > > > Cc: Wolfgang Denk > > > > Cc: Heiko Schocher > > > > --- > > > > Changes in v5: > > > > - Fix test_pstore.py license > > > > > > > > Changes in v4: > > > > - Fix PStore memory address in sandbox defconfig files for tests > > > > > > > > Changes in v3: > > > > - Replace 1M test file by 3 * 4K files and build pstore memory during > > > > test > > > > > > > > New in v2: > > > > - Add unit tests > > > > > > > > configs/sandbox64_defconfig| 2 + > > > > configs/sandbox_defconfig | 2 + > > > > test/py/tests/test_pstore.py | 73 + > > > > test/py/tests/test_pstore_data_console.hex | Bin 0 -> 4096 bytes > > > > test/py/tests/test_pstore_data_panic1.hex | Bin 0 -> 4096 bytes > > > > test/py/tests/test_pstore_data_panic2.hex | Bin 0 -> 4096 bytes > > > > 6 files changed, 77 insertions(+) > > > > create mode 100644 test/py/tests/test_pstore.py > > > > create mode 100644 test/py/tests/test_pstore_data_console.hex > > > > create mode 100644 test/py/tests/test_pstore_data_panic1.hex > > > > create mode 100644 test/py/tests/test_pstore_data_panic2.hex > > > Sorry for the delay here. When I run the tests I see: > > > Captured stdout call > > > - > > > => > > > => => host load hostfs - 0x300 > > > test/py/tests/test_pstore_data_panic1.hex > > > 4096 bytes read in 0 ms > > > => => host load hostfs - 0x3001000 > > > test/py/tests/test_pstore_data_panic2.hex > > > 0 bytes read in 0 ms > > > => => host load hostfs - 0x30fd000 > > > test/py/tests/test_pstore_data_console.hex > > > 4096 bytes read in 0 ms > > > => => pstore set 0x300 0x10 > > > => => pstore save hostfs - /tmp/tmp1xx0rahx > > > 3798 bytes written in 1 ms (3.6 MiB/s) > > > 4084 bytes written in 0 ms > > > => => load hostfs - 108 /tmp/tmp1xx0rahx/dmesg-ramoops-0 > > > 3798 bytes read in 0 ms > > > => => printenv filesize > > > filesize=ed6 > > > => => md5sum 108 $filesize > > > md5 for 0108 ... 01000edd ==> 8059335ab4cfa62c77324c491659c503 > > > => => setenv filesize > > > => => load hostfs - 108 /tmp/tmp1xx0rahx/dmesg-ramoops-1 > > > Failed to load '/tmp/tmp1xx0rahx/dmesg-ramoops-1' > > > => => printenv filesize > > > ## Error: "file > > > === short test summary info > > > === > > > > > > So I'm not sure why the second one fails to load. > > > > > It seems that the "test_pstore_data_panic2.hex" test file was not loaded > > correctly in memory, so the "dmesg-ramoops-1" was not generated > > So there's two problems. One of which is that we need to do something > like this: > diff --git a/test/py/tests/test_pstore.py b/test/py/tests/test_pstore.py > index 7388f335068c..153b8ff210ac 100644 > --- a/test/py/tests/test_pstore.py > +++ b/test/py/tests/test_pstore.py > @@ -4,6 +4,7 @@ > > import pytest > import u_boot_utils > +import os > import tempfile > import shutil > > @@ -18,9 +19,9 @@ def load_pstore(u_boot_console): > """Load PStore records from sample files""" > > output = u_boot_console.run_command_list([ > -'host load hostfs - 0x%x %s' % (PSTORE_ADDR, PSTORE_PANIC1), > -'host load hostfs - 0x%x %s' % (PSTORE_ADDR + 4096, PSTORE_PANIC2), > -'host load hostfs - 0x%x %s' % (PSTORE_ADDR + 253 * 4096, > PSTORE_CONSOLE), > +'host load hostfs - 0x%x %s' % (PSTORE_ADDR, > os.path.join(u_boot_console.config.source_dir, PSTORE_PANIC1)), > +'host load hostfs - 0x%x %s' % (PSTORE_ADDR + 4096, > os.path.join(u_boot_console.config.source_dir, PSTORE_PANIC2)), > +'host load hostfs - 0x%x %s' % (PSTORE_ADDR + 253 * 4096, > os.path.join(u_boot_console.config.source_dir, PSTORE_CONSOLE)), > 'pstore set 0x%x 0x%x' % (PSTORE_ADDR, PSTORE_LENGTH)]) > > def checkfile(u_boot_console, path, filesize, checksum): > > to ensure that we load from the source directory and not relative > directory. The other problem is that the patch results in a zero byte > file for that second one. To be clear-er, patchwork is missing the last part of the file and I can't quite grab it from https://lists.denx.de/pipermail/u-boot/2020-March/403645.html directly. If you just want to email me the file off-list, I can fix it up. Thanks! -- Tom signature.asc
Re: [PATCH v5 2/3] test: Add PStore command tests
On Tue, Oct 13, 2020 at 06:35:51PM +0200, Frédéric Danis wrote: > Hi Tom, > > On 13/10/2020 17:48, Tom Rini wrote: > > On Fri, Mar 20, 2020 at 10:59:23AM +0100, Frédéric Danis wrote: > > > > > Add PStore command to sandbox and sandbox64 defconfigs. > > > Add test checking: > > > - 'pstore display' of all records > > > - 'pstore display' only the 2nd dump record > > > - 'pstore save' of all records > > > > > > Signed-off-by: Frédéric Danis > > > Cc: Tom Rini > > > Cc: Heinrich Schuchardt > > > Cc: Wolfgang Denk > > > Cc: Heiko Schocher > > > --- > > > Changes in v5: > > > - Fix test_pstore.py license > > > > > > Changes in v4: > > > - Fix PStore memory address in sandbox defconfig files for tests > > > > > > Changes in v3: > > > - Replace 1M test file by 3 * 4K files and build pstore memory during test > > > > > > New in v2: > > > - Add unit tests > > > > > > configs/sandbox64_defconfig| 2 + > > > configs/sandbox_defconfig | 2 + > > > test/py/tests/test_pstore.py | 73 + > > > test/py/tests/test_pstore_data_console.hex | Bin 0 -> 4096 bytes > > > test/py/tests/test_pstore_data_panic1.hex | Bin 0 -> 4096 bytes > > > test/py/tests/test_pstore_data_panic2.hex | Bin 0 -> 4096 bytes > > > 6 files changed, 77 insertions(+) > > > create mode 100644 test/py/tests/test_pstore.py > > > create mode 100644 test/py/tests/test_pstore_data_console.hex > > > create mode 100644 test/py/tests/test_pstore_data_panic1.hex > > > create mode 100644 test/py/tests/test_pstore_data_panic2.hex > > Sorry for the delay here. When I run the tests I see: > > Captured stdout call > > - > > => > > => => host load hostfs - 0x300 test/py/tests/test_pstore_data_panic1.hex > > 4096 bytes read in 0 ms > > => => host load hostfs - 0x3001000 test/py/tests/test_pstore_data_panic2.hex > > 0 bytes read in 0 ms > > => => host load hostfs - 0x30fd000 > > test/py/tests/test_pstore_data_console.hex > > 4096 bytes read in 0 ms > > => => pstore set 0x300 0x10 > > => => pstore save hostfs - /tmp/tmp1xx0rahx > > 3798 bytes written in 1 ms (3.6 MiB/s) > > 4084 bytes written in 0 ms > > => => load hostfs - 108 /tmp/tmp1xx0rahx/dmesg-ramoops-0 > > 3798 bytes read in 0 ms > > => => printenv filesize > > filesize=ed6 > > => => md5sum 108 $filesize > > md5 for 0108 ... 01000edd ==> 8059335ab4cfa62c77324c491659c503 > > => => setenv filesize > > => => load hostfs - 108 /tmp/tmp1xx0rahx/dmesg-ramoops-1 > > Failed to load '/tmp/tmp1xx0rahx/dmesg-ramoops-1' > > => => printenv filesize > > ## Error: "file > > === short test summary info > > === > > > > So I'm not sure why the second one fails to load. > > > It seems that the "test_pstore_data_panic2.hex" test file was not loaded > correctly in memory, so the "dmesg-ramoops-1" was not generated So there's two problems. One of which is that we need to do something like this: diff --git a/test/py/tests/test_pstore.py b/test/py/tests/test_pstore.py index 7388f335068c..153b8ff210ac 100644 --- a/test/py/tests/test_pstore.py +++ b/test/py/tests/test_pstore.py @@ -4,6 +4,7 @@ import pytest import u_boot_utils +import os import tempfile import shutil @@ -18,9 +19,9 @@ def load_pstore(u_boot_console): """Load PStore records from sample files""" output = u_boot_console.run_command_list([ -'host load hostfs - 0x%x %s' % (PSTORE_ADDR, PSTORE_PANIC1), -'host load hostfs - 0x%x %s' % (PSTORE_ADDR + 4096, PSTORE_PANIC2), -'host load hostfs - 0x%x %s' % (PSTORE_ADDR + 253 * 4096, PSTORE_CONSOLE), +'host load hostfs - 0x%x %s' % (PSTORE_ADDR, os.path.join(u_boot_console.config.source_dir, PSTORE_PANIC1)), +'host load hostfs - 0x%x %s' % (PSTORE_ADDR + 4096, os.path.join(u_boot_console.config.source_dir, PSTORE_PANIC2)), +'host load hostfs - 0x%x %s' % (PSTORE_ADDR + 253 * 4096, os.path.join(u_boot_console.config.source_dir, PSTORE_CONSOLE)), 'pstore set 0x%x 0x%x' % (PSTORE_ADDR, PSTORE_LENGTH)]) def checkfile(u_boot_console, path, filesize, checksum): to ensure that we load from the source directory and not relative directory. The other problem is that the patch results in a zero byte file for that second one. -- Tom signature.asc Description: PGP signature
Re: [PATCH v5 2/3] test: Add PStore command tests
Hi Tom, On 13/10/2020 17:48, Tom Rini wrote: On Fri, Mar 20, 2020 at 10:59:23AM +0100, Frédéric Danis wrote: Add PStore command to sandbox and sandbox64 defconfigs. Add test checking: - 'pstore display' of all records - 'pstore display' only the 2nd dump record - 'pstore save' of all records Signed-off-by: Frédéric Danis Cc: Tom Rini Cc: Heinrich Schuchardt Cc: Wolfgang Denk Cc: Heiko Schocher --- Changes in v5: - Fix test_pstore.py license Changes in v4: - Fix PStore memory address in sandbox defconfig files for tests Changes in v3: - Replace 1M test file by 3 * 4K files and build pstore memory during test New in v2: - Add unit tests configs/sandbox64_defconfig| 2 + configs/sandbox_defconfig | 2 + test/py/tests/test_pstore.py | 73 + test/py/tests/test_pstore_data_console.hex | Bin 0 -> 4096 bytes test/py/tests/test_pstore_data_panic1.hex | Bin 0 -> 4096 bytes test/py/tests/test_pstore_data_panic2.hex | Bin 0 -> 4096 bytes 6 files changed, 77 insertions(+) create mode 100644 test/py/tests/test_pstore.py create mode 100644 test/py/tests/test_pstore_data_console.hex create mode 100644 test/py/tests/test_pstore_data_panic1.hex create mode 100644 test/py/tests/test_pstore_data_panic2.hex Sorry for the delay here. When I run the tests I see: Captured stdout call - => => => host load hostfs - 0x300 test/py/tests/test_pstore_data_panic1.hex 4096 bytes read in 0 ms => => host load hostfs - 0x3001000 test/py/tests/test_pstore_data_panic2.hex 0 bytes read in 0 ms => => host load hostfs - 0x30fd000 test/py/tests/test_pstore_data_console.hex 4096 bytes read in 0 ms => => pstore set 0x300 0x10 => => pstore save hostfs - /tmp/tmp1xx0rahx 3798 bytes written in 1 ms (3.6 MiB/s) 4084 bytes written in 0 ms => => load hostfs - 108 /tmp/tmp1xx0rahx/dmesg-ramoops-0 3798 bytes read in 0 ms => => printenv filesize filesize=ed6 => => md5sum 108 $filesize md5 for 0108 ... 01000edd ==> 8059335ab4cfa62c77324c491659c503 => => setenv filesize => => load hostfs - 108 /tmp/tmp1xx0rahx/dmesg-ramoops-1 Failed to load '/tmp/tmp1xx0rahx/dmesg-ramoops-1' => => printenv filesize ## Error: "file === short test summary info === So I'm not sure why the second one fails to load. It seems that the "test_pstore_data_panic2.hex" test file was not loaded correctly in memory, so the "dmesg-ramoops-1" was not generated Regards, Fred
Re: [PATCH v5 2/3] test: Add PStore command tests
On Fri, Mar 20, 2020 at 10:59:23AM +0100, Frédéric Danis wrote: > Add PStore command to sandbox and sandbox64 defconfigs. > Add test checking: > - 'pstore display' of all records > - 'pstore display' only the 2nd dump record > - 'pstore save' of all records > > Signed-off-by: Frédéric Danis > Cc: Tom Rini > Cc: Heinrich Schuchardt > Cc: Wolfgang Denk > Cc: Heiko Schocher > --- > Changes in v5: > - Fix test_pstore.py license > > Changes in v4: > - Fix PStore memory address in sandbox defconfig files for tests > > Changes in v3: > - Replace 1M test file by 3 * 4K files and build pstore memory during test > > New in v2: > - Add unit tests > > configs/sandbox64_defconfig| 2 + > configs/sandbox_defconfig | 2 + > test/py/tests/test_pstore.py | 73 + > test/py/tests/test_pstore_data_console.hex | Bin 0 -> 4096 bytes > test/py/tests/test_pstore_data_panic1.hex | Bin 0 -> 4096 bytes > test/py/tests/test_pstore_data_panic2.hex | Bin 0 -> 4096 bytes > 6 files changed, 77 insertions(+) > create mode 100644 test/py/tests/test_pstore.py > create mode 100644 test/py/tests/test_pstore_data_console.hex > create mode 100644 test/py/tests/test_pstore_data_panic1.hex > create mode 100644 test/py/tests/test_pstore_data_panic2.hex Sorry for the delay here. When I run the tests I see: Captured stdout call - => => => host load hostfs - 0x300 test/py/tests/test_pstore_data_panic1.hex 4096 bytes read in 0 ms => => host load hostfs - 0x3001000 test/py/tests/test_pstore_data_panic2.hex 0 bytes read in 0 ms => => host load hostfs - 0x30fd000 test/py/tests/test_pstore_data_console.hex 4096 bytes read in 0 ms => => pstore set 0x300 0x10 => => pstore save hostfs - /tmp/tmp1xx0rahx 3798 bytes written in 1 ms (3.6 MiB/s) 4084 bytes written in 0 ms => => load hostfs - 108 /tmp/tmp1xx0rahx/dmesg-ramoops-0 3798 bytes read in 0 ms => => printenv filesize filesize=ed6 => => md5sum 108 $filesize md5 for 0108 ... 01000edd ==> 8059335ab4cfa62c77324c491659c503 => => setenv filesize => => load hostfs - 108 /tmp/tmp1xx0rahx/dmesg-ramoops-1 Failed to load '/tmp/tmp1xx0rahx/dmesg-ramoops-1' => => printenv filesize ## Error: "file === short test summary info === So I'm not sure why the second one fails to load. -- Tom signature.asc Description: PGP signature
[PATCH v5 2/3] test: Add PStore command tests
Add PStore command to sandbox and sandbox64 defconfigs. Add test checking: - 'pstore display' of all records - 'pstore display' only the 2nd dump record - 'pstore save' of all records Signed-off-by: Frédéric Danis Cc: Tom Rini Cc: Heinrich Schuchardt Cc: Wolfgang Denk Cc: Heiko Schocher --- Changes in v5: - Fix test_pstore.py license Changes in v4: - Fix PStore memory address in sandbox defconfig files for tests Changes in v3: - Replace 1M test file by 3 * 4K files and build pstore memory during test New in v2: - Add unit tests configs/sandbox64_defconfig| 2 + configs/sandbox_defconfig | 2 + test/py/tests/test_pstore.py | 73 + test/py/tests/test_pstore_data_console.hex | Bin 0 -> 4096 bytes test/py/tests/test_pstore_data_panic1.hex | Bin 0 -> 4096 bytes test/py/tests/test_pstore_data_panic2.hex | Bin 0 -> 4096 bytes 6 files changed, 77 insertions(+) create mode 100644 test/py/tests/test_pstore.py create mode 100644 test/py/tests/test_pstore_data_console.hex create mode 100644 test/py/tests/test_pstore_data_panic1.hex create mode 100644 test/py/tests/test_pstore_data_panic2.hex diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 71a4d7fccb..f7b3544ae5 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -68,6 +68,8 @@ CONFIG_CMD_CBFS=y CONFIG_CMD_CRAMFS=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_MTDPARTS=y +CONFIG_CMD_PSTORE=y +CONFIG_CMD_PSTORE_MEM_ADDR=0x300 CONFIG_MAC_PARTITION=y CONFIG_AMIGA_PARTITION=y CONFIG_OF_CONTROL=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index f96891ecae..64b878abac 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -77,6 +77,8 @@ CONFIG_CMD_CBFS=y CONFIG_CMD_CRAMFS=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_MTDPARTS=y +CONFIG_CMD_PSTORE=y +CONFIG_CMD_PSTORE_MEM_ADDR=0x300 CONFIG_MAC_PARTITION=y CONFIG_AMIGA_PARTITION=y CONFIG_OF_CONTROL=y diff --git a/test/py/tests/test_pstore.py b/test/py/tests/test_pstore.py new file mode 100644 index 00..7388f33506 --- /dev/null +++ b/test/py/tests/test_pstore.py @@ -0,0 +1,73 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2020, Collabora +# Author: Frédéric Danis + +import pytest +import u_boot_utils +import tempfile +import shutil + +PSTORE_ADDR=0x300 +PSTORE_LENGTH=0x10 +PSTORE_PANIC1='test/py/tests/test_pstore_data_panic1.hex' +PSTORE_PANIC2='test/py/tests/test_pstore_data_panic2.hex' +PSTORE_CONSOLE='test/py/tests/test_pstore_data_console.hex' +ADDR=0x0108 + +def load_pstore(u_boot_console): +"""Load PStore records from sample files""" + +output = u_boot_console.run_command_list([ +'host load hostfs - 0x%x %s' % (PSTORE_ADDR, PSTORE_PANIC1), +'host load hostfs - 0x%x %s' % (PSTORE_ADDR + 4096, PSTORE_PANIC2), +'host load hostfs - 0x%x %s' % (PSTORE_ADDR + 253 * 4096, PSTORE_CONSOLE), +'pstore set 0x%x 0x%x' % (PSTORE_ADDR, PSTORE_LENGTH)]) + +def checkfile(u_boot_console, path, filesize, checksum): +"""Check file against MD5 checksum""" + +output = u_boot_console.run_command_list([ +'load hostfs - %x %s' % (ADDR, path), +'printenv filesize']) +assert('filesize=%x' % (filesize) in ''.join(output)) + +output = u_boot_console.run_command_list([ +'md5sum %x $filesize' % ADDR, +'setenv filesize']) +assert(checksum in ''.join(output)) + +@pytest.mark.buildconfigspec('cmd_pstore') +def test_pstore_display_all_records(u_boot_console): +"""Test that pstore displays all records.""" + +u_boot_console.run_command('') +load_pstore(u_boot_console) +response = u_boot_console.run_command('pstore display') +assert(' Dump' in response) +assert(' Console' in response) + +@pytest.mark.buildconfigspec('cmd_pstore') +def test_pstore_display_one_record(u_boot_console): +"""Test that pstore displays only one record.""" + +u_boot_console.run_command('') +load_pstore(u_boot_console) +response = u_boot_console.run_command('pstore display dump 1') +assert('Panic#2 Part1' in response) +assert(' Console' not in response) + +@pytest.mark.buildconfigspec('cmd_pstore') +def test_pstore_save_records(u_boot_console): +"""Test that pstore saves all records.""" + +outdir = tempfile.mkdtemp() + +u_boot_console.run_command('') +load_pstore(u_boot_console) +u_boot_console.run_command('pstore save hostfs - %s' % (outdir)) + +checkfile(u_boot_console, '%s/dmesg-ramoops-0' % (outdir), 3798, '8059335ab4cfa62c77324c491659c503') +checkfile(u_boot_console, '%s/dmesg-ramoops-1' % (outdir), 4035, '3ff30df3429d81939c75d0070b5187b9') +checkfile(u_boot_console, '%s/console-ramoops-0' % (outdir), 4084, 'bb44de4a9b8ebd9b17ae98003287325b') + +shutil.rmtree(outdir) diff --git a/test/py/tests/test_pstore_data_console.hex b/test/py/tests/test_pstore_data_console.hex new