# 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 six
import sys
import platform
import tempfile
""" Set up environment for doing testing.
We set PYTHONPATH and PATH so that they reference the proto
area, and clear packaging related environment variables
(every variable prefixed with PKG_).
path_to_proto should be a relative path indicating a path
to proto area of the workspace. So, if your test case is
"../../../proto"
This function looks at argv[0] to compute the ultimate
path to the proto area; this is nice because you can then
invoke test cases like normal commands; i.e.:
"python cli/t_my_test_case.py" will just work.
If 'covdir' is provided, coverage will be started and the
related coverage object returned.
If 'system_test' is True, tests will run on live system.
"""
proc = 'unknown'
if osname == 'sunos':
elif osname == 'linux':
elif osname == 'windows':
elif osname == 'darwin':
elif osname == 'aix':
else:
print("Unable to determine appropriate proto area location.")
print("This is a porting problem.")
# Figure out from where we're invoking the command
else:
if system_test:
pkg_path = "/"
else:
# Clean up relative ../../, etc. out of path to proto
#
# Because subprocesses must also source from the proto area,
# we need to set PYTHONPATH in the environment as well as
# in sys.path.
#
else:
pypath = ""
# Because some test cases will fail under Python 3 if the locale is set
# to "C". A "C" locale supports only "ascii" characters, so essentially
# if we want to test unicode characters, we need to use "utf-8" locale.
# Proxy environment variables cause all kinds of problems, strip them
# all out.
# Use "keys"; otherwise we'll change dictionary size during iteration.
#
# Tell package manager where its application data files live.
#
import pkg5unittest
# Save off the value for tempdir when we were invoked, since the
# suite will subsequently modify tempdir to sandbox test cases.