2 ##########################################################################
4 # Copyright 2011 Jose Fonseca
7 # Permission is hereby granted, free of charge, to any person obtaining a copy
8 # of this software and associated documentation files (the "Software"), to deal
9 # in the Software without restriction, including without limitation the rights
10 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 # copies of the Software, and to permit persons to whom the Software is
12 # furnished to do so, subject to the following conditions:
14 # The above copyright notice and this permission notice shall be included in
15 # all copies or substantial portions of the Software.
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 ##########################################################################/
33 from test import Report, TestCase
36 def runtest(report, demo):
37 app = os.path.join(options.mesa_demos, 'src', demo)
38 dirname, basename = os.path.split(app)
39 name = demo.replace('/', '-')
40 args = [os.path.join('.', basename)]
46 build = options.build,
47 results = options.results,
52 def parse_spec(filename):
54 for line in open(filename, 'rt'):
55 if line.lstrip().startswith('#') or not line.strip():
65 if options.cwd is not None:
66 cwd = os.path.join(options.cwd, cwd)
67 if not os.path.dirname(args[0]):
68 args[0] = os.path.join('.', args[0])
76 build = options.build,
77 results = options.results,
87 # Parse command line options
88 optparser = optparse.OptionParser(
89 usage='\n\t%prog [options] testspec [glob] ...',
92 '-B', '--build', metavar='PATH',
93 type='string', dest='build', default=None,
94 help='path to apitrace build')
96 '-C', '--directory', metavar='PATH',
97 type='string', dest='cwd', default=None,
98 help='change to directory')
100 '-R', '--results', metavar='PATH',
101 type='string', dest='results', default='results',
102 help='results directory [default=%default]')
104 (options, args) = optparser.parse_args(sys.argv[1:])
106 optparser.error('a test spec must be specified')
109 testlist = parse_spec(spec)
113 for test in testlist:
115 if fnmatch.fnmatchcase(test.name, pattern):
116 new_testlist.append(test)
117 testlist = new_testlist
119 report = Report(options.results)
120 for test in testlist:
124 if __name__ == '__main__':