diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/skiboot/external/pflash/test | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/skiboot/external/pflash/test')
29 files changed, 1103 insertions, 0 deletions
diff --git a/roms/skiboot/external/pflash/test/files/01-info.ffs b/roms/skiboot/external/pflash/test/files/01-info.ffs new file mode 100644 index 000000000..41cbb68cb --- /dev/null +++ b/roms/skiboot/external/pflash/test/files/01-info.ffs @@ -0,0 +1,6 @@ +ONE,0x00003000,0x00001000,EV,,/dev/zero +TWO,0x00004000,0x00001000,EF,,/dev/zero +THREE,0x00005000,0x00001000,EF,,/dev/zero +FOUR,0x00006000,0x00001000,EF,,/dev/zero +FIVE,0x00007000,0x1000,L,,/dev/zero +SIX,0x00008000,0x1000,C,,/dev/zero diff --git a/roms/skiboot/external/pflash/test/files/02-erase.ffs b/roms/skiboot/external/pflash/test/files/02-erase.ffs new file mode 100644 index 000000000..ff64d4e69 --- /dev/null +++ b/roms/skiboot/external/pflash/test/files/02-erase.ffs @@ -0,0 +1,4 @@ +ONE,0x00000300,0x00000100,EV,,/dev/urandom +TWO,0x00000400,0x00000100,EF,,/dev/urandom +THREE,0x00000500,0x00000100,EF,,/dev/urandom +FOUR,0x00000600,0x00000100,EF,,/dev/urandom diff --git a/roms/skiboot/external/pflash/test/files/03-erase-parts.ffs b/roms/skiboot/external/pflash/test/files/03-erase-parts.ffs new file mode 100644 index 000000000..ff64d4e69 --- /dev/null +++ b/roms/skiboot/external/pflash/test/files/03-erase-parts.ffs @@ -0,0 +1,4 @@ +ONE,0x00000300,0x00000100,EV,,/dev/urandom +TWO,0x00000400,0x00000100,EF,,/dev/urandom +THREE,0x00000500,0x00000100,EF,,/dev/urandom +FOUR,0x00000600,0x00000100,EF,,/dev/urandom diff --git a/roms/skiboot/external/pflash/test/files/04-program-rand.ffs b/roms/skiboot/external/pflash/test/files/04-program-rand.ffs new file mode 100644 index 000000000..ff64d4e69 --- /dev/null +++ b/roms/skiboot/external/pflash/test/files/04-program-rand.ffs @@ -0,0 +1,4 @@ +ONE,0x00000300,0x00000100,EV,,/dev/urandom +TWO,0x00000400,0x00000100,EF,,/dev/urandom +THREE,0x00000500,0x00000100,EF,,/dev/urandom +FOUR,0x00000600,0x00000100,EF,,/dev/urandom diff --git a/roms/skiboot/external/pflash/test/files/05-bad-numbers.ffs b/roms/skiboot/external/pflash/test/files/05-bad-numbers.ffs new file mode 100644 index 000000000..ff64d4e69 --- /dev/null +++ b/roms/skiboot/external/pflash/test/files/05-bad-numbers.ffs @@ -0,0 +1,4 @@ +ONE,0x00000300,0x00000100,EV,,/dev/urandom +TWO,0x00000400,0x00000100,EF,,/dev/urandom +THREE,0x00000500,0x00000100,EF,,/dev/urandom +FOUR,0x00000600,0x00000100,EF,,/dev/urandom diff --git a/roms/skiboot/external/pflash/test/files/06-miscprint.ffs b/roms/skiboot/external/pflash/test/files/06-miscprint.ffs new file mode 100644 index 000000000..d7e91b0e1 --- /dev/null +++ b/roms/skiboot/external/pflash/test/files/06-miscprint.ffs @@ -0,0 +1,6 @@ +PRESERVED,0x003000,0x1000,P,,/dev/zero +READONLY,0x0004000,0x1000,R,,/dev/zero +REPROVISION,0x5000,0x1000,F,,/dev/zero +BACKUP,0x000006000,0x1000,B,,/dev/zero +VOLATILE,0x000007000,0x1000,V,,/dev/zero +CLEARECC,0x000008000,0x1000,C,,/dev/zero diff --git a/roms/skiboot/external/pflash/test/make-check-test b/roms/skiboot/external/pflash/test/make-check-test new file mode 100755 index 000000000..7f0094860 --- /dev/null +++ b/roms/skiboot/external/pflash/test/make-check-test @@ -0,0 +1 @@ +make -C external/pflash/ check diff --git a/roms/skiboot/external/pflash/test/results/00-usage.err b/roms/skiboot/external/pflash/test/results/00-usage.err new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/00-usage.err diff --git a/roms/skiboot/external/pflash/test/results/00-usage.out b/roms/skiboot/external/pflash/test/results/00-usage.out new file mode 100644 index 000000000..a3721ca8e --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/00-usage.out @@ -0,0 +1,114 @@ +Open-Power Flash tool VERSION +Usage: ./pflash [options] commands... + + Options: + -a address, --address=address + Specify the start address for erasing, reading + or flashing + + -s size, --size=size + Specify the size in bytes for erasing, reading + or flashing + + -P part_name, --partition=part_name + Specify the partition whose content is to be erased + programmed or read. This is an alternative to -a and -s + if both -P and -s are specified, the smallest of the + two will be used + + -f, --force + Don't ask for confirmation before erasing or flashing + + -d, --dummy + Don't write to flash + + --direct + Bypass all safety provided to you by the kernel driver + and use the flash driver built into pflash. + If you have mtd devices and you use this command, the + system may become unstable. + If you are reading this sentence then this flag is not + what you want! Using this feature without knowing + what it does can and likely will result in a bricked + machine + + -b, --bmc + Target BMC flash instead of host flash. + Note: This carries a high chance of bricking your BMC if you + don't know what you're doing. Consider --mtd to be safe(r) + + -F filename, --flash-file filename + Target filename instead of actual flash. + + -S, --side + Side of the flash on which to operate, 0 (default) or 1 + + --skip=N + Skip N number of bytes from the start when reading + + -T, --toc + libffs TOC on which to operate, defaults to 0. + leading 0x is required for interpretation of a hex value + + -g + Enable verbose libflash debugging + + Commands: + -4, --enable-4B + Switch the flash and controller to 4-bytes address + mode (no confirmation needed). + + -3, --disable-4B + Switch the flash and controller to 3-bytes address + mode (no confirmation needed). + + -r file, --read=file + Read flash content from address into file, use -s + to specify the size to read (or it will use the source + file size if used in conjunction with -p and -s is not + specified). When using -r together with -e or -p, the + read will be performed first + + -E, --erase-all + Erase entire flash chip + (Not supported on all chips/controllers) + + -e, --erase + Erase the specified region. If size or address are not + specified, but '--program' is used, then the file + size will be used (rounded to an erase block) and the + address defaults to 0. + + -p file, --program=file + Will program the file to flash. If the address is not + specified, it will use 0. If the size is not specified + it will use the file size. Otherwise it will limit to + the specified size (whatever is smaller). If used in + conjunction with any erase command, the erase will + take place first. + + -t, --tune + Just tune the flash controller & access size + Must be used in conjuction with --direct + (Implicit for all other operations) + + -c --clear + Used to ECC clear a partition of the flash + Must be used in conjunction with -P. Will erase the + partition and then set all the ECC bits as they should be + + -9 --ecc + Encode/Decode ECC where specified in the FFS header. + This 9 byte ECC method is used for some OpenPOWER + partitions. + -i, --info + Display some information about the flash. + + --detail + Displays detailed info about a particular partition. + Accepts a numeric partition or can be used in conjuction + with the -P flag. + + -h, --help + This message. + diff --git a/roms/skiboot/external/pflash/test/results/01-info.err b/roms/skiboot/external/pflash/test/results/01-info.err new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/01-info.err diff --git a/roms/skiboot/external/pflash/test/results/01-info.out b/roms/skiboot/external/pflash/test/results/01-info.out new file mode 100644 index 000000000..6dfa9216f --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/01-info.out @@ -0,0 +1,15 @@ +Flash info: +----------- +Name = FILE +Total size = 0MB Flags E:ECC, P:PRESERVED, R:READONLY, B:BACKUP +Erase granule = 0KB F:REPROVISION, V:VOLATILE, C:CLEARECC + +TOC@0x00000000 Partitions: +----------- +ID=00 part 0x00000000..0x00001000 (actual=0x00001000) [----------] +ID=01 ONE 0x00003000..0x00004000 (actual=0x00001000) [E--------V] +ID=02 TWO 0x00004000..0x00005000 (actual=0x00001000) [E-----F---] +ID=03 THREE 0x00005000..0x00006000 (actual=0x00001000) [E-----F---] +ID=04 FOUR 0x00006000..0x00007000 (actual=0x00001000) [E-----F---] +ID=05 FIVE 0x00007000..0x00008000 (actual=0x00001000) [-L--------] +ID=06 SIX 0x00008000..0x00009000 (actual=0x00001000) [--------C-] diff --git a/roms/skiboot/external/pflash/test/results/02-erase.err b/roms/skiboot/external/pflash/test/results/02-erase.err new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/02-erase.err diff --git a/roms/skiboot/external/pflash/test/results/02-erase.out b/roms/skiboot/external/pflash/test/results/02-erase.out new file mode 100644 index 000000000..7d251a70c --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/02-erase.out @@ -0,0 +1,105 @@ +About to erase chip ! +WARNING ! This will modify your HOST flash chip content ! +Enter "yes" to confirm:Erasing... (may take a while) + +[ ] 0% +[= ] 1% +[= ] 2% +[== ] 3% +[== ] 4% +[=== ] 5% +[=== ] 6% +[==== ] 7% +[==== ] 8% +[===== ] 9% +[===== ] 10% +[====== ] 11% +[====== ] 12% +[======= ] 13% +[======= ] 14% +[======== ] 15% +[======== ] 16% +[========= ] 17% +[========= ] 18% +[========== ] 19% +[========== ] 20% +[=========== ] 21% +[=========== ] 22% +[============ ] 23% +[============ ] 24% +[============= ] 25% +[============= ] 26% +[============== ] 27% +[============== ] 28% +[=============== ] 29% +[=============== ] 30% +[================ ] 31% +[================ ] 32% +[================= ] 33% +[================= ] 34% +[================== ] 35% +[================== ] 36% +[=================== ] 37% +[=================== ] 38% +[==================== ] 39% +[==================== ] 40% +[===================== ] 41% +[===================== ] 42% +[====================== ] 43% +[====================== ] 44% +[======================= ] 45% +[======================= ] 46% +[======================== ] 47% +[======================== ] 48% +[========================= ] 49% +[========================= ] 50% +[========================== ] 51% +[========================== ] 52% +[=========================== ] 53% +[=========================== ] 54% +[============================ ] 55% +[============================ ] 56% +[============================= ] 57% +[============================= ] 58% +[============================== ] 59% +[============================== ] 60% +[=============================== ] 61% +[=============================== ] 62% +[================================ ] 63% +[================================ ] 64% +[================================= ] 65% +[================================= ] 66% +[================================== ] 67% +[================================== ] 68% +[=================================== ] 69% +[=================================== ] 70% +[==================================== ] 71% +[==================================== ] 72% +[===================================== ] 73% +[===================================== ] 74% +[====================================== ] 75% +[====================================== ] 76% +[======================================= ] 77% +[======================================= ] 78% +[======================================== ] 79% +[======================================== ] 80% +[========================================= ] 81% +[========================================= ] 82% +[========================================== ] 83% +[========================================== ] 84% +[=========================================== ] 85% +[=========================================== ] 86% +[============================================ ] 87% +[============================================ ] 88% +[============================================= ] 89% +[============================================= ] 90% +[============================================== ] 91% +[============================================== ] 92% +[=============================================== ] 93% +[=============================================== ] 94% +[================================================ ] 95% +[================================================ ] 96% +[================================================= ] 97% +[================================================= ] 98% +[==================================================] 99% +done ! diff --git a/roms/skiboot/external/pflash/test/results/03-erase-parts.err b/roms/skiboot/external/pflash/test/results/03-erase-parts.err new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/03-erase-parts.err diff --git a/roms/skiboot/external/pflash/test/results/03-erase-parts.out b/roms/skiboot/external/pflash/test/results/03-erase-parts.out new file mode 100644 index 000000000..28f0b23d1 --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/03-erase-parts.out @@ -0,0 +1,106 @@ +About to erase 0x00000300..0x00000400 ! +WARNING ! This will modify your HOST flash chip content ! +Enter "yes" to confirm:Erasing... + +[ ] 0% +[= ] 1% +[= ] 2% +[== ] 3% +[== ] 4% +[=== ] 5% +[=== ] 6% +[==== ] 7% +[==== ] 8% +[===== ] 9% +[===== ] 10% +[====== ] 11% +[====== ] 12% +[======= ] 13% +[======= ] 14% +[======== ] 15% +[======== ] 16% +[========= ] 17% +[========= ] 18% +[========== ] 19% +[========== ] 20% +[=========== ] 21% +[=========== ] 22% +[============ ] 23% +[============ ] 24% +[============= ] 25% +[============= ] 26% +[============== ] 27% +[============== ] 28% +[=============== ] 29% +[=============== ] 30% +[================ ] 31% +[================ ] 32% +[================= ] 33% +[================= ] 34% +[================== ] 35% +[================== ] 36% +[=================== ] 37% +[=================== ] 38% +[==================== ] 39% +[==================== ] 40% +[===================== ] 41% +[===================== ] 42% +[====================== ] 43% +[====================== ] 44% +[======================= ] 45% +[======================= ] 46% +[======================== ] 47% +[======================== ] 48% +[========================= ] 49% +[========================= ] 50% +[========================== ] 51% +[========================== ] 52% +[=========================== ] 53% +[=========================== ] 54% +[============================ ] 55% +[============================ ] 56% +[============================= ] 57% +[============================= ] 58% +[============================== ] 59% +[============================== ] 60% +[=============================== ] 61% +[=============================== ] 62% +[================================ ] 63% +[================================ ] 64% +[================================= ] 65% +[================================= ] 66% +[================================== ] 67% +[================================== ] 68% +[=================================== ] 69% +[=================================== ] 70% +[==================================== ] 71% +[==================================== ] 72% +[===================================== ] 73% +[===================================== ] 74% +[====================================== ] 75% +[====================================== ] 76% +[======================================= ] 77% +[======================================= ] 78% +[======================================== ] 79% +[======================================== ] 80% +[========================================= ] 81% +[========================================= ] 82% +[========================================== ] 83% +[========================================== ] 84% +[=========================================== ] 85% +[=========================================== ] 86% +[============================================ ] 87% +[============================================ ] 88% +[============================================= ] 89% +[============================================= ] 90% +[============================================== ] 91% +[============================================== ] 92% +[=============================================== ] 93% +[=============================================== ] 94% +[================================================ ] 95% +[================================================ ] 96% +[================================================= ] 97% +[================================================= ] 98% +[==================================================] 99% +[==================================================] 100% +Updating actual size in partition header... diff --git a/roms/skiboot/external/pflash/test/results/04-program-rand.err b/roms/skiboot/external/pflash/test/results/04-program-rand.err new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/04-program-rand.err diff --git a/roms/skiboot/external/pflash/test/results/04-program-rand.out b/roms/skiboot/external/pflash/test/results/04-program-rand.out new file mode 100644 index 000000000..b0df327cd --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/04-program-rand.out @@ -0,0 +1,111 @@ +About to erase 0x00000300..0x00000400 ! +WARNING ! This will modify your HOST flash chip content ! +Enter "yes" to confirm:Erasing... + +[ ] 0% +[= ] 1% +[= ] 2% +[== ] 3% +[== ] 4% +[=== ] 5% +[=== ] 6% +[==== ] 7% +[==== ] 8% +[===== ] 9% +[===== ] 10% +[====== ] 11% +[====== ] 12% +[======= ] 13% +[======= ] 14% +[======== ] 15% +[======== ] 16% +[========= ] 17% +[========= ] 18% +[========== ] 19% +[========== ] 20% +[=========== ] 21% +[=========== ] 22% +[============ ] 23% +[============ ] 24% +[============= ] 25% +[============= ] 26% +[============== ] 27% +[============== ] 28% +[=============== ] 29% +[=============== ] 30% +[================ ] 31% +[================ ] 32% +[================= ] 33% +[================= ] 34% +[================== ] 35% +[================== ] 36% +[=================== ] 37% +[=================== ] 38% +[==================== ] 39% +[==================== ] 40% +[===================== ] 41% +[===================== ] 42% +[====================== ] 43% +[====================== ] 44% +[======================= ] 45% +[======================= ] 46% +[======================== ] 47% +[======================== ] 48% +[========================= ] 49% +[========================= ] 50% +[========================== ] 51% +[========================== ] 52% +[=========================== ] 53% +[=========================== ] 54% +[============================ ] 55% +[============================ ] 56% +[============================= ] 57% +[============================= ] 58% +[============================== ] 59% +[============================== ] 60% +[=============================== ] 61% +[=============================== ] 62% +[================================ ] 63% +[================================ ] 64% +[================================= ] 65% +[================================= ] 66% +[================================== ] 67% +[================================== ] 68% +[=================================== ] 69% +[=================================== ] 70% +[==================================== ] 71% +[==================================== ] 72% +[===================================== ] 73% +[===================================== ] 74% +[====================================== ] 75% +[====================================== ] 76% +[======================================= ] 77% +[======================================= ] 78% +[======================================== ] 79% +[======================================== ] 80% +[========================================= ] 81% +[========================================= ] 82% +[========================================== ] 83% +[========================================== ] 84% +[=========================================== ] 85% +[=========================================== ] 86% +[============================================ ] 87% +[============================================ ] 88% +[============================================= ] 89% +[============================================= ] 90% +[============================================== ] 91% +[============================================== ] 92% +[=============================================== ] 93% +[=============================================== ] 94% +[================================================ ] 95% +[================================================ ] 96% +[================================================= ] 97% +[================================================= ] 98% +[==================================================] 99% +[==================================================] 100% +About to program "FILE" at 0x00000300..0x00000400 ! +Programming & Verifying... + +[ ] 0% +[==================================================] 100% +Updating actual size in partition header... diff --git a/roms/skiboot/external/pflash/test/results/05-bad-numbers.err b/roms/skiboot/external/pflash/test/results/05-bad-numbers.err new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/05-bad-numbers.err diff --git a/roms/skiboot/external/pflash/test/results/05-bad-numbers.out b/roms/skiboot/external/pflash/test/results/05-bad-numbers.out new file mode 100644 index 000000000..2a76c28c0 --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/05-bad-numbers.out @@ -0,0 +1,224 @@ +Open-Power Flash tool VERSION +Usage: ./pflash [options] commands... + + Options: + -a address, --address=address + Specify the start address for erasing, reading + or flashing + + -s size, --size=size + Specify the size in bytes for erasing, reading + or flashing + + -P part_name, --partition=part_name + Specify the partition whose content is to be erased + programmed or read. This is an alternative to -a and -s + if both -P and -s are specified, the smallest of the + two will be used + + -f, --force + Don't ask for confirmation before erasing or flashing + + -d, --dummy + Don't write to flash + + --direct + Bypass all safety provided to you by the kernel driver + and use the flash driver built into pflash. + If you have mtd devices and you use this command, the + system may become unstable. + If you are reading this sentence then this flag is not + what you want! Using this feature without knowing + what it does can and likely will result in a bricked + machine + + -b, --bmc + Target BMC flash instead of host flash. + Note: This carries a high chance of bricking your BMC if you + don't know what you're doing. Consider --mtd to be safe(r) + + -F filename, --flash-file filename + Target filename instead of actual flash. + + -S, --side + Side of the flash on which to operate, 0 (default) or 1 + + --skip=N + Skip N number of bytes from the start when reading + + -T, --toc + libffs TOC on which to operate, defaults to 0. + leading 0x is required for interpretation of a hex value + + -g + Enable verbose libflash debugging + + Commands: + -4, --enable-4B + Switch the flash and controller to 4-bytes address + mode (no confirmation needed). + + -3, --disable-4B + Switch the flash and controller to 3-bytes address + mode (no confirmation needed). + + -r file, --read=file + Read flash content from address into file, use -s + to specify the size to read (or it will use the source + file size if used in conjunction with -p and -s is not + specified). When using -r together with -e or -p, the + read will be performed first + + -E, --erase-all + Erase entire flash chip + (Not supported on all chips/controllers) + + -e, --erase + Erase the specified region. If size or address are not + specified, but '--program' is used, then the file + size will be used (rounded to an erase block) and the + address defaults to 0. + + -p file, --program=file + Will program the file to flash. If the address is not + specified, it will use 0. If the size is not specified + it will use the file size. Otherwise it will limit to + the specified size (whatever is smaller). If used in + conjunction with any erase command, the erase will + take place first. + + -t, --tune + Just tune the flash controller & access size + Must be used in conjuction with --direct + (Implicit for all other operations) + + -c --clear + Used to ECC clear a partition of the flash + Must be used in conjunction with -P. Will erase the + partition and then set all the ECC bits as they should be + + -9 --ecc + Encode/Decode ECC where specified in the FFS header. + This 9 byte ECC method is used for some OpenPOWER + partitions. + -i, --info + Display some information about the flash. + + --detail + Displays detailed info about a particular partition. + Accepts a numeric partition or can be used in conjuction + with the -P flag. + + -h, --help + This message. + +About to erase 0x00000300..0x00000400 ! +WARNING ! This will modify your HOST flash chip content ! +Enter "yes" to confirm:Erasing... + +[ ] 0% +[= ] 1% +[= ] 2% +[== ] 3% +[== ] 4% +[=== ] 5% +[=== ] 6% +[==== ] 7% +[==== ] 8% +[===== ] 9% +[===== ] 10% +[====== ] 11% +[====== ] 12% +[======= ] 13% +[======= ] 14% +[======== ] 15% +[======== ] 16% +[========= ] 17% +[========= ] 18% +[========== ] 19% +[========== ] 20% +[=========== ] 21% +[=========== ] 22% +[============ ] 23% +[============ ] 24% +[============= ] 25% +[============= ] 26% +[============== ] 27% +[============== ] 28% +[=============== ] 29% +[=============== ] 30% +[================ ] 31% +[================ ] 32% +[================= ] 33% +[================= ] 34% +[================== ] 35% +[================== ] 36% +[=================== ] 37% +[=================== ] 38% +[==================== ] 39% +[==================== ] 40% +[===================== ] 41% +[===================== ] 42% +[====================== ] 43% +[====================== ] 44% +[======================= ] 45% +[======================= ] 46% +[======================== ] 47% +[======================== ] 48% +[========================= ] 49% +[========================= ] 50% +[========================== ] 51% +[========================== ] 52% +[=========================== ] 53% +[=========================== ] 54% +[============================ ] 55% +[============================ ] 56% +[============================= ] 57% +[============================= ] 58% +[============================== ] 59% +[============================== ] 60% +[=============================== ] 61% +[=============================== ] 62% +[================================ ] 63% +[================================ ] 64% +[================================= ] 65% +[================================= ] 66% +[================================== ] 67% +[================================== ] 68% +[=================================== ] 69% +[=================================== ] 70% +[==================================== ] 71% +[==================================== ] 72% +[===================================== ] 73% +[===================================== ] 74% +[====================================== ] 75% +[====================================== ] 76% +[======================================= ] 77% +[======================================= ] 78% +[======================================== ] 79% +[======================================== ] 80% +[========================================= ] 81% +[========================================= ] 82% +[========================================== ] 83% +[========================================== ] 84% +[=========================================== ] 85% +[=========================================== ] 86% +[============================================ ] 87% +[============================================ ] 88% +[============================================= ] 89% +[============================================= ] 90% +[============================================== ] 91% +[============================================== ] 92% +[=============================================== ] 93% +[=============================================== ] 94% +[================================================ ] 95% +[================================================ ] 96% +[================================================= ] 97% +[================================================= ] 98% +[==================================================] 99% +[==================================================] 100% +About to program "FILE" at 0x00000300..0x00000400 ! +Programming & Verifying... + +[ ] 0% +[==================================================] 100% diff --git a/roms/skiboot/external/pflash/test/results/06-miscprint.err b/roms/skiboot/external/pflash/test/results/06-miscprint.err new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/06-miscprint.err diff --git a/roms/skiboot/external/pflash/test/results/06-miscprint.out b/roms/skiboot/external/pflash/test/results/06-miscprint.out new file mode 100644 index 000000000..58a6b889c --- /dev/null +++ b/roms/skiboot/external/pflash/test/results/06-miscprint.out @@ -0,0 +1,54 @@ +Detailed partition information +Name: +PRESERVED (ID=01) + +Start End Actual +0x00003000 0x00004000 0x00001000 + +Flags: +PRESERVED [P] +Detailed partition information +Name: +READONLY (ID=02) + +Start End Actual +0x00004000 0x00005000 0x00001000 + +Flags: +READONLY [R] +Detailed partition information +Name: +REPROVISION (ID=03) + +Start End Actual +0x00005000 0x00006000 0x00001000 + +Flags: +REPROVISION [F] +Detailed partition information +Name: +BACKUP (ID=04) + +Start End Actual +0x00006000 0x00007000 0x00000000 + +Flags: +BACKUP [B] +Detailed partition information +Name: +VOLATILE (ID=05) + +Start End Actual +0x00007000 0x00008000 0x00001000 + +Flags: +VOLATILE [V] +Detailed partition information +Name: +CLEARECC (ID=06) + +Start End Actual +0x00008000 0x00009000 0x00001000 + +Flags: +CLEARECC [C] diff --git a/roms/skiboot/external/pflash/test/test-pflash b/roms/skiboot/external/pflash/test/test-pflash new file mode 100755 index 000000000..dd775bda3 --- /dev/null +++ b/roms/skiboot/external/pflash/test/test-pflash @@ -0,0 +1,59 @@ +#! /bin/sh + +. test/test.sh + +get_part_start() { + #We want to fail the test if the caller passed garbage + if [ "$#" -ne 2 ] || ! grep -q "$2" "$1" ; then + fail_test; + fi + grep "$2" "$1" | cut -f2 -d, | xargs printf "%d"; +} + +get_part_len() { + #We want to fail the test if the caller passed garbage + if [ "$#" -ne 2 ] || ! grep -q "$2" "$1" ; then + fail_test; + fi + grep "$2" "$1" | cut -f3 -d, | xargs printf "%d"; +} + +get_part_end() { + start=$(get_part_start "$1" "$2"); + len=$(get_part_len "$1" "$2"); + expr "$start" \+ "$len"; +} + +cmp_with_ff() { + if [ "$#" -ne 3 ] ; then + fail_test; + fi + file="$1"; + start="$2"; + len="$3"; + + blank=$(mktemp --tmpdir="$DATA_DIR" blank.pnorXXXXXX); + dd status=none if=/dev/zero bs="$len" count=1 | tr '\000' '\377' > "$blank" + cmp --bytes="$len" --ignore-initial="$start:0" "$file" "$blank"; + if [ "$?" -ne 0 ] ; then + fail_test; + fi + #fail_test; will trigger a cleanup straight away + rm $blank; +} + +#The reason for it is that this way there is a completely independant +#way of calculating checksums so if checksums fail, we can be +#confident its because libflash/libffs changed +update_checksum() { + if [ "$#" -ne 2 ] ; then + fail_test; + fi + file=$1; + part=$2; + dd if="$file" bs=1 skip="$part" count=124 status=none | perl -e 'use integer; binmode STDIN; binmode STDOUT; my $result=0; while (read STDIN, $word, 4) { $result = $result ^ unpack("N", $word); } print pack("N",$result)' | dd of="$file" seek="$(expr $part \+ 124)" bs=1 count=4 status=none conv=notrunc +} + +run_tests "test/tests/*" "test/results" "test/files" + + diff --git a/roms/skiboot/external/pflash/test/tests/00-usage b/roms/skiboot/external/pflash/test/tests/00-usage new file mode 100644 index 000000000..4c4ba2aa5 --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/00-usage @@ -0,0 +1,13 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +run_binary "./pflash" "-h" +if [ "$?" -ne 0 ] ; then + fail_test +fi + +strip_version_from_result "pflash" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/01-info b/roms/skiboot/external/pflash/test/tests/01-info new file mode 100644 index 000000000..583d275c4 --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/01-info @@ -0,0 +1,23 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +touch "$DATA_DIR/$CUR_TEST.pnor" + +# Don't record the output of ffspart +../ffspart/ffspart -s 0x1000 -c 10 -i "$DATA_DIR/$CUR_TEST.ffs" \ + -p "$DATA_DIR/$CUR_TEST.pnor" 2>&1 >/dev/null +if [ "$?" -ne 0 ] ; then + fail_test +fi + +run_binary "./pflash" "-F $DATA_DIR/$CUR_TEST.pnor --info" +if [ "$?" -ne 0 ] ; then + fail_test +fi + +#--info will print the name of the file which will change between runs +sed -i "s|$DATA_DIR/$CUR_TEST.pnor|FILE|" "$STDOUT_OUT" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/02-erase b/roms/skiboot/external/pflash/test/tests/02-erase new file mode 100644 index 000000000..f1db99266 --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/02-erase @@ -0,0 +1,27 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +touch "$DATA_DIR/$CUR_TEST.pnor" + +# Don't record the output of ffspart +../ffspart/ffspart -s 0x100 -c 10 -i "$DATA_DIR/$CUR_TEST.ffs" \ + -p "$DATA_DIR/$CUR_TEST.pnor" 2>&1 >/dev/null +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +yes yes | run_binary "./pflash" "-F $DATA_DIR/$CUR_TEST.pnor -E" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp_with_ff "$DATA_DIR/$CUR_TEST.pnor" 0 \ + "$(stat --printf="%s" "$DATA_DIR/$CUR_TEST.pnor")" + +# The test infrastructure will clean up but lets not chew unnecessarily +# though disk space +rm "$DATA_DIR/$CUR_TEST.pnor" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/03-erase-parts b/roms/skiboot/external/pflash/test/tests/03-erase-parts new file mode 100644 index 000000000..91b0a145e --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/03-erase-parts @@ -0,0 +1,56 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +touch "$DATA_DIR/$CUR_TEST.pnor" + +# Don't record the output of ffspart +../ffspart/ffspart -s 0x100 -c 10 -i "$DATA_DIR/$CUR_TEST.ffs" \ + -p "$DATA_DIR/$CUR_TEST.pnor" 2>&1 >/dev/null +if [ "$?" -ne 0 ] ; then + fail_test +fi + +cp "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test +fi + +#Let us all take a second to appreciate the fragility of this. +#The reason we need is that pflash -e will set the actual size of the +#partition to zero, which we'll do here. Examination determined that +#it will be at byte 216 in the file +dd if=/dev/zero of="$DATA_DIR/$CUR_TEST.bk" \ + bs=1 seek=216 count=4 conv=notrunc status=none + +#176 Should be where the FFS header for partition ONE starts +update_checksum "$DATA_DIR/$CUR_TEST.bk" "176"; + +yes yes | run_binary "./pflash" "-F $DATA_DIR/$CUR_TEST.pnor -e -P ONE" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +one_start=$(get_part_start "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_len=$(get_part_len "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_end=$(get_part_end "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +cmp_with_ff "$DATA_DIR/$CUR_TEST.pnor" "$one_start" "$one_len" + +cmp --bytes="$one_start" "$DATA_DIR/$CUR_TEST.pnor" \ + "$DATA_DIR/$CUR_TEST.bk"; +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --ignore-initial="$one_end" \ + --bytes="$(expr $(stat --printf="%s" "$DATA_DIR/$CUR_TEST.pnor") - "$one_end")" \ + "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +# The test infrastructure will clean up but lets no chew unnecessarily +# though disk space +rm "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/04-program-rand b/roms/skiboot/external/pflash/test/tests/04-program-rand new file mode 100644 index 000000000..fc8abb648 --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/04-program-rand @@ -0,0 +1,55 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +touch "$DATA_DIR/$CUR_TEST.pnor" + +# Don't record the output of ffspart +../ffspart/ffspart -s 0x100 -c 10 -i "$DATA_DIR/$CUR_TEST.ffs" \ + -p "$DATA_DIR/$CUR_TEST.pnor" 2>&1 >/dev/null +if [ "$?" -ne 0 ] ; then + fail_test +fi + +cp "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test +fi + +one_len=$(get_part_len "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_start=$(get_part_start "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_end=$(get_part_end "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +dd if=/dev/urandom bs="$one_len" count=1 of="$DATA_DIR/random" status=none + +yes yes | run_binary "./pflash" \ + "-F $DATA_DIR/$CUR_TEST.pnor -e -P ONE -p $DATA_DIR/random" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --ignore-initial="$one_start:0" --bytes="$one_len" \ + "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/random" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --bytes="$one_start" "$DATA_DIR/$CUR_TEST.pnor" \ + "$DATA_DIR/$CUR_TEST.bk"; +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --ignore-initial="$one_end" \ + --bytes="$(expr $(stat --printf="%s" "$DATA_DIR/$CUR_TEST.pnor") - "$one_end")" \ + "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +sed -i "s|$DATA_DIR/random|FILE|" "$STDOUT_OUT" + +# The test infrastructure will clean up but lets no chew unnecessarily +# though disk space +rm "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" "$DATA_DIR/random" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/05-bad-numbers b/roms/skiboot/external/pflash/test/tests/05-bad-numbers new file mode 100644 index 000000000..03cc39ebf --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/05-bad-numbers @@ -0,0 +1,66 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +touch "$DATA_DIR/$CUR_TEST.pnor" + +# Don't record the output of ffspart +../ffspart/ffspart -s 0x100 -c 10 -i "$DATA_DIR/$CUR_TEST.ffs" \ + -p "$DATA_DIR/$CUR_TEST.pnor" 2>&1 >/dev/null +if [ "$?" -ne 0 ] ; then + fail_test +fi + +cp "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test +fi + +one_len=$(get_part_len "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_start=$(get_part_start "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +one_end=$(get_part_end "$DATA_DIR/$CUR_TEST.ffs" "ONE"); +dd if=/dev/urandom bs="$one_len" count=1 of="$DATA_DIR/random" status=none + +#This should error out +run_binary "./pflash" \ + "-F $DATA_DIR/$CUR_TEST.pnor -e -a NOT_A_NUMBER -s ALSO_NOT_A_NUMBER" +if [ "$?" -eq 0 ] ; then + fail_test; +fi + +one_start_decimal=$(printf "%d" $one_start); +one_len_decimal=$(printf "%d" $one_len); +yes yes | run_binary "./pflash" \ + "-F $DATA_DIR/$CUR_TEST.pnor -e -a $one_start_decimal \ + -s $one_len_decimal -p $DATA_DIR/random" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --ignore-initial="$one_start:0" --bytes="$one_len" \ + "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/random" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --bytes="$one_start" "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk"; +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +cmp --ignore-initial="$one_end" \ + --bytes="$(expr $(stat --printf="%s" "$DATA_DIR/$CUR_TEST.pnor") - "$one_end")" \ + "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +sed -i "s|$DATA_DIR/random|FILE|" "$STDOUT_OUT" + +# The test infrastructure will clean up but lets no chew unnecessarily +# though disk space +rm "$DATA_DIR/$CUR_TEST.pnor" "$DATA_DIR/$CUR_TEST.bk" "$DATA_DIR/random" + +strip_version_from_result "pflash" + +diff_with_result + +pass_test diff --git a/roms/skiboot/external/pflash/test/tests/06-miscprint b/roms/skiboot/external/pflash/test/tests/06-miscprint new file mode 100644 index 000000000..bee84afc5 --- /dev/null +++ b/roms/skiboot/external/pflash/test/tests/06-miscprint @@ -0,0 +1,46 @@ +#! /bin/sh +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later + +touch "$DATA_DIR/$CUR_TEST.pnor" + +# Don't record the output of ffspart +../ffspart/ffspart -s 0x1000 -c 10 -i "$DATA_DIR/$CUR_TEST.ffs" \ + -p "$DATA_DIR/$CUR_TEST.pnor" 2>&1 >/dev/null +if [ "$?" -ne 0 ] ; then + fail_test +fi + +run_binary "./pflash" "--detail=1 -F $DATA_DIR/$CUR_TEST.pnor" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +run_binary "./pflash" "--detail=2 -F $DATA_DIR/$CUR_TEST.pnor" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +run_binary "./pflash" "--detail=3 -F $DATA_DIR/$CUR_TEST.pnor" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +run_binary "./pflash" "--detail=4 -F $DATA_DIR/$CUR_TEST.pnor" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +run_binary "./pflash" "--detail=5 -F $DATA_DIR/$CUR_TEST.pnor" +if [ "$?" -ne 0 ] ; then + fail_test; +fi +run_binary "./pflash" "--detail=6 -F $DATA_DIR/$CUR_TEST.pnor" +if [ "$?" -ne 0 ] ; then + fail_test; +fi + +# The test infrastructure will clean up but lets no chew unnecessarily +# though disk space +rm "$DATA_DIR/$CUR_TEST.pnor" + +strip_version_from_result "pflash" + +diff_with_result + +pass_test |