MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MyTAP API

Macros

#define SKIP_BLOCK_IF(SKIP_IF_TRUE, COUNT, REASON)   if (SKIP_IF_TRUE) skip((COUNT),(REASON)); else
#define SKIP_BIG_TESTS(COUNT)   if (skip_big_tests) skip((COUNT), "big test"); else

Functions

void plan (int const count)
void ok (int const pass, char const *fmt,...) __attribute__((format(printf
void void ok1 (int const pass)
void skip (int how_many, char const *reason,...) __attribute__((format(printf
void diag (char const *fmt,...) __attribute__((format(printf
void void BAIL_OUT (char const *fmt,...) __attribute__((noreturn
void void format (printf, 1, 2)))
int exit_status (void)
void skip_all (char const *reason,...) __attribute__((noreturn
void todo_start (char const *message,...) __attribute__((format(printf
void void todo_end ()

Detailed Description

MySQL support for performing unit tests according to TAP.

Macro Definition Documentation

#define SKIP_BIG_TESTS (   COUNT)    if (skip_big_tests) skip((COUNT), "big test"); else

Helper macro to skip a group of "big" tests. It is used in the following manner:

{
ok(life_universe_and_everything() == 42, "The answer is CORRECT");
}
See Also
skip_big_tests

Definition at line 210 of file tap.h.

#define SKIP_BLOCK_IF (   SKIP_IF_TRUE,
  COUNT,
  REASON 
)    if (SKIP_IF_TRUE) skip((COUNT),(REASON)); else

Helper macro to skip a block of code. The macro can be used to simplify conditionally skipping a block of code. It is used in the following manner:

SKIP_BLOCK_IF(ducks == 0, 2, "No ducks in the pond")
{
int i;
for (i = 0 ; i < 2 ; ++i)
ok(duck[i] == paddling, "is duck %d paddling?", i);
}
See Also
skip

Definition at line 192 of file tap.h.

Function Documentation

void void BAIL_OUT ( char const *  fmt,
  ... 
)

Print a bail out message.

A bail out message can be issued when no further testing can be done, e.g., when there are missing dependencies.

The test will exit with status 255. This function does not return.

BAIL_OUT("Lost connection to server %s", server_name);
Note
A bail out message is printed if a signal that generates a core is raised.
Parameters
fmtBail out message in printf() format.
void diag ( char const *  fmt,
  ... 
)

Print a diagnostics message.

Parameters
fmtDiagnostics message in printf() format.

Here is the caller graph for this function:

int exit_status ( void  )

Print summary report and return exit status.

This function will print a summary report of how many tests passed, how many were skipped, and how many remains to do. The function should be called after all tests are executed in the following manner:

return exit_status();
Returns
EXIT_SUCCESS if all tests passed, EXIT_FAILURE if one or more tests failed.

Definition at line 311 of file tap.c.

Here is the call graph for this function:

void ok ( int const  pass,
char const *  fmt,
  ... 
)

Report test result as a TAP line.

Function used to write status of an individual test. Call this function in the following manner:

ok(ducks == paddling,
"%d ducks did not paddle", ducks - paddling);
Parameters
passZero if the test failed, non-zero if it passed.
fmtFormat string in printf() format. NULL is not allowed, use ok1() in this case.

Here is the caller graph for this function:

void void ok1 ( int const  pass)

Report test result as a TAP line.

Same as ok() but does not take a message to be printed.

Parameters
passZero if the test failed, non-zero if it passed.

Definition at line 255 of file tap.c.

void plan ( int const  count)

Set number of tests that is planned to execute.

The function also accepts the predefined constant NO_PLAN. If invoked with this constant – or not invoked at all – the test plan will be printed after all the test lines.

The plan() function will install signal handlers for all signals that generate a core, so if you want to override these signals, do it after you have called the plan() function.

It will also set skip_big_tests variable if MYTAP_CONFIG environment variable is defined.

See Also
skip_big_tests
Parameters
countThe planned number of tests to run.

Definition at line 195 of file tap.c.

Here is the caller graph for this function:

void skip ( int  how_many,
char const *  reason,
  ... 
)

Skip a determined number of tests.

Function to print that how_many tests have been skipped. The reason is printed for each skipped test. Observe that this function does not do the actual skipping for you, it just prints information that tests have been skipped. This function is not usually used, but rather the macro SKIP_BLOCK_IF, which does the skipping for you.

It shall be used in the following manner:

if (ducks == 0) {
skip(2, "No ducks in the pond");
} else {
int i;
for (i = 0 ; i < 2 ; ++i)
ok(duck[i] == paddling, "is duck %d paddling?", i);
}
See Also
SKIP_BLOCK_IF
Parameters
how_manyNumber of tests that are to be skipped.
reasonA reason for skipping the tests

Here is the caller graph for this function:

void skip_all ( char const *  reason,
  ... 
)

Skip entire test suite.

To skip the entire test suite, use this function. It will automatically call exit(), so there is no need to have checks around it.

void void todo_end ( )

End a section of tests that are not yet ready.

Definition at line 306 of file tap.c.

void todo_start ( char const *  message,
  ... 
)

Start section of tests that are not yet ready.

To start a section of tests that are not ready and are expected to fail, use this function and todo_end() in the following manner:

todo_start("Not ready yet");
ok(is_rocketeering(duck), "Rocket-propelled ducks");
ok(is_kamikaze(duck), "Kamikaze ducks");
See Also
todo_end
Note
It is not possible to nest todo sections.
Parameters
messageMessage that will be printed before the todo tests.