aboutsummaryrefslogtreecommitdiff
path: root/libflash/test
AgeCommit message (Collapse)AuthorFilesLines
2017-12-18libflash/test: Add tests for mbox-flashCyril Bur6-7/+966
A first basic set of tests for mbox-flash. These tests do their testing by stubbing out or otherwise replacing functions not in libflash/mbox-flash.c. The stubbed out version of the function can then be used to emulate a BMC mbox daemon talking to back to the code in mbox-flash and it can ensure that there is some adherence to the protocol and that from a blocklevel api point of view the world appears sane. This makes these tests simple to run and they have been integrated into `make check`. The down side is that these tests rely on duplicated feature incomplete BMC daemon behaviour. Therefore these tests are a strong indicator of broken behaviour but a very unreliable indicator of correctness. Full integration tests with a 'real' BMC daemon are probably beyond the scope of this repository. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> [stewart: fix TESTS_LOOPS printf] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-08-24libflash/test/test-blocklevel: fix memory leak on exitStewart Smith1-0/+2
==8304==ERROR: LeakSanitizer: detected memory leaks Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7f70eda8f850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x408ba0 in main libflash/test/test-blocklevel.c:298 #2 0x7f70ec8e1509 in __libc_start_main (/lib64/libc.so.6+0x20509) Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-08-24libflash/test/test-flash.c: fix memory leak on exitStewart Smith1-0/+1
LeakSanitizer spotted this: Direct leak of 131072 byte(s) in 1 object(s) allocated from: #0 0x7fb99e42b850 in malloc (/lib64/libasan.so.4+0xde850) #1 0x408612 in main libflash/test/test-flash.c:380 #2 0x7fb99d27d509 in __libc_start_main (/lib64/libc.so.6+0x20509) Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-08-01external/pflash: tests: Move the test-miscprint to pflash testsCyril Bur3-32/+2
New code that is very much pflash functionality was added in commit f2c87a3d2f6 "pflash option to retrieve PNOR partition flags". Unfortunately at the time there wasn't an easy way to test pflash. The previous patch adds pflash infrastructure and plumbs it into `make check` nicely. This commit converts the tests originally added to libflash tests. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-08-01libflash: Adding debugging outputCyril Bur1-0/+2
Also add usage text to pflash. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-07-19pflash option to retrieve PNOR partition flagsMichael Tritz3-2/+32
This commit extends pflash with an option to retrieve and print information for a particular partition, including the content from "pflash -i" and a verbose list of set miscellaneous flags. -i option is also updated to print a short list of flags in addition to the ECC flag, with one character per flag. A test of the new option is included in libflash/test. Signed-off-by: Michael Tritz <mtritz@us.ibm.com> Reviewed-by: Cyril Bur <cyril.bur@au1.ibm.com> [stewart@linux.vnet.ibm.com: various test fixes, enable gcov] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-04-07libflash: Add tests for blocklevel_smart_erase()Cyril Bur1-2/+225
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-11libflash/blocklevel: Allow double ecc protecting a regionCyril Bur1-12/+42
Currently the policy for calling ECC protecting a range at the blocklevel layer is that the requested region be completely unprotected otherwise the call will return an error. It turns out that duplicate calls to ffs_init() with true as the last parameter (for the same blocklevel structure) will cause duplicate attempts to ecc_protect() ranges. Change the policy within blocklevel to allow duplicate protecting. In fact the new policy almost guarantees no failure (baring something odd like malloc() failing). It will detect that the range is currently already fully protected and do nothing, detect that part of the range is or is not and extend the existing range or detect that a range fits perfectly between two ranges in which case it will merge the ranges. Also adjust tests to match the new policy. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-09-02consolidate gcov flags into HOSTGCOVFLAGS for host binariesStewart Smith1-1/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-02flash: Make size 64 bit safeMichael Neuling2-3/+4
This makes the size of flash 64 bit safe so that we can have flash devices greater than 4GB. This is especially useful for mambo disks passed through to Linux. Fortunately the device tree interface and the linux device driver are 64bit safe so no changes are required there. Userspace gard and flash tools are also updated to ensure "make check" still passes. Signed-off-by: Michael Neuling <mikey@neuling.org> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-12make check: make test runs less noisyStewart Smith1-2/+2
Run a small wrapper around some unit tests with the QTEST makefile macro (QTEST=Quiet TEST). Also, wrap boot tests in mambo and qemu to be quiet by default. Both ./test/run.sh and the modified mambo/qemu test runner scripts output full stdout and stderr in the event of error. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-03-30*/test/*: Added '<subdir>-check' make targetsOliver O'Halloran1-2/+5
Currently these exist for some parts of the source tree, but not all of it. They're nice if you are only modifing code in a one part of the tree as the full test suite can be a little slow. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-08libflash/test: Attempted fix of Coverity defect 98799Cyril Bur1-1/+1
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-08libflash/test: Fix Coverity defect 98827Cyril Bur1-1/+1
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-28libflash: Return a pointer to internal structure.Cyril Bur1-1/+1
There are some functions (notably: erase_chip and set_4b_mode) which cannot be abstracted away by the blocklevel interface, this means that if they are really needed (by pflash for example) then at the moment a program like pflash would need to pass a blocklevel_device struct to libflash. This forces libflash to trust that it was given a blocklevel that it did init. If it didn't init it the container_of call will return junk and libflash has no way to protect its self. This method (while very useful) has destroyed type safety. As such, this commit reintroduces some typesafety back into this stack. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-23libflash/blocklevel: Extend the block level to be able to do eccCyril Bur2-2/+185
At the moment ECC reads and writes are still being handled by the low level core of libflash. ECC should be none of libflashes concern, it is primarily a hardware access backend. It makes sense for blocklevel to take care of ECC but currently it has no way of knowing. With some simple modifications (which are rudimentary at the moment and will need a performance improvement) blocklevel can handle ECC, and with a little more effort this can be extended to provide read and write protection in blocklevel. Reviewed-By: Alistair Popple <alistair@popple.id.au> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-23libflash/ecc: Simplify and cleanup ecc code.Cyril Bur1-8/+8
The ecc 'memcpy' style functions return success or fail in terms of the ECC enum. This doesn't really make sense, use true or false. As the result the ecc enum doesn't need to be exposed anymore, which makes more sense, not clear why it was exposed in the first place. Convert some of the ecc #defines to static inlines, shouldn't make any difference but feels safer. Fix minor stylistic and typo issues. Reviewed-By: Alistair Popple <alistair@popple.id.au> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-09libflash: start using the blocklevel interface.Cyril Bur1-10/+10
Converted all the libflash calls to use the blocklevel interface, modified all callers to libflash to use the blocklevel interface. This patch should introduce next to no functional change. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-04-18libflash: remove *.d files tests/ during make cleanCyril Bur1-1/+2
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-03-17libflash: Improved ECC interfaceCyril Bur3-2/+532
This patch is twofold. 1. Improves the low level ecc memcpy code to better specify that we're reading/writing buffers with ecc bytes. 2. Improves/creates the libflash interfaces for ecc. This patch also includes some tests Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-26libflash: move ffs_flash_read into libflashJeremy Kerr2-1/+2
We have ffs_flash_read to do optionally-ecc-ed reads of flash data. However, this isn't really related to the ffs partitioning. This change moves ffs_flash_read into libflash.c, named flash_read_corrected. The function itself isn't changed. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-12-19Exclude all test cases from coverage-reportStewart Smith1-0/+2
This way we get a true representation from the lcov coverage-report about what firmware code we're testing (besides, test cases are always going to only have 50% of branches hit - we're asserting the tests pass!) Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-12-19Pretty print make check and coverage outputStewart Smith1-5/+5
Can still get the details with V=1, just like normal make. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-12-15Fix makefile dependency generation, especially for HOSTCCStewart Smith1-1/+1
Instead of having individual rules to generate .d, add -MMD to HOSTCC parameters, and just include the generated .d files. This fixes a few weird dependency issues. Also, make the mambo hello_kernel test depend on skiboot.lid Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-10-22Preliminary code coverage reporting infrastructureStewart Smith1-1/+12
Add support in core/test/Makefile.check to build -gcov binaries (with -lgcov and -fprofile-blah-blah) as well as some targets for producing lcov HTML code coverage reports. As part of this, I had to fix up an oddity in run-mem_region_init where that due to running under Valgrind, we'd be malloc()ed a heap with a small address, well inside the mem_regions we added but when not running under valgrind (e.g. for code coverage reporting) we would get a much larger address, outside this range and hit an assert. So, after fiddling with the memory stuff for this test, I think I have it right - it passes both under valgrind and not and does produce code coverage data. Currently, we're at this level of code coverage by unit tests: Hit Total Coverage Lines: 1936 2574 75.2 % Functions: 177 225 78.7 % Branches: 1243 2360 52.7 % The totals should largely be ignored due to the only code being counted is that linked into the unit tests (total LOC is ~50kLOC according to sloccount... so unit tests currently cover < 5%) Try the "make coverage-report" target, you'll get coverage-report directory with a LCOV HTML report Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-07-02Initial commit of Open Source releaseBenjamin Herrenschmidt3-0/+454
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>