[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210304032610.3112996-5-nakamura.shun@fujitsu.com>
Date: Thu, 4 Mar 2021 12:26:10 +0900
From: Shunsuke Nakamura <nakamura.shun@...itsu.com>
To: john.garry@...wei.com, will@...nel.org, mathieu.poirier@...aro.org,
leo.yan@...aro.org, peterz@...radead.org, mingo@...hat.com,
acme@...nel.org, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
namhyung@...nel.org
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH v7 4/4] perf test: Add test for event name starting with a number
From: Shunsuke Nakamura <nakamura.shun@...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@...itsu.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@...d\\-read\\,axi_mask\\=0xffff\\,axi_id\\=0x0000@ * 4", },
{ "(cstate_pkg@c2\\-residency@ / msr@tsc@) * 100", },
{ "(imx8_ddr0@...d\\-cycles@ + imx8_ddr0@...te\\-cycles@)", },
+ { "0inst_commit + 1inst_commit + 2inst_commit + 3inst_commit + 4inst_commit",} ,
};
static int metric_parse_fake(const char *str)
--
2.25.1
Powered by blists - more mailing lists