3 # Copyright (C) 2016 Julien Desfossez <jdesfossez@efficios.com>
5 # SPDX-License-Identifier: GPL-2.0-only
13 from collections
import defaultdict
18 # quick fix for debian-based distros
19 sys
.path
.append("/usr/local/lib/python%d.%d/site-packages" %
20 (sys
.version_info
.major
, sys
.version_info
.minor
))
23 NSEC_PER_SEC
= 1000000000
26 def __init__(self
, trace_msg_iter
, pid
):
27 self
.trace
= trace_msg_iter
30 # This dictionnary holds the results of each testcases of a test.
31 # Its layout is the following:
33 # 'event_name_1': {'check_1': 0, 'check_2: 1},
34 # 'event_name_2': {'check_1': 1}
36 # Each test classes checks the payload of different events. Each of
37 # those checks are stored in a event_name specific dictionnary in this
39 self
.expect
= defaultdict(lambda : defaultdict(int))
41 # This dictionnary holds the value recorded in the trace that are
42 # tested. Its content is use to print the values that caused a test to
44 self
.recorded_values
= {}
46 def ns_to_hour_nsec(self
, ns
):
47 d
= time
.localtime(ns
/NSEC_PER_SEC
)
48 return "%02d:%02d:%02d.%09d" % (d
.tm_hour
, d
.tm_min
, d
.tm_sec
,
52 # iterate over all the events
53 for msg
in self
.trace
:
54 if type(msg
) is not bt2
._EventMessageConst
:
57 if self
.pid
is not None and msg
.event
["pid"] != self
.pid
:
60 method_name
= "handle_%s" % msg
.event
.name
.replace(":", "_").replace(
62 # call the function to handle each event individually
63 if hasattr(TraceParser
, method_name
):
64 func
= getattr(TraceParser
, method_name
)
68 # For each event of the test case, check all entries for failed
69 for event_name
, event_results
in self
.expect
.items():
70 for val
in event_results
.keys():
71 if self
.expect
[event_name
][val
] == 0:
72 print("%s not validated" % val
)
73 print("Values of the local variables of this test:")
74 # using pprint for pretty printing the dictionnary
75 pprint
.pprint(self
.recorded_values
[event_name
])
81 def handle_compat_syscall_entry_epoll_ctl(self
, event
):
82 self
.epoll_ctl_entry(event
)
84 def handle_compat_syscall_exit_epoll_ctl(self
, event
):
85 self
.epoll_ctl_exit(event
)
87 def handle_syscall_entry_epoll_ctl(self
, event
):
88 self
.epoll_ctl_entry(event
)
90 def handle_syscall_exit_epoll_ctl(self
, event
):
91 self
.epoll_ctl_exit(event
)
93 def epoll_ctl_entry(self
, event
):
96 def epoll_ctl_exit(self
, event
):
99 # epoll_wait + epoll_pwait
100 def handle_compat_syscall_entry_epoll_wait(self
, event
):
101 self
.epoll_wait_entry(event
)
103 def handle_compat_syscall_exit_epoll_wait(self
, event
):
104 self
.epoll_wait_exit(event
)
106 def handle_syscall_entry_epoll_wait(self
, event
):
107 self
.epoll_wait_entry(event
)
109 def handle_syscall_exit_epoll_wait(self
, event
):
110 self
.epoll_wait_exit(event
)
112 def handle_compat_syscall_entry_epoll_pwait(self
, event
):
113 self
.epoll_wait_entry(event
)
115 def handle_compat_syscall_exit_epoll_pwait(self
, event
):
116 self
.epoll_wait_exit(event
)
118 def handle_syscall_entry_epoll_pwait(self
, event
):
119 self
.epoll_wait_entry(event
)
121 def handle_syscall_exit_epoll_pwait(self
, event
):
122 self
.epoll_wait_exit(event
)
124 def epoll_wait_entry(self
, event
):
127 def epoll_wait_exit(self
, event
):
131 def handle_compat_syscall_entry_poll(self
, event
):
132 self
.poll_entry(event
)
134 def handle_compat_syscall_exit_poll(self
, event
):
135 self
.poll_exit(event
)
137 def handle_syscall_entry_poll(self
, event
):
138 self
.poll_entry(event
)
140 def handle_syscall_exit_poll(self
, event
):
141 self
.poll_exit(event
)
143 def handle_compat_syscall_entry_ppoll(self
, event
):
144 self
.poll_entry(event
)
146 def handle_compat_syscall_exit_ppoll(self
, event
):
147 self
.poll_exit(event
)
149 def handle_syscall_entry_ppoll(self
, event
):
150 self
.poll_entry(event
)
152 def handle_syscall_exit_ppoll(self
, event
):
153 self
.poll_exit(event
)
155 def poll_entry(self
, event
):
158 def poll_exit(self
, event
):
162 def handle_compat_syscall_entry_epoll_create1(self
, event
):
163 self
.epoll_create_entry(event
)
165 def handle_compat_syscall_exit_epoll_create1(self
, event
):
166 self
.epoll_create_exit(event
)
168 def handle_compat_syscall_entry_epoll_create(self
, event
):
169 self
.epoll_create_entry(event
)
171 def handle_compat_syscall_exit_epoll_create(self
, event
):
172 self
.epoll_create_exit(event
)
174 def handle_syscall_entry_epoll_create1(self
, event
):
175 self
.epoll_create_entry(event
)
177 def handle_syscall_exit_epoll_create1(self
, event
):
178 self
.epoll_create_exit(event
)
180 def handle_syscall_entry_epoll_create(self
, event
):
181 self
.epoll_create_entry(event
)
183 def handle_syscall_exit_epoll_create(self
, event
):
184 self
.epoll_create_exit(event
)
186 def epoll_create_entry(self
, event
):
189 def epoll_create_exit(self
, event
):
193 def handle_syscall_entry_pselect6(self
, event
):
194 self
.select_entry(event
)
196 def handle_syscall_exit_pselect6(self
, event
):
197 self
.select_exit(event
)
199 def handle_compat_syscall_entry_pselect6(self
, event
):
200 self
.select_entry(event
)
202 def handle_compat_syscall_exit_pselect6(self
, event
):
203 self
.select_exit(event
)
205 def handle_syscall_entry_select(self
, event
):
206 self
.select_entry(event
)
208 def handle_syscall_exit_select(self
, event
):
209 self
.select_exit(event
)
211 def handle_compat_syscall_entry_select(self
, event
):
212 self
.select_entry(event
)
214 def handle_compat_syscall_exit_select(self
, event
):
215 self
.select_exit(event
)
217 def select_entry(self
, event
):
220 def select_exit(self
, event
):
224 class Test1(TraceParser
):
225 def __init__(self
, trace
, pid
):
226 super().__init
__(trace
, pid
)
227 self
.expect
["select_entry"]["select_in_fd0"] = 0
228 self
.expect
["select_entry"]["select_in_fd1023"] = 0
229 self
.expect
["select_exit"]["select_out_fd0"] = 0
230 self
.expect
["select_exit"]["select_out_fd1023"] = 0
231 self
.expect
["poll_entry"]["poll_in_nfds1"] = 0
232 self
.expect
["poll_exit"]["poll_out_nfds1"] = 0
233 self
.expect
["epoll_ctl_entry"]["epoll_ctl_in_add"] = 0
234 self
.expect
["epoll_ctl_exit"]["epoll_ctl_out_ok"] = 0
235 self
.expect
["epoll_wait_entry"]["epoll_wait_in_ok"] = 0
236 self
.expect
["epoll_wait_exit"]["epoll_wait_out_fd0"] = 0
238 def select_entry(self
, event
):
240 overflow
= event
["overflow"]
241 readfd_0
= event
["readfds"][0]
243 # check that the FD 0 is actually set in the readfds
244 if n
== 1 and readfd_0
== 1:
245 self
.expect
["select_entry"]["select_in_fd0"] = 1
247 readfd_127
= event
["readfds"][127]
248 writefd_127
= event
["writefds"][127]
249 exceptfd_127
= event
["exceptfds"][127]
251 # check that the FD 1023 is actually set in the readfds
252 if readfd_127
== 0x40 and writefd_127
== 0 and \
253 exceptfd_127
== 0 and overflow
== 0:
254 self
.expect
["select_entry"]["select_in_fd1023"] = 1
256 # Save values of local variables to print in case of test failure
257 self
.recorded_values
["select_entry"] = locals()
259 def select_exit(self
, event
):
262 overflow
= event
["overflow"]
263 _readfds_length
= event
["_readfds_length"]
266 # check that the FD 0 is actually set in the readfds
267 readfd_0
= event
["readfds"][0]
270 self
.expect
["select_exit"]["select_out_fd0"] = 1
271 # check that the FD 1023 is actually set in the readfds
272 if _readfds_length
== 128:
273 readfd_127
= event
["readfds"][127]
274 writefd_127
= event
["writefds"][127]
275 exceptfd_127
= event
["exceptfds"][127]
276 if readfd_127
== 0x40 and writefd_127
== 0 and \
277 exceptfd_127
== 0 and tvp
== 0:
278 self
.expect
["select_exit"]["select_out_fd1023"] = 1
280 # Save values of local variables to print in case of test failure
281 self
.recorded_values
["select_exit"] = locals()
283 def poll_entry(self
, event
):
285 fds_length
= event
["fds_length"]
286 overflow
= event
["overflow"]
288 # check that only one FD is set, that it has the POLLIN flag and that
289 # the raw value matches the events bit field.
290 if nfds
== 1 and fds_length
== 1:
291 fd_0
= event
["fds"][0]
292 if fd_0
["raw_events"] == 0x3 and fd_0
["events"]["POLLIN"] == 1 and \
293 fd_0
["events"]["padding"] == 0:
294 self
.expect
["poll_entry"]["poll_in_nfds1"] = 1
296 # Save values of local variables to print in case of test failure
297 self
.recorded_values
["poll_entry"] = locals()
299 def poll_exit(self
, event
):
301 fds_length
= event
["fds_length"]
303 # check that only one FD is set, that it has the POLLIN flag and that
304 # the raw value matches the events bit field.
305 if ret
== 1 and fds_length
== 1:
306 fd_0
= event
["fds"][0]
307 if fd_0
["raw_events"] == 0x1 and fd_0
["events"]["POLLIN"] == 1 and \
308 fd_0
["events"]["padding"] == 0:
309 self
.expect
["poll_exit"]["poll_out_nfds1"] = 1
311 # Save values of local variables to print in case of test failure
312 self
.recorded_values
["poll_exit"] = locals()
314 def epoll_ctl_entry(self
, event
):
316 op_enum
= event
["op_enum"]
318 _event
= event
["event"]
320 # check that we have FD 0 waiting for EPOLLIN|EPOLLPRI and that
322 if epfd
== 3 and 'EPOLL_CTL_ADD' in op_enum
.labels
and fd
== 0 and \
323 _event
["data_union"]["fd"] == 0 and \
324 _event
["events"]["EPOLLIN"] == 1 and \
325 _event
["events"]["EPOLLPRI"] == 1:
326 self
.expect
["epoll_ctl_entry"]["epoll_ctl_in_add"] = 1
328 # Save values of local variables to print in case of test failure
329 self
.recorded_values
["epoll_ctl_entry"] = locals()
331 def epoll_ctl_exit(self
, event
):
335 self
.expect
["epoll_ctl_exit"]["epoll_ctl_out_ok"] = 1
337 # Save values of local variables to print in case of test failure
338 self
.recorded_values
["epoll_ctl_exit"] = locals()
340 def epoll_wait_entry(self
, event
):
342 maxevents
= event
["maxevents"]
343 timeout
= event
["timeout"]
345 if epfd
== 3 and maxevents
== 1 and timeout
== -1:
346 self
.expect
["epoll_wait_entry"]["epoll_wait_in_ok"] = 1
348 # Save values of local variables to print in case of test failure
349 self
.recorded_values
["epoll_wait_entry"] = locals()
351 def epoll_wait_exit(self
, event
):
353 fds_length
= event
["fds_length"]
354 overflow
= event
["overflow"]
356 # check that FD 0 returned with EPOLLIN and the right data.fd
357 if ret
== 1 and fds_length
== 1:
358 fd_0
= event
["fds"][0]
359 if overflow
== 0 and fd_0
["data_union"]["fd"] == 0 and \
360 fd_0
["events"]["EPOLLIN"] == 1:
361 self
.expect
["epoll_wait_exit"]["epoll_wait_out_fd0"] = 1
363 # Save values of local variables to print in case of test failure
364 self
.recorded_values
["epoll_wait_exit"] = locals()
367 class Test2(TraceParser
):
368 def __init__(self
, trace
, pid
):
369 super().__init
__(trace
, pid
)
370 self
.expect
["select_entry"]["select_timeout_in_fd0"] = 0
371 self
.expect
["select_entry"]["select_timeout_in_fd1023"] = 0
372 self
.expect
["select_exit"]["select_timeout_out"] = 0
373 self
.expect
["poll_entry"]["poll_timeout_in"] = 0
374 self
.expect
["poll_exit"]["poll_timeout_out"] = 0
375 self
.expect
["epoll_ctl_entry"]["epoll_ctl_timeout_in_add"] = 0
376 self
.expect
["epoll_ctl_exit"]["epoll_ctl_timeout_out_ok"] = 0
377 self
.expect
["epoll_wait_entry"]["epoll_wait_timeout_in"] = 0
378 self
.expect
["epoll_wait_exit"]["epoll_wait_timeout_out"] = 0
380 def select_entry(self
, event
):
384 if n
== 1 and tvp
!= 0:
385 self
.expect
["select_entry"]["select_timeout_in_fd0"] = 1
387 readfd_127
= event
["readfds"][127]
388 writefd_127
= event
["writefds"][127]
389 exceptfd_127
= event
["exceptfds"][127]
391 if readfd_127
== 0x40 and writefd_127
== 0 and \
392 exceptfd_127
== 0 and tvp
!= 0:
393 self
.expect
["select_entry"]["select_timeout_in_fd1023"] = 1
395 # Save values of local variables to print in case of test failure
396 self
.recorded_values
["select_entry"] = locals()
398 def select_exit(self
, event
):
402 if ret
== 0 and tvp
!= 0:
403 self
.expect
["select_exit"]["select_timeout_out"] = 1
405 # Save values of local variables to print in case of test failure
406 self
.recorded_values
["select_exit"] = locals()
408 def poll_entry(self
, event
):
410 fds_length
= event
["fds_length"]
412 # check that we wait on FD 0 for POLLIN and that the raw_events
413 # field matches the value of POLLIN
414 if nfds
== 1 and fds_length
== 1:
415 fd_0
= event
["fds"][0]
416 if fd_0
["raw_events"] == 0x3 and \
417 fd_0
["events"]["POLLIN"] == 1 and \
418 fd_0
["events"]["padding"] == 0:
419 self
.expect
["poll_entry"]["poll_timeout_in"] = 1
421 # Save values of local variables to print in case of test failure
422 self
.recorded_values
["poll_entry"] = locals()
424 def poll_exit(self
, event
):
427 fds_length
= event
["fds_length"]
429 if ret
== 0 and nfds
== 1 and fds_length
== 0:
430 self
.expect
["poll_exit"]["poll_timeout_out"] = 1
432 # Save values of local variables to print in case of test failure
433 self
.recorded_values
["poll_exit"] = locals()
435 def epoll_ctl_entry(self
, event
):
436 op_enum
= event
["op_enum"]
437 _event
= event
["event"]
439 # make sure we see a EPOLLIN|EPOLLPRI
440 if 'EPOLL_CTL_ADD' in op_enum
.labels
and \
441 _event
["events"]["EPOLLIN"] == 1 and \
442 _event
["events"]["EPOLLPRI"] == 1:
443 self
.expect
["epoll_ctl_entry"]["epoll_ctl_timeout_in_add"] = 1
445 # Save values of local variables to print in case of test failure
446 self
.recorded_values
["epoll_ctl_entry"] = locals()
448 def epoll_ctl_exit(self
, event
):
452 self
.expect
["epoll_ctl_exit"]["epoll_ctl_timeout_out_ok"] = 1
454 # Save values of local variables to print in case of test failure
455 self
.recorded_values
["epoll_ctl_exit"] = locals()
457 def epoll_wait_entry(self
, event
):
458 maxevents
= event
["maxevents"]
459 timeout
= event
["timeout"]
461 if maxevents
== 1 and timeout
== 1:
462 self
.expect
["epoll_wait_entry"]["epoll_wait_timeout_in"] = 1
464 # Save values of local variables to print in case of test failure
465 self
.recorded_values
["epoll_wait_entry"] = locals()
467 def epoll_wait_exit(self
, event
):
469 fds_length
= event
["fds_length"]
470 overflow
= event
["overflow"]
472 if ret
== 0 and fds_length
== 0 and overflow
== 0:
473 self
.expect
["epoll_wait_exit"]["epoll_wait_timeout_out"] = 1
475 # Save values of local variables to print in case of test failure
476 self
.recorded_values
["epoll_wait_exit"] = locals()
479 class Test3(TraceParser
):
480 def __init__(self
, trace
, pid
):
481 super().__init
__(trace
, pid
)
482 self
.expect
["select_entry"]["select_invalid_fd_in"] = 0
483 self
.expect
["select_exit"]["select_invalid_fd_out"] = 0
485 def select_entry(self
, event
):
487 overflow
= event
["overflow"]
489 if n
> 0 and overflow
== 0:
490 self
.expect
["select_entry"]["select_invalid_fd_in"] = 1
492 # Save values of local variables to print in case of test failure
493 self
.recorded_values
["select_entry"] = locals()
495 def select_exit(self
, event
):
497 overflow
= event
["overflow"]
498 _readfds_length
= event
["_readfds_length"]
500 # make sure the event has a ret field equal to -EBADF
501 if ret
== -9 and overflow
== 0 and _readfds_length
== 0:
502 self
.expect
["select_exit"]["select_invalid_fd_out"] = 1
504 # Save values of local variables to print in case of test failure
505 self
.recorded_values
["select_exit"] = locals()
508 class Test4(TraceParser
):
509 def __init__(self
, trace
, pid
):
510 super().__init
__(trace
, pid
)
511 self
.expect
["poll_entry"]["big_poll_in"] = 0
512 self
.expect
["poll_exit"]["big_poll_out"] = 0
514 def poll_entry(self
, event
):
516 fds_length
= event
["fds_length"]
517 overflow
= event
["overflow"]
519 # test of big list of FDs and the behaviour of the overflow
520 if nfds
== 2047 and fds_length
== 512 and overflow
== 1:
521 fd_0
= event
["fds"][0]
522 fd_511
= event
["fds"][511]
523 if fd_0
["raw_events"] == 0x3 and fd_0
["events"]["POLLIN"] == 1 and \
524 fd_0
["events"]["padding"] == 0 and \
525 fd_511
["events"]["POLLIN"] == 1 and \
526 fd_511
["events"]["POLLPRI"] == 1:
527 self
.expect
["poll_entry"]["big_poll_in"] = 1
529 # Save values of local variables to print in case of test failure
530 self
.recorded_values
["poll_entry"] = locals()
532 def poll_exit(self
, event
):
535 fds_length
= event
["fds_length"]
536 overflow
= event
["overflow"]
538 # test of big list of FDs and the behaviour of the overflow
539 if ret
== 2047 and nfds
== 2047 and fds_length
== 512 and overflow
== 1:
540 fd_0
= event
["fds"][0]
541 fd_511
= event
["fds"][511]
542 if fd_0
["events"]["POLLIN"] == 1 and fd_511
["events"]["POLLIN"] == 1:
543 self
.expect
["poll_exit"]["big_poll_out"] = 1
545 # Save values of local variables to print in case of test failure
546 self
.recorded_values
["poll_exit"] = locals()
548 class Test5(TraceParser
):
549 def __init__(self
, trace
, pid
):
550 super().__init
__(trace
, pid
)
551 self
.expect
["poll_entry"]["poll_overflow_in"] = 0
552 self
.expect
["poll_exit"]["poll_overflow_out"] = 0
554 def poll_entry(self
, event
):
556 fds_length
= event
["fds_length"]
557 overflow
= event
["overflow"]
559 # test that event in valid even though the target buffer is too small
560 # and the program segfaults
561 if nfds
== 100 and fds_length
== 100 and overflow
== 0:
562 fd_0
= event
["fds"][0]
563 if fd_0
["events"]["POLLIN"] == 1:
564 self
.expect
["poll_entry"]["poll_overflow_in"] = 1
566 # Save values of local variables to print in case of test failure
567 self
.recorded_values
["poll_entry"] = locals()
569 def poll_exit(self
, event
):
571 overflow
= event
["overflow"]
573 # test that event in valid even though the target buffer is too small
574 # and the program segfaults
575 if nfds
== 100 and overflow
== 0:
576 self
.expect
["poll_exit"]["poll_overflow_out"] = 1
578 # Save values of local variables to print in case of test failure
579 self
.recorded_values
["poll_exit"] = locals()
582 class Test6(TraceParser
):
583 def __init__(self
, trace
, pid
):
584 super().__init
__(trace
, pid
)
585 self
.expect
["select_entry"]["pselect_invalid_in"] = 0
586 self
.expect
["select_exit"]["pselect_invalid_out"] = 0
588 def select_entry(self
, event
):
590 overflow
= event
["overflow"]
591 _readfds_length
= event
["_readfds_length"]
593 # test that event in valid even though the target buffer pointer is
594 # invalid and the program segfaults
595 if n
== 1 and overflow
== 0 and _readfds_length
== 0:
596 self
.expect
["select_entry"]["pselect_invalid_in"] = 1
598 # Save values of local variables to print in case of test failure
599 self
.recorded_values
["select_entry"] = locals()
601 def select_exit(self
, event
):
603 overflow
= event
["overflow"]
604 _readfds_length
= event
["_readfds_length"]
606 # test that event in valid even though the target buffer pointer is
607 # invalid and the program segfaults
608 if ret
== -14 and overflow
== 0 and _readfds_length
== 0:
609 self
.expect
["select_exit"]["pselect_invalid_out"] = 1
611 # Save values of local variables to print in case of test failure
612 self
.recorded_values
["select_exit"] = locals()
615 class Test7(TraceParser
):
616 def __init__(self
, trace
, pid
):
617 super().__init
__(trace
, pid
)
618 self
.expect
["poll_entry"]["poll_max_in"] = 0
619 self
.expect
["poll_exit"]["poll_max_out"] = 0
621 def poll_entry(self
, event
):
623 overflow
= event
["overflow"]
625 # check the proper working of INT_MAX maxevent value
626 if nfds
== 4294967295 and overflow
== 1:
627 self
.expect
["poll_entry"]["poll_max_in"] = 1
629 # Save values of local variables to print in case of test failure
630 self
.recorded_values
["poll_entry"] = locals()
633 def poll_exit(self
, event
):
636 overflow
= event
["overflow"]
638 # check the proper working of UINT_MAX maxevent value
639 if ret
== -22 and nfds
== 4294967295 and overflow
== 0:
640 self
.expect
["poll_exit"]["poll_max_out"] = 1
642 # Save values of local variables to print in case of test failure
643 self
.recorded_values
["poll_exit"] = locals()
646 class Test8(TraceParser
):
647 def __init__(self
, trace
, pid
):
648 super().__init
__(trace
, pid
)
649 self
.expect
["epoll_wait_entry"]["epoll_wait_invalid_in"] = 0
650 self
.expect
["epoll_wait_exit"]["epoll_wait_invalid_out"] = 0
652 def epoll_wait_entry(self
, event
):
654 maxevents
= event
["maxevents"]
655 timeout
= event
["timeout"]
657 # test that event in valid even though the target buffer pointer is
658 # invalid and the program segfaults
659 if epfd
== 3 and maxevents
== 1 and timeout
== -1:
660 self
.expect
["epoll_wait_entry"]["epoll_wait_invalid_in"] = 1
662 # Save values of local variables to print in case of test failure
663 self
.recorded_values
["epoll_wait_entry"] = locals()
665 def epoll_wait_exit(self
, event
):
667 fds_length
= event
["fds_length"]
668 overflow
= event
["overflow"]
670 # test that event in valid even though the target buffer pointer is
671 # invalid and the program segfaults
672 if ret
== -14 and fds_length
== 0 and overflow
== 0:
673 self
.expect
["epoll_wait_exit"]["epoll_wait_invalid_out"] = 1
675 # Save values of local variables to print in case of test failure
676 self
.recorded_values
["epoll_wait_exit"] = locals()
679 class Test9(TraceParser
):
680 def __init__(self
, trace
, pid
):
681 super().__init
__(trace
, pid
)
682 self
.expect
["epoll_wait_entry"]["epoll_wait_max_in"] = 0
683 self
.expect
["epoll_wait_exit"]["epoll_wait_max_out"] = 0
685 def epoll_wait_entry(self
, event
):
687 maxevents
= event
["maxevents"]
688 timeout
= event
["timeout"]
690 # check the proper working of INT_MAX maxevent value
691 if epfd
== 3 and maxevents
== 2147483647 and timeout
== -1:
692 self
.expect
["epoll_wait_entry"]["epoll_wait_max_in"] = 1
694 # Save values of local variables to print in case of test failure
695 self
.recorded_values
["epoll_wait_entry"] = locals()
697 def epoll_wait_exit(self
, event
):
699 fds_length
= event
["fds_length"]
700 overflow
= event
["overflow"]
702 # check the proper working of INT_MAX maxevent value
703 if ret
== -22 and fds_length
== 0 and overflow
== 0:
704 self
.expect
["epoll_wait_exit"]["epoll_wait_max_out"] = 1
706 # Save values of local variables to print in case of test failure
707 self
.recorded_values
["epoll_wait_exit"] = locals()
710 if __name__
== "__main__":
711 parser
= argparse
.ArgumentParser(description
='Trace parser')
712 parser
.add_argument('path', metavar
="<path/to/trace>", help='Trace path')
713 parser
.add_argument('-t', '--test', type=int, help='Test to validate')
714 parser
.add_argument('-p', '--pid', type=int, help='PID of the app')
715 args
= parser
.parse_args()
718 print("Need to pass a test to validate (-t)")
722 print("Need to pass the PID to check (-p)")
725 traces
= bt2
.TraceCollectionMessageIterator(args
.path
)
730 t
= Test1(traces
, args
.pid
)
732 t
= Test2(traces
, args
.pid
)
734 t
= Test3(traces
, args
.pid
)
736 t
= Test4(traces
, args
.pid
)
738 t
= Test5(traces
, args
.pid
)
740 t
= Test6(traces
, args
.pid
)
742 t
= Test7(traces
, args
.pid
)
744 t
= Test8(traces
, args
.pid
)
746 t
= Test9(traces
, args
.pid
)
747 elif args
.test
== 10:
748 # stress test, nothing reliable to check
750 elif args
.test
== 11:
751 # stress test, nothing reliable to check
754 print("Invalid test case")
This page took 0.048856 seconds and 6 git commands to generate.