20 if (a_item == b_item):
22 elif (a_item ==
'*')
or (b_item ==
'*'):
32 return '\'%s\' - %s' % (self.
test.path, self.
msg)
39 return '[%s] \'%s\'' % (self.
arch, self.
test.path)
45 return '\'%s\'' % self.
test.path
77 'exclude_callchain_kernel',
78 'exclude_callchain_user',
90 log.debug(
" %s = %s" % (key, val))
94 log.debug(
" Event %s" % name);
101 for t
in Event.terms:
102 log.debug(
" [%s] %s %s" % (t, self[t], other[t]));
103 if not self.has_key(t)
or not other.has_key(t):
110 if self.has_key(
'optional')
and self[
'optional'] ==
'1':
115 for t
in Event.terms:
116 if not self.has_key(t)
or not other.has_key(t):
119 log.warning(
"expected %s=%s, got %s" % (t, self[t], other[t]))
137 parser = ConfigParser.SafeConfigParser()
140 log.warning(
"running '%s'" % path)
145 self.
command = parser.get(
'config',
'command')
146 self.
args = parser.get(
'config',
'args')
149 self.
ret = parser.get(
'config',
'ret')
154 self.
arch = parser.get(
'config',
'arch')
155 log.warning(
"test limitation '%s'" % self.
arch)
161 log.debug(
" loading expected events");
165 if name.find(
"event") == -1:
177 arch_list = self.
arch.split(
',')
180 if arch_list[0][0] ==
'!':
181 arch_list[0] = arch_list[0][1:]
182 log.warning(
"excluded architecture list %s" % arch_list)
183 for arch_item
in arch_list:
185 if arch_item == myarch:
189 for arch_item
in arch_list:
191 if arch_item == myarch:
196 parser_event = ConfigParser.SafeConfigParser()
197 parser_event.read(path)
204 parser_items = parser_event.items(section);
209 base = section[section.index(
':') + 1:]
210 parser_base = ConfigParser.SafeConfigParser()
211 parser_base.read(self.
test_dir +
'/' + base)
212 base_items = parser_base.items(
'event')
214 e =
Event(section, parser_items, base_items)
218 junk1, junk2, junk3, junk4, myarch = (os.uname())
221 raise Notest(self, myarch)
223 cmd =
"PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir,
225 ret = os.WEXITSTATUS(os.system(cmd))
227 log.info(
" '%s' ret '%s', expected '%s'" % (cmd,
str(ret),
str(self.
ret)))
235 log.debug(
" compare");
239 for exp_name, exp_event
in expect.items():
242 log.debug(
" matching [%s]" % exp_name)
243 for res_name, res_event
in result.items():
244 log.debug(
" to [%s]" % res_name)
245 if (exp_event.equal(res_event)):
246 exp_list.append(res_name)
249 log.debug(
" ->FAIL");
251 log.debug(
" match: [%s] matches %s" % (exp_name,
str(exp_list)))
255 if exp_event.optional():
256 log.debug(
" %s does not match, but is optional" % exp_name)
259 log.debug(
" res_event is empty");
261 exp_event.diff(res_event)
262 raise Fail(self,
'match failure');
264 match[exp_name] = exp_list
268 for exp_name, exp_event
in expect.items():
269 group = exp_event.group
274 for res_name
in match[exp_name]:
275 res_group = result[res_name].group
276 if res_group
not in match[group]:
277 raise Fail(self,
'group failure')
279 log.debug(
" group: [%s] matches group leader %s" %
280 (exp_name,
str(match[group])))
282 log.debug(
" matched")
285 for name, event
in events.items():
286 group_fd = event[
'group_fd'];
290 for iname, ievent
in events.items():
291 if (ievent[
'fd'] == group_fd):
293 log.debug(
'[%s] has group leader [%s]' % (name, iname))
297 tempdir = tempfile.mkdtemp();
304 log.debug(
" loading result events");
305 for f
in glob.glob(tempdir +
'/event*'):
318 shutil.rmtree(tempdir)
322 for f
in glob.glob(options.test_dir +
'/' + options.test):
324 Test(f, options).run()
326 log.warning(
"unsupp %s" % obj.getMsg())
328 log.warning(
"skipped %s" % obj.getMsg())
332 level = logging.CRITICAL
335 level = logging.WARNING
339 level = logging.DEBUG
341 log = logging.getLogger(
'test')
343 ch = logging.StreamHandler()
345 formatter = logging.Formatter(
'%(message)s')
346 ch.setFormatter(formatter)
349 USAGE =
'''%s [OPTIONS] 351 -p path # perf binary 352 -t test # single test 357 parser = optparse.OptionParser(usage=USAGE)
359 parser.add_option(
"-t",
"--test",
360 action=
"store", type=
"string", dest=
"test")
361 parser.add_option(
"-d",
"--test-dir",
362 action=
"store", type=
"string", dest=
"test_dir")
363 parser.add_option(
"-p",
"--perf",
364 action=
"store", type=
"string", dest=
"perf")
365 parser.add_option(
"-v",
"--verbose",
366 action=
"count", dest=
"verbose")
368 options, args = parser.parse_args()
370 parser.error(
'FAILED wrong arguments %s' %
' '.join(args))
375 if not options.test_dir:
376 print 'FAILED no -d option specified' 380 options.test =
'test*' 386 print "FAILED %s" % obj.getMsg();
391 if __name__ ==
'__main__':
def compare(self, expect, result)
def __init__(self, test, msg)
def run_cmd(self, tempdir)
static int str(yyscan_t scanner, int token)
def skip_test(self, myarch)
def resolve_groups(self, events)
def __init__(self, name, data, base)
def __init__(self, test, arch)
def load_events(self, path, events)
struct strfilter * filter
def __init__(self, path, options)