Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <stdarg.h>
0003 #include <stdio.h>
0004 #include <perf/cpumap.h>
0005 #include <internal/tests.h>
0006 #include "tests.h"
0007 
0008 static int libperf_print(enum libperf_print_level level,
0009              const char *fmt, va_list ap)
0010 {
0011     return vfprintf(stderr, fmt, ap);
0012 }
0013 
0014 int test_cpumap(int argc, char **argv)
0015 {
0016     struct perf_cpu_map *cpus;
0017     struct perf_cpu cpu;
0018     int idx;
0019 
0020     __T_START;
0021 
0022     libperf_init(libperf_print);
0023 
0024     cpus = perf_cpu_map__dummy_new();
0025     if (!cpus)
0026         return -1;
0027 
0028     perf_cpu_map__get(cpus);
0029     perf_cpu_map__put(cpus);
0030     perf_cpu_map__put(cpus);
0031 
0032     cpus = perf_cpu_map__default_new();
0033     if (!cpus)
0034         return -1;
0035 
0036     perf_cpu_map__for_each_cpu(cpu, idx, cpus)
0037         __T("wrong cpu number", cpu.cpu != -1);
0038 
0039     perf_cpu_map__put(cpus);
0040 
0041     __T_END;
0042     return tests_failed == 0 ? 0 : -1;
0043 }