Linux Audio

Check our new training course

In-person Linux kernel drivers training

Jun 16-20, 2025
Register
Loading...
v6.8
 1// SPDX-License-Identifier: GPL-2.0
 2#include <stdarg.h>
 3#include <stdio.h>
 4#include <perf/cpumap.h>
 5#include <internal/tests.h>
 6#include "tests.h"
 7
 8static int libperf_print(enum libperf_print_level level,
 9			 const char *fmt, va_list ap)
10{
11	return vfprintf(stderr, fmt, ap);
12}
13
14int test_cpumap(int argc, char **argv)
15{
16	struct perf_cpu_map *cpus;
17	struct perf_cpu cpu;
18	int idx;
19
20	__T_START;
21
22	libperf_init(libperf_print);
23
24	cpus = perf_cpu_map__new_any_cpu();
25	if (!cpus)
26		return -1;
27
28	perf_cpu_map__get(cpus);
29	perf_cpu_map__put(cpus);
30	perf_cpu_map__put(cpus);
31
32	cpus = perf_cpu_map__new_online_cpus();
33	if (!cpus)
34		return -1;
35
36	perf_cpu_map__for_each_cpu(cpu, idx, cpus)
37		__T("wrong cpu number", cpu.cpu != -1);
38
39	perf_cpu_map__put(cpus);
40
41	__T_END;
42	return tests_failed == 0 ? 0 : -1;
43}
v5.9
 1// SPDX-License-Identifier: GPL-2.0
 2#include <stdarg.h>
 3#include <stdio.h>
 4#include <perf/cpumap.h>
 5#include <internal/tests.h>
 
 6
 7static int libperf_print(enum libperf_print_level level,
 8			 const char *fmt, va_list ap)
 9{
10	return vfprintf(stderr, fmt, ap);
11}
12
13int main(int argc, char **argv)
14{
15	struct perf_cpu_map *cpus;
 
 
16
17	__T_START;
18
19	libperf_init(libperf_print);
20
21	cpus = perf_cpu_map__dummy_new();
22	if (!cpus)
23		return -1;
24
25	perf_cpu_map__get(cpus);
26	perf_cpu_map__put(cpus);
27	perf_cpu_map__put(cpus);
28
 
 
 
 
 
 
 
 
 
29	__T_END;
30	return 0;
31}