From 90cb27276a2157c33323d48ff068e7ecf4821131 Mon Sep 17 00:00:00 2001 From: Joyce Kong Date: Mon, 15 Apr 2019 17:04:39 +0800 Subject: [PATCH] test/ticketlock: fix autotest Add ticketlock_autotest implementation in python. Fixes: efbcdaa55b93 ("test/ticketlock: add test cases") Signed-off-by: Joyce Kong Reviewed-by: Phil Yang Tested-by: Phil Yang --- app/test/autotest_data.py | 2 +- app/test/autotest_test_funcs.py | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py index db2527489e..72c56e5288 100644 --- a/app/test/autotest_data.py +++ b/app/test/autotest_data.py @@ -175,7 +175,7 @@ parallel_test_list = [ "Command": "ticketlock_autotest", "Func": ticketlock_autotest, "Report": None, - } + }, { "Name": "Byte order autotest", "Command": "byteorder_autotest", diff --git a/app/test/autotest_test_funcs.py b/app/test/autotest_test_funcs.py index 65fe335397..31cc0f5ee4 100644 --- a/app/test/autotest_test_funcs.py +++ b/app/test/autotest_test_funcs.py @@ -131,6 +131,40 @@ def rwlock_autotest(child, test_name): return 0, "Success" +def ticketlock_autotest(child, test_name): + i = 0 + ir = 0 + child.sendline(test_name) + while True: + index = child.expect(["Test OK", + "Test Failed", + "Hello from core ([0-9]*) !", + "Hello from within recursive locks " + "from ([0-9]*) !", + pexpect.TIMEOUT], timeout=5) + # ok + if index == 0: + break + + # message, check ordering + elif index == 2: + if int(child.match.groups()[0]) < i: + return -1, "Fail [Bad order]" + i = int(child.match.groups()[0]) + elif index == 3: + if int(child.match.groups()[0]) < ir: + return -1, "Fail [Bad order]" + ir = int(child.match.groups()[0]) + + # fail + elif index == 4: + return -1, "Fail [Timeout]" + elif index == 1: + return -1, "Fail" + + return 0, "Success" + + def logs_autotest(child, test_name): child.sendline(test_name) -- 2.20.1