1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2014 Intel Corporation
8 # default autotest, used to run most tests
12 def default_autotest(child, test_name):
13 child.sendline(test_name)
14 result = child.expect(["Test OK", "Test Failed",
15 "Command not found", pexpect.TIMEOUT], timeout=900)
19 return -1, "Fail [Not found]"
21 return -1, "Fail [Timeout]"
24 # autotest used to run dump commands
25 # just fires the command
28 def dump_autotest(child, test_name):
29 child.sendline(test_name)
33 # reads output and waits for Test OK
36 def memory_autotest(child, test_name):
39 child.sendline(test_name)
41 regexp = "IOVA:0x[0-9a-f]*, len:([0-9]*), virt:0x[0-9a-f]*, " \
43 index = child.expect([regexp, "Test OK", "Test Failed",
44 pexpect.TIMEOUT], timeout=10)
46 return -1, "Fail [Timeout]"
53 size = int(child.match.groups()[0], 10)
58 return -1, "Fail [No entries]"
60 return -1, "Fail [{}]".format(error)
64 def spinlock_autotest(child, test_name):
67 child.sendline(test_name)
69 index = child.expect(["Test OK",
71 "Hello from core ([0-9]*) !",
72 "Hello from within recursive locks "
74 pexpect.TIMEOUT], timeout=5)
79 # message, check ordering
81 if int(child.match.groups()[0]) < i:
82 return -1, "Fail [Bad order]"
83 i = int(child.match.groups()[0])
85 if int(child.match.groups()[0]) < ir:
86 return -1, "Fail [Bad order]"
87 ir = int(child.match.groups()[0])
91 return -1, "Fail [Timeout]"
98 def rwlock_autotest(child, test_name):
100 child.sendline(test_name)
102 index = child.expect(["Test OK",
104 "Hello from core ([0-9]*) !",
105 "Global write lock taken on master "
107 pexpect.TIMEOUT], timeout=10)
111 return -1, "Fail [Message is missing]"
114 # message, check ordering
116 if int(child.match.groups()[0]) < i:
117 return -1, "Fail [Bad order]"
118 i = int(child.match.groups()[0])
120 # must be the last message, check ordering
125 return -1, "Fail [Timeout]"
134 def logs_autotest(child, test_name):
135 child.sendline(test_name)
138 "TESTAPP1: error message",
139 "TESTAPP1: critical message",
140 "TESTAPP2: critical message",
141 "TESTAPP1: error message",
144 for log_msg in log_list:
145 index = child.expect([log_msg,
148 pexpect.TIMEOUT], timeout=10)
151 return -1, "Fail [Timeout]"
156 index = child.expect(["Test OK",
158 pexpect.TIMEOUT], timeout=10)
163 def timer_autotest(child, test_name):
164 child.sendline(test_name)
166 index = child.expect(["Start timer stress tests",
168 pexpect.TIMEOUT], timeout=5)
173 return -1, "Fail [Timeout]"
175 index = child.expect(["Start timer stress tests 2",
177 pexpect.TIMEOUT], timeout=5)
182 return -1, "Fail [Timeout]"
184 index = child.expect(["Start timer basic tests",
186 pexpect.TIMEOUT], timeout=5)
191 return -1, "Fail [Timeout]"
199 index = child.expect(["TESTTIMER: ([0-9]*): callback id=([0-9]*) "
200 "count=([0-9]*) on core ([0-9]*)",
203 pexpect.TIMEOUT], timeout=10)
211 return -1, "Fail [Timeout]"
214 id = int(child.match.groups()[1])
215 cnt = int(child.match.groups()[2])
216 lcore = int(child.match.groups()[3])
218 return -1, "Fail [Cannot parse]"
220 # timer0 always expires on the same core when cnt < 20
224 elif lcore != lcore_tim0 and cnt < 20:
225 return -1, "Fail [lcore != lcore_tim0 (%d, %d)]" \
226 % (lcore, lcore_tim0)
228 return -1, "Fail [tim0 cnt > 21]"
230 # timer1 each time expires on a different core
232 if lcore == lcore_tim1:
233 return -1, "Fail [lcore == lcore_tim1 (%d, %d)]" \
234 % (lcore, lcore_tim1)
237 return -1, "Fail [tim1 cnt > 30]"
239 # timer0 always expires on the same core
243 elif lcore != lcore_tim2:
244 return -1, "Fail [lcore != lcore_tim2 (%d, %d)]" \
245 % (lcore, lcore_tim2)
247 return -1, "Fail [tim2 cnt > 30]"
249 # timer0 always expires on the same core
253 elif lcore != lcore_tim3:
254 return -1, "Fail [lcore_tim3 changed (%d -> %d)]" \
255 % (lcore, lcore_tim3)
257 return -1, "Fail [tim3 cnt > 30]"
259 # must be 2 different cores
260 if lcore_tim0 == lcore_tim3:
261 return -1, "Fail [lcore_tim0 (%d) == lcore_tim3 (%d)]" \
262 % (lcore_tim0, lcore_tim3)
267 def ring_autotest(child, test_name):
268 child.sendline(test_name)
269 index = child.expect(["Test OK", "Test Failed",
270 pexpect.TIMEOUT], timeout=2)
274 return -1, "Fail [Timeout]"