#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
import os
import sys
import unittest
"""Test result baseline recording and checking. """
# filename from which to get or store baseline results
# 'generating' keeps track of whether we are currently
# generating a baseline or not: if either the baseline doesn't
# exist or the "-g" option is specified on the commandline.
# List of tuples (name, result) for failed tests
self.__failed_list = []
# dict of "test name" -> "result"
"""Add a result if we're generating the baseline file,
otherwise check it against the current result set.
Returns a value to indicate whether the result matched
the baseline."""
if self.__generating:
return BASELINE_MATCH
return BASELINE_MISMATCH
return BASELINE_MATCH
# The assumption if we're generating, or if we don't
# have a result in baseline, is that the test should pass.
if self.__generating:
return "pass"
"""Return the list of failed tests."""
return self.__failed_list
"""Display all test cases that failed to match the baseline
and their result.
"""
if lst:
print("BASELINE MISMATCH: The following results didn't "
"""Store the result set."""
# Only store the result set if we're generating a baseline
if not self.__generating:
return
try:
except IOError as xxx_todo_changeme:
print("Failed to open {0}: {1}".format(
return
# Sort the results to make baseline diffs easier
for s in results_sorted:
f.flush()
f.close()
"""Load the result set."""
return
try:
except IOError as xxx_todo_changeme1:
print("Failed to open {0}: {1}".format(
return
f.close()
raise NotImplementedError()