3 # Copyright (C) 2016 Julien Desfossez <jdesfossez@efficios.com>
5 # SPDX-License-Identifier: GPL-2.0-only
13 from collections
import defaultdict
15 NSEC_PER_SEC
= 1000000000
18 from babeltrace
import TraceCollection
20 # quick fix for debian-based distros
21 sys
.path
.append("/usr/local/lib/python%d.%d/site-packages" %
22 (sys
.version_info
.major
, sys
.version_info
.minor
))
23 from babeltrace
import TraceCollection
27 def __init__(self
, trace
, pid
):
31 # This dictionnary holds the results of each testcases of a test.
32 # Its layout is the following:
34 # 'event_name_1': {'check_1': 0, 'check_2: 1},
35 # 'event_name_2': {'check_1': 1}
37 # Each test classes checks the payload of different events. Each of
38 # those checks are stored in a event_name specific dictionnary in this
40 self
.expect
= defaultdict(lambda : defaultdict(int))
42 # This dictionnary holds the value recorded in the trace that are
43 # tested. Its content is use to print the values that caused a test to
45 self
.recorded_values
= {}
47 def ns_to_hour_nsec(self
, ns
):
48 d
= time
.localtime(ns
/NSEC_PER_SEC
)
49 return "%02d:%02d:%02d.%09d" % (d
.tm_hour
, d
.tm_min
, d
.tm_sec
,
53 # iterate over all the events
54 for event
in self
.trace
.events
:
55 if self
.pid
is not None and event
["pid"] != self
.pid
:
58 method_name
= "handle_%s" % event
.name
.replace(":", "_").replace(
60 # call the function to handle each event individually
61 if hasattr(TraceParser
, method_name
):
62 func
= getattr(TraceParser
, method_name
)
66 # For each event of the test case, check all entries for failed
67 for event_name
, event_results
in self
.expect
.items():
68 for val
in event_results
.keys():
69 if self
.expect
[event_name
][val
] == 0:
70 print("%s not validated" % val
)
71 print("Values of the local variables of this test:")
72 # using pprint for pretty printing the dictionnary
73 pprint
.pprint(self
.recorded_values
[event_name
])
79 def handle_compat_syscall_entry_epoll_ctl(self
, event
):
80 self
.epoll_ctl_entry(event
)
82 def handle_compat_syscall_exit_epoll_ctl(self
, event
):
83 self
.epoll_ctl_exit(event
)
85 def handle_syscall_entry_epoll_ctl(self
, event
):
86 self
.epoll_ctl_entry(event
)
88 def handle_syscall_exit_epoll_ctl(self
, event
):
89 self
.epoll_ctl_exit(event
)
91 def epoll_ctl_entry(self
, event
):
94 def epoll_ctl_exit(self
, event
):
97 # epoll_wait + epoll_pwait
98 def handle_compat_syscall_entry_epoll_wait(self
, event
):
99 self
.epoll_wait_entry(event
)
101 def handle_compat_syscall_exit_epoll_wait(self
, event
):
102 self
.epoll_wait_exit(event
)
104 def handle_syscall_entry_epoll_wait(self
, event
):
105 self
.epoll_wait_entry(event
)
107 def handle_syscall_exit_epoll_wait(self
, event
):
108 self
.epoll_wait_exit(event
)
110 def handle_compat_syscall_entry_epoll_pwait(self
, event
):
111 self
.epoll_wait_entry(event
)
113 def handle_compat_syscall_exit_epoll_pwait(self
, event
):
114 self
.epoll_wait_exit(event
)
116 def handle_syscall_entry_epoll_pwait(self
, event
):
117 self
.epoll_wait_entry(event
)
119 def handle_syscall_exit_epoll_pwait(self
, event
):
120 self
.epoll_wait_exit(event
)
122 def epoll_wait_entry(self
, event
):
125 def epoll_wait_exit(self
, event
):
129 def handle_compat_syscall_entry_poll(self
, event
):
130 self
.poll_entry(event
)
132 def handle_compat_syscall_exit_poll(self
, event
):
133 self
.poll_exit(event
)
135 def handle_syscall_entry_poll(self
, event
):
136 self
.poll_entry(event
)
138 def handle_syscall_exit_poll(self
, event
):
139 self
.poll_exit(event
)
141 def handle_compat_syscall_entry_ppoll(self
, event
):
142 self
.poll_entry(event
)
144 def handle_compat_syscall_exit_ppoll(self
, event
):
145 self
.poll_exit(event
)
147 def handle_syscall_entry_ppoll(self
, event
):
148 self
.poll_entry(event
)
150 def handle_syscall_exit_ppoll(self
, event
):
151 self
.poll_exit(event
)
153 def poll_entry(self
, event
):
156 def poll_exit(self
, event
):
160 def handle_compat_syscall_entry_epoll_create1(self
, event
):
161 self
.epoll_create_entry(event
)
163 def handle_compat_syscall_exit_epoll_create1(self
, event
):
164 self
.epoll_create_exit(event
)
166 def handle_compat_syscall_entry_epoll_create(self
, event
):
167 self
.epoll_create_entry(event
)
169 def handle_compat_syscall_exit_epoll_create(self
, event
):
170 self
.epoll_create_exit(event
)
172 def handle_syscall_entry_epoll_create1(self
, event
):
173 self
.epoll_create_entry(event
)
175 def handle_syscall_exit_epoll_create1(self
, event
):
176 self
.epoll_create_exit(event
)
178 def handle_syscall_entry_epoll_create(self
, event
):
179 self
.epoll_create_entry(event
)
181 def handle_syscall_exit_epoll_create(self
, event
):
182 self
.epoll_create_exit(event
)
184 def epoll_create_entry(self
, event
):
187 def epoll_create_exit(self
, event
):
191 def handle_syscall_entry_pselect6(self
, event
):
192 self
.select_entry(event
)
194 def handle_syscall_exit_pselect6(self
, event
):
195 self
.select_exit(event
)
197 def handle_compat_syscall_entry_pselect6(self
, event
):
198 self
.select_entry(event
)
200 def handle_compat_syscall_exit_pselect6(self
, event
):
201 self
.select_exit(event
)
203 def handle_syscall_entry_select(self
, event
):
204 self
.select_entry(event
)
206 def handle_syscall_exit_select(self
, event
):
207 self
.select_exit(event
)
209 def handle_compat_syscall_entry_select(self
, event
):
210 self
.select_entry(event
)
212 def handle_compat_syscall_exit_select(self
, event
):
213 self
.select_exit(event
)
215 def select_entry(self
, event
):
218 def select_exit(self
, event
):
222 class Test1(TraceParser
):
223 def __init__(self
, trace
, pid
):
224 super().__init
__(trace
, pid
)
225 self
.expect
["select_entry"]["select_in_fd0"] = 0
226 self
.expect
["select_entry"]["select_in_fd1023"] = 0
227 self
.expect
["select_exit"]["select_out_fd0"] = 0
228 self
.expect
["select_exit"]["select_out_fd1023"] = 0
229 self
.expect
["poll_entry"]["poll_in_nfds1"] = 0
230 self
.expect
["poll_exit"]["poll_out_nfds1"] = 0
231 self
.expect
["epoll_ctl_entry"]["epoll_ctl_in_add"] = 0
232 self
.expect
["epoll_ctl_exit"]["epoll_ctl_out_ok"] = 0
233 self
.expect
["epoll_wait_entry"]["epoll_wait_in_ok"] = 0
234 self
.expect
["epoll_wait_exit"]["epoll_wait_out_fd0"] = 0
236 def select_entry(self
, event
):
238 overflow
= event
["overflow"]
239 readfd_0
= event
["readfds"][0]
241 # check that the FD 0 is actually set in the readfds
242 if n
== 1 and readfd_0
== 1:
243 self
.expect
["select_entry"]["select_in_fd0"] = 1
245 readfd_127
= event
["readfds"][127]
246 writefd_127
= event
["writefds"][127]
247 exceptfd_127
= event
["exceptfds"][127]
249 # check that the FD 1023 is actually set in the readfds
250 if readfd_127
== 0x40 and writefd_127
== 0 and \
251 exceptfd_127
== 0 and overflow
== 0:
252 self
.expect
["select_entry"]["select_in_fd1023"] = 1
254 # Save values of local variables to print in case of test failure
255 self
.recorded_values
["select_entry"] = locals()
257 def select_exit(self
, event
):
260 overflow
= event
["overflow"]
261 _readfds_length
= event
["_readfds_length"]
264 # check that the FD 0 is actually set in the readfds
265 readfd_0
= event
["readfds"][0]
268 self
.expect
["select_exit"]["select_out_fd0"] = 1
269 # check that the FD 1023 is actually set in the readfds
270 if _readfds_length
== 128:
271 readfd_127
= event
["readfds"][127]
272 writefd_127
= event
["writefds"][127]
273 exceptfd_127
= event
["exceptfds"][127]
274 if readfd_127
== 0x40 and writefd_127
== 0 and \
275 exceptfd_127
== 0 and tvp
== 0:
276 self
.expect
["select_exit"]["select_out_fd1023"] = 1
278 # Save values of local variables to print in case of test failure
279 self
.recorded_values
["select_exit"] = locals()
281 def poll_entry(self
, event
):
283 fds_length
= event
["fds_length"]
284 overflow
= event
["overflow"]
286 # check that only one FD is set, that it has the POLLIN flag and that
287 # the raw value matches the events bit field.
288 if nfds
== 1 and fds_length
== 1:
289 fd_0
= event
["fds"][0]
290 if fd_0
["raw_events"] == 0x3 and fd_0
["events"]["POLLIN"] == 1 and \
291 fd_0
["events"]["padding"] == 0:
292 self
.expect
["poll_entry"]["poll_in_nfds1"] = 1
294 # Save values of local variables to print in case of test failure
295 self
.recorded_values
["poll_entry"] = locals()
297 def poll_exit(self
, event
):
299 fds_length
= event
["fds_length"]
301 # check that only one FD is set, that it has the POLLIN flag and that
302 # the raw value matches the events bit field.
303 if ret
== 1 and fds_length
== 1:
304 fd_0
= event
["fds"][0]
305 if fd_0
["raw_events"] == 0x1 and fd_0
["events"]["POLLIN"] == 1 and \
306 fd_0
["events"]["padding"] == 0:
307 self
.expect
["poll_exit"]["poll_out_nfds1"] = 1
309 # Save values of local variables to print in case of test failure
310 self
.recorded_values
["poll_exit"] = locals()
312 def epoll_ctl_entry(self
, event
):
314 op_enum
= event
["op_enum"]
316 _event
= event
["event"]
318 # check that we have FD 0 waiting for EPOLLIN|EPOLLPRI and that
320 if epfd
== 3 and op_enum
== "EPOLL_CTL_ADD" and fd
== 0 and \
321 _event
["data_union"]["fd"] == 0 and \
322 _event
["events"]["EPOLLIN"] == 1 and \
323 _event
["events"]["EPOLLPRI"] == 1:
324 self
.expect
["epoll_ctl_entry"]["epoll_ctl_in_add"] = 1
326 # Save values of local variables to print in case of test failure
327 self
.recorded_values
["epoll_ctl_entry"] = locals()
329 def epoll_ctl_exit(self
, event
):
333 self
.expect
["epoll_ctl_exit"]["epoll_ctl_out_ok"] = 1
335 # Save values of local variables to print in case of test failure
336 self
.recorded_values
["epoll_ctl_exit"] = locals()
338 def epoll_wait_entry(self
, event
):
340 maxevents
= event
["maxevents"]
341 timeout
= event
["timeout"]
343 if epfd
== 3 and maxevents
== 1 and timeout
== -1:
344 self
.expect
["epoll_wait_entry"]["epoll_wait_in_ok"] = 1
346 # Save values of local variables to print in case of test failure
347 self
.recorded_values
["epoll_wait_entry"] = locals()
349 def epoll_wait_exit(self
, event
):
351 fds_length
= event
["fds_length"]
352 overflow
= event
["overflow"]
354 # check that FD 0 returned with EPOLLIN and the right data.fd
355 if ret
== 1 and fds_length
== 1:
356 fd_0
= event
["fds"][0]
357 if overflow
== 0 and fd_0
["data_union"]["fd"] == 0 and \
358 fd_0
["events"]["EPOLLIN"] == 1:
359 self
.expect
["epoll_wait_exit"]["epoll_wait_out_fd0"] = 1
361 # Save values of local variables to print in case of test failure
362 self
.recorded_values
["epoll_wait_exit"] = locals()
365 class Test2(TraceParser
):
366 def __init__(self
, trace
, pid
):
367 super().__init
__(trace
, pid
)
368 self
.expect
["select_entry"]["select_timeout_in_fd0"] = 0
369 self
.expect
["select_entry"]["select_timeout_in_fd1023"] = 0
370 self
.expect
["select_exit"]["select_timeout_out"] = 0
371 self
.expect
["poll_entry"]["poll_timeout_in"] = 0
372 self
.expect
["poll_exit"]["poll_timeout_out"] = 0
373 self
.expect
["epoll_ctl_entry"]["epoll_ctl_timeout_in_add"] = 0
374 self
.expect
["epoll_ctl_exit"]["epoll_ctl_timeout_out_ok"] = 0
375 self
.expect
["epoll_wait_entry"]["epoll_wait_timeout_in"] = 0
376 self
.expect
["epoll_wait_exit"]["epoll_wait_timeout_out"] = 0
378 def select_entry(self
, event
):
382 if n
== 1 and tvp
!= 0:
383 self
.expect
["select_entry"]["select_timeout_in_fd0"] = 1
385 readfd_127
= event
["readfds"][127]
386 writefd_127
= event
["writefds"][127]
387 exceptfd_127
= event
["exceptfds"][127]
389 if readfd_127
== 0x40 and writefd_127
== 0 and \
390 exceptfd_127
== 0 and tvp
!= 0:
391 self
.expect
["select_entry"]["select_timeout_in_fd1023"] = 1
393 # Save values of local variables to print in case of test failure
394 self
.recorded_values
["select_entry"] = locals()
396 def select_exit(self
, event
):
400 if ret
== 0 and tvp
!= 0:
401 self
.expect
["select_exit"]["select_timeout_out"] = 1
403 # Save values of local variables to print in case of test failure
404 self
.recorded_values
["select_exit"] = locals()
406 def poll_entry(self
, event
):
408 fds_length
= event
["fds_length"]
410 # check that we wait on FD 0 for POLLIN and that the raw_events
411 # field matches the value of POLLIN
412 if nfds
== 1 and fds_length
== 1:
413 fd_0
= event
["fds"][0]
414 if fd_0
["raw_events"] == 0x3 and \
415 fd_0
["events"]["POLLIN"] == 1 and \
416 fd_0
["events"]["padding"] == 0:
417 self
.expect
["poll_entry"]["poll_timeout_in"] = 1
419 # Save values of local variables to print in case of test failure
420 self
.recorded_values
["poll_entry"] = locals()
422 def poll_exit(self
, event
):
425 fds_length
= event
["fds_length"]
427 if ret
== 0 and nfds
== 1 and fds_length
== 0:
428 self
.expect
["poll_exit"]["poll_timeout_out"] = 1
430 # Save values of local variables to print in case of test failure
431 self
.recorded_values
["poll_exit"] = locals()
433 def epoll_ctl_entry(self
, event
):
434 op_enum
= event
["op_enum"]
435 _event
= event
["event"]
437 # make sure we see a EPOLLIN|EPOLLPRI
438 if op_enum
== "EPOLL_CTL_ADD" and \
439 _event
["events"]["EPOLLIN"] == 1 and \
440 _event
["events"]["EPOLLPRI"] == 1:
441 self
.expect
["epoll_ctl_entry"]["epoll_ctl_timeout_in_add"] = 1
443 # Save values of local variables to print in case of test failure
444 self
.recorded_values
["epoll_ctl_entry"] = locals()
446 def epoll_ctl_exit(self
, event
):
450 self
.expect
["epoll_ctl_exit"]["epoll_ctl_timeout_out_ok"] = 1
452 # Save values of local variables to print in case of test failure
453 self
.recorded_values
["epoll_ctl_exit"] = locals()
455 def epoll_wait_entry(self
, event
):
456 maxevents
= event
["maxevents"]
457 timeout
= event
["timeout"]
459 if maxevents
== 1 and timeout
== 1:
460 self
.expect
["epoll_wait_entry"]["epoll_wait_timeout_in"] = 1
462 # Save values of local variables to print in case of test failure
463 self
.recorded_values
["epoll_wait_entry"] = locals()
465 def epoll_wait_exit(self
, event
):
467 fds_length
= event
["fds_length"]
468 overflow
= event
["overflow"]
470 if ret
== 0 and fds_length
== 0 and overflow
== 0:
471 self
.expect
["epoll_wait_exit"]["epoll_wait_timeout_out"] = 1
473 # Save values of local variables to print in case of test failure
474 self
.recorded_values
["epoll_wait_exit"] = locals()
477 class Test3(TraceParser
):
478 def __init__(self
, trace
, pid
):
479 super().__init
__(trace
, pid
)
480 self
.expect
["select_entry"]["select_invalid_fd_in"] = 0
481 self
.expect
["select_exit"]["select_invalid_fd_out"] = 0
483 def select_entry(self
, event
):
485 overflow
= event
["overflow"]
487 if n
> 0 and overflow
== 0:
488 self
.expect
["select_entry"]["select_invalid_fd_in"] = 1
490 # Save values of local variables to print in case of test failure
491 self
.recorded_values
["select_entry"] = locals()
493 def select_exit(self
, event
):
495 overflow
= event
["overflow"]
496 _readfds_length
= event
["_readfds_length"]
498 # make sure the event has a ret field equal to -EBADF
499 if ret
== -9 and overflow
== 0 and _readfds_length
== 0:
500 self
.expect
["select_exit"]["select_invalid_fd_out"] = 1
502 # Save values of local variables to print in case of test failure
503 self
.recorded_values
["select_exit"] = locals()
506 class Test4(TraceParser
):
507 def __init__(self
, trace
, pid
):
508 super().__init
__(trace
, pid
)
509 self
.expect
["poll_entry"]["big_poll_in"] = 0
510 self
.expect
["poll_exit"]["big_poll_out"] = 0
512 def poll_entry(self
, event
):
514 fds_length
= event
["fds_length"]
515 overflow
= event
["overflow"]
517 # test of big list of FDs and the behaviour of the overflow
518 if nfds
== 2047 and fds_length
== 512 and overflow
== 1:
519 fd_0
= event
["fds"][0]
520 fd_511
= event
["fds"][511]
521 if fd_0
["raw_events"] == 0x3 and fd_0
["events"]["POLLIN"] == 1 and \
522 fd_0
["events"]["padding"] == 0 and \
523 fd_511
["events"]["POLLIN"] == 1 and \
524 fd_511
["events"]["POLLPRI"] == 1:
525 self
.expect
["poll_entry"]["big_poll_in"] = 1
527 # Save values of local variables to print in case of test failure
528 self
.recorded_values
["poll_entry"] = locals()
530 def poll_exit(self
, event
):
533 fds_length
= event
["fds_length"]
534 overflow
= event
["overflow"]
536 # test of big list of FDs and the behaviour of the overflow
537 if ret
== 2047 and nfds
== 2047 and fds_length
== 512 and overflow
== 1:
538 fd_0
= event
["fds"][0]
539 fd_511
= event
["fds"][511]
540 if fd_0
["events"]["POLLIN"] == 1 and fd_511
["events"]["POLLIN"] == 1:
541 self
.expect
["poll_exit"]["big_poll_out"] = 1
543 # Save values of local variables to print in case of test failure
544 self
.recorded_values
["poll_exit"] = locals()
546 class Test5(TraceParser
):
547 def __init__(self
, trace
, pid
):
548 super().__init
__(trace
, pid
)
549 self
.expect
["poll_entry"]["poll_overflow_in"] = 0
550 self
.expect
["poll_exit"]["poll_overflow_out"] = 0
552 def poll_entry(self
, event
):
554 fds_length
= event
["fds_length"]
555 overflow
= event
["overflow"]
557 # test that event in valid even though the target buffer is too small
558 # and the program segfaults
559 if nfds
== 100 and fds_length
== 100 and overflow
== 0:
560 fd_0
= event
["fds"][0]
561 if fd_0
["events"]["POLLIN"] == 1:
562 self
.expect
["poll_entry"]["poll_overflow_in"] = 1
564 # Save values of local variables to print in case of test failure
565 self
.recorded_values
["poll_entry"] = locals()
567 def poll_exit(self
, event
):
569 overflow
= event
["overflow"]
571 # test that event in valid even though the target buffer is too small
572 # and the program segfaults
573 if nfds
== 100 and overflow
== 0:
574 self
.expect
["poll_exit"]["poll_overflow_out"] = 1
576 # Save values of local variables to print in case of test failure
577 self
.recorded_values
["poll_exit"] = locals()
580 class Test6(TraceParser
):
581 def __init__(self
, trace
, pid
):
582 super().__init
__(trace
, pid
)
583 self
.expect
["select_entry"]["pselect_invalid_in"] = 0
584 self
.expect
["select_exit"]["pselect_invalid_out"] = 0
586 def select_entry(self
, event
):
588 overflow
= event
["overflow"]
589 _readfds_length
= event
["_readfds_length"]
591 # test that event in valid even though the target buffer pointer is
592 # invalid and the program segfaults
593 if n
== 1 and overflow
== 0 and _readfds_length
== 0:
594 self
.expect
["select_entry"]["pselect_invalid_in"] = 1
596 # Save values of local variables to print in case of test failure
597 self
.recorded_values
["select_entry"] = locals()
599 def select_exit(self
, event
):
601 overflow
= event
["overflow"]
602 _readfds_length
= event
["_readfds_length"]
604 # test that event in valid even though the target buffer pointer is
605 # invalid and the program segfaults
606 if ret
== -14 and overflow
== 0 and _readfds_length
== 0:
607 self
.expect
["select_exit"]["pselect_invalid_out"] = 1
609 # Save values of local variables to print in case of test failure
610 self
.recorded_values
["select_exit"] = locals()
613 class Test7(TraceParser
):
614 def __init__(self
, trace
, pid
):
615 super().__init
__(trace
, pid
)
616 self
.expect
["poll_entry"]["poll_max_in"] = 0
617 self
.expect
["poll_exit"]["poll_max_out"] = 0
619 def poll_entry(self
, event
):
621 overflow
= event
["overflow"]
623 # check the proper working of INT_MAX maxevent value
624 if nfds
== 4294967295 and overflow
== 1:
625 self
.expect
["poll_entry"]["poll_max_in"] = 1
627 # Save values of local variables to print in case of test failure
628 self
.recorded_values
["poll_entry"] = locals()
631 def poll_exit(self
, event
):
634 overflow
= event
["overflow"]
636 # check the proper working of UINT_MAX maxevent value
637 if ret
== -22 and nfds
== 4294967295 and overflow
== 0:
638 self
.expect
["poll_exit"]["poll_max_out"] = 1
640 # Save values of local variables to print in case of test failure
641 self
.recorded_values
["poll_exit"] = locals()
644 class Test8(TraceParser
):
645 def __init__(self
, trace
, pid
):
646 super().__init
__(trace
, pid
)
647 self
.expect
["epoll_wait_entry"]["epoll_wait_invalid_in"] = 0
648 self
.expect
["epoll_wait_exit"]["epoll_wait_invalid_out"] = 0
650 def epoll_wait_entry(self
, event
):
652 maxevents
= event
["maxevents"]
653 timeout
= event
["timeout"]
655 # test that event in valid even though the target buffer pointer is
656 # invalid and the program segfaults
657 if epfd
== 3 and maxevents
== 1 and timeout
== -1:
658 self
.expect
["epoll_wait_entry"]["epoll_wait_invalid_in"] = 1
660 # Save values of local variables to print in case of test failure
661 self
.recorded_values
["epoll_wait_entry"] = locals()
663 def epoll_wait_exit(self
, event
):
665 fds_length
= event
["fds_length"]
666 overflow
= event
["overflow"]
668 # test that event in valid even though the target buffer pointer is
669 # invalid and the program segfaults
670 if ret
== -14 and fds_length
== 0 and overflow
== 0:
671 self
.expect
["epoll_wait_exit"]["epoll_wait_invalid_out"] = 1
673 # Save values of local variables to print in case of test failure
674 self
.recorded_values
["epoll_wait_exit"] = locals()
677 class Test9(TraceParser
):
678 def __init__(self
, trace
, pid
):
679 super().__init
__(trace
, pid
)
680 self
.expect
["epoll_wait_entry"]["epoll_wait_max_in"] = 0
681 self
.expect
["epoll_wait_exit"]["epoll_wait_max_out"] = 0
683 def epoll_wait_entry(self
, event
):
685 maxevents
= event
["maxevents"]
686 timeout
= event
["timeout"]
688 # check the proper working of INT_MAX maxevent value
689 if epfd
== 3 and maxevents
== 2147483647 and timeout
== -1:
690 self
.expect
["epoll_wait_entry"]["epoll_wait_max_in"] = 1
692 # Save values of local variables to print in case of test failure
693 self
.recorded_values
["epoll_wait_entry"] = locals()
695 def epoll_wait_exit(self
, event
):
697 fds_length
= event
["fds_length"]
698 overflow
= event
["overflow"]
700 # check the proper working of INT_MAX maxevent value
701 if ret
== -22 and fds_length
== 0 and overflow
== 0:
702 self
.expect
["epoll_wait_exit"]["epoll_wait_max_out"] = 1
704 # Save values of local variables to print in case of test failure
705 self
.recorded_values
["epoll_wait_exit"] = locals()
708 if __name__
== "__main__":
709 parser
= argparse
.ArgumentParser(description
='Trace parser')
710 parser
.add_argument('path', metavar
="<path/to/trace>", help='Trace path')
711 parser
.add_argument('-t', '--test', type=int, help='Test to validate')
712 parser
.add_argument('-p', '--pid', type=int, help='PID of the app')
713 args
= parser
.parse_args()
716 print("Need to pass a test to validate (-t)")
720 print("Need to pass the PID to check (-p)")
723 traces
= TraceCollection()
724 handle
= traces
.add_traces_recursive(args
.path
, "ctf")
731 t
= Test1(traces
, args
.pid
)
733 t
= Test2(traces
, args
.pid
)
735 t
= Test3(traces
, args
.pid
)
737 t
= Test4(traces
, args
.pid
)
739 t
= Test5(traces
, args
.pid
)
741 t
= Test6(traces
, args
.pid
)
743 t
= Test7(traces
, args
.pid
)
745 t
= Test8(traces
, args
.pid
)
747 t
= Test9(traces
, args
.pid
)
748 elif args
.test
== 10:
749 # stress test, nothing reliable to check
751 elif args
.test
== 11:
752 # stress test, nothing reliable to check
755 print("Invalid test case")
761 for h
in handle
.values():
762 traces
.remove_trace(h
)
This page took 0.046912 seconds and 4 git commands to generate.