|
NAMEtst_resm - Print result messagetst_resm_hexd - Print result message, including specified buffer in hexadecimal format tst_brkm - Print result message and break remaining test cases tst_old_flush - Print any messages pending because of CONDENSE mode, and flush output stream tst_exit - Exit test with a meaningful exit value tst_environ - Keep results coming to original stdout SYNOPSIS#include "test.h"void tst_resm(int ttype, char *tmesg, [arg ...]) void tst_resm_hexd(int ttype, const void *buf, size_t size, char *tmesg, [arg ...]) void tst_brkm(int ttype, void (*func)(), char *tmesg, [arg ...]) void tst_old_flush() void tst_exit() int tst_environ() extern int tst_count;
DESCRIPTIONIntroductionThis library of functions are used by UNICOS tests to report results to standard output in a consistent manner. It is assumed that tests using this library have a distinct number of test cases, and that each test case is distinct and uniquely identified by the test case number. It is also assumed that test case results are printed in consecutive order, starting with 1. The library maintains a set of global variables (TCID, TST_TOTAL, tst_count), which are used by the various functions to format the results and to keep track of the current result reporting state (i.e. how many total test cases there are, and how many have been reported so far) for the calling test.The TCID and TST_TOTAL global variables are externed in the library, and MUST be defined/initialized by tests using the library. TCID must be set to the Test Case IDentifier, and TST_TOTAL must be set to the total number of test cases that will be reported. The other global variables are available as externs to tests linked with tst_res.o. tst_count is the running count of the number of test results that have been reported so far. The library initializes it to 0, and it should not be modified by the test. The details are described below under the appropriate functions. Arguments
Result TypesThe possible test result types defined in test.h are as follows:
Function Descriptionstst_resm() and tst_resm_hexd() are the basic result reporting functions. They report 1 or more test case results of the specified ttype. All result types are valid for these functions. The tst_range global variable indicates the number of results that will be reported for each call to one of these functions. It is initialized by the library to 1, but may be set to a value > 1 by the test. Each call to one of these functions will result in tst_range test case results being reported, each with an identical message (tmesg). tst_range is always reset to 1 by the library before returning to the caller.tst_brk() and tst_brkm() are used to report results for all test cases remaining in the test, and then call a cleanup function. The only result types that are valid for these functions are: TFAIL, TBROK, and TCONF. When called with a ttype of TFAIL or TBROK, one result of the specified ttype will be printed, followed by results of type TBROK for the remaining test cases. When called with a ttype of TCONF, the specified ttype will be printed for all remaining test cases. If func is not NULL, tst_brk() and tst_brkm() will call func after all results have been printed. If the call to func returns, tst_brk() and tst_brkm() will then call tst_exit(). If func is NULL, tst_brk() and tst_brkm() return to the caller after all results have been printed. If tst_brk() is called with a fname argument, the contents of the file will only be printed for the first reported result. tst_brk() takes the fname argument whereas tst_brkm() does not. tst_old_flush() is used to print any results pending because of CONDENSE or NOPASS modes (described below), and flushes the output stream. tst_exit() is used to allow tests to exit with a meaningful exit value. A bit is set in the exit value for each of the non passing test case result types (TFAIL, TBROK, and TWARN) encountered by the library. Thus any bit which is set in the exit value indicates that the corresponding result flag was used at least once in the test run. The current bit fields for the result types are as follows:
NOTE: TPASS and TINFO do not have an effect on the test program exit status. tst_environ() is used to ensure that results reported by this library will go to the original stdout, even if the test changes the original stdout to another file, or closes it. A test may want to do this in order to redirect output that normally goes to stdout (e.g. printf() output) to a file. tst_environ() returns 0 upon successful completion, and -1 if it encountered any problems. Output ModesFour output display modes are supported by the tst_resm() family of functions to enhance output readability. The active mode is controlled via the environment variable TOUTPUT, which must be set prior to the start of the test in order to have any effect (see ksh(1) for information on environment variables). The supported modes are as follows:
EXAMPLES#include "test.h" char *TCID = "tsttcs01"; /* set test case identifier */ int TST_TOTAL = 15; /* set total number of test results */ main() { . . /* a successful test result */ tst_resm(TPASS, "what was tested"); . . /* break all remaining test results */ tst_brkm(TBROK, cleanup, "what didn't work"); /* or */ tst_brk(TBROK, file, cleanup, "what didn't work"); . . /* exit after all test results have been passed to tst_res */ tst_exit(); } Sample output: tsttcs01 1 PASS : Able to create MAXUP processes tsttcs01 2 FAIL : Too many processes (MAXUP+1) created tsttcs01 3 BROK : tabinfo(PROCTAB, &tbs) failed; errno = 13: Permission denied SEE ALSOtst_setup(1), printf(3C), ksh(1).DIAGNOSTICSA WARN result message will be printed if any of the following occur:If an invalid test type is specified. If tst_count is negative. If one of the tst_brk[m]() routines is called with a test type other than TFAIL, TBROK, TCONF. If there are any problems opening/reading/writing the contents of fname. LIMITATIONSIf fname is NULL and tmesg is NULL or empty, the result message will be empty. This allows a test to not print a message for a result, but it is not advised.NOTESIn multithreaded environment, output of tst_resm_hexd() may be interleaved with messages produced by other threads.BUGSThe programmer is free to alter the value of tst_count causing possible test result order problems.
Visit the GSP FreeBSD Man Page Interface. |