From 9d075a728a448b3cb65ac51a2f0f749f0d54e058 Mon Sep 17 00:00:00 2001 From: He Yin Ling Date: Mon, 5 Jul 2021 20:19:00 +0800 Subject: [PATCH] ttfw: fix incorrect length when flush data cache after expect: data cache is unicode. while we use bytes in RegEx expect. The index of matched pattern is calculated with bytes, could be different from unicode. Now we fix this issue by using unicode in expect. --- tools/tiny-test-fw/DUT.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/tiny-test-fw/DUT.py b/tools/tiny-test-fw/DUT.py index 36d373ae38..76b2fa244c 100644 --- a/tools/tiny-test-fw/DUT.py +++ b/tools/tiny-test-fw/DUT.py @@ -543,13 +543,11 @@ class BaseDUT(object): :return: match groups if match succeed otherwise None """ ret = None - if isinstance(pattern.pattern, type(u'')): - pattern = re.compile(BaseDUT.u_to_bytearray(pattern.pattern)) - if isinstance(data, type(u'')): - data = BaseDUT.u_to_bytearray(data) + if isinstance(pattern.pattern, bytes): + pattern = re.compile(_decode_data(pattern.pattern)) match = pattern.search(data) if match: - ret = tuple(None if x is None else x.decode() for x in match.groups()) + ret = tuple(x for x in match.groups()) index = match.end() else: index = -1