From 26f555a6e5454043ed0b0a12d6fce252f5ae5b80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Fri, 20 Mar 2020 10:59:23 +0100 Subject: [PATCH] test: Add PStore command tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 [trini: Adjust to always load files from source directory] Signed-off-by: Tom Rini Cc: Heinrich Schuchardt Cc: Wolfgang Denk Cc: Heiko Schocher --- configs/sandbox64_defconfig | 2 + configs/sandbox_defconfig | 2 + test/py/tests/test_pstore.py | 77 +++++++++++++++++++++ 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, 81 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 c3ca796d51..7c713cb4a4 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -80,6 +80,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=0x3000000 CONFIG_MAC_PARTITION=y CONFIG_AMIGA_PARTITION=y CONFIG_OF_CONTROL=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 18f787cb51..6ac2919977 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -93,6 +93,8 @@ CONFIG_CMD_CRAMFS=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_SQUASHFS=y CONFIG_CMD_MTDPARTS=y +CONFIG_CMD_PSTORE=y +CONFIG_CMD_PSTORE_MEM_ADDR=0x3000000 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 0000000000..5a35724f60 --- /dev/null +++ b/test/py/tests/test_pstore.py @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2020, Collabora +# Author: Frédéric Danis + +import pytest +import u_boot_utils +import os +import tempfile +import shutil + +PSTORE_ADDR=0x3000000 +PSTORE_LENGTH=0x100000 +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=0x01000008 + +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, + 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): + """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 file mode 100644 index 0000000000000000000000000000000000000000..e7f426e8928a2793457baced5f66ee165ef429f6 GIT binary patch literal 4096 zcmcgv%TnVw6lJ!(nP0e*4NyZ8zvNd{7IX(_s%e@b&{Z=OMcI}D8f?ie*$MgY`GC1f z?1ZL6Cktj4lpUjc?>YA&9Sz@~dDb&-IDxkz1&BYW{HH_2@lNt}`hF%c=vQY{D}JqApUVz+M^#mQS38q21kR=dA1k z656*dwDxHrn#gIb!N!=1-E&>xgDwrjz_Af2FP@z4lvdzaX=YhgZ%XBT48sLX{ZLm_ zPDKnyPbK0<-l>$;Z%Z$c>pK{J@i~S|h6zy>7x$oN7_fK;cGUADG6$&=L1hs`0QKS( zril``cu(&`!L?=-Xw9IKpfIgDFSv1Kf*Ch~>qQYlPHM`l7^+#x2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~}1Kscpl?vhvVqczWil;5%@`FY_!c!G$7KJQC^?A zV2B?^GQplPx#Pd)f@9X3Xu*hn$y6Ud*s_TqwCoxp8N|QIzZ&HqwJYfG9sfIg2fG1@ z`ylU*wx`W*M{FA-envsyqw<)1&;Ps8Hpab2?z?OVU-FnTn9~Z3i4KYm-b!H@SKQ}AdtWx9dxJfAFlT)ub1Uk z%@qusho@-*3-8&E(Gp|h;zQJi|cD! z!-b6DB64+i@4<_4Q{H*_u=&8vrfN7h73#gaQKg+fc!=C2lCcND{Qy zMh?`DF{R)ED#0dFS3$;B?|>%U4G%FrH+xTyRxS#-kGnvR`Hs;55_JK5c96Ag(_A&J zV+O8~bF7$KurL?_$D#0$*6(h$t=a-Ni|zpLkK|m%v^$aw_TI=g5ee@~wksL$Kbw7Z z_a^^^lCh&}!b22||9i>U<9kuyuDt(s$rzO5#Ft(I;+*65h3i7-u4*Wkc^Dx{0scp3 z*7!kS$O?s8jiFN;>Q3oC4Yp*0zpWBm^6c#F6;f!{-7CyY(mcWnC7^&YO- z!6n`&$0wcM$uT=PJUKamIeLzcpvsQ$IX-58gW8%M;?p%~&88>pfU!&Z)%y4lsCeAi z(fW{0r?@YEvSw_0#GW&vDO(d`KV$fa9-)Qj@LM{XqWM{8baKe(+4Q4zCt!4qI8Oe- gK1K6im&c6#eu`;b{uY4j*Km4t@E9X-&W;cM16+S2TL1t6 literal 0 HcmV?d00001 diff --git a/test/py/tests/test_pstore_data_panic2.hex b/test/py/tests/test_pstore_data_panic2.hex new file mode 100644 index 0000000000000000000000000000000000000000..8f9d56cbe01e38f5f8fac6d46491497c9d7bda8f GIT binary patch literal 4096 zcmcIn%Wm676lIDmnrzxn7$6%5h2?qNc?oG2vD(x?3%EcE6bKA;G#ti+ElQ=N*x6;# zzwFQS4qql?*)a;5fZ-uDbLR3s&bfE?=I!yn-z7=>`w<@|wO~vLX(phxVf=9R{L~e> zf5FMAE4S?VD|r2$5T?z9a>c=%k@v4W6_m@=ygnlbA96oGcS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