Thread (9 messages) flat view 9 messages, 3 authors, 2021-03-08
STALE1986d

[PATCH v7 4/4] perf test: Add test for event name starting with a number

From: Shunsuke Nakamura <hidden>
Date: 2021-03-04 03:34:21
Also in: lkml
Subsystem: performance events subsystem, the rest · Maintainers: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Linus Torvalds

From: Shunsuke Nakamura <redacted>

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 <redacted>
---
 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@axid\\-read\\,axi_mask\\=0xffff\\,axi_id\\=0x0000@ * 4", },
 	{ "(cstate_pkg@c2\\-residency@ / msr@tsc@) * 100", },
 	{ "(imx8_ddr0@read\\-cycles@ + imx8_ddr0@write\\-cycles@)", },
+	{ "0inst_commit + 1inst_commit + 2inst_commit + 3inst_commit + 4inst_commit",} ,
 };
 
 static int metric_parse_fake(const char *str)
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help