diff options
Diffstat (limited to 'tools/perf/tests/parse-events.c')
| -rw-r--r-- | tools/perf/tests/parse-events.c | 43 | 
1 files changed, 38 insertions, 5 deletions
| diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 7d4077068454..3b97ac018d5a 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -1309,6 +1309,11 @@ static int test__checkevent_config_cache(struct perf_evlist *evlist)  	return 0;  } +static bool test__intel_pt_valid(void) +{ +	return !!perf_pmu__find("intel_pt"); +} +  static int test__intel_pt(struct perf_evlist *evlist)  {  	struct perf_evsel *evsel = perf_evlist__first(evlist); @@ -1317,6 +1322,14 @@ static int test__intel_pt(struct perf_evlist *evlist)  	return 0;  } +static int test__checkevent_complex_name(struct perf_evlist *evlist) +{ +	struct perf_evsel *evsel = perf_evlist__first(evlist); + +	TEST_ASSERT_VAL("wrong complex name parsing", strcmp(evsel->name, "COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks") == 0); +	return 0; +} +  static int count_tracepoints(void)  {  	struct dirent *events_ent; @@ -1375,6 +1388,7 @@ struct evlist_test {  	const char *name;  	__u32 type;  	const int id; +	bool (*valid)(void);  	int (*check)(struct perf_evlist *evlist);  }; @@ -1648,9 +1662,15 @@ static struct evlist_test test__events[] = {  	},  	{  		.name  = "intel_pt//u", +		.valid = test__intel_pt_valid,  		.check = test__intel_pt,  		.id    = 52,  	}, +	{ +		.name  = "cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk", +		.check = test__checkevent_complex_name, +		.id    = 53 +	}  };  static struct evlist_test test__events_pmu[] = { @@ -1669,6 +1689,11 @@ static struct evlist_test test__events_pmu[] = {  		.check = test__checkevent_pmu_partial_time_callgraph,  		.id    = 2,  	}, +	{ +		.name  = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp", +		.check = test__checkevent_complex_name, +		.id    = 3, +	}  };  struct terms_test { @@ -1686,17 +1711,24 @@ static struct terms_test test__terms[] = {  static int test_event(struct evlist_test *e)  { +	struct parse_events_error err = { .idx = 0, };  	struct perf_evlist *evlist;  	int ret; +	if (e->valid && !e->valid()) { +		pr_debug("... SKIP"); +		return 0; +	} +  	evlist = perf_evlist__new();  	if (evlist == NULL)  		return -ENOMEM; -	ret = parse_events(evlist, e->name, NULL); +	ret = parse_events(evlist, e->name, &err);  	if (ret) { -		pr_debug("failed to parse event '%s', err %d\n", -			 e->name, ret); +		pr_debug("failed to parse event '%s', err %d, str '%s'\n", +			 e->name, ret, err.str); +		parse_events_print_error(&err, e->name);  	} else {  		ret = e->check(evlist);  	} @@ -1714,10 +1746,11 @@ static int test_events(struct evlist_test *events, unsigned cnt)  	for (i = 0; i < cnt; i++) {  		struct evlist_test *e = &events[i]; -		pr_debug("running test %d '%s'\n", e->id, e->name); +		pr_debug("running test %d '%s'", e->id, e->name);  		ret1 = test_event(e);  		if (ret1)  			ret2 = ret1; +		pr_debug("\n");  	}  	return ret2; @@ -1799,7 +1832,7 @@ static int test_pmu_events(void)  	}  	while (!ret && (ent = readdir(dir))) { -		struct evlist_test e; +		struct evlist_test e = { .id = 0, };  		char name[2 * NAME_MAX + 1 + 12 + 3];  		/* Names containing . are special and cannot be used directly */ |