Test for select, poll and epoll syscall overrides
[lttng-tools.git] / tests / regression / kernel / validate_select_poll_epoll.py
1 #!/usr/bin/env python3
2
3 import sys
4 import time
5 import argparse
6
7 NSEC_PER_SEC = 1000000000
8
9 try:
10 from babeltrace import TraceCollection
11 except ImportError:
12 # quick fix for debian-based distros
13 sys.path.append("/usr/local/lib/python%d.%d/site-packages" %
14 (sys.version_info.major, sys.version_info.minor))
15 from babeltrace import TraceCollection
16
17
18 class TraceParser:
19 def __init__(self, trace, pid):
20 self.trace = trace
21 self.pid = pid
22 self.expect = {}
23
24 def ns_to_hour_nsec(self, ns):
25 d = time.localtime(ns/NSEC_PER_SEC)
26 return "%02d:%02d:%02d.%09d" % (d.tm_hour, d.tm_min, d.tm_sec,
27 ns % NSEC_PER_SEC)
28
29 def parse(self):
30 # iterate over all the events
31 for event in self.trace.events:
32 if self.pid is not None and event["pid"] != self.pid:
33 continue
34
35 method_name = "handle_%s" % event.name.replace(":", "_").replace(
36 "+", "_")
37 # call the function to handle each event individually
38 if hasattr(TraceParser, method_name):
39 func = getattr(TraceParser, method_name)
40 func(self, event)
41
42 ret = 0
43 for i in self.expect.keys():
44 if self.expect[i] == 0:
45 print("%s not validated" % i)
46 ret = 1
47
48 return ret
49
50 # epoll_ctl
51 def handle_compat_syscall_entry_epoll_ctl(self, event):
52 self.epoll_ctl_entry(event)
53
54 def handle_compat_syscall_exit_epoll_ctl(self, event):
55 self.epoll_ctl_exit(event)
56
57 def handle_syscall_entry_epoll_ctl(self, event):
58 self.epoll_ctl_entry(event)
59
60 def handle_syscall_exit_epoll_ctl(self, event):
61 self.epoll_ctl_exit(event)
62
63 def epoll_ctl_entry(self, event):
64 pass
65
66 def epoll_ctl_exit(self, event):
67 pass
68
69 # epoll_wait + epoll_pwait
70 def handle_compat_syscall_entry_epoll_wait(self, event):
71 self.epoll_wait_entry(event)
72
73 def handle_compat_syscall_exit_epoll_wait(self, event):
74 self.epoll_wait_exit(event)
75
76 def handle_syscall_entry_epoll_wait(self, event):
77 self.epoll_wait_entry(event)
78
79 def handle_syscall_exit_epoll_wait(self, event):
80 self.epoll_wait_exit(event)
81
82 def handle_compat_syscall_entry_epoll_pwait(self, event):
83 self.epoll_wait_entry(event)
84
85 def handle_compat_syscall_exit_epoll_pwait(self, event):
86 self.epoll_wait_exit(event)
87
88 def handle_syscall_entry_epoll_pwait(self, event):
89 self.epoll_wait_entry(event)
90
91 def handle_syscall_exit_epoll_pwait(self, event):
92 self.epoll_wait_exit(event)
93
94 def epoll_wait_entry(self, event):
95 pass
96
97 def epoll_wait_exit(self, event):
98 pass
99
100 ## poll + ppoll
101 def handle_compat_syscall_entry_poll(self, event):
102 self.poll_entry(event)
103
104 def handle_compat_syscall_exit_poll(self, event):
105 self.poll_exit(event)
106
107 def handle_syscall_entry_poll(self, event):
108 self.poll_entry(event)
109
110 def handle_syscall_exit_poll(self, event):
111 self.poll_exit(event)
112
113 def handle_compat_syscall_entry_ppoll(self, event):
114 self.poll_entry(event)
115
116 def handle_compat_syscall_exit_ppoll(self, event):
117 self.poll_exit(event)
118
119 def handle_syscall_entry_ppoll(self, event):
120 self.poll_entry(event)
121
122 def handle_syscall_exit_ppoll(self, event):
123 self.poll_exit(event)
124
125 def poll_entry(self, event):
126 pass
127
128 def poll_exit(self, event):
129 pass
130
131 # epoll_create
132 def handle_compat_syscall_entry_epoll_create1(self, event):
133 self.epoll_create_entry(event)
134
135 def handle_compat_syscall_exit_epoll_create1(self, event):
136 self.epoll_create_exit(event)
137
138 def handle_compat_syscall_entry_epoll_create(self, event):
139 self.epoll_create_entry(event)
140
141 def handle_compat_syscall_exit_epoll_create(self, event):
142 self.epoll_create_exit(event)
143
144 def handle_syscall_entry_epoll_create1(self, event):
145 self.epoll_create_entry(event)
146
147 def handle_syscall_exit_epoll_create1(self, event):
148 self.epoll_create_exit(event)
149
150 def handle_syscall_entry_epoll_create(self, event):
151 self.epoll_create_entry(event)
152
153 def handle_syscall_exit_epoll_create(self, event):
154 self.epoll_create_exit(event)
155
156 def epoll_create_entry(self, event):
157 pass
158
159 def epoll_create_exit(self, event):
160 pass
161
162 # select + pselect6
163 def handle_syscall_entry_pselect6(self, event):
164 self.select_entry(event)
165
166 def handle_syscall_exit_pselect6(self, event):
167 self.select_exit(event)
168
169 def handle_compat_syscall_entry_pselect6(self, event):
170 self.select_entry(event)
171
172 def handle_compat_syscall_exit_pselect6(self, event):
173 self.select_exit(event)
174
175 def handle_syscall_entry_select(self, event):
176 self.select_entry(event)
177
178 def handle_syscall_exit_select(self, event):
179 self.select_exit(event)
180
181 def handle_compat_syscall_entry_select(self, event):
182 self.select_entry(event)
183
184 def handle_compat_syscall_exit_select(self, event):
185 self.select_exit(event)
186
187 def select_entry(self, event):
188 pass
189
190 def select_exit(self, event):
191 pass
192
193
194 class Test1(TraceParser):
195 def __init__(self, trace, pid):
196 super().__init__(trace, pid)
197 self.expect["select_in_fd0"] = 0
198 self.expect["select_in_fd1023"] = 0
199 self.expect["select_out_fd0"] = 0
200 self.expect["select_out_fd1023"] = 0
201 self.expect["poll_in_nfds1"] = 0
202 self.expect["poll_out_nfds1"] = 0
203 self.expect["epoll_ctl_in_add"] = 0
204 self.expect["epoll_ctl_out_ok"] = 0
205 self.expect["epoll_wait_in_ok"] = 0
206 self.expect["epoll_wait_out_fd0"] = 0
207
208 def select_entry(self, event):
209 timestamp = event.timestamp
210 cpu_id = event["cpu_id"]
211 n = event["n"]
212 overflow = event["overflow"]
213 tvp = event["tvp"]
214 _readfds_length = event["_readfds_length"]
215 readfds = event["readfds"]
216 _writefds_length = event["_writefds_length"]
217 writefds = event["writefds"]
218 _exceptfds_length = event["_exceptfds_length"]
219 exceptfds = event["exceptfds"]
220
221 # check that the FD 0 is actually set in the readfds
222 if n == 1 and readfds[0] == 1:
223 self.expect["select_in_fd0"] = 1
224 if n == 1023:
225 # check that the FD 1023 is actually set in the readfds
226 if readfds[127] == 0x40 and writefds[127] == 0 and \
227 exceptfds[127] == 0 and overflow == 0:
228 self.expect["select_in_fd1023"] = 1
229
230 def select_exit(self, event):
231 timestamp = event.timestamp
232 cpu_id = event["cpu_id"]
233 ret = event["ret"]
234 overflow = event["overflow"]
235 tvp = event["tvp"]
236 _readfds_length = event["_readfds_length"]
237 readfds = event["readfds"]
238 _writefds_length = event["_writefds_length"]
239 writefds = event["writefds"]
240 _exceptfds_length = event["_exceptfds_length"]
241 exceptfds = event["exceptfds"]
242
243 if ret == 1:
244 # check that the FD 0 is actually set in the readfds
245 if readfds[0] == 1:
246 self.expect["select_out_fd0"] = 1
247 # check that the FD 1023 is actually set in the readfds
248 if _readfds_length == 128 and readfds[127] == 0x40 and \
249 writefds[127] == 0 and exceptfds[127] == 0 and tvp == 0:
250 self.expect["select_out_fd1023"] = 1
251
252 def poll_entry(self, event):
253 timestamp = event.timestamp
254 cpu_id = event["cpu_id"]
255 nfds = event["nfds"]
256 fds_length = event["fds_length"]
257 overflow = event["overflow"]
258 fds = event["fds"]
259
260 # check that only one FD is set, that it has the POLLIN flag and that
261 # the raw value matches the events bit field.
262 if nfds == 1 and fds_length == 1 and fds[0]["raw_events"] == 0x3 \
263 and fds[0]["events"]["POLLIN"] == 1 and \
264 fds[0]["events"]["padding"] == 0:
265 self.expect["poll_in_nfds1"] = 1
266
267 def poll_exit(self, event):
268 timestamp = event.timestamp
269 cpu_id = event["cpu_id"]
270 ret = event["ret"]
271 nfds = event["nfds"]
272 fds_length = event["fds_length"]
273 fds = event["fds"]
274
275 # check that only one FD is set, that it has the POLLIN flag and that
276 # the raw value matches the events bit field.
277 if ret == 1 and fds_length == 1 and fds[0]["raw_events"] == 0x1 \
278 and fds[0]["events"]["POLLIN"] == 1 and \
279 fds[0]["events"]["padding"] == 0:
280 self.expect["poll_out_nfds1"] = 1
281
282 def epoll_ctl_entry(self, event):
283 timestamp = event.timestamp
284 cpu_id = event["cpu_id"]
285 epfd = event["epfd"]
286 op_enum = event["op_enum"]
287 fd = event["fd"]
288 _event = event["event"]
289
290 # check that we have FD 0 waiting for EPOLLIN|EPOLLPRI and that
291 # data.fd = 0
292 if epfd == 3 and op_enum == "EPOLL_CTL_ADD" and fd == 0 and \
293 _event["data_union"]["fd"] == 0 and \
294 _event["events"]["EPOLLIN"] == 1 and \
295 _event["events"]["EPOLLPRI"] == 1:
296 self.expect["epoll_ctl_in_add"] = 1
297
298 def epoll_ctl_exit(self, event):
299 timestamp = event.timestamp
300 cpu_id = event["cpu_id"]
301 ret = event["ret"]
302
303 if ret == 0:
304 self.expect["epoll_ctl_out_ok"] = 1
305
306 def epoll_wait_entry(self, event):
307 timestamp = event.timestamp
308 cpu_id = event["cpu_id"]
309 epfd = event["epfd"]
310 maxevents = event["maxevents"]
311 timeout = event["timeout"]
312
313 if epfd == 3 and maxevents == 1 and timeout == -1:
314 self.expect["epoll_wait_in_ok"] = 1
315
316 def epoll_wait_exit(self, event):
317 timestamp = event.timestamp
318 cpu_id = event["cpu_id"]
319 ret = event["ret"]
320 fds_length = event["fds_length"]
321 overflow = event["overflow"]
322 fds = event["fds"]
323
324 # check that FD 0 returned with EPOLLIN and the right data.fd
325 if ret == 1 and fds_length == 1 and overflow == 0 and \
326 fds[0]["data_union"]["fd"] == 0 and \
327 fds[0]["events"]["EPOLLIN"] == 1:
328 self.expect["epoll_wait_out_fd0"] = 1
329
330
331 class Test2(TraceParser):
332 def __init__(self, trace, pid):
333 super().__init__(trace, pid)
334 self.expect["select_timeout_in_fd0"] = 0
335 self.expect["select_timeout_in_fd1023"] = 0
336 self.expect["select_timeout_out"] = 0
337 self.expect["poll_timeout_in"] = 0
338 self.expect["poll_timeout_out"] = 0
339 self.expect["epoll_ctl_timeout_in_add"] = 0
340 self.expect["epoll_ctl_timeout_out_ok"] = 0
341 self.expect["epoll_wait_timeout_in"] = 0
342 self.expect["epoll_wait_timeout_out"] = 0
343
344 def select_entry(self, event):
345 timestamp = event.timestamp
346 cpu_id = event["cpu_id"]
347 n = event["n"]
348 overflow = event["overflow"]
349 tvp = event["tvp"]
350 _readfds_length = event["_readfds_length"]
351 readfds = event["readfds"]
352 _writefds_length = event["_writefds_length"]
353 writefds = event["writefds"]
354 _exceptfds_length = event["_exceptfds_length"]
355 exceptfds = event["exceptfds"]
356
357 if n == 1 and tvp != 0:
358 self.expect["select_timeout_in_fd0"] = 1
359 if n == 1023:
360 if readfds[127] == 0x40 and writefds[127] == 0 and \
361 exceptfds[127] == 0 and tvp != 0:
362 self.expect["select_timeout_in_fd1023"] = 1
363
364 def select_exit(self, event):
365 timestamp = event.timestamp
366 cpu_id = event["cpu_id"]
367 ret = event["ret"]
368 overflow = event["overflow"]
369 tvp = event["tvp"]
370 _readfds_length = event["_readfds_length"]
371 readfds = event["readfds"]
372 _writefds_length = event["_writefds_length"]
373 writefds = event["writefds"]
374 _exceptfds_length = event["_exceptfds_length"]
375 exceptfds = event["exceptfds"]
376
377 if ret == 0 and tvp != 0:
378 self.expect["select_timeout_out"] = 1
379
380 def poll_entry(self, event):
381 timestamp = event.timestamp
382 cpu_id = event["cpu_id"]
383 nfds = event["nfds"]
384 fds_length = event["fds_length"]
385 overflow = event["overflow"]
386 fds = event["fds"]
387
388 # check that we wait on FD 0 for POLLIN and that the raw_events
389 # field matches the value of POLLIN
390 if nfds == 1 and fds_length == 1 and fds[0]["raw_events"] == 0x3 \
391 and fds[0]["events"]["POLLIN"] == 1 and \
392 fds[0]["events"]["padding"] == 0:
393 self.expect["poll_timeout_in"] = 1
394
395 def poll_exit(self, event):
396 timestamp = event.timestamp
397 cpu_id = event["cpu_id"]
398 ret = event["ret"]
399 nfds = event["nfds"]
400 fds_length = event["fds_length"]
401 fds = event["fds"]
402
403 if ret == 0 and nfds == 1 and fds_length == 0:
404 self.expect["poll_timeout_out"] = 1
405
406 def epoll_ctl_entry(self, event):
407 timestamp = event.timestamp
408 cpu_id = event["cpu_id"]
409 epfd = event["epfd"]
410 op_enum = event["op_enum"]
411 fd = event["fd"]
412 _event = event["event"]
413
414 # make sure we see a EPOLLIN|EPOLLPRI
415 if op_enum == "EPOLL_CTL_ADD" and \
416 _event["events"]["EPOLLIN"] == 1 and \
417 _event["events"]["EPOLLPRI"] == 1:
418 self.expect["epoll_ctl_timeout_in_add"] = 1
419
420 def epoll_ctl_exit(self, event):
421 timestamp = event.timestamp
422 cpu_id = event["cpu_id"]
423 ret = event["ret"]
424
425 if ret == 0:
426 self.expect["epoll_ctl_timeout_out_ok"] = 1
427
428 def epoll_wait_entry(self, event):
429 timestamp = event.timestamp
430 cpu_id = event["cpu_id"]
431 epfd = event["epfd"]
432 maxevents = event["maxevents"]
433 timeout = event["timeout"]
434
435 if maxevents == 1 and timeout == 1:
436 self.expect["epoll_wait_timeout_in"] = 1
437
438 def epoll_wait_exit(self, event):
439 timestamp = event.timestamp
440 cpu_id = event["cpu_id"]
441 ret = event["ret"]
442 fds_length = event["fds_length"]
443 overflow = event["overflow"]
444 fds = event["fds"]
445
446 if ret == 0 and fds_length == 0 and overflow == 0:
447 self.expect["epoll_wait_timeout_out"] = 1
448
449
450 class Test3(TraceParser):
451 def __init__(self, trace, pid):
452 super().__init__(trace, pid)
453 self.expect["select_too_big_in"] = 0
454 self.expect["select_too_big_out"] = 0
455
456 def select_entry(self, event):
457 timestamp = event.timestamp
458 cpu_id = event["cpu_id"]
459 n = event["n"]
460 overflow = event["overflow"]
461 tvp = event["tvp"]
462 _readfds_length = event["_readfds_length"]
463 readfds = event["readfds"]
464 _writefds_length = event["_writefds_length"]
465 writefds = event["writefds"]
466 _exceptfds_length = event["_exceptfds_length"]
467 exceptfds = event["exceptfds"]
468
469 # make sure an invalid value still produces a valid event
470 if n == 2048 and overflow == 0 and _readfds_length == 0:
471 self.expect["select_too_big_in"] = 1
472
473 def select_exit(self, event):
474 timestamp = event.timestamp
475 cpu_id = event["cpu_id"]
476 ret = event["ret"]
477 overflow = event["overflow"]
478 tvp = event["tvp"]
479 _readfds_length = event["_readfds_length"]
480 readfds = event["readfds"]
481 _writefds_length = event["_writefds_length"]
482 writefds = event["writefds"]
483 _exceptfds_length = event["_exceptfds_length"]
484 exceptfds = event["exceptfds"]
485
486 # make sure an invalid value still produces a valid event
487 if ret == -9 and overflow == 0 and _readfds_length == 0:
488 self.expect["select_too_big_out"] = 1
489
490
491 class Test4(TraceParser):
492 def __init__(self, trace, pid):
493 super().__init__(trace, pid)
494 self.expect["big_poll_in"] = 0
495 self.expect["big_poll_out"] = 0
496
497 def poll_entry(self, event):
498 timestamp = event.timestamp
499 cpu_id = event["cpu_id"]
500 nfds = event["nfds"]
501 fds_length = event["fds_length"]
502 overflow = event["overflow"]
503 fds = event["fds"]
504
505 # test of big list of FDs and the behaviour of the overflow
506 if nfds == 2047 and fds_length == 512 and overflow == 1 and \
507 fds[0]["raw_events"] == 0x3 \
508 and fds[0]["events"]["POLLIN"] == 1 and \
509 fds[0]["events"]["padding"] == 0 and \
510 fds[511]["events"]["POLLIN"] == 1 and \
511 fds[511]["events"]["POLLPRI"] == 1:
512 self.expect["big_poll_in"] = 1
513
514 def poll_exit(self, event):
515 timestamp = event.timestamp
516 cpu_id = event["cpu_id"]
517 ret = event["ret"]
518 nfds = event["nfds"]
519 fds_length = event["fds_length"]
520 overflow = event["overflow"]
521 fds = event["fds"]
522
523 # test of big list of FDs and the behaviour of the overflow
524 if ret == 2047 and nfds == 2047 and fds_length == 512 and \
525 overflow == 1 and fds[0]["events"]["POLLIN"] == 1 and \
526 fds[511]["events"]["POLLIN"] == 1:
527 self.expect["big_poll_out"] = 1
528
529
530 class Test5(TraceParser):
531 def __init__(self, trace, pid):
532 super().__init__(trace, pid)
533 self.expect["poll_overflow_in"] = 0
534 self.expect["poll_overflow_out"] = 0
535
536 def poll_entry(self, event):
537 timestamp = event.timestamp
538 cpu_id = event["cpu_id"]
539 nfds = event["nfds"]
540 fds_length = event["fds_length"]
541 overflow = event["overflow"]
542 fds = event["fds"]
543
544 # test that event in valid even though the target buffer is too small
545 # and the program segfaults
546 if nfds == 100 and fds_length == 100 and overflow == 0 and \
547 fds[0]["events"]["POLLIN"] == 1:
548 self.expect["poll_overflow_in"] = 1
549
550 def poll_exit(self, event):
551 timestamp = event.timestamp
552 cpu_id = event["cpu_id"]
553 ret = event["ret"]
554 nfds = event["nfds"]
555 fds_length = event["fds_length"]
556 overflow = event["overflow"]
557 fds = event["fds"]
558
559 # test that event in valid even though the target buffer is too small
560 # and the program segfaults
561 if nfds == 100 and overflow == 0:
562 self.expect["poll_overflow_out"] = 1
563
564
565 class Test6(TraceParser):
566 def __init__(self, trace, pid):
567 super().__init__(trace, pid)
568 self.expect["pselect_invalid_in"] = 0
569 self.expect["pselect_invalid_out"] = 0
570
571 def select_entry(self, event):
572 timestamp = event.timestamp
573 cpu_id = event["cpu_id"]
574 n = event["n"]
575 overflow = event["overflow"]
576 tvp = event["tvp"]
577 _readfds_length = event["_readfds_length"]
578 readfds = event["readfds"]
579 _writefds_length = event["_writefds_length"]
580 writefds = event["writefds"]
581 _exceptfds_length = event["_exceptfds_length"]
582 exceptfds = event["exceptfds"]
583
584 # test that event in valid even though the target buffer pointer is
585 # invalid and the program segfaults
586 if n == 1 and overflow == 0 and _readfds_length == 0:
587 self.expect["pselect_invalid_in"] = 1
588
589 def select_exit(self, event):
590 timestamp = event.timestamp
591 cpu_id = event["cpu_id"]
592 ret = event["ret"]
593 overflow = event["overflow"]
594 tvp = event["tvp"]
595 _readfds_length = event["_readfds_length"]
596 readfds = event["readfds"]
597 _writefds_length = event["_writefds_length"]
598 writefds = event["writefds"]
599 _exceptfds_length = event["_exceptfds_length"]
600 exceptfds = event["exceptfds"]
601
602 # test that event in valid even though the target buffer pointer is
603 # invalid and the program segfaults
604 if ret == -14 and overflow == 0 and _readfds_length == 0:
605 self.expect["pselect_invalid_out"] = 1
606
607
608 class Test7(TraceParser):
609 def __init__(self, trace, pid):
610 super().__init__(trace, pid)
611 self.expect["poll_max_in"] = 0
612 self.expect["poll_max_out"] = 0
613
614 def poll_entry(self, event):
615 timestamp = event.timestamp
616 cpu_id = event["cpu_id"]
617 nfds = event["nfds"]
618 fds_length = event["fds_length"]
619 overflow = event["overflow"]
620 fds = event["fds"]
621
622 # check the proper working of INT_MAX maxevent value
623 if nfds == 4294967295 and overflow == 1:
624 self.expect["poll_max_in"] = 1
625
626 def poll_exit(self, event):
627 timestamp = event.timestamp
628 cpu_id = event["cpu_id"]
629 ret = event["ret"]
630 nfds = event["nfds"]
631 fds_length = event["fds_length"]
632 overflow = event["overflow"]
633 fds = event["fds"]
634
635 # check the proper working of UINT_MAX maxevent value
636 if ret == -22 and nfds == 4294967295 and overflow == 0:
637 self.expect["poll_max_out"] = 1
638
639
640 class Test8(TraceParser):
641 def __init__(self, trace, pid):
642 super().__init__(trace, pid)
643 self.expect["epoll_wait_invalid_in"] = 0
644 self.expect["epoll_wait_invalid_out"] = 0
645
646 def epoll_wait_entry(self, event):
647 timestamp = event.timestamp
648 cpu_id = event["cpu_id"]
649 epfd = event["epfd"]
650 maxevents = event["maxevents"]
651 timeout = event["timeout"]
652
653 # test that event in valid even though the target buffer pointer is
654 # invalid and the program segfaults
655 if epfd == 3 and maxevents == 1 and timeout == -1:
656 self.expect["epoll_wait_invalid_in"] = 1
657
658 def epoll_wait_exit(self, event):
659 timestamp = event.timestamp
660 cpu_id = event["cpu_id"]
661 ret = event["ret"]
662 fds_length = event["fds_length"]
663 overflow = event["overflow"]
664 fds = event["fds"]
665
666 # test that event in valid even though the target buffer pointer is
667 # invalid and the program segfaults
668 if ret == -14 and fds_length == 0 and overflow == 0:
669 self.expect["epoll_wait_invalid_out"] = 1
670
671
672 class Test9(TraceParser):
673 def __init__(self, trace, pid):
674 super().__init__(trace, pid)
675 self.expect["epoll_wait_max_in"] = 0
676 self.expect["epoll_wait_max_out"] = 0
677
678 def epoll_wait_entry(self, event):
679 timestamp = event.timestamp
680 cpu_id = event["cpu_id"]
681 epfd = event["epfd"]
682 maxevents = event["maxevents"]
683 timeout = event["timeout"]
684
685 # check the proper working of INT_MAX maxevent value
686 if epfd == 3 and maxevents == 2147483647 and timeout == -1:
687 self.expect["epoll_wait_max_in"] = 1
688
689 def epoll_wait_exit(self, event):
690 timestamp = event.timestamp
691 cpu_id = event["cpu_id"]
692 ret = event["ret"]
693 fds_length = event["fds_length"]
694 overflow = event["overflow"]
695 fds = event["fds"]
696
697 # check the proper working of INT_MAX maxevent value
698 if ret == -22 and fds_length == 0 and overflow == 0:
699 self.expect["epoll_wait_max_out"] = 1
700
701
702 if __name__ == "__main__":
703 parser = argparse.ArgumentParser(description='Trace parser')
704 parser.add_argument('path', metavar="<path/to/trace>", help='Trace path')
705 parser.add_argument('-t', '--test', type=int, help='Test to validate')
706 parser.add_argument('-p', '--pid', type=int, help='PID of the app')
707 args = parser.parse_args()
708
709 if not args.test:
710 print("Need to pass a test to validate (-t)")
711 sys.exit(1)
712
713 if not args.pid:
714 print("Need to pass the PID to check (-p)")
715 sys.exit(1)
716
717 traces = TraceCollection()
718 handle = traces.add_traces_recursive(args.path, "ctf")
719 if handle is None:
720 sys.exit(1)
721
722 t = None
723
724 if args.test == 1:
725 t = Test1(traces, args.pid)
726 elif args.test == 2:
727 t = Test2(traces, args.pid)
728 elif args.test == 3:
729 t = Test3(traces, args.pid)
730 elif args.test == 4:
731 t = Test4(traces, args.pid)
732 elif args.test == 5:
733 t = Test5(traces, args.pid)
734 elif args.test == 6:
735 t = Test6(traces, args.pid)
736 elif args.test == 7:
737 t = Test7(traces, args.pid)
738 elif args.test == 8:
739 t = Test8(traces, args.pid)
740 elif args.test == 9:
741 t = Test9(traces, args.pid)
742 elif args.test == 10:
743 # stress test, nothing reliable to check
744 ret = 0
745 elif args.test == 11:
746 # stress test, nothing reliable to check
747 ret = 0
748 else:
749 print("Invalid test case")
750 sys.exit(1)
751
752 if t is not None:
753 ret = t.parse()
754
755 for h in handle.values():
756 traces.remove_trace(h)
757
758 sys.exit(ret)
This page took 0.049236 seconds and 6 git commands to generate.