Commit 30b992bd authored by Dylan Baker's avatar Dylan Baker

profile: use gz to compress profiles

This results in substantially smaller profiles and doesn't seem to
affect runtime.

v2: - install xml and xml.gz files. This is needed so that meta profiles
      will be installed.
Tested-by: Rafael Antognolli's avatarRafael Antognolli <rafael.antognolli@intel.com>
parent 2f02cf0d
......@@ -533,14 +533,14 @@ install (
install (
DIRECTORY tests
DESTINATION ${PIGLIT_INSTALL_LIBDIR}
FILES_MATCHING REGEX ".*\\.(xml|py|program_test|shader_test|frag|vert|geom|tesc|tese|comp|ktx|cl|txt|inc)$"
FILES_MATCHING REGEX ".*\\.(xml|xml.gz|py|program_test|shader_test|frag|vert|geom|tesc|tese|comp|ktx|cl|txt|inc)$"
REGEX "CMakeFiles|CMakeLists|serializer.py|opengl.py|cl.py|quick_gl.py|glslparser.py|shader.py|quick_shader.py|no_error.py|llvmpipe_gl.py|sanity.py" EXCLUDE
)
install (
DIRECTORY ${CMAKE_BINARY_DIR}/tests
DESTINATION ${PIGLIT_INSTALL_LIBDIR}
FILES_MATCHING REGEX ".*\\.xml"
FILES_MATCHING REGEX ".*\\.xml.gz"
)
install (
......
......@@ -34,8 +34,8 @@ import ast
import collections
import contextlib
import copy
import gzip
import importlib
import io
import itertools
import multiprocessing
import multiprocessing.dummy
......@@ -318,7 +318,7 @@ class XMLProfile(object):
def __len__(self):
if not (self.filters or self.forced_test_list):
with io.open(self.filename, 'rt') as f:
with gzip.open(self.filename, 'rt') as f:
iter_ = et.iterparse(f, events=(b'start', ))
for _, elem in iter_:
if elem.tag == 'PiglitTestList':
......@@ -333,7 +333,7 @@ class XMLProfile(object):
def _itertests(self):
"""Always iterates tests instead of using the forced test_list."""
with io.open(self.filename, 'rt') as f:
with gzip.open(self.filename, 'rt') as f:
doc = et.iterparse(f, events=(b'end', ))
_, root = next(doc) # get the root so we can keep clearing it
for _, e in doc:
......@@ -517,13 +517,13 @@ def load_test_profile(filename, python=None):
if os.path.exists(meta):
return MetaProfile(meta)
xml = os.path.join(ROOT_DIR, 'tests', name + '.xml')
xml = os.path.join(ROOT_DIR, 'tests', name + '.xml.gz')
if os.path.exists(xml):
return XMLProfile(xml)
if python is False:
raise exceptions.PiglitFatalError(
'Cannot open "tests/{0}.xml" or "tests/{0}.meta.xml"'.format(name))
'Cannot open "tests/{0}.xml.gz" or "tests/{0}.meta.xml"'.format(name))
try:
mod = importlib.import_module('tests.{0}'.format(name))
......
......@@ -45,14 +45,14 @@ add_custom_target(
function(piglit_generate_xml name profile meta_target extra_args)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/tests/${name}.xml
COMMAND ${CMAKE_COMMAND} -E env PIGLIT_BUILD_TREE=${CMAKE_BINARY_DIR} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/serializer.py ${name} ${CMAKE_CURRENT_SOURCE_DIR}/${profile}.py ${CMAKE_BINARY_DIR}/tests/${name}.xml ${extra_args}
OUTPUT ${CMAKE_BINARY_DIR}/tests/${name}.xml.gz
COMMAND ${CMAKE_COMMAND} -E env PIGLIT_BUILD_TREE=${CMAKE_BINARY_DIR} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/serializer.py ${name} ${CMAKE_CURRENT_SOURCE_DIR}/${profile}.py ${CMAKE_BINARY_DIR}/tests/${name}.xml.gz ${extra_args}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${profile}.py ${CMAKE_CURRENT_SOURCE_DIR}/serializer.py ${ARGN}
VERBATIM
)
add_custom_target(
generate-${name}-xml
DEPENDS ${CMAKE_BINARY_DIR}/tests/${name}.xml
DEPENDS ${CMAKE_BINARY_DIR}/tests/${name}.xml.gz
)
add_dependencies(${meta_target} generate-${name}-xml)
endfunction()
......
......@@ -22,6 +22,7 @@
"""Script for taking profiles in python format and serializing them to XML."""
import argparse
import gzip
import os
import sys
import xml.etree.cElementTree as et
......@@ -133,7 +134,8 @@ def serializer(name, profile, outfile):
et.SubElement(env, 'env', name=k, value=v)
tree = et.ElementTree(root)
tree.write(outfile, encoding='utf-8', xml_declaration=True)
with gzip.open(outfile, 'wb') as f:
tree.write(f, encoding='utf-8', xml_declaration=True)
def main():
......
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