• Home
  • Raw
  • Download

Lines Matching +full:self +full:- +full:test

1 # SPDX-License-Identifier: GPL-2.0
33 def __init__(self, test, msg): argument
34 self.msg = msg
35 self.test = test
36 def getMsg(self): argument
37 return '\'%s\' - %s' % (self.test.path, self.msg)
40 def __init__(self, test, arch): argument
41 self.arch = arch
42 self.test = test
43 def getMsg(self): argument
44 return '[%s] \'%s\'' % (self.arch, self.test.path)
47 def __init__(self, test): argument
48 self.test = test
49 def getMsg(self): argument
50 return '\'%s\'' % self.test.path
93 def add(self, data): argument
96 self[key] = val
98 def __init__(self, name, data, base): argument
100 self.name = name;
101 self.group = ''
102 self.add(base)
103 self.add(data)
105 def equal(self, other): argument
107 log.debug(" [%s] %s %s" % (t, self[t], other[t]));
108 if t not in self or t not in other:
110 if not data_equal(self[t], other[t]):
114 def optional(self): argument
115 if 'optional' in self and self['optional'] == '1':
119 def diff(self, other): argument
121 if t not in self or t not in other:
123 if not data_equal(self[t], other[t]):
124 log.warning("expected %s=%s, got %s" % (t, self[t], other[t]))
126 # Test file description needs to have following sections:
128 # - just single instance in file
129 # - needs to specify:
130 # 'command' - perf command name
131 # 'args' - special command arguments
132 # 'ret' - expected command return value (0 by default)
133 # 'arch' - architecture specific test (optional)
138 # - one or multiple instances in file
139 # - expected values assignments
140 class Test(object): class
141 def __init__(self, path, options): argument
147 self.path = path
148 self.test_dir = options.test_dir
149 self.perf = options.perf
150 self.command = parser.get('config', 'command')
151 self.args = parser.get('config', 'args')
154 self.ret = parser.get('config', 'ret')
156 self.ret = 0
159 self.arch = parser.get('config', 'arch')
160 log.warning("test limitation '%s'" % self.arch)
162 self.arch = ''
164 self.expect = {}
165 self.result = {}
167 self.load_events(path, self.expect)
169 def is_event(self, name): argument
170 if name.find("event") == -1:
175 def skip_test(self, myarch): argument
176 # If architecture not set always run test
177 if self.arch == '':
178 # log.warning("test for arch %s is ok" % myarch)
182 arch_list = self.arch.split(',')
189 # log.warning("test for %s arch is %s" % (arch_item, myarch))
195 # log.warning("test for architecture '%s' current '%s'" % (arch_item, myarch))
200 def load_events(self, path, events): argument
207 for section in filter(self.is_event, parser_event.sections()):
216 parser_base.read(self.test_dir + '/' + base)
222 def run_cmd(self, tempdir): argument
225 if self.skip_test(myarch):
226 raise Notest(self, myarch)
228 cmd = "PERF_TEST_ATTR=%s %s %s -o %s/perf.data %s" % (tempdir,
229 self.perf, self.command, tempdir, self.args)
232 log.info(" '%s' ret '%s', expected '%s'" % (cmd, str(ret), str(self.ret)))
234 if not data_equal(str(ret), str(self.ret)):
235 raise Unsup(self)
237 def compare(self, expect, result): argument
252 log.debug(" ->OK")
254 log.debug(" ->FAIL");
258 # we did not any matching event - fail
267 raise Fail(self, 'match failure');
282 raise Fail(self, 'group failure')
289 def resolve_groups(self, events): argument
292 if group_fd == '-1':
301 def run(self): argument
305 # run the test script
306 self.run_cmd(tempdir);
308 # load events expectation for the test
311 self.load_events(f, self.result);
314 self.resolve_groups(self.expect);
315 self.resolve_groups(self.result);
317 # do the expectation - results matching - both ways
318 self.compare(self.expect, self.result)
319 self.compare(self.result, self.expect)
327 for f in glob.glob(options.test_dir + '/' + options.test):
329 Test(f, options).run()
346 log = logging.getLogger('test')
355 -d dir # tests dir
356 -p path # perf binary
357 -t test # single test
358 -v # verbose level
364 parser.add_option("-t", "--test",
365 action="store", type="string", dest="test")
366 parser.add_option("-d", "--test-dir",
368 parser.add_option("-p", "--perf",
370 parser.add_option("-v", "--verbose",
376 return -1
381 print('FAILED no -d option specified')
382 sys.exit(-1)
384 if not options.test:
385 options.test = 'test*'
392 sys.exit(-1)