test/memory: fix autotest parsing

This patch fixes three problems in memory autotest:
 - the regex for IOVA
 - missing validation of second and following output lines
 - propagation of error to consecutive tests
 - conversion base for mem size (hex indtead of dec)
First fix is for changes introduced with IOVA, the regex was not
updated which lead to unit test failure.  Patch now also uses loop for
line outputs processing to verify more than just one line. By this we
also satisfy the pexpect() and scan the "Test OK"/"Test Failed" so in
case of error all output lines are consumed and does not break the
consecutive test (error does not propagate).

Fixes: 7ba49d39f1 ("mem: rename segment address from physical to IOVA")
Fixes: b4ce15aa2b ("app/test: fix memory autotest")

Signed-off-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
This commit is contained in:
Radoslaw Biernacki 2017-11-09 19:14:32 +01:00 committed by Thomas Monjalon
parent 71330483a1
commit f046826e76

View File

@ -62,21 +62,30 @@ def dump_autotest(child, test_name):
def memory_autotest(child, test_name): def memory_autotest(child, test_name):
lines = 0
error = ''
child.sendline(test_name) child.sendline(test_name)
regexp = "phys:0x[0-9a-f]*, len:([0-9]*), virt:0x[0-9a-f]*, " \ while True:
"socket_id:[0-9]*" regexp = "IOVA:0x[0-9a-f]*, len:([0-9]*), virt:0x[0-9a-f]*, " \
index = child.expect([regexp, pexpect.TIMEOUT], timeout=180) "socket_id:[0-9]*"
if index != 0: index = child.expect([regexp, "Test OK", "Test Failed",
return -1, "Fail [Timeout]" pexpect.TIMEOUT], timeout=10)
size = int(child.match.groups()[0], 16) if index == 3:
if size <= 0: return -1, "Fail [Timeout]"
return -1, "Fail [Bad size]" elif index == 1:
index = child.expect(["Test OK", "Test Failed", break
pexpect.TIMEOUT], timeout=10) elif index == 2:
if index == 1: return -1, "Fail"
return -1, "Fail" else:
elif index == 2: lines = lines + 1
return -1, "Fail [Timeout]" size = int(child.match.groups()[0], 10)
if size <= 0:
error = 'Bad size'
if lines <= 0:
return -1, "Fail [No entries]"
if error != '':
return -1, "Fail [{}]".format(error)
return 0, "Success" return 0, "Success"