perf tests: Fixies for perf_event_attr tests
cover perf tests: Fixies for perf_event_attr tests
hi,
this patches address comments and some other small fixies. It's based on current Arnaldo's perf/core.
Attached patches:
1/4 perf tests: Add attr stat basic test 2/4 perf tests: Factor attr tests WRITE_ASS macro 3/4 perf tests: Fix attr watermark field name typo 4/4 perf tests: Removing 'optional' field
Also available here:git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/linux.git
perf/test7
thanks,
jirka
--- tools/perf/tests/attr.c | 87 +++++++++++++++++++++++++++++++++++++++++++-------------------------------------------- tools/perf/tests/attr.py | 31 +++++++++++++++++++------------ tools/perf/tests/attr/base-record | 2 +- tools/perf/tests/attr/base-stat | 40 ++++++++++++++++++++++++++++++++++++++++ tools/perf/tests/attr/test-stat-basic | 6 ++++++ 5 files changed, 109 insertions(+), 57 deletions(-)
PATCH 1/4 perf tests: Add attr stat basic test
Adding test to validate perf_event_attr data for command:
'stat -e cycles'
--- tools/perf/tests/attr/base-stat | 40 +++++++++++++++++++++++++++++++++++ tools/perf/tests/attr/test-stat-basic | 6 ++++++ 2 files changed, 46 insertions(+) create mode 100644 tools/perf/tests/attr/base-stat create mode 100644 tools/perf/tests/attr/test-stat-basic
tools/perf/tests/attr/base-stat new file +40 -0
@@ -0,0 +1,40 @@ +[event] +fd=1 +group_fd=-1 +flags=0 +type=0 +size=96 +config=0 +sample_period=0 +sample_type=0 +read_format=3 +disabled=1 +inherit=1 +pinned=0 +exclusive=0 +exclude_user=0 +exclude_kernel=0 +exclude_hv=0 +exclude_idle=0 +mmap=0 +comm=0 +freq=0 +inherit_stat=0 +enable_on_exec=1 +task=0 +watermask=0 +precise_ip=0 +mmap_data=0 +sample_id_all=0 +exclude_host=0 +exclude_guest=1 +exclude_callchain_kernel=0 +exclude_callchain_user=0 +wakeup_events=0 +bp_type=0 +config1=0 +config2=0 +branch_sample_type=0 +sample_regs_user=0 +sample_stack_user=0 +optional=0
tools/perf/tests/attr/test-stat-basic new file +6 -0
@@ -0,0 +1,6 @@ +[config] +command = stat +args = -e cycles kill >/dev/null 2>&1 +ret = 1 + +[event:base-stat]
Signature · 1 line
1.7.11.7
[tip:perf/core] perf tests: Add missing attr stat basic test
Commit-ID: df4c6de857774252702acc20d4b0eddb329d8808 Gitweb: http://git.kernel.org/tip/df4c6de857774252702acc20d4b0eddb329d8808 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Nov 2012 16:49:36 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Nov 2012 14:03:59 -0300
perf tests: Add missing attr stat basic test
Adding test to validate perf_event_attr data for command:
'stat -e cycles'
---
tools/perf/tests/attr/{base-record => base-stat} | 16 ++++++++--------
.../attr/{test-stat-no-inherit => test-stat-basic} | 3 +--
2 files changed, 9 insertions(+), 10 deletions(-)tools/perf/tests/attr/base-stat renamed from tools/perf/tests/attr/base-record +8 -8
@@ -2,12 +2,12 @@ fd=1 group_fd=-1 flags=0 -type=0|1 +type=0 size=96 config=0 -sample_period=4000 -sample_type=263 -read_format=7 +sample_period=0 +sample_type=0 +read_format=3 disabled=1 inherit=1 pinned=0
@@ -16,16 +16,16 @@ exclude_user=0 exclude_kernel=0 exclude_hv=0 exclude_idle=0 -mmap=1 -comm=1 -freq=1 +mmap=0 +comm=0 +freq=0 inherit_stat=0 enable_on_exec=1 task=0 watermask=0 precise_ip=0 mmap_data=0 -sample_id_all=1 +sample_id_all=0 exclude_host=0 exclude_guest=1 exclude_callchain_kernel=0
tools/perf/tests/attr/test-stat-basic renamed from tools/perf/tests/attr/test-stat-no-inherit +1 -2
@@ -1,7 +1,6 @@ [config] command = stat -args = -i -e cycles kill >/dev/null 2>&1 +args = -e cycles kill >/dev/null 2>&1 ret = 1 [event:base-stat] -inherit=0
PATCH 2/4 perf tests: Factor attr tests WRITE_ASS macro
In reply to Jiri OlsaChanging WRITE_ASS macro per Namhyung's comments, so the main usage case takes only attr field name and format string.
--- tools/perf/tests/attr.c | 89 +++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 44 deletions(-)
tools/perf/tests/attr.c +45 -44
@@ -44,7 +44,7 @@ void test_attr__init(void)#define BUFSIZE 1024 -#define WRITE_ASS (str, fmt, data) \ +#define __WRITE_ASS (str, fmt, data) \ do { \ char buf[BUFSIZE]; \ size_t size; \
@@ -58,6 +58,8 @@ do { \ \ } while (0) +#define WRITE_ASS (field, fmt) __WRITE_ASS(field, fmt, attr->field) +static int store_event (struct perf_event_attr *attr,pid_t pid,int cpu,int fd,int group_fd,unsigned long flags) {
@@ -81,51 +83,50 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu, }/* syscall arguments */ -WRITE_ASS (fd,"d" , fd); -WRITE_ASS (group_fd,"d" , group_fd); -WRITE_ASS (cpu,"d" , cpu); -WRITE_ASS (pid,"d" , pid); -WRITE_ASS (flags,"lu" , flags); +__WRITE_ASS (fd,"d" , fd); +__WRITE_ASS (group_fd,"d" , group_fd); +__WRITE_ASS (cpu,"d" , cpu); +__WRITE_ASS (pid,"d" , pid); +__WRITE_ASS (flags,"lu" , flags);/* struct perf_event_attr */ -WRITE_ASS (type, PRIu32, attr->type); -WRITE_ASS (size, PRIu32, attr->size); -WRITE_ASS (config,"llu" , attr->config); -WRITE_ASS (sample_period,"llu" , attr->sample_period); -WRITE_ASS (sample_type,"llu" , attr->sample_type); -WRITE_ASS (read_format,"llu" , attr->read_format); -WRITE_ASS (disabled,"d" , attr->disabled); -WRITE_ASS (inherit,"d" , attr->inherit); -WRITE_ASS (pinned,"d" , attr->pinned); -WRITE_ASS (exclusive,"d" , attr->exclusive); -WRITE_ASS (exclude_user,"d" , attr->exclude_user); -WRITE_ASS (exclude_kernel,"d" , attr->exclude_kernel); -WRITE_ASS (exclude_hv,"d" , attr->exclude_hv); -WRITE_ASS (exclude_idle,"d" , attr->exclude_idle); -WRITE_ASS (mmap,"d" , attr->mmap); -WRITE_ASS (comm,"d" , attr->comm); -WRITE_ASS (freq,"d" , attr->freq); -WRITE_ASS (inherit_stat,"d" , attr->inherit_stat); -WRITE_ASS (enable_on_exec,"d" , attr->enable_on_exec); -WRITE_ASS (task,"d" , attr->task); -WRITE_ASS (watermask,"d" , attr->watermark); -WRITE_ASS (precise_ip,"d" , attr->precise_ip); -WRITE_ASS (mmap_data,"d" , attr->mmap_data); -WRITE_ASS (sample_id_all,"d" , attr->sample_id_all); -WRITE_ASS (exclude_host,"d" , attr->exclude_host); -WRITE_ASS (exclude_guest,"d" , attr->exclude_guest); -WRITE_ASS (exclude_callchain_kernel,"d" , - attr->exclude_callchain_kernel); -WRITE_ASS (exclude_callchain_user,"d" , - attr->exclude_callchain_user); -WRITE_ASS (wakeup_events, PRIu32, attr->wakeup_events); -WRITE_ASS (bp_type, PRIu32, attr->bp_type); -WRITE_ASS (config1,"llu" , attr->config1); -WRITE_ASS (config2,"llu" , attr->config2); -WRITE_ASS (branch_sample_type,"llu" , attr->branch_sample_type); -WRITE_ASS (sample_regs_user,"llu" , attr->sample_regs_user); -WRITE_ASS (sample_stack_user, PRIu32, attr->sample_stack_user); -WRITE_ASS (optional,"d" ,0 ); +WRITE_ASS (type, PRIu32); +WRITE_ASS (size, PRIu32); +WRITE_ASS (config,"llu" ); +WRITE_ASS (sample_period,"llu" ); +WRITE_ASS (sample_type,"llu" ); +WRITE_ASS (read_format,"llu" ); +WRITE_ASS (disabled,"d" ); +WRITE_ASS (inherit,"d" ); +WRITE_ASS (pinned,"d" ); +WRITE_ASS (exclusive,"d" ); +WRITE_ASS (exclude_user,"d" ); +WRITE_ASS (exclude_kernel,"d" ); +WRITE_ASS (exclude_hv,"d" ); +WRITE_ASS (exclude_idle,"d" ); +WRITE_ASS (mmap,"d" ); +WRITE_ASS (comm,"d" ); +WRITE_ASS (freq,"d" ); +WRITE_ASS (inherit_stat,"d" ); +WRITE_ASS (enable_on_exec,"d" ); +WRITE_ASS (task,"d" ); +WRITE_ASS (watermask,"d" ); +WRITE_ASS (precise_ip,"d" ); +WRITE_ASS (mmap_data,"d" ); +WRITE_ASS (sample_id_all,"d" ); +WRITE_ASS (exclude_host,"d" ); +WRITE_ASS (exclude_guest,"d" ); +WRITE_ASS (exclude_callchain_kernel,"d" ); +WRITE_ASS (exclude_callchain_user,"d" ); +WRITE_ASS (wakeup_events, PRIu32); +WRITE_ASS (bp_type, PRIu32); +WRITE_ASS (config1,"llu" ); +WRITE_ASS (config2,"llu" ); +WRITE_ASS (branch_sample_type,"llu" ); +WRITE_ASS (sample_regs_user,"llu" ); +WRITE_ASS (sample_stack_user, PRIu32); + +__WRITE_ASS (optional,"d" ,0 );fclose (file);return 0 ;
Signature · 1 line
1.7.11.7
[tip:perf/core] perf tests: Factor attr tests WRITE_ASS macro
Commit-ID: 89f552d684925ef9f1dca8b4b2b18fb981dc3d8c Gitweb: http://git.kernel.org/tip/89f552d684925ef9f1dca8b4b2b18fb981dc3d8c Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Nov 2012 16:49:37 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Nov 2012 14:03:59 -0300
perf tests: Factor attr tests WRITE_ASS macro
Changing WRITE_ASS macro per Namhyung's comments, so the main usage case takes only attr field name and format string.
--- tools/perf/tests/attr.c | 89 ++++++++++++++++++++++++----------------------- 1 files changed, 45 insertions(+), 44 deletions(-)
tools/perf/tests/attr.c +45 -44
@@ -44,7 +44,7 @@ void test_attr__init(void)#define BUFSIZE 1024 -#define WRITE_ASS (str, fmt, data) \ +#define __WRITE_ASS (str, fmt, data) \ do { \ char buf[BUFSIZE]; \ size_t size; \
@@ -58,6 +58,8 @@ do { \ \ } while (0) +#define WRITE_ASS (field, fmt) __WRITE_ASS(field, fmt, attr->field) +static int store_event (struct perf_event_attr *attr,pid_t pid,int cpu,int fd,int group_fd,unsigned long flags) {
@@ -81,51 +83,50 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu, }/* syscall arguments */ -WRITE_ASS (fd,"d" , fd); -WRITE_ASS (group_fd,"d" , group_fd); -WRITE_ASS (cpu,"d" , cpu); -WRITE_ASS (pid,"d" , pid); -WRITE_ASS (flags,"lu" , flags); +__WRITE_ASS (fd,"d" , fd); +__WRITE_ASS (group_fd,"d" , group_fd); +__WRITE_ASS (cpu,"d" , cpu); +__WRITE_ASS (pid,"d" , pid); +__WRITE_ASS (flags,"lu" , flags);/* struct perf_event_attr */ -WRITE_ASS (type, PRIu32, attr->type); -WRITE_ASS (size, PRIu32, attr->size); -WRITE_ASS (config,"llu" , attr->config); -WRITE_ASS (sample_period,"llu" , attr->sample_period); -WRITE_ASS (sample_type,"llu" , attr->sample_type); -WRITE_ASS (read_format,"llu" , attr->read_format); -WRITE_ASS (disabled,"d" , attr->disabled); -WRITE_ASS (inherit,"d" , attr->inherit); -WRITE_ASS (pinned,"d" , attr->pinned); -WRITE_ASS (exclusive,"d" , attr->exclusive); -WRITE_ASS (exclude_user,"d" , attr->exclude_user); -WRITE_ASS (exclude_kernel,"d" , attr->exclude_kernel); -WRITE_ASS (exclude_hv,"d" , attr->exclude_hv); -WRITE_ASS (exclude_idle,"d" , attr->exclude_idle); -WRITE_ASS (mmap,"d" , attr->mmap); -WRITE_ASS (comm,"d" , attr->comm); -WRITE_ASS (freq,"d" , attr->freq); -WRITE_ASS (inherit_stat,"d" , attr->inherit_stat); -WRITE_ASS (enable_on_exec,"d" , attr->enable_on_exec); -WRITE_ASS (task,"d" , attr->task); -WRITE_ASS (watermask,"d" , attr->watermark); -WRITE_ASS (precise_ip,"d" , attr->precise_ip); -WRITE_ASS (mmap_data,"d" , attr->mmap_data); -WRITE_ASS (sample_id_all,"d" , attr->sample_id_all); -WRITE_ASS (exclude_host,"d" , attr->exclude_host); -WRITE_ASS (exclude_guest,"d" , attr->exclude_guest); -WRITE_ASS (exclude_callchain_kernel,"d" , - attr->exclude_callchain_kernel); -WRITE_ASS (exclude_callchain_user,"d" , - attr->exclude_callchain_user); -WRITE_ASS (wakeup_events, PRIu32, attr->wakeup_events); -WRITE_ASS (bp_type, PRIu32, attr->bp_type); -WRITE_ASS (config1,"llu" , attr->config1); -WRITE_ASS (config2,"llu" , attr->config2); -WRITE_ASS (branch_sample_type,"llu" , attr->branch_sample_type); -WRITE_ASS (sample_regs_user,"llu" , attr->sample_regs_user); -WRITE_ASS (sample_stack_user, PRIu32, attr->sample_stack_user); -WRITE_ASS (optional,"d" ,0 ); +WRITE_ASS (type, PRIu32); +WRITE_ASS (size, PRIu32); +WRITE_ASS (config,"llu" ); +WRITE_ASS (sample_period,"llu" ); +WRITE_ASS (sample_type,"llu" ); +WRITE_ASS (read_format,"llu" ); +WRITE_ASS (disabled,"d" ); +WRITE_ASS (inherit,"d" ); +WRITE_ASS (pinned,"d" ); +WRITE_ASS (exclusive,"d" ); +WRITE_ASS (exclude_user,"d" ); +WRITE_ASS (exclude_kernel,"d" ); +WRITE_ASS (exclude_hv,"d" ); +WRITE_ASS (exclude_idle,"d" ); +WRITE_ASS (mmap,"d" ); +WRITE_ASS (comm,"d" ); +WRITE_ASS (freq,"d" ); +WRITE_ASS (inherit_stat,"d" ); +WRITE_ASS (enable_on_exec,"d" ); +WRITE_ASS (task,"d" ); +WRITE_ASS (watermask,"d" ); +WRITE_ASS (precise_ip,"d" ); +WRITE_ASS (mmap_data,"d" ); +WRITE_ASS (sample_id_all,"d" ); +WRITE_ASS (exclude_host,"d" ); +WRITE_ASS (exclude_guest,"d" ); +WRITE_ASS (exclude_callchain_kernel,"d" ); +WRITE_ASS (exclude_callchain_user,"d" ); +WRITE_ASS (wakeup_events, PRIu32); +WRITE_ASS (bp_type, PRIu32); +WRITE_ASS (config1,"llu" ); +WRITE_ASS (config2,"llu" ); +WRITE_ASS (branch_sample_type,"llu" ); +WRITE_ASS (sample_regs_user,"llu" ); +WRITE_ASS (sample_stack_user, PRIu32); + +__WRITE_ASS (optional,"d" ,0 );fclose (file);return 0 ;
PATCH 3/4 perf tests: Fix attr watermark field name typo
In reply to Jiri OlsaCurrently the 'watermark' field is coded as 'watermask'.
As the type is global through the framework and tests, the typo spawned no error.
--- tools/perf/tests/attr.c | 2 +- tools/perf/tests/attr.py | 2 +- tools/perf/tests/attr/base-record | 2 +- tools/perf/tests/attr/base-stat | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
tools/perf/tests/attr.c +1 -1
@@ -110,7 +110,7 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu,WRITE_ASS (inherit_stat,"d" );WRITE_ASS (enable_on_exec,"d" );WRITE_ASS (task,"d" ); -WRITE_ASS (watermask,"d" ); +WRITE_ASS (watermark,"d" );WRITE_ASS (precise_ip,"d" );WRITE_ASS (mmap_data,"d" );WRITE_ASS (sample_id_all,"d" );
tools/perf/tests/attr.py +1 -1
@@ -45,7 +45,7 @@ class Event(dict): 'inherit_stat', 'enable_on_exec', 'task', - 'watermask', + 'watermark', 'precise_ip', 'mmap_data', 'sample_id_all',
tools/perf/tests/attr/base-record +1 -1
@@ -22,7 +22,7 @@ freq=1 inherit_stat=0 enable_on_exec=1 task=0 -watermask=0 +watermark=0 precise_ip=0 mmap_data=0 sample_id_all=1
tools/perf/tests/attr/base-stat +1 -1
@@ -22,7 +22,7 @@ freq=0 inherit_stat=0 enable_on_exec=1 task=0 -watermask=0 +watermark=0 precise_ip=0 mmap_data=0 sample_id_all=0
Signature · 1 line
1.7.11.7
[tip:perf/core] perf tests: Fix attr watermark field name typo
Commit-ID: 45e4089bc6398da2cf0609b614bc519970cb8442 Gitweb: http://git.kernel.org/tip/45e4089bc6398da2cf0609b614bc519970cb8442 Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Nov 2012 16:49:38 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Nov 2012 14:03:59 -0300
perf tests: Fix attr watermark field name typo
Currently the 'watermark' field is coded as 'watermask'.
As the type is global through the framework and tests, the typo spawned no error.
--- tools/perf/tests/attr.c | 2 +- tools/perf/tests/attr.py | 2 +- tools/perf/tests/attr/base-record | 2 +- tools/perf/tests/attr/base-stat | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
tools/perf/tests/attr.c +1 -1
@@ -110,7 +110,7 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu,WRITE_ASS (inherit_stat,"d" );WRITE_ASS (enable_on_exec,"d" );WRITE_ASS (task,"d" ); -WRITE_ASS (watermask,"d" ); +WRITE_ASS (watermark,"d" );WRITE_ASS (precise_ip,"d" );WRITE_ASS (mmap_data,"d" );WRITE_ASS (sample_id_all,"d" );
tools/perf/tests/attr.py +1 -1
@@ -45,7 +45,7 @@ class Event(dict): 'inherit_stat', 'enable_on_exec', 'task', - 'watermask', + 'watermark', 'precise_ip', 'mmap_data', 'sample_id_all',
tools/perf/tests/attr/base-record +1 -1
@@ -22,7 +22,7 @@ freq=1 inherit_stat=0 enable_on_exec=1 task=0 -watermask=0 +watermark=0 precise_ip=0 mmap_data=0 sample_id_all=1
tools/perf/tests/attr/base-stat +1 -1
@@ -22,7 +22,7 @@ freq=0 inherit_stat=0 enable_on_exec=1 task=0 -watermask=0 +watermark=0 precise_ip=0 mmap_data=0 sample_id_all=0
PATCH 4/4 perf tests: Removing 'optional' field
In reply to Jiri OlsaSince we allow multiple values in event field assignment, there's no need for 'optional' field.. old version removal leftover.
Adding some comments into attr.py script regarding the test event load.
--- tools/perf/tests/attr.c | 2 -- tools/perf/tests/attr.py | 29 ++++++++++++++++++----------- tools/perf/tests/attr/base-record | 1 - tools/perf/tests/attr/base-stat | 1 - 4 files changed, 18 insertions(+), 15 deletions(-)
tools/perf/tests/attr.c +0 -2
@@ -126,8 +126,6 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu,WRITE_ASS (sample_regs_user,"llu" );WRITE_ASS (sample_stack_user, PRIu32); -__WRITE_ASS (optional,"d" ,0 ); -fclose (file);return 0 ; }
tools/perf/tests/attr.py +18 -11
@@ -75,6 +75,7 @@ class Event(dict): self.add(data) def compare_data(self, a, b): + # Allow multiple values in assignment separated by '|' a_list = a.split('|') b_list = b.split('|')
@@ -96,12 +97,17 @@ class Event(dict): return False return True - def is_optional(self): - if self['optional'] == '1': - return True - else: - return False - +# Test file description needs to have following sections: +# [config] +# - just single instance in file +# - needs to specify: +# 'command' - perf command name +# 'args' - special command arguments +# 'ret' - expected command return value (0 by default) +# +# [eventX:base] +# - one or multiple instances in file +# - expected values assignments class Test(object): def __init__(self, path, options): parser = ConfigParser.SafeConfigParser()
@@ -135,11 +141,15 @@ class Test(object): parser_event = ConfigParser.SafeConfigParser() parser_event.read(path) + # The event record section header contains 'event' word, + # optionaly followed by ':' allowing to load 'parent + # event' first as a base for section in filter(self.is_event, parser_event.sections()): parser_items = parser_event.items(section); base_items = {} + # Read parent event if there's any if (':' in section): base = section[section.index(':') + 1:] parser_base = ConfigParser.SafeConfigParser()
@@ -177,11 +187,10 @@ class Test(object): else: log.debug(" ->FAIL"); - log.info(" match: [%s] optional(%d) matches %s" % - (exp_name, exp_event.is_optional(), str(exp_list))) + log.info(" match: [%s] matches %s" % (exp_name, str(exp_list))) # we did not any matching event - fail - if (not exp_list) and (not exp_event.is_optional()): + if (not exp_list): raise Fail(self, 'match failure'); match[exp_name] = exp_list
@@ -194,8 +203,6 @@ class Test(object): if (group == ''): continue - # XXX group matching does not account for - # optional events as above matching does for res_name in match[exp_name]: res_group = result[res_name].group if res_group not in match[group]:
tools/perf/tests/attr/base-record +0 -1
@@ -37,4 +37,3 @@ config2=0 branch_sample_type=0 sample_regs_user=0 sample_stack_user=0 -optional=0
tools/perf/tests/attr/base-stat +0 -1
@@ -37,4 +37,3 @@ config2=0 branch_sample_type=0 sample_regs_user=0 sample_stack_user=0 -optional=0
Signature · 1 line
1.7.11.7
[tip:perf/core] perf tests: Removing 'optional' field
Commit-ID: 8dfec403e39b7c37fd6e8813bacc01da1e1210ab Gitweb: http://git.kernel.org/tip/8dfec403e39b7c37fd6e8813bacc01da1e1210ab Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 5 Nov 2012 16:49:39 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 5 Nov 2012 14:03:59 -0300
perf tests: Removing 'optional' field
Since we allow multiple values in event field assignment, there's no need for 'optional' field.. old version removal leftover.
Adding some comments into attr.py script regarding the test event load.
--- tools/perf/tests/attr.c | 2 -- tools/perf/tests/attr.py | 29 ++++++++++++++++++----------- tools/perf/tests/attr/base-record | 1 - tools/perf/tests/attr/base-stat | 1 - 4 files changed, 18 insertions(+), 15 deletions(-)
tools/perf/tests/attr.c +0 -2
@@ -126,8 +126,6 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu,WRITE_ASS (sample_regs_user,"llu" );WRITE_ASS (sample_stack_user, PRIu32); -__WRITE_ASS (optional,"d" ,0 ); -fclose (file);return 0 ; }
tools/perf/tests/attr.py +18 -11
@@ -75,6 +75,7 @@ class Event(dict): self.add(data) def compare_data(self, a, b): + # Allow multiple values in assignment separated by '|' a_list = a.split('|') b_list = b.split('|')
@@ -96,12 +97,17 @@ class Event(dict): return False return True - def is_optional(self): - if self['optional'] == '1': - return True - else: - return False - +# Test file description needs to have following sections: +# [config] +# - just single instance in file +# - needs to specify: +# 'command' - perf command name +# 'args' - special command arguments +# 'ret' - expected command return value (0 by default) +# +# [eventX:base] +# - one or multiple instances in file +# - expected values assignments class Test(object): def __init__(self, path, options): parser = ConfigParser.SafeConfigParser()
@@ -135,11 +141,15 @@ class Test(object): parser_event = ConfigParser.SafeConfigParser() parser_event.read(path) + # The event record section header contains 'event' word, + # optionaly followed by ':' allowing to load 'parent + # event' first as a base for section in filter(self.is_event, parser_event.sections()): parser_items = parser_event.items(section); base_items = {} + # Read parent event if there's any if (':' in section): base = section[section.index(':') + 1:] parser_base = ConfigParser.SafeConfigParser()
@@ -177,11 +187,10 @@ class Test(object): else: log.debug(" ->FAIL"); - log.info(" match: [%s] optional(%d) matches %s" % - (exp_name, exp_event.is_optional(), str(exp_list))) + log.info(" match: [%s] matches %s" % (exp_name, str(exp_list))) # we did not any matching event - fail - if (not exp_list) and (not exp_event.is_optional()): + if (not exp_list): raise Fail(self, 'match failure'); match[exp_name] = exp_list
@@ -194,8 +203,6 @@ class Test(object): if (group == ''): continue - # XXX group matching does not account for - # optional events as above matching does for res_name in match[exp_name]: res_group = result[res_name].group if res_group not in match[group]:
tools/perf/tests/attr/base-record +0 -1
@@ -37,4 +37,3 @@ config2=0 branch_sample_type=0 sample_regs_user=0 sample_stack_user=0 -optional=0
tools/perf/tests/attr/base-stat +0 -1
@@ -37,4 +37,3 @@ config2=0 branch_sample_type=0 sample_regs_user=0 sample_stack_user=0 -optional=0