]> git.saurik.com Git - apple/xnu.git/blame - tests/kperf_helpers.c
xnu-7195.50.7.100.1.tar.gz
[apple/xnu.git] / tests / kperf_helpers.c
CommitLineData
39037602
A
1#include "kperf_helpers.h"
2
3#include <darwintest.h>
4#include <kperf/kperf.h>
5#include <unistd.h>
6
7void
f427ee49 8configure_kperf_stacks_timer(pid_t pid, unsigned int period_ms, bool quiet)
39037602 9{
0a7de745 10 kperf_reset();
39037602 11
0a7de745
A
12 (void)kperf_action_count_set(1);
13 (void)kperf_timer_count_set(1);
39037602 14
f427ee49
A
15 if (quiet) {
16 T_QUIET;
17 }
0a7de745
A
18 T_ASSERT_POSIX_SUCCESS(kperf_action_samplers_set(1,
19 KPERF_SAMPLER_USTACK | KPERF_SAMPLER_KSTACK), NULL);
39037602 20
0a7de745 21 if (pid != -1) {
f427ee49
A
22 if (quiet) {
23 T_QUIET;
24 }
0a7de745
A
25 T_ASSERT_POSIX_SUCCESS(kperf_action_filter_set_by_pid(1, pid), NULL);
26 }
39037602 27
f427ee49
A
28 if (quiet) {
29 T_QUIET;
30 }
0a7de745 31 T_ASSERT_POSIX_SUCCESS(kperf_timer_action_set(0, 1), NULL);
f427ee49
A
32 if (quiet) {
33 T_QUIET;
34 }
0a7de745
A
35 T_ASSERT_POSIX_SUCCESS(kperf_timer_period_set(0,
36 kperf_ns_to_ticks(period_ms * NSEC_PER_MSEC)), NULL);
39037602 37}