Commit 9e6407e8 authored by Dylan Baker's avatar Dylan Baker

Split resume functionality out of piglit-run.py

The resume functionality actually shares only a little boilerplate with
the run functionality, and there is a lot of extra boilerplate that
exists (or should exist) to make resumes work correctly with all of the
command line options allowed by piglit-run. Therefore, it makes more
sense to split it out into it's own file.

Reviewed by: Kenney Phillis <Kkphillisjr@gmail.com>
Signed-off-by: Dylan Baker's avatarDylan Baker <baker.dylan.c@gmail.com>
parent 0618aa38
......@@ -366,6 +366,7 @@ install (
piglit-merge-results.py
piglit-print-commands.py
piglit-run.py
piglit-resume.py
piglit-summary.py
piglit-summary-html.py
piglit-summary-junit.py
......
#!/usr/bin/env python
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# This permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR(S) BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
import sys
import os
import os.path as path
import argparse
import framework.core as core
def main():
parser = argparse.ArgumentParser()
parser.add_argument("results_path",
type=path.realpath,
metavar="<Results Path>",
help="Path to results folder")
args = parser.parse_args()
results = core.load_results(args.results_path)
env = core.Environment(concurrent=results.options['concurrent'],
exclude_filter=results.options['exclude_filter'],
include_filter=results.options['filter'],
execute=results.options['execute'],
valgrind=results.options['valgrind'],
dmesg=results.options['dmesg'])
# Change working directory to the piglit directory
os.chdir(path.dirname(path.realpath(sys.argv[0])))
results_path = path.join(args.results_path, "main")
json_writer = core.JSONWriter(open(results_path, 'w+'))
json_writer.open_dict()
json_writer.write_dict_key("options")
json_writer.open_dict()
for key, value in results.options.iteritems():
json_writer.write_dict_item(key, value)
json_writer.close_dict()
json_writer.write_dict_item('name', results.name)
for (key, value) in env.collectData().items():
json_writer.write_dict_item(key, value)
json_writer.write_dict_key('tests')
json_writer.open_dict()
for key, value in results.tests.iteritems():
json_writer.write_dict_item(key, value)
env.exclude_tests.add(key)
json_writer.close_dict()
profile = core.loadTestProfile(results.options['profile'])
# This is resumed, don't bother with time since it wont be accurate anyway
profile.run(env, json_writer)
json_writer.close_dict()
json_writer.close_dict()
json_writer.file.close()
print("\n"
"Thank you for running Piglit!\n"
"Results have ben wrriten to {0}".format(results_path))
if __name__ == "__main__":
main()
\ No newline at end of file
......@@ -36,17 +36,10 @@ from framework.threads import synchronized_self
def main():
parser = argparse.ArgumentParser(sys.argv)
# Either require that a name for the test is passed or that
# resume is requested
excGroup1 = parser.add_mutually_exclusive_group()
excGroup1.add_argument("-n", "--name",
metavar="<test name>",
default=None,
help="Name of this test run")
excGroup1.add_argument("-r", "--resume",
action="store_true",
help="Resume an interupted test run")
# Setting the --dry-run flag is equivalent to env.execute=false
parser.add_argument("-n", "--name",
metavar="<test name>",
default=None,
help="Name of this test run")
parser.add_argument("-d", "--dry-run",
action="store_false",
dest="execute",
......@@ -90,21 +83,6 @@ def main():
if args.platform:
os.environ['PIGLIT_PLATFORM'] = args.platform
# If resume is requested attempt to load the results file
# in the specified path
if args.resume is True:
# Load settings from the old results JSON
old_results = core.load_results(args.results_path)
args.test_profile = old_results.options['profile']
# Changing the args to the old args allows us to set them
# all in one places down the way
args.exclude_tests = old_results.options['exclude_filter']
args.include_tests = old_results.options['filter']
args.concurrency = old_results.options['concurrency']
# Otherwise parse additional settings from the command line
# Pass arguments into Environment
env = core.Environment(concurrent=args.concurrency,
exclude_filter=args.exclude_tests,
......@@ -116,7 +94,6 @@ def main():
# Change working directory to the root of the piglit directory
piglit_dir = path.dirname(path.realpath(sys.argv[0]))
os.chdir(piglit_dir)
core.checkDir(args.results_path, False)
results = core.TestrunResult()
......@@ -149,16 +126,6 @@ def main():
json_writer.write_dict_key('tests')
json_writer.open_dict()
# If resuming an interrupted test run, re-write all of the existing
# results since we clobbered the results file. Also, exclude them
# from being run again.
if args.resume is True:
for (key, value) in old_results.tests.items():
if os.path.sep != '/':
key = key.replace(os.path.sep, '/', -1)
json_writer.write_dict_item(key, value)
env.exclude_tests.add(key)
time_start = time.time()
profile.run(env, json_writer)
time_end = time.time()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment