Add more structure constructor tests.
[piglit/hramrach.git] / piglit-run.py
blob9f0eca6708572701a156627f90e2d715e251bbe0
1 #!/usr/bin/env python
3 # Permission is hereby granted, free of charge, to any person
4 # obtaining a copy of this software and associated documentation
5 # files (the "Software"), to deal in the Software without
6 # restriction, including without limitation the rights to use,
7 # copy, modify, merge, publish, distribute, sublicense, and/or
8 # sell copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following
10 # conditions:
12 # This permission notice shall be included in all copies or
13 # substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
18 # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR(S) BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
21 # OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 # DEALINGS IN THE SOFTWARE.
25 from getopt import getopt, GetoptError
26 import re
27 import sys
29 import framework.core as core
33 #############################################################################
34 ##### Main program
35 #############################################################################
36 def usage():
37 USAGE = """\
38 Usage: %(progName)s [options] [profile.tests] [results]
40 Options:
41 -h, --help Show this message
42 -d, --dry-run Do not execute the tests
43 -t regexp, --tests=regexp Run only matching tests (can be used more
44 than once)
45 -x regexp, --exclude-tests=regexp Excludey matching tests (can be used
46 more than once)
47 -n name, --name=name Name of the testrun
49 Example:
50 %(progName)s tests/all.tests results/all
51 Run all tests, store the results in the directory results/all
53 %(progName)s -t basic tests/all.tests results/all
54 Run all tests whose path contains the word 'basic'
56 %(progName)s -t ^glean/ -t tex tests/all.tests results/all
57 Run all tests that are in the 'glean' group or whose path contains
58 the substring 'tex'
59 """
60 print USAGE % {'progName': sys.argv[0]}
61 sys.exit(1)
63 def main():
64 env = core.Environment()
66 try:
67 options, args = getopt(sys.argv[1:], "hdt:n:x:", [ "help", "dry-run", "tests=", "name=", "exclude-tests=" ])
68 except GetoptError:
69 usage()
71 OptionName = ''
73 for name, value in options:
74 if name in ('-h', '--help'):
75 usage()
76 elif name in ('-d', '--dry-run'):
77 env.execute = False
78 elif name in ('-t', '--tests'):
79 env.filter[:0] = [re.compile(value)]
80 elif name in ('-x', '--exclude-tests'):
81 env.exclude_filter[:0] = [re.compile(value)]
82 elif name in ('-n', '--name'):
83 OptionName = value
85 if len(args) != 2:
86 usage()
88 profileFilename = args[0]
89 resultsDir = args[1]
91 core.checkDir(resultsDir, False)
93 profile = core.loadTestProfile(profileFilename)
94 env.file = open(resultsDir + '/main', "w")
95 print >>env.file, "name: %(name)s" % { 'name': core.encode(OptionName) }
96 env.collectData()
97 profile.run(env)
98 env.file.close()
100 print "Writing summary file..."
101 results = core.loadTestResults(resultsDir)
102 for testname, result in results.allTestResults().items():
103 if 'info' in result:
104 if len(result['info']) > 4096:
105 result['info'] = result['info'][0:4096]
106 file = open(resultsDir + '/summary', "w")
107 results.write(file)
108 file.close()
110 print
111 print 'Thank you for running Piglit!'
112 print 'Summary for submission has been written to ' + resultsDir + '/summary'
115 if __name__ == "__main__":
116 main()