diff options
Diffstat (limited to 'tools/perf/tests')
-rw-r--r-- | tools/perf/tests/attr/README | 6 | ||||
-rw-r--r-- | tools/perf/tests/attr/test-record-graph-default | 2 | ||||
-rw-r--r-- | tools/perf/tests/attr/test-record-graph-dwarf | 2 | ||||
-rw-r--r-- | tools/perf/tests/attr/test-record-graph-fp | 2 | ||||
-rw-r--r-- | tools/perf/tests/code-reading.c | 18 | ||||
-rw-r--r-- | tools/perf/tests/dso-data.c | 1 | ||||
-rw-r--r-- | tools/perf/tests/evsel-tp-sched.c | 4 | ||||
-rw-r--r-- | tools/perf/tests/hists_link.c | 14 | ||||
-rw-r--r-- | tools/perf/tests/keep-tracking.c | 1 | ||||
-rw-r--r-- | tools/perf/tests/mmap-basic.c | 3 | ||||
-rw-r--r-- | tools/perf/tests/open-syscall-all-cpus.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/open-syscall-tp-fields.c | 6 | ||||
-rw-r--r-- | tools/perf/tests/open-syscall.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/parse-events.c | 9 | ||||
-rw-r--r-- | tools/perf/tests/perf-record.c | 14 | ||||
-rw-r--r-- | tools/perf/tests/perf-time-to-tsc.c | 4 | ||||
-rw-r--r-- | tools/perf/tests/rdpmc.c | 2 | ||||
-rw-r--r-- | tools/perf/tests/sample-parsing.c | 11 | ||||
-rw-r--r-- | tools/perf/tests/sw-clock.c | 19 | ||||
-rw-r--r-- | tools/perf/tests/task-exit.c | 22 |
20 files changed, 79 insertions, 65 deletions
diff --git a/tools/perf/tests/attr/README b/tools/perf/tests/attr/README index d102957cd59a..430024f618f1 100644 --- a/tools/perf/tests/attr/README +++ b/tools/perf/tests/attr/README | |||
@@ -44,9 +44,9 @@ Following tests are defined (with perf commands): | |||
44 | perf record -c 123 kill (test-record-count) | 44 | perf record -c 123 kill (test-record-count) |
45 | perf record -d kill (test-record-data) | 45 | perf record -d kill (test-record-data) |
46 | perf record -F 100 kill (test-record-freq) | 46 | perf record -F 100 kill (test-record-freq) |
47 | perf record -g -- kill (test-record-graph-default) | 47 | perf record -g kill (test-record-graph-default) |
48 | perf record -g dwarf -- kill (test-record-graph-dwarf) | 48 | perf record --call-graph dwarf kill (test-record-graph-dwarf) |
49 | perf record -g fp kill (test-record-graph-fp) | 49 | perf record --call-graph fp kill (test-record-graph-fp) |
50 | perf record --group -e cycles,instructions kill (test-record-group) | 50 | perf record --group -e cycles,instructions kill (test-record-group) |
51 | perf record -e '{cycles,instructions}' kill (test-record-group1) | 51 | perf record -e '{cycles,instructions}' kill (test-record-group1) |
52 | perf record -D kill (test-record-no-delay) | 52 | perf record -D kill (test-record-no-delay) |
diff --git a/tools/perf/tests/attr/test-record-graph-default b/tools/perf/tests/attr/test-record-graph-default index 833d1849d767..853597a9a8f6 100644 --- a/tools/perf/tests/attr/test-record-graph-default +++ b/tools/perf/tests/attr/test-record-graph-default | |||
@@ -1,6 +1,6 @@ | |||
1 | [config] | 1 | [config] |
2 | command = record | 2 | command = record |
3 | args = -g -- kill >/dev/null 2>&1 | 3 | args = -g kill >/dev/null 2>&1 |
4 | 4 | ||
5 | [event:base-record] | 5 | [event:base-record] |
6 | sample_type=295 | 6 | sample_type=295 |
diff --git a/tools/perf/tests/attr/test-record-graph-dwarf b/tools/perf/tests/attr/test-record-graph-dwarf index e93e082f5208..d6f324ea578c 100644 --- a/tools/perf/tests/attr/test-record-graph-dwarf +++ b/tools/perf/tests/attr/test-record-graph-dwarf | |||
@@ -1,6 +1,6 @@ | |||
1 | [config] | 1 | [config] |
2 | command = record | 2 | command = record |
3 | args = -g dwarf -- kill >/dev/null 2>&1 | 3 | args = --call-graph dwarf -- kill >/dev/null 2>&1 |
4 | 4 | ||
5 | [event:base-record] | 5 | [event:base-record] |
6 | sample_type=12583 | 6 | sample_type=12583 |
diff --git a/tools/perf/tests/attr/test-record-graph-fp b/tools/perf/tests/attr/test-record-graph-fp index 7cef3743f03f..055e3bee7993 100644 --- a/tools/perf/tests/attr/test-record-graph-fp +++ b/tools/perf/tests/attr/test-record-graph-fp | |||
@@ -1,6 +1,6 @@ | |||
1 | [config] | 1 | [config] |
2 | command = record | 2 | command = record |
3 | args = -g fp kill >/dev/null 2>&1 | 3 | args = --call-graph fp kill >/dev/null 2>&1 |
4 | 4 | ||
5 | [event:base-record] | 5 | [event:base-record] |
6 | sample_type=295 | 6 | sample_type=295 |
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c index 6fb781d5586c..85d4919dd623 100644 --- a/tools/perf/tests/code-reading.c +++ b/tools/perf/tests/code-reading.c | |||
@@ -275,8 +275,19 @@ static int process_event(struct machine *machine, struct perf_evlist *evlist, | |||
275 | if (event->header.type == PERF_RECORD_SAMPLE) | 275 | if (event->header.type == PERF_RECORD_SAMPLE) |
276 | return process_sample_event(machine, evlist, event, state); | 276 | return process_sample_event(machine, evlist, event, state); |
277 | 277 | ||
278 | if (event->header.type < PERF_RECORD_MAX) | 278 | if (event->header.type == PERF_RECORD_THROTTLE || |
279 | return machine__process_event(machine, event); | 279 | event->header.type == PERF_RECORD_UNTHROTTLE) |
280 | return 0; | ||
281 | |||
282 | if (event->header.type < PERF_RECORD_MAX) { | ||
283 | int ret; | ||
284 | |||
285 | ret = machine__process_event(machine, event, NULL); | ||
286 | if (ret < 0) | ||
287 | pr_debug("machine__process_event failed, event type %u\n", | ||
288 | event->header.type); | ||
289 | return ret; | ||
290 | } | ||
280 | 291 | ||
281 | return 0; | 292 | return 0; |
282 | } | 293 | } |
@@ -290,6 +301,7 @@ static int process_events(struct machine *machine, struct perf_evlist *evlist, | |||
290 | for (i = 0; i < evlist->nr_mmaps; i++) { | 301 | for (i = 0; i < evlist->nr_mmaps; i++) { |
291 | while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) { | 302 | while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) { |
292 | ret = process_event(machine, evlist, event, state); | 303 | ret = process_event(machine, evlist, event, state); |
304 | perf_evlist__mmap_consume(evlist, i); | ||
293 | if (ret < 0) | 305 | if (ret < 0) |
294 | return ret; | 306 | return ret; |
295 | } | 307 | } |
@@ -440,7 +452,7 @@ static int do_test_code_reading(bool try_kcore) | |||
440 | } | 452 | } |
441 | 453 | ||
442 | ret = perf_event__synthesize_thread_map(NULL, threads, | 454 | ret = perf_event__synthesize_thread_map(NULL, threads, |
443 | perf_event__process, machine); | 455 | perf_event__process, machine, false); |
444 | if (ret < 0) { | 456 | if (ret < 0) { |
445 | pr_debug("perf_event__synthesize_thread_map failed\n"); | 457 | pr_debug("perf_event__synthesize_thread_map failed\n"); |
446 | goto out_err; | 458 | goto out_err; |
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index dffe0551acaa..9cc81a3eb9b4 100644 --- a/tools/perf/tests/dso-data.c +++ b/tools/perf/tests/dso-data.c | |||
@@ -35,6 +35,7 @@ static char *test_file(int size) | |||
35 | if (size != write(fd, buf, size)) | 35 | if (size != write(fd, buf, size)) |
36 | templ = NULL; | 36 | templ = NULL; |
37 | 37 | ||
38 | free(buf); | ||
38 | close(fd); | 39 | close(fd); |
39 | return templ; | 40 | return templ; |
40 | } | 41 | } |
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c index 9b98c1554833..4774f7fbb758 100644 --- a/tools/perf/tests/evsel-tp-sched.c +++ b/tools/perf/tests/evsel-tp-sched.c | |||
@@ -32,7 +32,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, | |||
32 | 32 | ||
33 | int test__perf_evsel__tp_sched_test(void) | 33 | int test__perf_evsel__tp_sched_test(void) |
34 | { | 34 | { |
35 | struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch", 0); | 35 | struct perf_evsel *evsel = perf_evsel__newtp("sched", "sched_switch"); |
36 | int ret = 0; | 36 | int ret = 0; |
37 | 37 | ||
38 | if (evsel == NULL) { | 38 | if (evsel == NULL) { |
@@ -63,7 +63,7 @@ int test__perf_evsel__tp_sched_test(void) | |||
63 | 63 | ||
64 | perf_evsel__delete(evsel); | 64 | perf_evsel__delete(evsel); |
65 | 65 | ||
66 | evsel = perf_evsel__newtp("sched", "sched_wakeup", 0); | 66 | evsel = perf_evsel__newtp("sched", "sched_wakeup"); |
67 | 67 | ||
68 | if (perf_evsel__test_field(evsel, "comm", 16, true)) | 68 | if (perf_evsel__test_field(evsel, "comm", 16, true)) |
69 | ret = -1; | 69 | ret = -1; |
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index 4228ffc0d968..173bf42cc03e 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c | |||
@@ -93,7 +93,7 @@ static struct machine *setup_fake_machine(struct machines *machines) | |||
93 | if (thread == NULL) | 93 | if (thread == NULL) |
94 | goto out; | 94 | goto out; |
95 | 95 | ||
96 | thread__set_comm(thread, fake_threads[i].comm); | 96 | thread__set_comm(thread, fake_threads[i].comm, 0); |
97 | } | 97 | } |
98 | 98 | ||
99 | for (i = 0; i < ARRAY_SIZE(fake_mmap_info); i++) { | 99 | for (i = 0; i < ARRAY_SIZE(fake_mmap_info); i++) { |
@@ -110,7 +110,7 @@ static struct machine *setup_fake_machine(struct machines *machines) | |||
110 | strcpy(fake_mmap_event.mmap.filename, | 110 | strcpy(fake_mmap_event.mmap.filename, |
111 | fake_mmap_info[i].filename); | 111 | fake_mmap_info[i].filename); |
112 | 112 | ||
113 | machine__process_mmap_event(machine, &fake_mmap_event); | 113 | machine__process_mmap_event(machine, &fake_mmap_event, NULL); |
114 | } | 114 | } |
115 | 115 | ||
116 | for (i = 0; i < ARRAY_SIZE(fake_symbols); i++) { | 116 | for (i = 0; i < ARRAY_SIZE(fake_symbols); i++) { |
@@ -222,7 +222,8 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) | |||
222 | &sample) < 0) | 222 | &sample) < 0) |
223 | goto out; | 223 | goto out; |
224 | 224 | ||
225 | he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1); | 225 | he = __hists__add_entry(&evsel->hists, &al, NULL, |
226 | NULL, NULL, 1, 1, 0); | ||
226 | if (he == NULL) | 227 | if (he == NULL) |
227 | goto out; | 228 | goto out; |
228 | 229 | ||
@@ -244,7 +245,8 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) | |||
244 | &sample) < 0) | 245 | &sample) < 0) |
245 | goto out; | 246 | goto out; |
246 | 247 | ||
247 | he = __hists__add_entry(&evsel->hists, &al, NULL, 1, 1); | 248 | he = __hists__add_entry(&evsel->hists, &al, NULL, |
249 | NULL, NULL, 1, 1, 0); | ||
248 | if (he == NULL) | 250 | if (he == NULL) |
249 | goto out; | 251 | goto out; |
250 | 252 | ||
@@ -419,7 +421,7 @@ static void print_hists(struct hists *hists) | |||
419 | he = rb_entry(node, struct hist_entry, rb_node_in); | 421 | he = rb_entry(node, struct hist_entry, rb_node_in); |
420 | 422 | ||
421 | pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n", | 423 | pr_info("%2d: entry: %-8s [%-8s] %20s: period = %"PRIu64"\n", |
422 | i, he->thread->comm, he->ms.map->dso->short_name, | 424 | i, thread__comm_str(he->thread), he->ms.map->dso->short_name, |
423 | he->ms.sym->name, he->stat.period); | 425 | he->ms.sym->name, he->stat.period); |
424 | 426 | ||
425 | i++; | 427 | i++; |
@@ -465,7 +467,7 @@ int test__hists_link(void) | |||
465 | goto out; | 467 | goto out; |
466 | 468 | ||
467 | list_for_each_entry(evsel, &evlist->entries, node) { | 469 | list_for_each_entry(evsel, &evlist->entries, node) { |
468 | hists__collapse_resort(&evsel->hists); | 470 | hists__collapse_resort(&evsel->hists, NULL); |
469 | 471 | ||
470 | if (verbose > 2) | 472 | if (verbose > 2) |
471 | print_hists(&evsel->hists); | 473 | print_hists(&evsel->hists); |
diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c index d444ea2c47d9..376c35608534 100644 --- a/tools/perf/tests/keep-tracking.c +++ b/tools/perf/tests/keep-tracking.c | |||
@@ -36,6 +36,7 @@ static int find_comm(struct perf_evlist *evlist, const char *comm) | |||
36 | (pid_t)event->comm.tid == getpid() && | 36 | (pid_t)event->comm.tid == getpid() && |
37 | strcmp(event->comm.comm, comm) == 0) | 37 | strcmp(event->comm.comm, comm) == 0) |
38 | found += 1; | 38 | found += 1; |
39 | perf_evlist__mmap_consume(evlist, i); | ||
39 | } | 40 | } |
40 | } | 41 | } |
41 | return found; | 42 | return found; |
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index c4185b9aeb80..d64ab79c6d35 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c | |||
@@ -65,7 +65,7 @@ int test__basic_mmap(void) | |||
65 | char name[64]; | 65 | char name[64]; |
66 | 66 | ||
67 | snprintf(name, sizeof(name), "sys_enter_%s", syscall_names[i]); | 67 | snprintf(name, sizeof(name), "sys_enter_%s", syscall_names[i]); |
68 | evsels[i] = perf_evsel__newtp("syscalls", name, i); | 68 | evsels[i] = perf_evsel__newtp("syscalls", name); |
69 | if (evsels[i] == NULL) { | 69 | if (evsels[i] == NULL) { |
70 | pr_debug("perf_evsel__new\n"); | 70 | pr_debug("perf_evsel__new\n"); |
71 | goto out_free_evlist; | 71 | goto out_free_evlist; |
@@ -122,6 +122,7 @@ int test__basic_mmap(void) | |||
122 | goto out_munmap; | 122 | goto out_munmap; |
123 | } | 123 | } |
124 | nr_events[evsel->idx]++; | 124 | nr_events[evsel->idx]++; |
125 | perf_evlist__mmap_consume(evlist, 0); | ||
125 | } | 126 | } |
126 | 127 | ||
127 | err = 0; | 128 | err = 0; |
diff --git a/tools/perf/tests/open-syscall-all-cpus.c b/tools/perf/tests/open-syscall-all-cpus.c index b0657a9ccda6..5fecdbd2f5f7 100644 --- a/tools/perf/tests/open-syscall-all-cpus.c +++ b/tools/perf/tests/open-syscall-all-cpus.c | |||
@@ -26,7 +26,7 @@ int test__open_syscall_event_on_all_cpus(void) | |||
26 | 26 | ||
27 | CPU_ZERO(&cpu_set); | 27 | CPU_ZERO(&cpu_set); |
28 | 28 | ||
29 | evsel = perf_evsel__newtp("syscalls", "sys_enter_open", 0); | 29 | evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); |
30 | if (evsel == NULL) { | 30 | if (evsel == NULL) { |
31 | pr_debug("is debugfs mounted on /sys/kernel/debug?\n"); | 31 | pr_debug("is debugfs mounted on /sys/kernel/debug?\n"); |
32 | goto out_thread_map_delete; | 32 | goto out_thread_map_delete; |
diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c index fc5b9fca8b47..41cc0badb74b 100644 --- a/tools/perf/tests/open-syscall-tp-fields.c +++ b/tools/perf/tests/open-syscall-tp-fields.c | |||
@@ -27,7 +27,7 @@ int test__syscall_open_tp_fields(void) | |||
27 | goto out; | 27 | goto out; |
28 | } | 28 | } |
29 | 29 | ||
30 | evsel = perf_evsel__newtp("syscalls", "sys_enter_open", 0); | 30 | evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); |
31 | if (evsel == NULL) { | 31 | if (evsel == NULL) { |
32 | pr_debug("%s: perf_evsel__newtp\n", __func__); | 32 | pr_debug("%s: perf_evsel__newtp\n", __func__); |
33 | goto out_delete_evlist; | 33 | goto out_delete_evlist; |
@@ -77,8 +77,10 @@ int test__syscall_open_tp_fields(void) | |||
77 | 77 | ||
78 | ++nr_events; | 78 | ++nr_events; |
79 | 79 | ||
80 | if (type != PERF_RECORD_SAMPLE) | 80 | if (type != PERF_RECORD_SAMPLE) { |
81 | perf_evlist__mmap_consume(evlist, i); | ||
81 | continue; | 82 | continue; |
83 | } | ||
82 | 84 | ||
83 | err = perf_evsel__parse_sample(evsel, event, &sample); | 85 | err = perf_evsel__parse_sample(evsel, event, &sample); |
84 | if (err) { | 86 | if (err) { |
diff --git a/tools/perf/tests/open-syscall.c b/tools/perf/tests/open-syscall.c index befc0671f95d..c1dc7d25f38c 100644 --- a/tools/perf/tests/open-syscall.c +++ b/tools/perf/tests/open-syscall.c | |||
@@ -15,7 +15,7 @@ int test__open_syscall_event(void) | |||
15 | return -1; | 15 | return -1; |
16 | } | 16 | } |
17 | 17 | ||
18 | evsel = perf_evsel__newtp("syscalls", "sys_enter_open", 0); | 18 | evsel = perf_evsel__newtp("syscalls", "sys_enter_open"); |
19 | if (evsel == NULL) { | 19 | if (evsel == NULL) { |
20 | pr_debug("is debugfs mounted on /sys/kernel/debug?\n"); | 20 | pr_debug("is debugfs mounted on /sys/kernel/debug?\n"); |
21 | goto out_thread_map_delete; | 21 | goto out_thread_map_delete; |
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 48114d164e9f..3cbd10496087 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c | |||
@@ -2,7 +2,7 @@ | |||
2 | #include "parse-events.h" | 2 | #include "parse-events.h" |
3 | #include "evsel.h" | 3 | #include "evsel.h" |
4 | #include "evlist.h" | 4 | #include "evlist.h" |
5 | #include "sysfs.h" | 5 | #include "fs.h" |
6 | #include <lk/debugfs.h> | 6 | #include <lk/debugfs.h> |
7 | #include "tests.h" | 7 | #include "tests.h" |
8 | #include <linux/hw_breakpoint.h> | 8 | #include <linux/hw_breakpoint.h> |
@@ -441,9 +441,8 @@ static int test__checkevent_pmu_name(struct perf_evlist *evlist) | |||
441 | 441 | ||
442 | static int test__checkevent_pmu_events(struct perf_evlist *evlist) | 442 | static int test__checkevent_pmu_events(struct perf_evlist *evlist) |
443 | { | 443 | { |
444 | struct perf_evsel *evsel; | 444 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
445 | 445 | ||
446 | evsel = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
447 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 446 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
448 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 447 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
449 | TEST_ASSERT_VAL("wrong exclude_user", | 448 | TEST_ASSERT_VAL("wrong exclude_user", |
@@ -1456,7 +1455,7 @@ static int test_pmu(void) | |||
1456 | int ret; | 1455 | int ret; |
1457 | 1456 | ||
1458 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", | 1457 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", |
1459 | sysfs_find_mountpoint()); | 1458 | sysfs__mountpoint()); |
1460 | 1459 | ||
1461 | ret = stat(path, &st); | 1460 | ret = stat(path, &st); |
1462 | if (ret) | 1461 | if (ret) |
@@ -1473,7 +1472,7 @@ static int test_pmu_events(void) | |||
1473 | int ret; | 1472 | int ret; |
1474 | 1473 | ||
1475 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", | 1474 | snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", |
1476 | sysfs_find_mountpoint()); | 1475 | sysfs__mountpoint()); |
1477 | 1476 | ||
1478 | ret = stat(path, &st); | 1477 | ret = stat(path, &st); |
1479 | if (ret) { | 1478 | if (ret) { |
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index b8a7056519ac..93a62b06c3af 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c | |||
@@ -45,7 +45,7 @@ int test__PERF_RECORD(void) | |||
45 | }; | 45 | }; |
46 | cpu_set_t cpu_mask; | 46 | cpu_set_t cpu_mask; |
47 | size_t cpu_mask_size = sizeof(cpu_mask); | 47 | size_t cpu_mask_size = sizeof(cpu_mask); |
48 | struct perf_evlist *evlist = perf_evlist__new(); | 48 | struct perf_evlist *evlist = perf_evlist__new_default(); |
49 | struct perf_evsel *evsel; | 49 | struct perf_evsel *evsel; |
50 | struct perf_sample sample; | 50 | struct perf_sample sample; |
51 | const char *cmd = "sleep"; | 51 | const char *cmd = "sleep"; |
@@ -66,16 +66,6 @@ int test__PERF_RECORD(void) | |||
66 | } | 66 | } |
67 | 67 | ||
68 | /* | 68 | /* |
69 | * We need at least one evsel in the evlist, use the default | ||
70 | * one: "cycles". | ||
71 | */ | ||
72 | err = perf_evlist__add_default(evlist); | ||
73 | if (err < 0) { | ||
74 | pr_debug("Not enough memory to create evsel\n"); | ||
75 | goto out_delete_evlist; | ||
76 | } | ||
77 | |||
78 | /* | ||
79 | * Create maps of threads and cpus to monitor. In this case | 69 | * Create maps of threads and cpus to monitor. In this case |
80 | * we start with all threads and cpus (-1, -1) but then in | 70 | * we start with all threads and cpus (-1, -1) but then in |
81 | * perf_evlist__prepare_workload we'll fill in the only thread | 71 | * perf_evlist__prepare_workload we'll fill in the only thread |
@@ -263,6 +253,8 @@ int test__PERF_RECORD(void) | |||
263 | type); | 253 | type); |
264 | ++errs; | 254 | ++errs; |
265 | } | 255 | } |
256 | |||
257 | perf_evlist__mmap_consume(evlist, i); | ||
266 | } | 258 | } |
267 | } | 259 | } |
268 | 260 | ||
diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c index 0ab61b1f408e..4ca1b938f6a6 100644 --- a/tools/perf/tests/perf-time-to-tsc.c +++ b/tools/perf/tests/perf-time-to-tsc.c | |||
@@ -122,7 +122,7 @@ int test__perf_time_to_tsc(void) | |||
122 | if (event->header.type != PERF_RECORD_COMM || | 122 | if (event->header.type != PERF_RECORD_COMM || |
123 | (pid_t)event->comm.pid != getpid() || | 123 | (pid_t)event->comm.pid != getpid() || |
124 | (pid_t)event->comm.tid != getpid()) | 124 | (pid_t)event->comm.tid != getpid()) |
125 | continue; | 125 | goto next_event; |
126 | 126 | ||
127 | if (strcmp(event->comm.comm, comm1) == 0) { | 127 | if (strcmp(event->comm.comm, comm1) == 0) { |
128 | CHECK__(perf_evsel__parse_sample(evsel, event, | 128 | CHECK__(perf_evsel__parse_sample(evsel, event, |
@@ -134,6 +134,8 @@ int test__perf_time_to_tsc(void) | |||
134 | &sample)); | 134 | &sample)); |
135 | comm2_time = sample.time; | 135 | comm2_time = sample.time; |
136 | } | 136 | } |
137 | next_event: | ||
138 | perf_evlist__mmap_consume(evlist, i); | ||
137 | } | 139 | } |
138 | } | 140 | } |
139 | 141 | ||
diff --git a/tools/perf/tests/rdpmc.c b/tools/perf/tests/rdpmc.c index ff94886aad99..46649c25fa5e 100644 --- a/tools/perf/tests/rdpmc.c +++ b/tools/perf/tests/rdpmc.c | |||
@@ -9,8 +9,6 @@ | |||
9 | 9 | ||
10 | #if defined(__x86_64__) || defined(__i386__) | 10 | #if defined(__x86_64__) || defined(__i386__) |
11 | 11 | ||
12 | #define barrier() asm volatile("" ::: "memory") | ||
13 | |||
14 | static u64 rdpmc(unsigned int counter) | 12 | static u64 rdpmc(unsigned int counter) |
15 | { | 13 | { |
16 | unsigned int low, high; | 14 | unsigned int low, high; |
diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c index 77f598dbd97a..1b677202638d 100644 --- a/tools/perf/tests/sample-parsing.c +++ b/tools/perf/tests/sample-parsing.c | |||
@@ -121,6 +121,9 @@ static bool samples_same(const struct perf_sample *s1, | |||
121 | if (type & PERF_SAMPLE_DATA_SRC) | 121 | if (type & PERF_SAMPLE_DATA_SRC) |
122 | COMP(data_src); | 122 | COMP(data_src); |
123 | 123 | ||
124 | if (type & PERF_SAMPLE_TRANSACTION) | ||
125 | COMP(transaction); | ||
126 | |||
124 | return true; | 127 | return true; |
125 | } | 128 | } |
126 | 129 | ||
@@ -165,6 +168,7 @@ static int do_test(u64 sample_type, u64 sample_regs_user, u64 read_format) | |||
165 | .cpu = 110, | 168 | .cpu = 110, |
166 | .raw_size = sizeof(raw_data), | 169 | .raw_size = sizeof(raw_data), |
167 | .data_src = 111, | 170 | .data_src = 111, |
171 | .transaction = 112, | ||
168 | .raw_data = (void *)raw_data, | 172 | .raw_data = (void *)raw_data, |
169 | .callchain = &callchain.callchain, | 173 | .callchain = &callchain.callchain, |
170 | .branch_stack = &branch_stack.branch_stack, | 174 | .branch_stack = &branch_stack.branch_stack, |
@@ -273,10 +277,11 @@ int test__sample_parsing(void) | |||
273 | 277 | ||
274 | /* | 278 | /* |
275 | * Fail the test if it has not been updated when new sample format bits | 279 | * Fail the test if it has not been updated when new sample format bits |
276 | * were added. | 280 | * were added. Please actually update the test rather than just change |
281 | * the condition below. | ||
277 | */ | 282 | */ |
278 | if (PERF_SAMPLE_MAX > PERF_SAMPLE_IDENTIFIER << 1) { | 283 | if (PERF_SAMPLE_MAX > PERF_SAMPLE_TRANSACTION << 1) { |
279 | pr_debug("sample format has changed - test needs updating\n"); | 284 | pr_debug("sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating\n"); |
280 | return -1; | 285 | return -1; |
281 | } | 286 | } |
282 | 287 | ||
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index 2e41e2d32ccc..6664a7cd828c 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #include "util/cpumap.h" | 9 | #include "util/cpumap.h" |
10 | #include "util/thread_map.h" | 10 | #include "util/thread_map.h" |
11 | 11 | ||
12 | #define NR_LOOPS 1000000 | 12 | #define NR_LOOPS 10000000 |
13 | 13 | ||
14 | /* | 14 | /* |
15 | * This test will open software clock events (cpu-clock, task-clock) | 15 | * This test will open software clock events (cpu-clock, task-clock) |
@@ -34,7 +34,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
34 | .freq = 1, | 34 | .freq = 1, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | attr.sample_freq = 10000; | 37 | attr.sample_freq = 500; |
38 | 38 | ||
39 | evlist = perf_evlist__new(); | 39 | evlist = perf_evlist__new(); |
40 | if (evlist == NULL) { | 40 | if (evlist == NULL) { |
@@ -42,7 +42,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
42 | return -1; | 42 | return -1; |
43 | } | 43 | } |
44 | 44 | ||
45 | evsel = perf_evsel__new(&attr, 0); | 45 | evsel = perf_evsel__new(&attr); |
46 | if (evsel == NULL) { | 46 | if (evsel == NULL) { |
47 | pr_debug("perf_evsel__new\n"); | 47 | pr_debug("perf_evsel__new\n"); |
48 | goto out_free_evlist; | 48 | goto out_free_evlist; |
@@ -57,7 +57,14 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
57 | goto out_delete_maps; | 57 | goto out_delete_maps; |
58 | } | 58 | } |
59 | 59 | ||
60 | perf_evlist__open(evlist); | 60 | if (perf_evlist__open(evlist)) { |
61 | const char *knob = "/proc/sys/kernel/perf_event_max_sample_rate"; | ||
62 | |||
63 | err = -errno; | ||
64 | pr_debug("Couldn't open evlist: %s\nHint: check %s, using %" PRIu64 " in this test.\n", | ||
65 | strerror(errno), knob, (u64)attr.sample_freq); | ||
66 | goto out_delete_maps; | ||
67 | } | ||
61 | 68 | ||
62 | err = perf_evlist__mmap(evlist, 128, true); | 69 | err = perf_evlist__mmap(evlist, 128, true); |
63 | if (err < 0) { | 70 | if (err < 0) { |
@@ -78,7 +85,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
78 | struct perf_sample sample; | 85 | struct perf_sample sample; |
79 | 86 | ||
80 | if (event->header.type != PERF_RECORD_SAMPLE) | 87 | if (event->header.type != PERF_RECORD_SAMPLE) |
81 | continue; | 88 | goto next_event; |
82 | 89 | ||
83 | err = perf_evlist__parse_sample(evlist, event, &sample); | 90 | err = perf_evlist__parse_sample(evlist, event, &sample); |
84 | if (err < 0) { | 91 | if (err < 0) { |
@@ -88,6 +95,8 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
88 | 95 | ||
89 | total_periods += sample.period; | 96 | total_periods += sample.period; |
90 | nr_samples++; | 97 | nr_samples++; |
98 | next_event: | ||
99 | perf_evlist__mmap_consume(evlist, 0); | ||
91 | } | 100 | } |
92 | 101 | ||
93 | if ((u64) nr_samples == total_periods) { | 102 | if ((u64) nr_samples == total_periods) { |
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index 28fe5894b061..d09ab579119e 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c | |||
@@ -28,7 +28,7 @@ int test__task_exit(void) | |||
28 | union perf_event *event; | 28 | union perf_event *event; |
29 | struct perf_evsel *evsel; | 29 | struct perf_evsel *evsel; |
30 | struct perf_evlist *evlist; | 30 | struct perf_evlist *evlist; |
31 | struct perf_target target = { | 31 | struct target target = { |
32 | .uid = UINT_MAX, | 32 | .uid = UINT_MAX, |
33 | .uses_mmap = true, | 33 | .uses_mmap = true, |
34 | }; | 34 | }; |
@@ -37,20 +37,11 @@ int test__task_exit(void) | |||
37 | signal(SIGCHLD, sig_handler); | 37 | signal(SIGCHLD, sig_handler); |
38 | signal(SIGUSR1, sig_handler); | 38 | signal(SIGUSR1, sig_handler); |
39 | 39 | ||
40 | evlist = perf_evlist__new(); | 40 | evlist = perf_evlist__new_default(); |
41 | if (evlist == NULL) { | 41 | if (evlist == NULL) { |
42 | pr_debug("perf_evlist__new\n"); | 42 | pr_debug("perf_evlist__new_default\n"); |
43 | return -1; | 43 | return -1; |
44 | } | 44 | } |
45 | /* | ||
46 | * We need at least one evsel in the evlist, use the default | ||
47 | * one: "cycles". | ||
48 | */ | ||
49 | err = perf_evlist__add_default(evlist); | ||
50 | if (err < 0) { | ||
51 | pr_debug("Not enough memory to create evsel\n"); | ||
52 | goto out_free_evlist; | ||
53 | } | ||
54 | 45 | ||
55 | /* | 46 | /* |
56 | * Create maps of threads and cpus to monitor. In this case | 47 | * Create maps of threads and cpus to monitor. In this case |
@@ -96,10 +87,10 @@ int test__task_exit(void) | |||
96 | 87 | ||
97 | retry: | 88 | retry: |
98 | while ((event = perf_evlist__mmap_read(evlist, 0)) != NULL) { | 89 | while ((event = perf_evlist__mmap_read(evlist, 0)) != NULL) { |
99 | if (event->header.type != PERF_RECORD_EXIT) | 90 | if (event->header.type == PERF_RECORD_EXIT) |
100 | continue; | 91 | nr_exit++; |
101 | 92 | ||
102 | nr_exit++; | 93 | perf_evlist__mmap_consume(evlist, 0); |
103 | } | 94 | } |
104 | 95 | ||
105 | if (!exited || !nr_exit) { | 96 | if (!exited || !nr_exit) { |
@@ -117,7 +108,6 @@ out_close_evlist: | |||
117 | perf_evlist__close(evlist); | 108 | perf_evlist__close(evlist); |
118 | out_delete_maps: | 109 | out_delete_maps: |
119 | perf_evlist__delete_maps(evlist); | 110 | perf_evlist__delete_maps(evlist); |
120 | out_free_evlist: | ||
121 | perf_evlist__delete(evlist); | 111 | perf_evlist__delete(evlist); |
122 | return err; | 112 | return err; |
123 | } | 113 | } |