[PATCH v7 4/4] perf test: Add test for event name starting with a number
Shunsuke Nakamura
nakamura.shun at fujitsu.com
Thu Mar 4 03:26:10 GMT 2021
From: Shunsuke Nakamura <nakamura.shun at jp.fujitsu.com>
Add test for event name starting with a number.
This test pattern checks that event names starting with a number do not
result in a 'parse error'.
Committer notes:
Testing arm64 and x86:
# ./perf test fake
10: PMU events :
10.4: Parsing of PMU event table metrics with fake PMUs : Ok
# ./perf test fake -vv
parsing metric: 0inst_commit + 1inst_commit + 2inst_commit + 3inst_commit + 4inst_commit
Attempting to add event pmu '4inst_commit' with '' that may result in non-fatal errors
Attempting to add event pmu '0inst_commit' with '' that may result in non-fatal errors
Attempting to add event pmu '2inst_commit' with '' that may result in non-fatal errors
Attempting to add event pmu '3inst_commit' with '' that may result in non-fatal errors
Attempting to add event pmu '1inst_commit' with '' that may result in non-fatal errors
parsing metric: 0inst_commit + 1inst_commit + 2inst_commit + 3inst_commit + 4inst_commit
lookup(0inst_commit): val 2.000000
lookup(1inst_commit): val 5.000000
lookup(2inst_commit): val 3.000000
lookup(3inst_commit): val 4.000000
lookup(4inst_commit): val 1.000000
test child finished with 0
---- end ----
PMU events subtest 4: Ok
Signed-off-by: Shunsuke Nakamura <nakamura.shun at fujitsu.com>
---
tools/perf/tests/pmu-events.c | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index 0ca6a5a53523..1a95080373ee 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -398,27 +398,12 @@ static int test_aliases(void)
return 0;
}
-static bool is_number(const char *str)
-{
- char *end_ptr;
- double v;
-
- errno = 0;
- v = strtod(str, &end_ptr);
- (void)v; // We're not interested in this value, only if it is valid
- return errno == 0 && end_ptr != str;
-}
-
static int check_parse_id(const char *id, struct parse_events_error *error,
struct perf_pmu *fake_pmu)
{
struct evlist *evlist;
int ret;
- /* Numbers are always valid. */
- if (is_number(id))
- return 0;
-
evlist = evlist__new();
if (!evlist)
return -ENOMEM;
@@ -540,6 +525,7 @@ static struct test_metric metrics[] = {
{ "imx8_ddr0 at axid\\-read\\,axi_mask\\=0xffff\\,axi_id\\=0x0000@ * 4", },
{ "(cstate_pkg at c2\\-residency@ / msr at tsc@) * 100", },
{ "(imx8_ddr0 at read\\-cycles@ + imx8_ddr0 at write\\-cycles@)", },
+ { "0inst_commit + 1inst_commit + 2inst_commit + 3inst_commit + 4inst_commit",} ,
};
static int metric_parse_fake(const char *str)
--
2.25.1
More information about the linux-arm-kernel
mailing list