The world's most popular open source database
#include "tap.h"#include <stdlib.h>#include <stdarg.h>#include <stdio.h>#include <string.h>Include dependency graph for tap.c:

Go to the source code of this file.
Defines | |
| #define | tapout stdout |
Functions | |
| static void | emit_tap (int pass, char const *fmt, va_list ap) |
| static void | emit_dir (const char *dir, const char *exp) |
| static void | emit_endl () |
| void | diag (char const *fmt,...) |
| void | plan (int const count) |
| void | skip_all (char const *reason,...) |
| void | ok (int const pass, char const *fmt,...) |
| void | skip (int how_many, char const *const fmt,...) |
| void | todo_start (char const *message,...) |
| void | todo_end () |
| int | exit_status () |
Variables | |
| static TEST_DATA | g_test = { 0, 0, 0, "" } |
| #define tapout stdout |
Output stream for test report message.
The macro is just a temporary solution.
Definition at line 42 of file tap.c.
Referenced by diag(), emit_dir(), emit_endl(), emit_tap(), plan(), and skip_all().
| void diag | ( | char const * | fmt, | |
| ... | ||||
| ) |
Definition at line 100 of file tap.c.
References tapout.
Referenced by do_test(), exit_status(), main(), test_atomic(), test_compare_operators(), test_count_bits_set(), test_get_all_bits(), test_get_first_bit(), test_get_next_bit(), and test_prefix().
00101 { 00102 va_list ap; 00103 va_start(ap, fmt); 00104 fprintf(tapout, "# "); 00105 vfprintf(tapout, fmt, ap); 00106 fprintf(tapout, "\n"); 00107 va_end(ap); 00108 }
Here is the caller graph for this function:

| static void emit_dir | ( | const char * | dir, | |
| const char * | exp | |||
| ) | [static] |
Emit a TAP directive.
TAP directives are comments after a have the form
| dir | Directive as a string | |
| exp | Explanation string |
Definition at line 84 of file tap.c.
References tapout.
Referenced by ok(), and skip().
00085 { 00086 fprintf(tapout, " # %s %s", dir, exp); 00087 }
Here is the caller graph for this function:

| static void emit_endl | ( | ) | [static] |
| static void emit_tap | ( | int | pass, | |
| char const * | fmt, | |||
| va_list | ap | |||
| ) | [static] |
Emit the beginning of a test line, that is: "(not) ok", test number, and description.
To emit the directive, use the emit_dir() function
| pass | 'true' if test passed, 'false' otherwise | |
| fmt | Description of test in printf() format. | |
| ap | Vararg list for the description string above. |
Definition at line 59 of file tap.c.
References g_test, and tapout.
Referenced by ok(), and skip().
00060 { 00061 fprintf(tapout, "%sok %d%s", 00062 pass ? "" : "not ", 00063 ++g_test.last, 00064 (fmt && *fmt) ? " - " : ""); 00065 if (fmt && *fmt) 00066 vfprintf(tapout, fmt, ap); 00067 }
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();
Definition at line 193 of file tap.c.
References diag(), g_test, NO_PLAN, and plan().
Referenced by main().
00193 { 00194 /* 00195 If there were no plan, we write one last instead. 00196 */ 00197 if (g_test.plan == NO_PLAN) 00198 plan(g_test.last); 00199 00200 if (g_test.plan != g_test.last) 00201 { 00202 diag("%d tests planned but%s %d executed", 00203 g_test.plan, (g_test.plan > g_test.last ? " only" : ""), g_test.last); 00204 return EXIT_FAILURE; 00205 } 00206 00207 if (g_test.failed > 0) 00208 { 00209 diag("Failed %d tests!", g_test.failed); 00210 return EXIT_FAILURE; 00211 } 00212 00213 return EXIT_SUCCESS; 00214 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void ok | ( | int const | pass, | |
| char const * | fmt, | |||
| ... | ||||
| ) |
Definition at line 139 of file tap.c.
References emit_dir(), emit_endl(), emit_tap(), and g_test.
Referenced by Dbtux::addAccLockOp(), Dbtup::addAccLockOp(), btr_search_validate(), Dbdict::checkSchemaStatus(), Dbdih::checkTakeOverInMasterStartNodeFailure(), Dbdih::checkTakeOverInNonMasterStartNodeFailure(), db_create_event(), do_exec(), ndb_mgm_configuration_iterator::enter(), Backup::execABORT_BACKUP_ORD(), Dbdict::execALTER_TAB_REQ(), Dbdict::execALTER_TABLE_REQ(), Dbdih::execCOPY_GCIREQ(), Dbdict::execDROP_TABLE_REQ(), Dbdict::execDUMP_STATE_ORD(), Dblqh::execEMPTY_LCP_REQ(), Dbtc::execFIRE_TRIG_ORD(), Dbdict::execLIST_TABLES_REQ(), Dbdict::execNODE_FAILREP(), Dbdict::execSCHEMA_INFO(), Suma::execSUB_SYNC_REQ(), Dbtux::execTUX_BOUND_INFO(), execute(), Dblqh::execWAIT_DROP_TAB_REQ(), CPCD::findUniqueId(), Page_cache_client::get_page(), EventBufData_hash::getpkhash(), ha_validate(), Dbdih::handleTakeOverNewMaster(), Pgman::lirs_stack_pop(), NdbDictInterface::listObjects(), lock_is_table_exclusive(), BackupRestore::logEntry(), main(), make_unique_view_field_name(), MD4_Init(), MD5_Init(), mysql_ha_read(), mysql_make_view(), number_to_datetime(), SimpleProperties::pack(), NdbBlob::packKeyValue(), SignalLoggerManager::printSignalData(), Pgman::process_bind(), Dbtup::readDiskFixedSizeNotNULL(), Dbtup::readFixedSizeTHManyWordNotNULL(), Dbdict::readSchemaConf(), Dbtup::readVarSizeNotNULL(), Dbtc::releaseAbortResources(), Dbtux::removeAccLockOp(), Dbdih::removeNodeFromTable(), DbUtil::reportSequence(), saveInConfigValues(), Pgman::seize_cache_page(), split_concatenated_pk(), test_atomic(), test_atomic_cas_handler(), NdbBlob::unpackKeyValue(), Dbdict::updateSchemaState(), and SimulatedBlock::xfrm_attr().
00140 { 00141 va_list ap; 00142 va_start(ap, fmt); 00143 00144 if (!pass && *g_test.todo == '\0') 00145 ++g_test.failed; 00146 00147 emit_tap(pass, fmt, ap); 00148 va_end(ap); 00149 if (*g_test.todo != '\0') 00150 emit_dir("todo", g_test.todo); 00151 emit_endl(); 00152 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void plan | ( | int | count | ) |
Set number of tests that is planned to execute.
The function also accepts the predefined constant NO_PLAN. If the function is not called, it is as if it was called with NO_PLAN, i.e., the test plan will be printed after all the test lines.
| count | The planned number of tests to run. |
Definition at line 112 of file tap.c.
References g_test, NO_PLAN, and tapout.
Referenced by exit_status(), main(), opt_check_order_by(), opt_classify_cols(), opt_classify_comparison(), opt_clust_access(), opt_determine_and_normalize_test_conds(), opt_find_all_cols(), opt_find_copy_cols(), opt_find_test_conds(), opt_print_query_plan(), opt_search_plan_for_table(), pars_update_statement(), plan_reset_cursor(), row_sel(), row_sel_build_prev_vers(), row_sel_get_clust_rec(), row_sel_open_pcur(), row_sel_restore_pcur_pos(), row_sel_test_end_conds(), row_sel_test_other_conds(), row_sel_try_search_shortcut(), sel_node_free_private(), sel_pop_prefetched_row(), and sel_push_prefetched_row().
00113 { 00114 g_test.plan= count; 00115 switch (count) 00116 { 00117 case NO_PLAN: 00118 break; 00119 default: 00120 if (count > 0) 00121 fprintf(tapout, "1..%d\n", count); 00122 break; 00123 } 00124 }
Here is the caller graph for this function:

| void skip | ( | int | how_many, | |
| char const *const | fmt, | |||
| ... | ||||
| ) |
Definition at line 156 of file tap.c.
References emit_dir(), emit_endl(), emit_tap(), and NULL.
Referenced by find_bit_type(), main(), my_instr_bin(), my_instr_simple(), NdbIndexScanOperation::next_result_ordered(), os_mem_alloc_large(), parse_ieee_bb(), r_strinstr(), strinstr(), String::strrstr(), strstr(), String::strstr(), test_space_compress(), Item_func_substr_index::val_str(), and Item_func_replace::val_str().
00157 { 00158 char reason[80]; 00159 if (fmt && *fmt) 00160 { 00161 va_list ap; 00162 va_start(ap, fmt); 00163 vsnprintf(reason, sizeof(reason), fmt, ap); 00164 va_end(ap); 00165 } 00166 else 00167 reason[0] = '\0'; 00168 00169 while (how_many-- > 0) 00170 { 00171 va_list ap; 00172 emit_tap(1, NULL, ap); 00173 emit_dir("skip", reason); 00174 emit_endl(); 00175 } 00176 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void skip_all | ( | char const * | reason, | |
| ... | ||||
| ) |
| void todo_end | ( | ) |
| void todo_start | ( | char const * | message, | |
| ... | ||||
| ) |
1.4.7

