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 ticketlock_autotest(child, test_name):
137 child.sendline(test_name)
139 index = child.expect(["Test OK",
141 "Hello from core ([0-9]*) !",
142 "Hello from within recursive locks "
144 pexpect.TIMEOUT], timeout=5)
149 # message, check ordering
151 if int(child.match.groups()[0]) < i:
152 return -1, "Fail [Bad order]"
153 i = int(child.match.groups()[0])
155 if int(child.match.groups()[0]) < ir:
156 return -1, "Fail [Bad order]"
157 ir = int(child.match.groups()[0])
161 return -1, "Fail [Timeout]"
168 def logs_autotest(child, test_name):
169 child.sendline(test_name)
172 "TESTAPP1: error message",
173 "TESTAPP1: critical message",
174 "TESTAPP2: critical message",
175 "TESTAPP1: error message",
178 for log_msg in log_list:
179 index = child.expect([log_msg,
182 pexpect.TIMEOUT], timeout=10)
185 return -1, "Fail [Timeout]"
190 index = child.expect(["Test OK",
192 pexpect.TIMEOUT], timeout=10)
197 def timer_autotest(child, test_name):
198 child.sendline(test_name)
200 index = child.expect(["Start timer stress tests",
202 pexpect.TIMEOUT], timeout=5)
207 return -1, "Fail [Timeout]"
209 index = child.expect(["Start timer stress tests 2",
211 pexpect.TIMEOUT], timeout=5)
216 return -1, "Fail [Timeout]"
218 index = child.expect(["Start timer basic tests",
220 pexpect.TIMEOUT], timeout=5)
225 return -1, "Fail [Timeout]"
233 index = child.expect(["TESTTIMER: ([0-9]*): callback id=([0-9]*) "
234 "count=([0-9]*) on core ([0-9]*)",
237 pexpect.TIMEOUT], timeout=10)
245 return -1, "Fail [Timeout]"
248 id = int(child.match.groups()[1])
249 cnt = int(child.match.groups()[2])
250 lcore = int(child.match.groups()[3])
252 return -1, "Fail [Cannot parse]"
254 # timer0 always expires on the same core when cnt < 20
258 elif lcore != lcore_tim0 and cnt < 20:
259 return -1, "Fail [lcore != lcore_tim0 (%d, %d)]" \
260 % (lcore, lcore_tim0)
262 return -1, "Fail [tim0 cnt > 21]"
264 # timer1 each time expires on a different core
266 if lcore == lcore_tim1:
267 return -1, "Fail [lcore == lcore_tim1 (%d, %d)]" \
268 % (lcore, lcore_tim1)
271 return -1, "Fail [tim1 cnt > 30]"
273 # timer0 always expires on the same core
277 elif lcore != lcore_tim2:
278 return -1, "Fail [lcore != lcore_tim2 (%d, %d)]" \
279 % (lcore, lcore_tim2)
281 return -1, "Fail [tim2 cnt > 30]"
283 # timer0 always expires on the same core
287 elif lcore != lcore_tim3:
288 return -1, "Fail [lcore_tim3 changed (%d -> %d)]" \
289 % (lcore, lcore_tim3)
291 return -1, "Fail [tim3 cnt > 30]"
293 # must be 2 different cores
294 if lcore_tim0 == lcore_tim3:
295 return -1, "Fail [lcore_tim0 (%d) == lcore_tim3 (%d)]" \
296 % (lcore_tim0, lcore_tim3)
301 def ring_autotest(child, test_name):
302 child.sendline(test_name)
303 index = child.expect(["Test OK", "Test Failed",
304 pexpect.TIMEOUT], timeout=2)
308 return -1, "Fail [Timeout]"