(Note: this builds on a single patch left over from a recent series, which
is why it is v2. That patch refactored the code but did not add tests.)

bootm's decompression functions currently have tests in the
'test_compression' unit test command, but this calls the decompression
routines directly and is more aimed at ensuring that they never overwrite
their output buffer.

But bootm is critical code and it is important that test coverage be
adequate for the task it performs. Existing tests in test/image provide
some coverage, but not for decompression.

This series adds a new unit test specifically for bootm's decompression.
It tests that bootm deals correctly with a normal decompress, a case where
there is insufficient output buffer space, and a case where part of the
data is corrupted.

Previously the uncompressed case had no error checking, so this is added.
This is a change in behaviour so I hope it will not cause problems.

The current error message on failure is confusing, since it is unclear
whether the image is too large or the data is corrupt. This is improved
and patches added to make sure we can distinguish these two cases for
each decompression method in most situations.

The existing 'Must RESET board to recover' message is retained, but this
is likely to be unnecessary, since all decompressions routines are, I
believe, careful not to overwrite their output buffer even in the case
of corrupted data. It may be desirable to remove it later.

The output of the new sandbox 'ut_image_decomp' command is below:

Testing: gzip compressed
   Uncompressing Kernel Image ... OK
   Uncompressing Kernel Image ... Error: inflate() returned -5
Image too large: increase CONFIG_SYS_BOOTM_LEN
Must RESET board to recover
   Uncompressing Kernel Image ... Error: inflate() returned -5
Image too large: increase CONFIG_SYS_BOOTM_LEN
Must RESET board to recover
Testing: bzip2 compressed
   Uncompressing Kernel Image ... OK
   Uncompressing Kernel Image ... Image too large: increase CONFIG_SYS_BOOTM_LEN
Must RESET board to recover
   Uncompressing Kernel Image ... bzip2 compressed: uncompress error -4
Must RESET board to recover
Testing: lzma compressed
   Uncompressing Kernel Image ... OK
   Uncompressing Kernel Image ... Image too large: increase CONFIG_SYS_BOOTM_LEN
Must RESET board to recover
   Uncompressing Kernel Image ... lzma compressed: uncompress error 1
Must RESET board to recover
Testing: lzo compressed
   Uncompressing Kernel Image ... OK
   Uncompressing Kernel Image ... Image too large: increase CONFIG_SYS_BOOTM_LEN
Must RESET board to recover
   Uncompressing Kernel Image ... lzo compressed: uncompress error -6
Must RESET board to recover
Testing: uncompressed
   Loading Kernel Image ... OK
   Loading Kernel Image ... Image too large: increase CONFIG_SYS_BOOTM_LEN
Must RESET board to recover
ut_image_decomp ok

Changes in v2:
- Add tests to cover the code changes
- Correct the overflow check for bzip2

Simon Glass (12):
  lzma: fix buffer bound check error further
  bootm: Move compression progress/error messages into a function
  sandbox: Correct ordering of 'sb save' commands
  test: Add DEBUG output option to test-fit.py
  bootm: Export bootm_decomp_image()
  test: Rename test_compression to ut_compression
  test: Add unit tests for bootm image decompression
  bootm: Use print_decomp_msg() in all cases
  bootm: Factor out common parts of image decompression code
  bzlib: Update destLen even on error
  gunzip: Update lenp even on error
  lzo: Update dst_len even on error

 common/bootm.c             | 150 ++++++++++++++++++++++++++-------------------
 common/cmd_sandbox.c       |   2 +-
 include/bootm.h            |  17 +++++
 lib/bzlib.c                |   2 +-
 lib/gunzip.c               |   7 ++-
 lib/lzma/LzmaTools.c       |   4 +-
 lib/lzo/lzo1x_decompress.c |   4 +-
 test/compression.c         |  93 ++++++++++++++++++++++++++--
 test/dm/sf.c               |   2 +-
 test/image/test-fit.py     |  16 ++++-
 10 files changed, 218 insertions(+), 79 deletions(-)

-- 
2.2.0.rc0.207.ga3a616c

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to