labgrid icon indicating copy to clipboard operation
labgrid copied to clipboard

ubootdriver: allow handling of console output decoding errors

Open ynezz opened this issue 2 years ago • 1 comments

Description

ubootdriver: allow handling of console output decoding errors

Some buggy vendor bootloaders can output non ASCII characters to the serial console:

 00001e50  74 68 20 6e 61 6d 65 20  5b 58 38 36 5f 36 34 20  |th name [X86_64 |
 00001e60  4c 45 44 45 20 4c 69 6e  75 78 2d 73 73 68 5f 5f  |LEDE Linux-ssh__|
 00001e70  5f 67 69 74 5f 64 65 73  69 1f 8b 08 5d 0d 0d 0a  |_git_desi...]...|
                                       |
                                       `-- printf buffer overflow starts here

Which leads to the following decoding issue as the default error handler is set to strict:

    '', before.decode('utf-8'), count=1000000
 UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 6453: invalid start byte

So fix it by allowing overriding of console output decoding errors via new console_decodeerrors config option, so one could use for example backslashreplace decoding error handler.

Checklist

  • [x] Documentation for the feature
  • [x] The arguments and description in doc/configuration.rst have been updated
  • [x] CHANGES.rst has been updated
  • [x] PR has been tested

ynezz avatar Jun 25 '22 15:06 ynezz

Codecov Report

Merging #944 (7c65591) into master (5d78a63) will increase coverage by 0.0%. The diff coverage is 50.0%.

:exclamation: Current head 7c65591 differs from pull request most recent head 448837e. Consider uploading reports for the commit 448837e to get more accurate results

@@          Coverage Diff           @@
##           master    #944   +/-   ##
======================================
  Coverage    57.1%   57.1%           
======================================
  Files         150     150           
  Lines       11194   11195    +1     
======================================
+ Hits         6402    6403    +1     
  Misses       4792    4792           
Impacted Files Coverage Δ
labgrid/driver/smallubootdriver.py 43.9% <0.0%> (ø)
labgrid/driver/ubootdriver.py 61.3% <66.6%> (+0.3%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5d78a63...448837e. Read the comment docs.

codecov[bot] avatar Jun 25 '22 15:06 codecov[bot]