~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/lib/perf/tests/test-threadmap.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/lib/perf/tests/test-threadmap.c (Architecture sparc64) and /tools/lib/perf/tests/test-threadmap.c (Architecture mips)


  1 // SPDX-License-Identifier: GPL-2.0                 1 // SPDX-License-Identifier: GPL-2.0
  2 #include <stdarg.h>                                 2 #include <stdarg.h>
  3 #include <stdio.h>                                  3 #include <stdio.h>
  4 #include <perf/threadmap.h>                         4 #include <perf/threadmap.h>
  5 #include <internal/tests.h>                         5 #include <internal/tests.h>
  6 #include "tests.h"                                  6 #include "tests.h"
  7                                                     7 
  8 static int libperf_print(enum libperf_print_le      8 static int libperf_print(enum libperf_print_level level,
  9                          const char *fmt, va_l      9                          const char *fmt, va_list ap)
 10 {                                                  10 {
 11         return vfprintf(stderr, fmt, ap);          11         return vfprintf(stderr, fmt, ap);
 12 }                                                  12 }
 13                                                    13 
 14 static int test_threadmap_array(int nr, pid_t      14 static int test_threadmap_array(int nr, pid_t *array)
 15 {                                                  15 {
 16         struct perf_thread_map *threads;           16         struct perf_thread_map *threads;
 17         int i;                                     17         int i;
 18                                                    18 
 19         threads = perf_thread_map__new_array(n     19         threads = perf_thread_map__new_array(nr, array);
 20         __T("Failed to allocate new thread map     20         __T("Failed to allocate new thread map", threads);
 21                                                    21 
 22         __T("Unexpected number of threads", pe     22         __T("Unexpected number of threads", perf_thread_map__nr(threads) == nr);
 23                                                    23 
 24         for (i = 0; i < nr; i++) {                 24         for (i = 0; i < nr; i++) {
 25                 __T("Unexpected initial value      25                 __T("Unexpected initial value of thread",
 26                     perf_thread_map__pid(threa     26                     perf_thread_map__pid(threads, i) == (array ? array[i] : -1));
 27         }                                          27         }
 28                                                    28 
 29         for (i = 1; i < nr; i++)                   29         for (i = 1; i < nr; i++)
 30                 perf_thread_map__set_pid(threa     30                 perf_thread_map__set_pid(threads, i, i * 100);
 31                                                    31 
 32         __T("Unexpected value of thread 0",        32         __T("Unexpected value of thread 0",
 33             perf_thread_map__pid(threads, 0) =     33             perf_thread_map__pid(threads, 0) == (array ? array[0] : -1));
 34                                                    34 
 35         for (i = 1; i < nr; i++) {                 35         for (i = 1; i < nr; i++) {
 36                 __T("Unexpected thread value",     36                 __T("Unexpected thread value",
 37                     perf_thread_map__pid(threa     37                     perf_thread_map__pid(threads, i) == i * 100);
 38         }                                          38         }
 39                                                    39 
 40         perf_thread_map__put(threads);             40         perf_thread_map__put(threads);
 41                                                    41 
 42         return 0;                                  42         return 0;
 43 }                                                  43 }
 44                                                    44 
 45 #define THREADS_NR      10                         45 #define THREADS_NR      10
 46 int test_threadmap(int argc, char **argv)          46 int test_threadmap(int argc, char **argv)
 47 {                                                  47 {
 48         struct perf_thread_map *threads;           48         struct perf_thread_map *threads;
 49         pid_t thr_array[THREADS_NR];               49         pid_t thr_array[THREADS_NR];
 50         int i;                                     50         int i;
 51                                                    51 
 52         __T_START;                                 52         __T_START;
 53                                                    53 
 54         libperf_init(libperf_print);               54         libperf_init(libperf_print);
 55                                                    55 
 56         threads = perf_thread_map__new_dummy()     56         threads = perf_thread_map__new_dummy();
 57         if (!threads)                              57         if (!threads)
 58                 return -1;                         58                 return -1;
 59                                                    59 
 60         perf_thread_map__get(threads);             60         perf_thread_map__get(threads);
 61         perf_thread_map__put(threads);             61         perf_thread_map__put(threads);
 62         perf_thread_map__put(threads);             62         perf_thread_map__put(threads);
 63                                                    63 
 64         test_threadmap_array(THREADS_NR, NULL)     64         test_threadmap_array(THREADS_NR, NULL);
 65                                                    65 
 66         for (i = 0; i < THREADS_NR; i++)           66         for (i = 0; i < THREADS_NR; i++)
 67                 thr_array[i] = i + 100;            67                 thr_array[i] = i + 100;
 68                                                    68 
 69         test_threadmap_array(THREADS_NR, thr_a     69         test_threadmap_array(THREADS_NR, thr_array);
 70                                                    70 
 71         __T_END;                                   71         __T_END;
 72         return tests_failed == 0 ? 0 : -1;         72         return tests_failed == 0 ? 0 : -1;
 73 }                                                  73 }
 74                                                    74 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php