mirror of
https://github.com/denoland/deno
synced 2024-08-25 02:57:22 +00:00
fix(test_util): parse strace usecs/call in total line if present (#18241)
Fixes https://github.com/denoland/deno/issues/18235
This commit is contained in:
parent
0eabd2c6d6
commit
c27e8da2c9
|
@ -2273,14 +2273,21 @@ pub fn parse_strace_output(output: &str) -> HashMap<String, StraceOutput> {
|
|||
}
|
||||
|
||||
let total_fields = total_line.split_whitespace().collect::<Vec<_>>();
|
||||
|
||||
let mut usecs_call_offset = 0;
|
||||
summary.insert(
|
||||
"total".to_string(),
|
||||
StraceOutput {
|
||||
percent_time: str::parse::<f64>(total_fields[0]).unwrap(),
|
||||
seconds: str::parse::<f64>(total_fields[1]).unwrap(),
|
||||
usecs_per_call: None,
|
||||
calls: str::parse::<u64>(total_fields[2]).unwrap(),
|
||||
errors: str::parse::<u64>(total_fields[3]).unwrap(),
|
||||
usecs_per_call: if total_fields.len() > 5 {
|
||||
usecs_call_offset = 1;
|
||||
Some(str::parse::<u64>(total_fields[2]).unwrap())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
calls: str::parse::<u64>(total_fields[2 + usecs_call_offset]).unwrap(),
|
||||
errors: str::parse::<u64>(total_fields[3 + usecs_call_offset]).unwrap(),
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -2384,6 +2391,7 @@ mod tests {
|
|||
// summary line
|
||||
assert_eq!(strace.get("total").unwrap().calls, 704);
|
||||
assert_eq!(strace.get("total").unwrap().errors, 5);
|
||||
assert_eq!(strace.get("total").unwrap().usecs_per_call, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2399,6 +2407,23 @@ mod tests {
|
|||
// summary line
|
||||
assert_eq!(strace.get("total").unwrap().calls, 821);
|
||||
assert_eq!(strace.get("total").unwrap().errors, 107);
|
||||
assert_eq!(strace.get("total").unwrap().usecs_per_call, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn strace_parse_3() {
|
||||
const TEXT: &str = include_str!("./testdata/strace_summary3.out");
|
||||
let strace = parse_strace_output(TEXT);
|
||||
|
||||
// first syscall line
|
||||
let futex = strace.get("mprotect").unwrap();
|
||||
assert_eq!(futex.calls, 90);
|
||||
assert_eq!(futex.errors, 0);
|
||||
|
||||
// summary line
|
||||
assert_eq!(strace.get("total").unwrap().calls, 543);
|
||||
assert_eq!(strace.get("total").unwrap().errors, 36);
|
||||
assert_eq!(strace.get("total").unwrap().usecs_per_call, Some(6));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
48
test_util/src/testdata/strace_summary3.out
vendored
Normal file
48
test_util/src/testdata/strace_summary3.out
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
% time seconds usecs/call calls errors syscall
|
||||
------ ----------- ----------- --------- --------- ------------------
|
||||
14.12 0.000501 5 90 mprotect
|
||||
12.23 0.000434 62 7 clone3
|
||||
8.51 0.000302 13 22 rt_sigprocmask
|
||||
7.10 0.000252 7 32 read
|
||||
7.02 0.000249 6 39 madvise
|
||||
6.31 0.000224 8 26 7 openat
|
||||
5.69 0.000202 5 34 mmap
|
||||
5.10 0.000181 4 39 2 newfstatat
|
||||
4.40 0.000156 4 39 fcntl
|
||||
4.17 0.000148 5 27 brk
|
||||
3.27 0.000116 4 26 close
|
||||
3.16 0.000112 14 8 rseq
|
||||
3.04 0.000108 15 7 prctl
|
||||
2.56 0.000091 11 8 set_robust_list
|
||||
2.20 0.000078 6 12 gettid
|
||||
1.69 0.000060 5 11 munmap
|
||||
1.55 0.000055 5 10 write
|
||||
1.38 0.000049 3 14 lseek
|
||||
1.01 0.000036 7 5 3 ioctl
|
||||
0.90 0.000032 6 5 getpid
|
||||
0.82 0.000029 4 7 getcwd
|
||||
0.65 0.000023 5 4 sched_getaffinity
|
||||
0.51 0.000018 18 1 1 pkey_alloc
|
||||
0.45 0.000016 8 2 unlink
|
||||
0.45 0.000016 1 16 9 statx
|
||||
0.31 0.000011 1 6 prlimit64
|
||||
0.31 0.000011 2 4 getrandom
|
||||
0.25 0.000009 9 1 uname
|
||||
0.23 0.000008 1 6 rt_sigaction
|
||||
0.23 0.000008 4 2 geteuid
|
||||
0.20 0.000007 7 1 ftruncate
|
||||
0.11 0.000004 1 3 sigaltstack
|
||||
0.08 0.000003 3 1 getppid
|
||||
0.00 0.000000 0 1 poll
|
||||
0.00 0.000000 0 4 pread64
|
||||
0.00 0.000000 0 1 1 access
|
||||
0.00 0.000000 0 1 socketpair
|
||||
0.00 0.000000 0 1 execve
|
||||
0.00 0.000000 0 13 12 readlink
|
||||
0.00 0.000000 0 2 1 arch_prctl
|
||||
0.00 0.000000 0 1 set_tid_address
|
||||
0.00 0.000000 0 2 epoll_ctl
|
||||
0.00 0.000000 0 1 eventfd2
|
||||
0.00 0.000000 0 1 epoll_create1
|
||||
------ ----------- ----------- --------- --------- ------------------
|
||||
100.00 0.003549 6 543 36 total
|
Loading…
Reference in a new issue