Commit 06b92174 authored by Dylan Baker's avatar Dylan Baker Committed by Tom Stellard

framework/core.py: Add a config parser

The config parser will read options from a file called piglit.conf
in the root of piglit's source directory or from a file specified
by the -f option to piglit-run.py

Tom Stellard:
  - Added command-line option
Reviewed-by: Dylan Baker's avatarDylan Baker <baker.dylan.c@gmail.com>
parent 3a05f362
......@@ -39,6 +39,8 @@ from threads import synchronized_self
import multiprocessing
import multiprocessing.dummy
import importlib
# TODO: ConfigParser is known as configparser in python3
import ConfigParser
try:
import simplejson as json
except ImportError:
......@@ -46,7 +48,8 @@ except ImportError:
import status
__all__ = ['Environment',
__all__ = ['PIGLIT_CONFIG',
'Environment',
'checkDir',
'loadTestProfile',
'TestrunResult',
......@@ -58,6 +61,8 @@ __all__ = ['Environment',
'testBinDir']
PIGLIT_CONFIG = ConfigParser.SafeConfigParser()
class PiglitJSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, status.Status):
......
......@@ -31,6 +31,7 @@ import traceback
sys.path.append(path.dirname(path.realpath(sys.argv[0])))
import framework.core as core
from framework.core import PIGLIT_CONFIG
from framework.threads import synchronized_self
......@@ -72,6 +73,11 @@ def main():
parser.add_argument("-p", "--platform",
choices=["glx", "x11_egl", "wayland", "gbm"],
help="Name of windows system passed to waffle")
parser.add_argument("-f", "--config",
dest="config_file",
type=argparse.FileType("r"),
help="Optionally specify a piglit config file to use. "
"Default is piglit.conf")
parser.add_argument("--valgrind",
action="store_true",
help="Run tests in valgrind's memcheck")
......@@ -93,6 +99,13 @@ def main():
if args.platform:
os.environ['PIGLIT_PLATFORM'] = args.platform
# Read the config file
if args.config_file:
PIGLIT_CONFIG.readfp(args.config_file)
args.config_file.close()
else:
PIGLIT_CONFIG.read(os.path.join(os.path.dirname(__file__), 'piglit.conf'))
# Pass arguments into Environment
env = core.Environment(concurrent=args.concurrency,
exclude_filter=args.exclude_tests,
......
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