sl@0: /************************************************************************ sl@0: * sl@0: * driver.h - testsuite driver declarations sl@0: * sl@0: * $Id: driver.h 287304 2005-09-15 00:41:16Z sebor $ sl@0: * sl@0: *************************************************************************** sl@0: * sl@0: * Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave sl@0: * Software division. Licensed under the Apache License, Version 2.0 (the sl@0: * "License"); you may not use this file except in compliance with the sl@0: * License. You may obtain a copy of the License at sl@0: * http://www.apache.org/licenses/LICENSE-2.0. Unless required by sl@0: * applicable law or agreed to in writing, software distributed under sl@0: * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR sl@0: * CONDITIONS OF ANY KIND, either express or implied. See the License sl@0: * for the specific language governing permissions and limitations under sl@0: * the License. sl@0: * sl@0: **************************************************************************/ sl@0: sl@0: #ifndef RW_DRIVER_H_INCLUDED sl@0: #define RW_DRIVER_H_INCLUDED sl@0: sl@0: #include // for test config macros sl@0: extern int failures; sl@0: sl@0: /** sl@0: * Initializes the test driver, passes program arguments to it, processes sl@0: * command line arguments, any arguments specified in the environment sl@0: * variable RWSTD_TESTOPTS, and if successful, invokes the program-supplied sl@0: * callback function. sl@0: * sl@0: * @param argc The number of non-null elements in the argv array. sl@0: * @param argv A null-terminated array of command line arguments. sl@0: * If (argc == 0) the argument may be null. sl@0: * @param filename The name of the source file name, typically sl@0: * the __FILE__ macro. The argument may be null. sl@0: * @param clause The clause exercised by the program, such as sl@0: * lib.basic.string. The argument may be null. sl@0: * @param comment An optional comment describing in more detail sl@0: * the functionality of the program. The argument may be null. sl@0: * @param testfun A pointer to a callback function to call by the sl@0: * driver after successful initialization. The argument must sl@0: * not be null. sl@0: * @param optspec An optional character string describing command sl@0: * line options accepted by the program. The argument may sl@0: * be null. sl@0: * @param ... Optional list of handlers of command line options sl@0: * corresponding to the optspec. sl@0: * sl@0: * @return If initialization is successful, returns the value returned sl@0: * by the callback function. Otherwise, returns the non-zero sl@0: * value returned by the last initialization function or sl@0: * command line option handler. sl@0: * sl@0: * After the driver has been initialzied the user-supplied callback function sl@0: * may call any of the driver diagnostic functions to record and perhaps also sl@0: * issue diagnostic messages of varying severity. sl@0: * sl@0: * There are 10 levels of severity with 0 being the lowest and 9 the highest. sl@0: * Diagnostics of all levels of severity come in two states: active and sl@0: * inactive. All diagnostics are recorded but normally only active diagnostics sl@0: * of severity 4 or above are issued. It is possible to cause diagnostics of sl@0: * lower severity levels to be issued via a command line option to the driver. sl@0: * Choosing to issue severity 0 diagnostics has the effect of issuing inactive sl@0: * diagnostics. sl@0: * sl@0: * After the callback function returns the driver displays a summary detailing sl@0: * the number of recorded diagnostics in each of the two states (active and sl@0: * inactive). sl@0: * sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_test (int argc, sl@0: char* argv[], sl@0: const char* filename, sl@0: const char* clause, sl@0: const char* comment, sl@0: int (*testfun)(int, char**), sl@0: const char* optspec, sl@0: ...); sl@0: sl@0: /** sl@0: * Records and optionally issues a diagnostic of the highest severity 9. sl@0: * sl@0: * @param expr A zero value denoting an active diagnostic or any non-zero sl@0: * vaue denoting an inactive diagnostic. sl@0: * @param filename An optional name of the file invoking the function. sl@0: * The argument may be null. sl@0: * @param line When positive, denotes the line number of the location sl@0: * relevant to the diagnostic. Negative values are ignored. sl@0: * @param fmtspec A printf format specifier (with extensions) used sl@0: * to format the text of the diagnostic. sl@0: * @param ... Optional list of values to format. sl@0: * sl@0: * @return Returns the value of expr passed to it. sl@0: * sl@0: * Every diagnostic is recorded but only active diagnostics may be issued, sl@0: * depending on the setting of the diagnosable severity. The value of the sl@0: * first argument determines whether a diagnostc is active or inactive. sl@0: * Unlike the remaining diagnostic functions, rw_fatal doesn't return to sl@0: * the caller when expr is 0 (i.e., when the diagnostic is active). sl@0: * Instead, it causes the driver the exit the process with the staus equal sl@0: * to 9, the severity of the diagnostic. sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_fatal (int expr, sl@0: const char* filename, sl@0: int line, sl@0: const char* fmtspec, sl@0: ...); sl@0: sl@0: /** sl@0: * Records and optionally issues a diagnostic of severity 8. sl@0: * sl@0: * @see #rw_fatal sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_error (int, const char*, int, const char*, ...); sl@0: sl@0: /** sl@0: * Records and optionally issues a diagnostic of severity 7. sl@0: * sl@0: * @see #rw_fatal sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_assert (int, const char*, int, const char*, ...); sl@0: sl@0: /** sl@0: * Records and optionally issues a diagnostic of severity 5. sl@0: * sl@0: * @see #rw_fatal sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_warn (int, const char*, int, const char*, ...); sl@0: sl@0: /** sl@0: * Records and optionally issues a diagnostic of severity 2. sl@0: * sl@0: * @see #rw_fatal sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_note (int, const char*, int, const char*, ...); sl@0: sl@0: /** sl@0: * Records and optionally issues a diagnostic of severity 1. sl@0: * sl@0: * @see #rw_fatal sl@0: */ sl@0: _TEST_EXPORT int sl@0: rw_info (int, const char*, int, const char*, ...); sl@0: sl@0: #endif // RW_DRIVER_H_INCLUDED