pkg5testenv.py revision 2692
1715N/A# The contents of this file are subject to the terms of the 1715N/A# Common Development and Distribution License (the "License"). 1715N/A# You may not use this file except in compliance with the License. 1715N/A# See the License for the specific language governing permissions 1715N/A# and limitations under the License. 1715N/A# When distributing Covered Code, include this CDDL HEADER in each 1715N/A# If applicable, add the following below this CDDL HEADER, with the 1715N/A# fields enclosed by brackets "[]" replaced with your own identifying 1715N/A# information: Portions Copyright [yyyy] [name of copyright owner] 2692N/A# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 1715N/A """ Set up environment for doing testing. 1715N/A We set PYTHONPATH and PATH so that they reference the proto 1715N/A area, and clear packaging related environment variables 1715N/A (every variable prefixed with PKG_). 1715N/A path_to_proto should be a relative path indicating a path 1715N/A to proto area of the workspace. So, if your test case is 1715N/A This function looks at argv[0] to compute the ultimate 1715N/A path to the proto area; this is nice because you can then 1715N/A invoke test cases like normal commands; i.e.: 1971N/A If 'covdir' is provided, coverage will be started and the 1971N/A related coverage object returned. 1715N/A print "Unable to determine appropriate proto area location." 1715N/A print "This is a porting problem." 1715N/A # Figure out from where we're invoking the command 1715N/A # Clean up relative ../../, etc. out of path to proto 1715N/A # Because subprocesses must also source from the proto area, 1715N/A # we need to set PYTHONPATH in the environment as well as 2692N/A # Proxy environment variables cause all kinds of problems, strip them 1715N/A # Use "keys"; otherwise we'll change dictionary size during iteration. 1971N/A # Start coverage before proceeding so that reports are accurate. 1971N/A # This must be imported here just after PYTHONPATH setup above. 1715N/A # Tell package manager where its application data files live. 1715N/A # Save off the value for tempdir when we were invoked, since the 1715N/A # suite will subsequently modify tempdir to sandbox test cases.