[Piglit] [PATCH V3] core.py: Fix sporadic loss of tests in summary

Chad Versace chad.versace at linux.intel.com
Wed Jun 5 13:53:13 PDT 2013


On 06/03/2013 10:14 PM, Dylan Baker wrote:
> The checking in TestrunResult to determine if a file was proper json or
> not is very fragile: it assumes that the last line of the file will be
> }. Sometimes this triggers and rebuilds a valid json file, dropping the
> last test and resulting in python overhead.
>
> This patch replaces that check with a try/except block. This block
> attempts to load the json file with json.load, and on failure attempts
> to fix the json.
>
> V2: - replaces json.loads with json.load: this was causing an error but
> 	  being caught by the except block.
> 	- Corrects issue created by the try block changing file.tell() so
> 	  that file.seek would fail in self.__repairFile()
> V3: - refactor duplicated code
>
> Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
> ---
>   framework/core.py | 18 ++++++++----------
>   1 file changed, 8 insertions(+), 10 deletions(-)


> @@ -353,13 +347,17 @@ class TestrunResult:
>           json.dump(raw_dict, file, indent=JSONWriter.INDENT)
>
>       def parseFile(self, file):
> -        file = self.__repairFile(file)
> -        raw_dict = json.load(file)
> +        # Attempt to open the json file normally, if it fails then attempt to
> +        # repair it.
> +        try:
> +            raw_dict = json.load(file)
> +        except ValueError:
> +            raw_dict = json.load(self.__repairFile(file))

This try/except block results in an infinite loop if __repairFile fails.
I confirmed that by running piglit-make-summary.py on a damaged results
file.



More information about the Piglit mailing list