diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-12-02 10:53:04 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-12-02 11:00:04 -0500 |
commit | f71c49e5e985897850406a152ab99001cfb86f2a (patch) | |
tree | 8ab0b3afaeb770457a2034b961311207a143df72 /tools/perf | |
parent | 3e7c439a7ce537ed662e347b9e6414d7881fb3dc (diff) |
perf test: Soft errors shouldn't stop the "Validate PERF_RECORD_" test
For errors that don't preclude checking for further errors, aka "soft"
errors, just continue testing for other errors.
Better coverage in verbose mode.
Suggested-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-jafcokbj26m845dsgm2hx6az@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-test.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index f1e36110b101..6173f780dce0 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
@@ -903,7 +903,7 @@ static int test__PERF_RECORD(void) | |||
903 | found_libc_mmap = false, | 903 | found_libc_mmap = false, |
904 | found_vdso_mmap = false, | 904 | found_vdso_mmap = false, |
905 | found_ld_mmap = false; | 905 | found_ld_mmap = false; |
906 | int err = -1, i, wakeups = 0, sample_size; | 906 | int err = -1, errs = 0, i, wakeups = 0, sample_size; |
907 | u32 cpu; | 907 | u32 cpu; |
908 | int total_events = 0, nr_events[PERF_RECORD_MAX] = { 0, }; | 908 | int total_events = 0, nr_events[PERF_RECORD_MAX] = { 0, }; |
909 | 909 | ||
@@ -1012,8 +1012,6 @@ static int test__PERF_RECORD(void) | |||
1012 | */ | 1012 | */ |
1013 | perf_evlist__start_workload(evlist); | 1013 | perf_evlist__start_workload(evlist); |
1014 | 1014 | ||
1015 | err = -1; | ||
1016 | |||
1017 | while (1) { | 1015 | while (1) { |
1018 | int before = total_events; | 1016 | int before = total_events; |
1019 | 1017 | ||
@@ -1028,9 +1026,10 @@ static int test__PERF_RECORD(void) | |||
1028 | if (type < PERF_RECORD_MAX) | 1026 | if (type < PERF_RECORD_MAX) |
1029 | nr_events[type]++; | 1027 | nr_events[type]++; |
1030 | 1028 | ||
1031 | if (perf_event__parse_sample(event, sample_type, | 1029 | err = perf_event__parse_sample(event, sample_type, |
1032 | sample_size, true, | 1030 | sample_size, true, |
1033 | &sample, false) < 0) { | 1031 | &sample, false); |
1032 | if (err < 0) { | ||
1034 | if (verbose) | 1033 | if (verbose) |
1035 | perf_event__fprintf(event, stderr); | 1034 | perf_event__fprintf(event, stderr); |
1036 | pr_debug("Couldn't parse sample\n"); | 1035 | pr_debug("Couldn't parse sample\n"); |
@@ -1045,7 +1044,7 @@ static int test__PERF_RECORD(void) | |||
1045 | if (prev_time > sample.time) { | 1044 | if (prev_time > sample.time) { |
1046 | pr_debug("%s going backwards in time, prev=%" PRIu64 ", curr=%" PRIu64 "\n", | 1045 | pr_debug("%s going backwards in time, prev=%" PRIu64 ", curr=%" PRIu64 "\n", |
1047 | name, prev_time, sample.time); | 1046 | name, prev_time, sample.time); |
1048 | goto out_err; | 1047 | ++errs; |
1049 | } | 1048 | } |
1050 | 1049 | ||
1051 | prev_time = sample.time; | 1050 | prev_time = sample.time; |
@@ -1053,19 +1052,19 @@ static int test__PERF_RECORD(void) | |||
1053 | if (sample.cpu != cpu) { | 1052 | if (sample.cpu != cpu) { |
1054 | pr_debug("%s with unexpected cpu, expected %d, got %d\n", | 1053 | pr_debug("%s with unexpected cpu, expected %d, got %d\n", |
1055 | name, cpu, sample.cpu); | 1054 | name, cpu, sample.cpu); |
1056 | goto out_err; | 1055 | ++errs; |
1057 | } | 1056 | } |
1058 | 1057 | ||
1059 | if ((pid_t)sample.pid != evlist->workload.pid) { | 1058 | if ((pid_t)sample.pid != evlist->workload.pid) { |
1060 | pr_debug("%s with unexpected pid, expected %d, got %d\n", | 1059 | pr_debug("%s with unexpected pid, expected %d, got %d\n", |
1061 | name, evlist->workload.pid, sample.pid); | 1060 | name, evlist->workload.pid, sample.pid); |
1062 | goto out_err; | 1061 | ++errs; |
1063 | } | 1062 | } |
1064 | 1063 | ||
1065 | if ((pid_t)sample.tid != evlist->workload.pid) { | 1064 | if ((pid_t)sample.tid != evlist->workload.pid) { |
1066 | pr_debug("%s with unexpected tid, expected %d, got %d\n", | 1065 | pr_debug("%s with unexpected tid, expected %d, got %d\n", |
1067 | name, evlist->workload.pid, sample.tid); | 1066 | name, evlist->workload.pid, sample.tid); |
1068 | goto out_err; | 1067 | ++errs; |
1069 | } | 1068 | } |
1070 | 1069 | ||
1071 | if ((type == PERF_RECORD_COMM || | 1070 | if ((type == PERF_RECORD_COMM || |
@@ -1074,21 +1073,21 @@ static int test__PERF_RECORD(void) | |||
1074 | type == PERF_RECORD_EXIT) && | 1073 | type == PERF_RECORD_EXIT) && |
1075 | (pid_t)event->comm.pid != evlist->workload.pid) { | 1074 | (pid_t)event->comm.pid != evlist->workload.pid) { |
1076 | pr_debug("%s with unexpected pid/tid\n", name); | 1075 | pr_debug("%s with unexpected pid/tid\n", name); |
1077 | goto out_err; | 1076 | ++errs; |
1078 | } | 1077 | } |
1079 | 1078 | ||
1080 | if ((type == PERF_RECORD_COMM || | 1079 | if ((type == PERF_RECORD_COMM || |
1081 | type == PERF_RECORD_MMAP) && | 1080 | type == PERF_RECORD_MMAP) && |
1082 | event->comm.pid != event->comm.tid) { | 1081 | event->comm.pid != event->comm.tid) { |
1083 | pr_debug("%s with different pid/tid!\n", name); | 1082 | pr_debug("%s with different pid/tid!\n", name); |
1084 | goto out_err; | 1083 | ++errs; |
1085 | } | 1084 | } |
1086 | 1085 | ||
1087 | switch (type) { | 1086 | switch (type) { |
1088 | case PERF_RECORD_COMM: | 1087 | case PERF_RECORD_COMM: |
1089 | if (strcmp(event->comm.comm, cmd)) { | 1088 | if (strcmp(event->comm.comm, cmd)) { |
1090 | pr_debug("%s with unexpected comm!\n", name); | 1089 | pr_debug("%s with unexpected comm!\n", name); |
1091 | goto out_err; | 1090 | ++errs; |
1092 | } | 1091 | } |
1093 | break; | 1092 | break; |
1094 | case PERF_RECORD_EXIT: | 1093 | case PERF_RECORD_EXIT: |
@@ -1112,7 +1111,7 @@ static int test__PERF_RECORD(void) | |||
1112 | default: | 1111 | default: |
1113 | pr_debug("Unexpected perf_event->header.type %d!\n", | 1112 | pr_debug("Unexpected perf_event->header.type %d!\n", |
1114 | type); | 1113 | type); |
1115 | goto out_err; | 1114 | ++errs; |
1116 | } | 1115 | } |
1117 | } | 1116 | } |
1118 | } | 1117 | } |
@@ -1128,42 +1127,40 @@ static int test__PERF_RECORD(void) | |||
1128 | sleep(1); | 1127 | sleep(1); |
1129 | if (++wakeups > 5) { | 1128 | if (++wakeups > 5) { |
1130 | pr_debug("No PERF_RECORD_EXIT event!\n"); | 1129 | pr_debug("No PERF_RECORD_EXIT event!\n"); |
1131 | goto out_err; | 1130 | break; |
1132 | } | 1131 | } |
1133 | } | 1132 | } |
1134 | 1133 | ||
1135 | found_exit: | 1134 | found_exit: |
1136 | if (nr_events[PERF_RECORD_COMM] > 1) { | 1135 | if (nr_events[PERF_RECORD_COMM] > 1) { |
1137 | pr_debug("Excessive number of PERF_RECORD_COMM events!\n"); | 1136 | pr_debug("Excessive number of PERF_RECORD_COMM events!\n"); |
1138 | goto out_err; | 1137 | ++errs; |
1139 | } | 1138 | } |
1140 | 1139 | ||
1141 | if (nr_events[PERF_RECORD_COMM] == 0) { | 1140 | if (nr_events[PERF_RECORD_COMM] == 0) { |
1142 | pr_debug("Missing PERF_RECORD_COMM for %s!\n", cmd); | 1141 | pr_debug("Missing PERF_RECORD_COMM for %s!\n", cmd); |
1143 | goto out_err; | 1142 | ++errs; |
1144 | } | 1143 | } |
1145 | 1144 | ||
1146 | if (!found_cmd_mmap) { | 1145 | if (!found_cmd_mmap) { |
1147 | pr_debug("PERF_RECORD_MMAP for %s missing!\n", cmd); | 1146 | pr_debug("PERF_RECORD_MMAP for %s missing!\n", cmd); |
1148 | goto out_err; | 1147 | ++errs; |
1149 | } | 1148 | } |
1150 | 1149 | ||
1151 | if (!found_libc_mmap) { | 1150 | if (!found_libc_mmap) { |
1152 | pr_debug("PERF_RECORD_MMAP for %s missing!\n", "libc"); | 1151 | pr_debug("PERF_RECORD_MMAP for %s missing!\n", "libc"); |
1153 | goto out_err; | 1152 | ++errs; |
1154 | } | 1153 | } |
1155 | 1154 | ||
1156 | if (!found_ld_mmap) { | 1155 | if (!found_ld_mmap) { |
1157 | pr_debug("PERF_RECORD_MMAP for %s missing!\n", "ld"); | 1156 | pr_debug("PERF_RECORD_MMAP for %s missing!\n", "ld"); |
1158 | goto out_err; | 1157 | ++errs; |
1159 | } | 1158 | } |
1160 | 1159 | ||
1161 | if (!found_vdso_mmap) { | 1160 | if (!found_vdso_mmap) { |
1162 | pr_debug("PERF_RECORD_MMAP for %s missing!\n", "[vdso]"); | 1161 | pr_debug("PERF_RECORD_MMAP for %s missing!\n", "[vdso]"); |
1163 | goto out_err; | 1162 | ++errs; |
1164 | } | 1163 | } |
1165 | |||
1166 | err = 0; | ||
1167 | out_err: | 1164 | out_err: |
1168 | perf_evlist__munmap(evlist); | 1165 | perf_evlist__munmap(evlist); |
1169 | out_free_cpu_mask: | 1166 | out_free_cpu_mask: |
@@ -1171,7 +1168,7 @@ out_free_cpu_mask: | |||
1171 | out_delete_evlist: | 1168 | out_delete_evlist: |
1172 | perf_evlist__delete(evlist); | 1169 | perf_evlist__delete(evlist); |
1173 | out: | 1170 | out: |
1174 | return err; | 1171 | return (err < 0 || errs > 0) ? -1 : 0; |
1175 | } | 1172 | } |
1176 | 1173 | ||
1177 | static struct test { | 1174 | static struct test { |