count: use parse_ts for parsing overhead value
* count.c (set_overhead): Change argument type to const char *, call parse_ts to parse it and set to overhead. * defs.h (set_overhead): Update declaration. * strace.c: (init) <case 'O'>: do not parse argument, pass optarg to set_overhead call. * tests/count.test (GENERIC, WALLCLOCK, HALFCLOCK): New variables with expected patterns. Add checks for the new -O syntax.
This commit is contained in:
parent
1a28b6dba2
commit
0a21612184
7
count.c
7
count.c
@ -116,10 +116,11 @@ set_sortby(const char *sortby)
|
||||
}
|
||||
}
|
||||
|
||||
void set_overhead(int n)
|
||||
void
|
||||
set_overhead(const char *str)
|
||||
{
|
||||
overhead.tv_sec = n / 1000000;
|
||||
overhead.tv_nsec = n % 1000000 * 1000;
|
||||
if (parse_ts(str, &overhead) < 0)
|
||||
error_msg_and_help("invalid -O argument: '%s'", str);
|
||||
}
|
||||
|
||||
static void
|
||||
|
2
defs.h
2
defs.h
@ -430,7 +430,7 @@ extern unsigned os_release;
|
||||
extern int read_int_from_file(struct tcb *, const char *, int *);
|
||||
|
||||
extern void set_sortby(const char *);
|
||||
extern void set_overhead(int);
|
||||
extern void set_overhead(const char *);
|
||||
extern void print_pc(struct tcb *);
|
||||
|
||||
extern int syscall_entering_decode(struct tcb *);
|
||||
|
5
strace.c
5
strace.c
@ -1675,10 +1675,7 @@ init(int argc, char *argv[])
|
||||
outfname = optarg;
|
||||
break;
|
||||
case 'O':
|
||||
i = string_to_uint(optarg);
|
||||
if (i < 0)
|
||||
error_opt_arg(c, optarg);
|
||||
set_overhead(i);
|
||||
set_overhead(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
process_opt_p_list(optarg);
|
||||
|
@ -49,13 +49,20 @@ grep_log()
|
||||
}
|
||||
}
|
||||
|
||||
grep_log ' *[^ ]+ +0\.0[^n]*nanosleep' -c
|
||||
grep_log ' *[^ ]+ +0\.0[^n]*nanosleep' -c -O1
|
||||
grep_log ' *[^ ]+ +0\.0[^n]*nanosleep' -c -enanosleep
|
||||
grep_log ' *[^ ]+ +0\.0[^n]*nanosleep' -c -O1 -enanosleep
|
||||
grep_log ' *[^ ]+ +(1\.[01]|0\.99)[^n]*nanosleep' -cw
|
||||
grep_log ' *[^ ]+ +(1\.[01]|0\.99)[^n]*nanosleep' -cw -O1
|
||||
grep_log '100\.00 +(1\.[01]|0\.99)[^n]*nanosleep' -cw -enanosleep
|
||||
grep_log '100\.00 +(1\.[01]|0\.99)[^n]*nanosleep' -cw -O1 -enanosleep
|
||||
GENERIC=' *[^ ]+ +0\.0[^n]*nanosleep *'
|
||||
WALLCLOCK=' *[^ ]+ +(1\.[01]|0\.99)[^n]*nanosleep *'
|
||||
HALFCLOCK=' *[^ ]+ +0\.[567][^n]*nanosleep *'
|
||||
|
||||
grep_log "$GENERIC" -c
|
||||
grep_log "$GENERIC" -c -O1
|
||||
grep_log "$GENERIC" -c -enanosleep
|
||||
grep_log "$GENERIC" -c -O1 -enanosleep
|
||||
grep_log "$WALLCLOCK" -cw
|
||||
grep_log "$WALLCLOCK" -cw -O1
|
||||
grep_log "$WALLCLOCK" -cw -enanosleep
|
||||
grep_log "$WALLCLOCK" -cw -O1 -enanosleep
|
||||
grep_log "$HALFCLOCK" -cw -O4.5e2ms -enanosleep
|
||||
grep_log "$HALFCLOCK" -cw -O4.5e-1s -enanosleep
|
||||
grep_log "$HALFCLOCK" -cw -O456789012ns -enanosleep
|
||||
|
||||
exit 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user