support/testing: do not print non-utf-8 chars on cbor test
authorRicardo Martincoski <ricardo.martincoski@gmail.com>
Thu, 8 Aug 2019 23:10:12 +0000 (20:10 -0300)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Sun, 11 Aug 2019 20:11:55 +0000 (22:11 +0200)
The python-cbor sample script to be run on the target dumps a binary
variable to the target stdout. This is done for debug purposes-only, in
the case the test on test infra fails.
This non-utf-8 is currently silently ignored by the Emulator class /
pexpect.spawn from the test infra because the infra uses Python 2, that
in turn do not differentiate between string and byte data.

Make the code Python3-friendly (Python 3 in the host) by doing the right
thing and encoding the data before printing it.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
support/testing/tests/package/sample_python_cbor_enc.py

index 1bde92bb9f0e7952247d349fd8a0ce596b88c693..31d937d4b891a92c2a892398d100119597f00be1 100644 (file)
@@ -9,6 +9,6 @@ data = {
     }
 }
 serialized = cbor.dumps(data)
-print(serialized)
+print(serialized.decode(errors="ignore"))
 with open("/tmp/data.cbor", "wb") as f:
     f.write(serialized)