dm thin metadata: fix __udivdi3 undefined on 32-bit
[linux/fpc-iii.git] / tools / perf / tests / thread-map.c
blob138a0e3431fafd7ae0b6441fa24b7845f7b51ea0
1 #include <sys/types.h>
2 #include <unistd.h>
3 #include "tests.h"
4 #include "thread_map.h"
5 #include "debug.h"
7 int test__thread_map(void)
9 struct thread_map *map;
11 /* test map on current pid */
12 map = thread_map__new_by_pid(getpid());
13 TEST_ASSERT_VAL("failed to alloc map", map);
15 thread_map__read_comms(map);
17 TEST_ASSERT_VAL("wrong nr", map->nr == 1);
18 TEST_ASSERT_VAL("wrong pid",
19 thread_map__pid(map, 0) == getpid());
20 TEST_ASSERT_VAL("wrong comm",
21 thread_map__comm(map, 0) &&
22 !strcmp(thread_map__comm(map, 0), "perf"));
23 TEST_ASSERT_VAL("wrong refcnt",
24 atomic_read(&map->refcnt) == 1);
25 thread_map__put(map);
27 /* test dummy pid */
28 map = thread_map__new_dummy();
29 TEST_ASSERT_VAL("failed to alloc map", map);
31 thread_map__read_comms(map);
33 TEST_ASSERT_VAL("wrong nr", map->nr == 1);
34 TEST_ASSERT_VAL("wrong pid", thread_map__pid(map, 0) == -1);
35 TEST_ASSERT_VAL("wrong comm",
36 thread_map__comm(map, 0) &&
37 !strcmp(thread_map__comm(map, 0), "dummy"));
38 TEST_ASSERT_VAL("wrong refcnt",
39 atomic_read(&map->refcnt) == 1);
40 thread_map__put(map);
41 return 0;