Home Corporate Contacts

TETware Knowledgebase


Products
Solutions

Information

Datasheet
Documentation
FAQ
Knowledgebase

Return to Knowledgebase Index

32. How to run test cases in a clean environment

 

Question

We want to be able to run test cases without being influenced by the environment that is in effect when tcc is invoked.

 

Answer

You can use a shellscript exec tool to execute the test case in a pristine environment. The tool must take care not to remove TETware communication variables from the environment, otherwise the TCM/API will be unable to function correctly.

For example:


#!/bin/sh
#
# exec tool which executes a test case in a known, pristine environment
#

tcname=${1:?}
shift

exec env - \
	${PATH+PATH="$PATH"} \
	${TZ+TZ="$TZ"} \
	${TET_ACTIVITY+TET_ACTIVITY="$TET_ACTIVITY"} \
	${TET_CODE+TET_CODE="$TET_CODE"} \
	${TET_CONFIG+TET_CONFIG="$TET_CONFIG"} \
	${TET_EXECUTE+TET_EXECUTE="$TET_EXECUTE"} \
	${TET_ROOT+TET_ROOT="$TET_ROOT"} \
	${TET_RUN+TET_RUN="$TET_RUN"} \
	${TET_SUITE_ROOT+TET_SUITE_ROOT="$TET_SUITE_ROOT"} \
	${TET_TMP_DIR+TET_TMP_DIR="$TET_TMP_DIR"} \
	${TET_TIARGS+TET_TIARGS="$TET_TIARGS"} \
	${TET_TSARGS+TET_TSARGS="$TET_TSARGS"} \
	./$tcname $*


When a process is executed by the env(1) command with the - option, it is necessary to pass all the required environment variables explicitly on the command line. Other variables which are inherited by the exec tool from tcc and/or tccd are not made available to the test case.

The ${ variable+ word} syntax is used to avoid passing an empty variable to the test case if the corresponding variable was not defined in the parent environment.

On some systems you may need to add other variables to the list. For example: HOME and LOGNAME; variables that might be needed by a dynamic linking scheme such as LD_LIBRARY_PATH, LIBPATH or SHLIB_PATH; anything to do with locales; and so forth. Be sure to include SystemRoot on a Win32 system, otherwise the Windows Socket library won't work.

 

See also

  • "Communication variables'' in the TETware Programmers Guide.

 


Home Contacts Legal Copyright Corporate News

Copyright © The Open Group 1995-2012, All Rights Reserved