diff --git a/CMakeLists.txt b/CMakeLists.txt index d288594129d7b5652e8287683dfd07acb81f3c4f..8771f1b8397546eeb6a6f3490ac1ee92e31c4e7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,6 @@ set (TARANTOOL_PRODUCT "box") set (TARANTOOL_MODULES "box") set (TARANTOOL_CLIENTS "") - # # Set default build type to Debug. This is to ease a developer's # life. Release binaries are built by BuildBot automatically anyway. @@ -131,7 +130,6 @@ if (TARANTOOL_VERSION STREQUAL "") "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") endif() - # # Set flags for all include files: those maintained by us and # coming from third parties. @@ -213,23 +211,15 @@ if (ENABLE_BACKTRACE) # on x86 architecture. message (FATAL_ERROR "ENABLE_BACKTRACE option is set but the system is not x86 based (${CMAKE_SYSTEM_PROCESSOR}) or the compiler is not GNU GCC (${CMAKE_C_COMPILER}).") endif() -# Use GNU bfd if present. + # Use GNU bfd if present. check_library_exists (bfd bfd_init "" HAVE_BFD_LIB) check_include_file(bfd.h HAVE_BFD_H) if (HAVE_BFD_LIB AND HAVE_BFD_H) set (HAVE_BFD True) - message (STATUS "Found GNU bfd headers and libs, enabling symbol ") - message (STATUS "resolve in backtraces.") - elseif (NOT HAVE_BFD_LIB) - message (STATUS "Not found GNU bfd binaries, no symbol resolve.") - elseif (NOT HAVE_BFD_H) - message (STATUS "Not found GNU bfd headers, no symbol resolve. ") - message (STATUS "Consider installing binutils-dev.") endif() endif() option(ENABLE_STATIC "Perform static linking whenever possible." OFF) - if (ENABLE_STATIC) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static") endif() @@ -257,6 +247,16 @@ install (FILES README LICENSE doc/box-protocol.txt DESTINATION share/doc/tarantool) include (cmake/tarantool_cpack.cmake) + +# tarantool info summary (used in server version output) +# +set(TARANTOOL_OPTIONS "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") +set(TARANTOOL_OPTIONS "${TARANTOOL_OPTIONS} -DENABLE_STATIC=${ENABLE_STATIC} -DENABLE_GCOV=${ENABLE_GCOV}") +set(TARANTOOL_OPTIONS "${TARANTOOL_OPTIONS} -DENABLE_TRACE=${ENABLE_TRACE} -DENABLE_BACKTRACE=${ENABLE_BACKTRACE}") +set(TARANTOOL_OPTIONS "${TARANTOOL_OPTIONS} -DENABLE_CLIENT=${ENABLE_CLIENT}") + +set(TARANTOOL_BUILD "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_BUILD_TYPE}") + # # Output compile-time defines into config.h. Do it at the end # of the script to make sure all variables are set. @@ -271,17 +271,19 @@ configure_file( ) message (STATUS "") -message (STATUS "Successfully configured Tarantool infrastructure on ") -message (STATUS "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}, build type '${CMAKE_BUILD_TYPE}'. ") -message (STATUS "The product you're building is \"${TARANTOOL_PRODUCT}\", enabled modules are ") -message (STATUS "${TARANTOOL_MODULES}.") -message (STATUS "Please check out CMakeCache.txt to view or modify configuration results.") +message (STATUS "Tarantool configuration is complete:") message (STATUS "") -message (STATUS "*** The following options are on in this configuration: ***") -message (STATUS "ENABLE_CLIENT: ${ENABLE_CLIENT}") +message (STATUS "VERSION: ${TARANTOOL_VERSION}") +message (STATUS "BUILD: ${TARANTOOL_BUILD}") +message (STATUS "CFLAGS:${CMAKE_C_FLAGS} ${core_cflags}") +message (STATUS "PREFIX: ${CMAKE_INSTALL_PREFIX}") +message (STATUS "MODULES: ${TARANTOOL_MODULES}") +message (STATUS "ENABLE_STATIC: ${ENABLE_STATIC}") message (STATUS "ENABLE_GCOV: ${ENABLE_GCOV}") message (STATUS "ENABLE_TRACE: ${ENABLE_TRACE}") -message (STATUS "ENABLE_BACKTRACE: ${ENABLE_BACKTRACE}") -message (STATUS "Backtrace is with symbol resolve: ${HAVE_BFD}") -message (STATUS "ENABLE_STATIC: ${ENABLE_STATIC}") +message (STATUS "ENABLE_BACKTRACE: ${ENABLE_BACKTRACE} (symbol resolve: ${HAVE_BFD})") +message (STATUS "ENABLE_CLIENT: ${ENABLE_CLIENT}") +message (STATUS "") +message (STATUS "To view or modify configuration results, check out CMakeCache.txt.") message (STATUS "") + diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 861e9e11b50625991fc72c715cceddf83b09b631..08a90869b7155dbed43f7377a8f43e2ce44785a3 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -62,7 +62,7 @@ set (recompiled_core_sources set (common_sources tbuf.m palloc.m util.m salloc.m pickle.m coro.m stat.m log_io.m cpu_feature.m - log_io_remote.m iproto.m exception.m errcode.c latch.m) + log_io_remote.m iproto.m exception.m errcode.c errinj.m latch.m) if (ENABLE_TRACE) set (common_sources ${common_sources} trace.m) diff --git a/core/admin.m b/core/admin.m index b403e23074f685a64f45ec6df0846abb268b8e22..04c948a1dd78088c765bcb7b65292d20d9334e0a 100644 --- a/core/admin.m +++ b/core/admin.m @@ -41,6 +41,7 @@ #include TARANTOOL_CONFIG #include <tbuf.h> #include <util.h> +#include <errinj.h> #include "third_party/luajit/src/lua.h" #include "third_party/luajit/src/lauxlib.h" #include "third_party/luajit/src/lualib.h" @@ -58,21 +59,22 @@ static const char *help = " - save coredump" CRLF " - save snapshot" CRLF " - lua command" CRLF - " - reload configuration" CRLF; - + " - reload configuration" CRLF + " - show injections (debug mode only)" CRLF + " - set injection <name> <state> (debug mode only)" CRLF; static const char *unknown_command = "unknown command. try typing help." CRLF; -#line 68 "core/admin.m" +#line 70 "core/admin.m" static const int admin_start = 1; -static const int admin_first_final = 108; +static const int admin_first_final = 135; static const int admin_error = 0; static const int admin_en_main = 1; -#line 67 "core/admin.rl" +#line 69 "core/admin.rl" @@ -123,6 +125,7 @@ admin_dispatch(lua_State *L) int cs; char *p, *pe; char *strstart, *strend; + bool state; while ((pe = memchr(fiber->rbuf->data, '\n', fiber->rbuf->size)) == NULL) { if (fiber_bread(fiber->rbuf, 1) <= 0) @@ -133,12 +136,12 @@ admin_dispatch(lua_State *L) p = fiber->rbuf->data; -#line 137 "core/admin.m" +#line 140 "core/admin.m" { cs = admin_start; } -#line 142 "core/admin.m" +#line 145 "core/admin.m" { if ( p == pe ) goto _test_eof; @@ -201,47 +204,47 @@ case 6: } goto st0; tr13: -#line 208 "core/admin.rl" +#line 239 "core/admin.rl" {slab_validate(); ok(out);} - goto st108; + goto st135; tr20: -#line 198 "core/admin.rl" +#line 227 "core/admin.rl" {return 0;} - goto st108; + goto st135; tr25: -#line 145 "core/admin.rl" +#line 154 "core/admin.rl" { start(out); tbuf_append(out, help, strlen(help)); end(out); } - goto st108; + goto st135; tr36: -#line 193 "core/admin.rl" +#line 213 "core/admin.rl" {strend = p;} -#line 151 "core/admin.rl" +#line 160 "core/admin.rl" { strstart[strend-strstart]='\0'; start(out); tarantool_lua(L, out, strstart); end(out); } - goto st108; + goto st135; tr43: -#line 158 "core/admin.rl" +#line 167 "core/admin.rl" { if (reload_cfg(err)) fail(out, err); else ok(out); } - goto st108; -tr66: -#line 206 "core/admin.rl" + goto st135; +tr67: +#line 237 "core/admin.rl" {coredump(60); ok(out);} - goto st108; -tr75: -#line 165 "core/admin.rl" + goto st135; +tr76: +#line 174 "core/admin.rl" { int ret = snapshot(NULL, 0); @@ -254,9 +257,37 @@ tr75: fail(out, err); } } - goto st108; -tr92: -#line 127 "core/admin.rl" + goto st135; +tr98: +#line 223 "core/admin.rl" + { state = false; } +#line 187 "core/admin.rl" + { + strstart[strend-strstart] = '\0'; + if (errinj_set_byname(strstart, state)) { + tbuf_printf(err, "can't find error injection '%s'", strstart); + fail(out, err); + } else { + ok(out); + } + } + goto st135; +tr101: +#line 222 "core/admin.rl" + { state = true; } +#line 187 "core/admin.rl" + { + strstart[strend-strstart] = '\0'; + if (errinj_set_byname(strstart, state)) { + tbuf_printf(err, "can't find error injection '%s'", strstart); + fail(out, err); + } else { + ok(out); + } + } + goto st135; +tr117: +#line 130 "core/admin.rl" { tarantool_cfg_iterator_t *i; char *key, *value; @@ -274,43 +305,51 @@ tr92: } end(out); } - goto st108; -tr106: -#line 201 "core/admin.rl" + goto st135; +tr131: +#line 230 "core/admin.rl" {start(out); fiber_info(out); end(out);} - goto st108; -tr112: -#line 200 "core/admin.rl" + goto st135; +tr137: +#line 229 "core/admin.rl" {start(out); tarantool_info(out); end(out);} - goto st108; -tr117: -#line 204 "core/admin.rl" + goto st135; +tr146: +#line 148 "core/admin.rl" + { + start(out); + errinj_info(out); + end(out); + } + goto st135; +tr152: +#line 233 "core/admin.rl" {start(out); palloc_stat(out); end(out);} - goto st108; -tr125: -#line 203 "core/admin.rl" + goto st135; +tr160: +#line 232 "core/admin.rl" {start(out); slab_stat(out); end(out);} - goto st108; -tr129: -#line 205 "core/admin.rl" + goto st135; +tr164: +#line 234 "core/admin.rl" {start(out); stat_print(out);end(out);} - goto st108; -st108: + goto st135; +st135: if ( ++p == pe ) - goto _test_eof108; -case 108: -#line 303 "core/admin.m" + goto _test_eof135; +case 135: +#line 342 "core/admin.m" goto st0; tr14: -#line 208 "core/admin.rl" +#line 239 "core/admin.rl" {slab_validate(); ok(out);} goto st7; tr21: -#line 198 "core/admin.rl" +#line 227 "core/admin.rl" {return 0;} goto st7; tr26: -#line 145 "core/admin.rl" +#line 154 "core/admin.rl" { start(out); tbuf_append(out, help, strlen(help)); @@ -318,9 +357,9 @@ tr26: } goto st7; tr37: -#line 193 "core/admin.rl" +#line 213 "core/admin.rl" {strend = p;} -#line 151 "core/admin.rl" +#line 160 "core/admin.rl" { strstart[strend-strstart]='\0'; start(out); @@ -329,7 +368,7 @@ tr37: } goto st7; tr44: -#line 158 "core/admin.rl" +#line 167 "core/admin.rl" { if (reload_cfg(err)) fail(out, err); @@ -337,12 +376,12 @@ tr44: ok(out); } goto st7; -tr67: -#line 206 "core/admin.rl" +tr68: +#line 237 "core/admin.rl" {coredump(60); ok(out);} goto st7; -tr76: -#line 165 "core/admin.rl" +tr77: +#line 174 "core/admin.rl" { int ret = snapshot(NULL, 0); @@ -356,8 +395,36 @@ tr76: } } goto st7; -tr93: -#line 127 "core/admin.rl" +tr99: +#line 223 "core/admin.rl" + { state = false; } +#line 187 "core/admin.rl" + { + strstart[strend-strstart] = '\0'; + if (errinj_set_byname(strstart, state)) { + tbuf_printf(err, "can't find error injection '%s'", strstart); + fail(out, err); + } else { + ok(out); + } + } + goto st7; +tr102: +#line 222 "core/admin.rl" + { state = true; } +#line 187 "core/admin.rl" + { + strstart[strend-strstart] = '\0'; + if (errinj_set_byname(strstart, state)) { + tbuf_printf(err, "can't find error injection '%s'", strstart); + fail(out, err); + } else { + ok(out); + } + } + goto st7; +tr118: +#line 130 "core/admin.rl" { tarantool_cfg_iterator_t *i; char *key, *value; @@ -376,33 +443,41 @@ tr93: end(out); } goto st7; -tr107: -#line 201 "core/admin.rl" +tr132: +#line 230 "core/admin.rl" {start(out); fiber_info(out); end(out);} goto st7; -tr113: -#line 200 "core/admin.rl" +tr138: +#line 229 "core/admin.rl" {start(out); tarantool_info(out); end(out);} goto st7; -tr118: -#line 204 "core/admin.rl" +tr147: +#line 148 "core/admin.rl" + { + start(out); + errinj_info(out); + end(out); + } + goto st7; +tr153: +#line 233 "core/admin.rl" {start(out); palloc_stat(out); end(out);} goto st7; -tr126: -#line 203 "core/admin.rl" +tr161: +#line 232 "core/admin.rl" {start(out); slab_stat(out); end(out);} goto st7; -tr130: -#line 205 "core/admin.rl" +tr165: +#line 234 "core/admin.rl" {start(out); stat_print(out);end(out);} goto st7; st7: if ( ++p == pe ) goto _test_eof7; case 7: -#line 404 "core/admin.m" +#line 479 "core/admin.m" if ( (*p) == 10 ) - goto st108; + goto st135; goto st0; st8: if ( ++p == pe ) @@ -553,28 +628,28 @@ case 23: } goto tr33; tr33: -#line 193 "core/admin.rl" +#line 213 "core/admin.rl" {strstart = p;} goto st24; st24: if ( ++p == pe ) goto _test_eof24; case 24: -#line 564 "core/admin.m" +#line 639 "core/admin.m" switch( (*p) ) { case 10: goto tr36; case 13: goto tr37; } goto st24; tr34: -#line 193 "core/admin.rl" +#line 213 "core/admin.rl" {strstart = p;} goto st25; st25: if ( ++p == pe ) goto _test_eof25; case 25: -#line 578 "core/admin.m" +#line 653 "core/admin.m" switch( (*p) ) { case 10: goto tr36; case 13: goto tr37; @@ -789,7 +864,8 @@ st48: case 48: switch( (*p) ) { case 97: goto st49; - case 104: goto st69; + case 101: goto st69; + case 104: goto st88; } goto st0; st49: @@ -823,8 +899,8 @@ st52: goto _test_eof52; case 52: switch( (*p) ) { - case 10: goto tr66; - case 13: goto tr67; + case 10: goto tr67; + case 13: goto tr68; case 114: goto st53; } goto st0; @@ -833,8 +909,8 @@ st53: goto _test_eof53; case 53: switch( (*p) ) { - case 10: goto tr66; - case 13: goto tr67; + case 10: goto tr67; + case 13: goto tr68; case 101: goto st54; } goto st0; @@ -843,8 +919,8 @@ st54: goto _test_eof54; case 54: switch( (*p) ) { - case 10: goto tr66; - case 13: goto tr67; + case 10: goto tr67; + case 13: goto tr68; case 100: goto st55; } goto st0; @@ -853,8 +929,8 @@ st55: goto _test_eof55; case 55: switch( (*p) ) { - case 10: goto tr66; - case 13: goto tr67; + case 10: goto tr67; + case 13: goto tr68; case 117: goto st56; } goto st0; @@ -863,8 +939,8 @@ st56: goto _test_eof56; case 56: switch( (*p) ) { - case 10: goto tr66; - case 13: goto tr67; + case 10: goto tr67; + case 13: goto tr68; case 109: goto st57; } goto st0; @@ -873,8 +949,8 @@ st57: goto _test_eof57; case 57: switch( (*p) ) { - case 10: goto tr66; - case 13: goto tr67; + case 10: goto tr67; + case 13: goto tr68; case 112: goto st58; } goto st0; @@ -883,8 +959,8 @@ st58: goto _test_eof58; case 58: switch( (*p) ) { - case 10: goto tr66; - case 13: goto tr67; + case 10: goto tr67; + case 13: goto tr68; } goto st0; st59: @@ -899,8 +975,8 @@ st60: goto _test_eof60; case 60: switch( (*p) ) { - case 10: goto tr75; - case 13: goto tr76; + case 10: goto tr76; + case 13: goto tr77; case 97: goto st61; } goto st0; @@ -909,8 +985,8 @@ st61: goto _test_eof61; case 61: switch( (*p) ) { - case 10: goto tr75; - case 13: goto tr76; + case 10: goto tr76; + case 13: goto tr77; case 112: goto st62; } goto st0; @@ -919,8 +995,8 @@ st62: goto _test_eof62; case 62: switch( (*p) ) { - case 10: goto tr75; - case 13: goto tr76; + case 10: goto tr76; + case 13: goto tr77; case 115: goto st63; } goto st0; @@ -929,8 +1005,8 @@ st63: goto _test_eof63; case 63: switch( (*p) ) { - case 10: goto tr75; - case 13: goto tr76; + case 10: goto tr76; + case 13: goto tr77; case 104: goto st64; } goto st0; @@ -939,8 +1015,8 @@ st64: goto _test_eof64; case 64: switch( (*p) ) { - case 10: goto tr75; - case 13: goto tr76; + case 10: goto tr76; + case 13: goto tr77; case 111: goto st65; } goto st0; @@ -949,8 +1025,8 @@ st65: goto _test_eof65; case 65: switch( (*p) ) { - case 10: goto tr75; - case 13: goto tr76; + case 10: goto tr76; + case 13: goto tr77; case 116: goto st66; } goto st0; @@ -959,8 +1035,8 @@ st66: goto _test_eof66; case 66: switch( (*p) ) { - case 10: goto tr75; - case 13: goto tr76; + case 10: goto tr76; + case 13: goto tr77; } goto st0; st67: @@ -985,7 +1061,7 @@ st69: case 69: switch( (*p) ) { case 32: goto st70; - case 111: goto st106; + case 116: goto st87; } goto st0; st70: @@ -994,18 +1070,14 @@ st70: case 70: switch( (*p) ) { case 32: goto st70; - case 99: goto st71; - case 102: goto st84; - case 105: goto st89; - case 112: goto st93; - case 115: goto st99; + case 105: goto st71; } goto st0; st71: if ( ++p == pe ) goto _test_eof71; case 71: - if ( (*p) == 111 ) + if ( (*p) == 110 ) goto st72; goto st0; st72: @@ -1013,39 +1085,45 @@ st72: goto _test_eof72; case 72: switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 110: goto st73; + case 32: goto st73; + case 106: goto st80; } goto st0; st73: if ( ++p == pe ) goto _test_eof73; case 73: - switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 102: goto st74; - } - goto st0; + if ( (*p) == 32 ) + goto st73; + if ( 33 <= (*p) && (*p) <= 126 ) + goto tr91; + goto st0; +tr91: +#line 221 "core/admin.rl" + { strstart = p; } + goto st74; st74: if ( ++p == pe ) goto _test_eof74; case 74: - switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 105: goto st75; - } +#line 1110 "core/admin.m" + if ( (*p) == 32 ) + goto tr92; + if ( 33 <= (*p) && (*p) <= 126 ) + goto st74; goto st0; +tr92: +#line 221 "core/admin.rl" + { strend = p; } + goto st75; st75: if ( ++p == pe ) goto _test_eof75; case 75: +#line 1124 "core/admin.m" switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 103: goto st76; + case 32: goto st75; + case 111: goto st76; } goto st0; st76: @@ -1053,9 +1131,8 @@ st76: goto _test_eof76; case 76: switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 117: goto st77; + case 102: goto st77; + case 110: goto st79; } goto st0; st77: @@ -1063,9 +1140,9 @@ st77: goto _test_eof77; case 77: switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 114: goto st78; + case 10: goto tr98; + case 13: goto tr99; + case 102: goto st78; } goto st0; st78: @@ -1073,9 +1150,8 @@ st78: goto _test_eof78; case 78: switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 97: goto st79; + case 10: goto tr98; + case 13: goto tr99; } goto st0; st79: @@ -1083,9 +1159,8 @@ st79: goto _test_eof79; case 79: switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 116: goto st80; + case 10: goto tr101; + case 13: goto tr102; } goto st0; st80: @@ -1093,9 +1168,8 @@ st80: goto _test_eof80; case 80: switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 105: goto st81; + case 32: goto st73; + case 101: goto st81; } goto st0; st81: @@ -1103,9 +1177,8 @@ st81: goto _test_eof81; case 81: switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 111: goto st82; + case 32: goto st73; + case 99: goto st82; } goto st0; st82: @@ -1113,9 +1186,8 @@ st82: goto _test_eof82; case 82: switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; - case 110: goto st83; + case 32: goto st73; + case 116: goto st83; } goto st0; st83: @@ -1123,81 +1195,79 @@ st83: goto _test_eof83; case 83: switch( (*p) ) { - case 10: goto tr92; - case 13: goto tr93; + case 32: goto st73; + case 105: goto st84; } goto st0; st84: if ( ++p == pe ) goto _test_eof84; case 84: - if ( (*p) == 105 ) - goto st85; + switch( (*p) ) { + case 32: goto st73; + case 111: goto st85; + } goto st0; st85: if ( ++p == pe ) goto _test_eof85; case 85: switch( (*p) ) { - case 10: goto tr106; - case 13: goto tr107; - case 98: goto st86; + case 32: goto st73; + case 110: goto st86; } goto st0; st86: if ( ++p == pe ) goto _test_eof86; case 86: - switch( (*p) ) { - case 10: goto tr106; - case 13: goto tr107; - case 101: goto st87; - } + if ( (*p) == 32 ) + goto st73; goto st0; st87: if ( ++p == pe ) goto _test_eof87; case 87: - switch( (*p) ) { - case 10: goto tr106; - case 13: goto tr107; - case 114: goto st88; - } + if ( (*p) == 32 ) + goto st70; goto st0; st88: if ( ++p == pe ) goto _test_eof88; case 88: switch( (*p) ) { - case 10: goto tr106; - case 13: goto tr107; + case 32: goto st89; + case 111: goto st133; } goto st0; st89: if ( ++p == pe ) goto _test_eof89; case 89: - if ( (*p) == 110 ) - goto st90; + switch( (*p) ) { + case 32: goto st89; + case 99: goto st90; + case 102: goto st103; + case 105: goto st108; + case 112: goto st120; + case 115: goto st126; + } goto st0; st90: if ( ++p == pe ) goto _test_eof90; case 90: - switch( (*p) ) { - case 10: goto tr112; - case 13: goto tr113; - case 102: goto st91; - } + if ( (*p) == 111 ) + goto st91; goto st0; st91: if ( ++p == pe ) goto _test_eof91; case 91: switch( (*p) ) { - case 10: goto tr112; - case 13: goto tr113; - case 111: goto st92; + case 10: goto tr117; + case 13: goto tr118; + case 110: goto st92; } goto st0; st92: @@ -1205,16 +1275,20 @@ st92: goto _test_eof92; case 92: switch( (*p) ) { - case 10: goto tr112; - case 13: goto tr113; + case 10: goto tr117; + case 13: goto tr118; + case 102: goto st93; } goto st0; st93: if ( ++p == pe ) goto _test_eof93; case 93: - if ( (*p) == 97 ) - goto st94; + switch( (*p) ) { + case 10: goto tr117; + case 13: goto tr118; + case 105: goto st94; + } goto st0; st94: if ( ++p == pe ) @@ -1223,7 +1297,7 @@ case 94: switch( (*p) ) { case 10: goto tr117; case 13: goto tr118; - case 108: goto st95; + case 103: goto st95; } goto st0; st95: @@ -1233,7 +1307,7 @@ case 95: switch( (*p) ) { case 10: goto tr117; case 13: goto tr118; - case 108: goto st96; + case 117: goto st96; } goto st0; st96: @@ -1243,7 +1317,7 @@ case 96: switch( (*p) ) { case 10: goto tr117; case 13: goto tr118; - case 111: goto st97; + case 114: goto st97; } goto st0; st97: @@ -1253,7 +1327,7 @@ case 97: switch( (*p) ) { case 10: goto tr117; case 13: goto tr118; - case 99: goto st98; + case 97: goto st98; } goto st0; st98: @@ -1263,6 +1337,7 @@ case 98: switch( (*p) ) { case 10: goto tr117; case 13: goto tr118; + case 116: goto st99; } goto st0; st99: @@ -1270,8 +1345,9 @@ st99: goto _test_eof99; case 99: switch( (*p) ) { - case 108: goto st100; - case 116: goto st103; + case 10: goto tr117; + case 13: goto tr118; + case 105: goto st100; } goto st0; st100: @@ -1279,9 +1355,9 @@ st100: goto _test_eof100; case 100: switch( (*p) ) { - case 10: goto tr125; - case 13: goto tr126; - case 97: goto st101; + case 10: goto tr117; + case 13: goto tr118; + case 111: goto st101; } goto st0; st101: @@ -1289,9 +1365,9 @@ st101: goto _test_eof101; case 101: switch( (*p) ) { - case 10: goto tr125; - case 13: goto tr126; - case 98: goto st102; + case 10: goto tr117; + case 13: goto tr118; + case 110: goto st102; } goto st0; st102: @@ -1299,28 +1375,25 @@ st102: goto _test_eof102; case 102: switch( (*p) ) { - case 10: goto tr125; - case 13: goto tr126; + case 10: goto tr117; + case 13: goto tr118; } goto st0; st103: if ( ++p == pe ) goto _test_eof103; case 103: - switch( (*p) ) { - case 10: goto tr129; - case 13: goto tr130; - case 97: goto st104; - } + if ( (*p) == 105 ) + goto st104; goto st0; st104: if ( ++p == pe ) goto _test_eof104; case 104: switch( (*p) ) { - case 10: goto tr129; - case 13: goto tr130; - case 116: goto st105; + case 10: goto tr131; + case 13: goto tr132; + case 98: goto st105; } goto st0; st105: @@ -1328,8 +1401,9 @@ st105: goto _test_eof105; case 105: switch( (*p) ) { - case 10: goto tr129; - case 13: goto tr130; + case 10: goto tr131; + case 13: goto tr132; + case 101: goto st106; } goto st0; st106: @@ -1337,16 +1411,266 @@ st106: goto _test_eof106; case 106: switch( (*p) ) { - case 32: goto st70; - case 119: goto st107; + case 10: goto tr131; + case 13: goto tr132; + case 114: goto st107; } goto st0; st107: if ( ++p == pe ) goto _test_eof107; case 107: + switch( (*p) ) { + case 10: goto tr131; + case 13: goto tr132; + } + goto st0; +st108: + if ( ++p == pe ) + goto _test_eof108; +case 108: + if ( (*p) == 110 ) + goto st109; + goto st0; +st109: + if ( ++p == pe ) + goto _test_eof109; +case 109: + switch( (*p) ) { + case 10: goto tr137; + case 13: goto tr138; + case 102: goto st110; + case 106: goto st112; + case 115: goto st115; + } + goto st0; +st110: + if ( ++p == pe ) + goto _test_eof110; +case 110: + switch( (*p) ) { + case 10: goto tr137; + case 13: goto tr138; + case 111: goto st111; + } + goto st0; +st111: + if ( ++p == pe ) + goto _test_eof111; +case 111: + switch( (*p) ) { + case 10: goto tr137; + case 13: goto tr138; + } + goto st0; +st112: + if ( ++p == pe ) + goto _test_eof112; +case 112: + switch( (*p) ) { + case 101: goto st113; + case 115: goto st115; + } + goto st0; +st113: + if ( ++p == pe ) + goto _test_eof113; +case 113: + switch( (*p) ) { + case 99: goto st114; + case 115: goto st115; + } + goto st0; +st114: + if ( ++p == pe ) + goto _test_eof114; +case 114: + switch( (*p) ) { + case 115: goto st115; + case 116: goto st116; + } + goto st0; +st115: + if ( ++p == pe ) + goto _test_eof115; +case 115: + switch( (*p) ) { + case 10: goto tr146; + case 13: goto tr147; + } + goto st0; +st116: + if ( ++p == pe ) + goto _test_eof116; +case 116: + switch( (*p) ) { + case 105: goto st117; + case 115: goto st115; + } + goto st0; +st117: + if ( ++p == pe ) + goto _test_eof117; +case 117: + switch( (*p) ) { + case 111: goto st118; + case 115: goto st115; + } + goto st0; +st118: + if ( ++p == pe ) + goto _test_eof118; +case 118: + switch( (*p) ) { + case 110: goto st119; + case 115: goto st115; + } + goto st0; +st119: + if ( ++p == pe ) + goto _test_eof119; +case 119: + if ( (*p) == 115 ) + goto st115; + goto st0; +st120: + if ( ++p == pe ) + goto _test_eof120; +case 120: + if ( (*p) == 97 ) + goto st121; + goto st0; +st121: + if ( ++p == pe ) + goto _test_eof121; +case 121: + switch( (*p) ) { + case 10: goto tr152; + case 13: goto tr153; + case 108: goto st122; + } + goto st0; +st122: + if ( ++p == pe ) + goto _test_eof122; +case 122: + switch( (*p) ) { + case 10: goto tr152; + case 13: goto tr153; + case 108: goto st123; + } + goto st0; +st123: + if ( ++p == pe ) + goto _test_eof123; +case 123: + switch( (*p) ) { + case 10: goto tr152; + case 13: goto tr153; + case 111: goto st124; + } + goto st0; +st124: + if ( ++p == pe ) + goto _test_eof124; +case 124: + switch( (*p) ) { + case 10: goto tr152; + case 13: goto tr153; + case 99: goto st125; + } + goto st0; +st125: + if ( ++p == pe ) + goto _test_eof125; +case 125: + switch( (*p) ) { + case 10: goto tr152; + case 13: goto tr153; + } + goto st0; +st126: + if ( ++p == pe ) + goto _test_eof126; +case 126: + switch( (*p) ) { + case 108: goto st127; + case 116: goto st130; + } + goto st0; +st127: + if ( ++p == pe ) + goto _test_eof127; +case 127: + switch( (*p) ) { + case 10: goto tr160; + case 13: goto tr161; + case 97: goto st128; + } + goto st0; +st128: + if ( ++p == pe ) + goto _test_eof128; +case 128: + switch( (*p) ) { + case 10: goto tr160; + case 13: goto tr161; + case 98: goto st129; + } + goto st0; +st129: + if ( ++p == pe ) + goto _test_eof129; +case 129: + switch( (*p) ) { + case 10: goto tr160; + case 13: goto tr161; + } + goto st0; +st130: + if ( ++p == pe ) + goto _test_eof130; +case 130: + switch( (*p) ) { + case 10: goto tr164; + case 13: goto tr165; + case 97: goto st131; + } + goto st0; +st131: + if ( ++p == pe ) + goto _test_eof131; +case 131: + switch( (*p) ) { + case 10: goto tr164; + case 13: goto tr165; + case 116: goto st132; + } + goto st0; +st132: + if ( ++p == pe ) + goto _test_eof132; +case 132: + switch( (*p) ) { + case 10: goto tr164; + case 13: goto tr165; + } + goto st0; +st133: + if ( ++p == pe ) + goto _test_eof133; +case 133: + switch( (*p) ) { + case 32: goto st89; + case 119: goto st134; + } + goto st0; +st134: + if ( ++p == pe ) + goto _test_eof134; +case 134: if ( (*p) == 32 ) - goto st70; + goto st89; goto st0; } _test_eof2: cs = 2; goto _test_eof; @@ -1354,7 +1678,7 @@ case 107: _test_eof4: cs = 4; goto _test_eof; _test_eof5: cs = 5; goto _test_eof; _test_eof6: cs = 6; goto _test_eof; - _test_eof108: cs = 108; goto _test_eof; + _test_eof135: cs = 135; goto _test_eof; _test_eof7: cs = 7; goto _test_eof; _test_eof8: cs = 8; goto _test_eof; _test_eof9: cs = 9; goto _test_eof; @@ -1456,12 +1780,39 @@ case 107: _test_eof105: cs = 105; goto _test_eof; _test_eof106: cs = 106; goto _test_eof; _test_eof107: cs = 107; goto _test_eof; + _test_eof108: cs = 108; goto _test_eof; + _test_eof109: cs = 109; goto _test_eof; + _test_eof110: cs = 110; goto _test_eof; + _test_eof111: cs = 111; goto _test_eof; + _test_eof112: cs = 112; goto _test_eof; + _test_eof113: cs = 113; goto _test_eof; + _test_eof114: cs = 114; goto _test_eof; + _test_eof115: cs = 115; goto _test_eof; + _test_eof116: cs = 116; goto _test_eof; + _test_eof117: cs = 117; goto _test_eof; + _test_eof118: cs = 118; goto _test_eof; + _test_eof119: cs = 119; goto _test_eof; + _test_eof120: cs = 120; goto _test_eof; + _test_eof121: cs = 121; goto _test_eof; + _test_eof122: cs = 122; goto _test_eof; + _test_eof123: cs = 123; goto _test_eof; + _test_eof124: cs = 124; goto _test_eof; + _test_eof125: cs = 125; goto _test_eof; + _test_eof126: cs = 126; goto _test_eof; + _test_eof127: cs = 127; goto _test_eof; + _test_eof128: cs = 128; goto _test_eof; + _test_eof129: cs = 129; goto _test_eof; + _test_eof130: cs = 130; goto _test_eof; + _test_eof131: cs = 131; goto _test_eof; + _test_eof132: cs = 132; goto _test_eof; + _test_eof133: cs = 133; goto _test_eof; + _test_eof134: cs = 134; goto _test_eof; _test_eof: {} _out: {} } -#line 214 "core/admin.rl" +#line 245 "core/admin.rl" tbuf_ltrim(fiber->rbuf, (void *)pe - (void *)fiber->rbuf->data); diff --git a/core/admin.rl b/core/admin.rl index 10d119709c4564bb9c32886f012845220c491f97..25b15e999c73273ee9a168daae2139c69e99b0f3 100644 --- a/core/admin.rl +++ b/core/admin.rl @@ -39,6 +39,7 @@ #include TARANTOOL_CONFIG #include <tbuf.h> #include <util.h> +#include <errinj.h> #include "third_party/luajit/src/lua.h" #include "third_party/luajit/src/lauxlib.h" #include "third_party/luajit/src/lualib.h" @@ -56,8 +57,9 @@ static const char *help = " - save coredump" CRLF " - save snapshot" CRLF " - lua command" CRLF - " - reload configuration" CRLF; - + " - reload configuration" CRLF + " - show injections (debug mode only)" CRLF + " - set injection <name> <state> (debug mode only)" CRLF; static const char *unknown_command = "unknown command. try typing help." CRLF; @@ -114,6 +116,7 @@ admin_dispatch(lua_State *L) int cs; char *p, *pe; char *strstart, *strend; + bool state; while ((pe = memchr(fiber->rbuf->data, '\n', fiber->rbuf->size)) == NULL) { if (fiber_bread(fiber->rbuf, 1) <= 0) @@ -142,6 +145,12 @@ admin_dispatch(lua_State *L) end(out); } + action show_injections { + start(out); + errinj_info(out); + end(out); + } + action help { start(out); tbuf_append(out, help, strlen(help)); @@ -175,6 +184,16 @@ admin_dispatch(lua_State *L) } } + action set_injection { + strstart[strend-strstart] = '\0'; + if (errinj_set_byname(strstart, state)) { + tbuf_printf(err, "can't find error injection '%s'", strstart); + fail(out, err); + } else { + ok(out); + } + } + eol = "\n" | "\r\n"; show = "sh"("o"("w")?)?; info = "in"("f"("o")?)?; @@ -185,6 +204,7 @@ admin_dispatch(lua_State *L) mod = "mo"("d")?; palloc = "pa"("l"("l"("o"("c")?)?)?)?; stat = "st"("a"("t")?)?; + help = "h"("e"("l"("p")?)?)?; exit = "e"("x"("i"("t")?)?)? | "q"("u"("i"("t")?)?)?; save = "sa"("v"("e")?)?; @@ -194,15 +214,26 @@ admin_dispatch(lua_State *L) reload = "re"("l"("o"("a"("d")?)?)?)?; lua = "lu"("a")?; + set = "se"("t")?; + injection = "in"("j"("e"("c"("t"("i"("o"("n")?)?)?)?)?)?)?; + injections = injection"s"; + namech = alnum | punct; + name = namech+ >{ strstart = p; } %{ strend = p; }; + state_on = "on" %{ state = true; }; + state_off = "of"("f")? %{ state = false; }; + state = state_on | state_off; + commands = (help %help | exit %{return 0;} | lua " "+ string %lua | - show " "+ info %{start(out); tarantool_info(out); end(out);} | + show " "+ info %{start(out); tarantool_info(out); end(out);} | show " "+ fiber %{start(out); fiber_info(out); end(out);} | show " "+ configuration %show_configuration | show " "+ slab %{start(out); slab_stat(out); end(out);} | show " "+ palloc %{start(out); palloc_stat(out); end(out);} | show " "+ stat %{start(out); stat_print(out);end(out);} | + show " "+ injections %show_injections | + set " "+ injection " "+ name " "+ state %set_injection | save " "+ coredump %{coredump(60); ok(out);} | save " "+ snapshot %save_snapshot | check " "+ slab %{slab_validate(); ok(out);} | diff --git a/core/errinj.m b/core/errinj.m new file mode 100644 index 0000000000000000000000000000000000000000..cb553e7d83d1ed43df5aff4997a02e280266f9a7 --- /dev/null +++ b/core/errinj.m @@ -0,0 +1,117 @@ + +/* + * Copyright (C) 2011 Mail.RU + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdbool.h> + +#include "config.h" +#include "util.h" +#include "say.h" +#include "tbuf.h" +#include "errinj.h" + +#define ERRINJ_MEMBER(n, s) { .name = #n, .state = s }, + +struct errinj errinjs[errinj_enum_MAX] = { + ERRINJ_LIST(ERRINJ_MEMBER) +}; + +static struct errinj * +errinj_lookup(char *name) +{ + int i; + for (i = 0 ; i < errinj_enum_MAX ; i++) { + if (strcmp(errinjs[i].name, name) == 0) + return &errinjs[i]; + } + return NULL; +} + +/** + * Get state of the error injection handle by id. + * + * @param id error injection id. + * + * @return error injection handle state. + */ +bool +errinj_get(int id) +{ + assert(id >= 0 && id < errinj_enum_MAX); + return errinjs[id].state; +} + +/** + * Set state of the error injection handle by id. + * + * @param id error injection id. + * @param state error injection handle state. + * + */ +void +errinj_set(int id, bool state) +{ + assert(id >= 0 && id < errinj_enum_MAX); + errinjs[id].state = state; +} + +/** + * Set state of the error injection handle by name. + * + * @param name error injection name. + * @param state error injection handle state. + * + * @return 0 on success, -1 if injection was not found. + */ +int +errinj_set_byname(char *name, bool state) +{ + struct errinj *ei = errinj_lookup(name); + if (ei == NULL) + return -1; + ei->state = state; + return 0; +} + +/** + * Dump error injection states to the buffer. + * + * @param out output buffer + */ +void +errinj_info(struct tbuf *out) +{ + tbuf_printf(out, "error injections:" CRLF); + int i; + for (i = 0 ; i < errinj_enum_MAX ; i++) { + struct errinj *inj = &errinjs[i]; + tbuf_printf(out, " - name: %s" CRLF, inj->name); + tbuf_printf(out, " state: %s" CRLF, + (inj->state) ? "on" : "off"); + } +} diff --git a/core/exception.m b/core/exception.m index 8580e1ee693b291dac714ccb50f1d7603124795b..420637094c014407aef7a09efabdb5bb007aa53c 100644 --- a/core/exception.m +++ b/core/exception.m @@ -89,3 +89,9 @@ } @end +@implementation ErrorInjection +- (id) init: (const char*) msg +{ + return [super init: ER_INJECTION, msg]; +} +@end diff --git a/core/tarantool.m b/core/tarantool.m index 8c079a07b1ea94230c0852bf39b12d491feedbce..055b0696f78e1bbc6824fb14d4fbe5cefd96a20e 100644 --- a/core/tarantool.m +++ b/core/tarantool.m @@ -366,7 +366,6 @@ tarantool_free(void) fiber_free(); palloc_free(); - ev_default_destroy(); #ifdef ENABLE_GCOV __gcov_flush(); @@ -383,7 +382,6 @@ initialize(double slab_alloc_arena, int slab_alloc_minimal, double slab_alloc_fa { if (!salloc_init(slab_alloc_arena * (1 << 30), slab_alloc_minimal, slab_alloc_factor)) panic_syserror("can't initialize slab allocator"); - fiber_init(); } @@ -459,6 +457,9 @@ main(int argc, char **argv) if (gopt(opt, 'V')) { printf("Tarantool/%s %s\n", mod_name, tarantool_version()); + printf("Target: %s\n", BUILD_INFO); + printf("Build options: %s\n", BUILD_OPTIONS); + printf("CFLAGS:%s\n", BUILD_CFLAGS); return 0; } diff --git a/include/admin.h b/include/admin.h index fc8afc1af7f35483ea74c595af96da6ee838ba57..7542cb51c880962b98a766b822fbd76753cd1cbb 100644 --- a/include/admin.h +++ b/include/admin.h @@ -26,7 +26,6 @@ * SUCH DAMAGE. */ - int admin_init(void); #endif /* TARANTOOL_ADMIN_H_INCLUDED */ diff --git a/include/config.h.cmake b/include/config.h.cmake index 80ae5a6c5d0a2c109c5e97ae928c8d4d90b80a2c..16a3d21ce915b4884fa41ccd31423c04a1376dd7 100644 --- a/include/config.h.cmake +++ b/include/config.h.cmake @@ -52,6 +52,11 @@ #cmakedefine HAVE_BYTE_ORDER_BIG_ENDIAN 1 #define SYSCONF_DIR "@CMAKE_SYSCONF_DIR@" +#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" +#define BUILD_TYPE "@CMAKE_BUILD_TYPE@" +#define BUILD_INFO "@TARANTOOL_BUILD@" +#define BUILD_CFLAGS "@CMAKE_C_FLAGS@ @core_cflags@" +#define BUILD_OPTIONS "cmake . @TARANTOOL_OPTIONS@" /* * vim: syntax=c */ diff --git a/include/errcode.h b/include/errcode.h index 19edbd1e34522cbefb6f94dc8e7e1abb3c38856c..0af265d21e23aa11a9a1d4b16c2794efc51a62b3 100644 --- a/include/errcode.h +++ b/include/errcode.h @@ -59,7 +59,7 @@ enum { TNT_ERRMSG_MAX = 512 }; /* 6 */_(ER_TUPLE_IS_LOCKED, 1, "Tuple is locked") \ /* 7 */_(ER_MEMORY_ISSUE, 1, "Failed to allocate %u bytes in %s for %s") \ /* 8 */_(ER_BAD_INTEGRITY, 2, "Bad graph integrity") \ - /* 9 */_(ER_UNUSED9, 0, "Unused9") \ + /* 9 */_(ER_INJECTION, 2, "Error injection '%s'") \ /* 10 */_(ER_UNSUPPORTED, 2, "Unsupported") \ /* silverproxy error codes */ \ /* 11 */_(ER_RESERVED11, 0, "Reserved11") \ diff --git a/include/errinj.h b/include/errinj.h new file mode 100644 index 0000000000000000000000000000000000000000..0b1e16193320f7bab6e5e1857ce39d3ca4292002 --- /dev/null +++ b/include/errinj.h @@ -0,0 +1,62 @@ +#ifndef TARANTOOL_ERRINJ_H_INCLUDED +#define TARANTOOL_ERRINJ_H_INCLUDED +/* + * Copyright (C) 2011 Mail.RU + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "exception.h" +#include "util.h" + +struct errinj { + char *name; + bool state; +}; + +/** + * list of error injection handles. + */ +#define ERRINJ_LIST(_) \ + _(ERRINJ_TESTING, false) + +ENUM0(errinj_enum, ERRINJ_LIST); +extern struct errinj errinjs[]; + +bool errinj_get(int id); + +void errinj_set(int id, bool state); +int errinj_set_byname(char *name, bool state); + +void errinj_info(struct tbuf *out); + +#ifdef NDEBUG +# define ERROR_INJECT(ID) +#else +# define ERROR_INJECT(ID) \ + do { \ + if (errinj_get(ID) == true) \ + tnt_raise(ErrorInjection, :#ID); \ + } while (0) +#endif + +#endif /* TATRANTOOL_ERRINJ_H_INCLUDED */ diff --git a/include/exception.h b/include/exception.h index 9f368494e4ec8a44db9fd3a9007f8257c44a00e8..49e8e8591471c205927235d5cf5722560d5e880d 100644 --- a/include/exception.h +++ b/include/exception.h @@ -74,6 +74,10 @@ - (id) init: (const char *)msg; @end +/** ER_INJECTION wrapper. */ +@interface ErrorInjection: LoggedError +- (id) init: (const char *)msg; +@end /** * A helper macro to add __FILE__ and __LINE__ information to diff --git a/mod/box/box.m b/mod/box/box.m index 75673f25b8ecaeb97fa8045023e524d9dd98cce9..466bea5e36ac483243f3f33ee25d3dac3076e099 100644 --- a/mod/box/box.m +++ b/mod/box/box.m @@ -42,6 +42,7 @@ #include <tarantool.h> #include <tbuf.h> #include <util.h> +#include <errinj.h> #include <cfg/tarantool_box_cfg.h> #include <mod/box/tuple.h> @@ -1176,6 +1177,7 @@ box_dispatch(struct box_txn *txn, struct tbuf *data) case SELECT: { + ERROR_INJECT(ERRINJ_TESTING); txn_assign_n(txn, data); u32 i = read_u32(data); u32 offset = read_u32(data); diff --git a/mod/box/index.m b/mod/box/index.m index c1bab7ea15ebdc99a6f6c698deff5b37fb792cb3..e304c32decc241e098b6e6ac15e4ce80ec032cdb 100644 --- a/mod/box/index.m +++ b/mod/box/index.m @@ -402,6 +402,8 @@ hash_iterator_free(struct iterator *iterator) :(int) part_count { assert(iterator->next = hash_iterator_next); + (void) part_count; /* Silence gcc warning in release mode. */ + struct hash_iterator *it = hash_iterator(iterator); if (part_count != 1) @@ -527,6 +529,7 @@ hash_iterator_free(struct iterator *iterator) - (void) initIterator: (struct iterator *) iterator :(void *) field :(int) part_count { + (void) part_count; /* Silence gcc warning in release mode. */ assert(iterator->next = hash_iterator_next); struct hash_iterator *it = hash_iterator(iterator); @@ -644,6 +647,7 @@ hash_iterator_free(struct iterator *iterator) - (void) initIterator: (struct iterator *) iterator :(void *) key :(int) part_count { + (void) part_count; /* Silence gcc warning in release mode. */ assert(iterator->next = hash_iterator_next); struct hash_iterator *it = hash_iterator(iterator); diff --git a/test/box/admin.result b/test/box/admin.result index 303872efd3b870acdfa4d233f3c39de5173d5e0d..0bd780a395a9bf4bd86dacb5814afe153e68308c 100644 --- a/test/box/admin.result +++ b/test/box/admin.result @@ -23,6 +23,8 @@ available commands: - save snapshot - lua command - reload configuration + - show injections (debug mode only) + - set injection <name> <state> (debug mode only) ... show configuration --- diff --git a/test/box/args.result b/test/box/args.result index eaf9313bfbb06245c6f0cbd792e53912e94e04b6..5116166ab5b7af63bf2582217e8b76d171bfce4d 100644 --- a/test/box/args.result +++ b/test/box/args.result @@ -75,9 +75,15 @@ tarantool_box: --background requires 'logger' configuration option to be set tarantool_box --version Tarantool/Box 1.minor.patch-<rev>-<commit> +Target: platform <build> +Build options: flags +CFLAGS: flags tarantool_box -V Tarantool/Box 1.minor.patch-<rev>-<commit> +Target: platform <build> +Build options: flags +CFLAGS: flags # # A test case for Bug#726778 "Gopt broke wal_dir and snap_dir: they are no diff --git a/test/box/args.test b/test/box/args.test index 2d014d162aafd4ee67245817bf08200b0a61b069..c79cb4d62a5f1c8ab72c47d33ef80ec2a0493562 100644 --- a/test/box/args.test +++ b/test/box/args.test @@ -27,9 +27,13 @@ server.test_option("--config=tarantool_bug750658.cfg --background") os.unlink(cfg) sys.stdout.pop_filter() sys.stdout.push_filter("(\d)\.\d\.\d(-\d+-\w+)?", "\\1.minor.patch-<rev>-<commit>") +sys.stdout.push_filter("Target: .*", "Target: platform <build>") +sys.stdout.push_filter("Build options: .*", "Build options: flags") +sys.stdout.push_filter("CFLAGS: .*", "CFLAGS: flags") + server.test_option("--version") server.test_option("-V ") -sys.stdout.pop_filter() +sys.stdout.clear_all_filters() print """# # A test case for Bug#726778 "Gopt broke wal_dir and snap_dir: they are no diff --git a/test/box/errinj.result b/test/box/errinj.result new file mode 100644 index 0000000000000000000000000000000000000000..47eb88d5e2ef10bc3564a5b24f16dc87f5e89337 --- /dev/null +++ b/test/box/errinj.result @@ -0,0 +1,22 @@ +show injections +--- +error injections: + - name: ERRINJ_TESTING + state: off +... +set injection some-injection on +--- +fail:can't find error injection 'some-injection' +... +select * from t0 where k0 = 222444 +No match +set injection ERRINJ_TESTING on +--- +ok +... +select * from t0 where k0 = 222444 +An error occurred: ER_INJECTION, 'Error injection 'ERRINJ_TESTING'' +set injection ERRINJ_TESTING off +--- +ok +... diff --git a/test/box/errinj.test b/test/box/errinj.test new file mode 100644 index 0000000000000000000000000000000000000000..b1d65dfccce9d1fcaf15cf12fd9c79b3a07f4346 --- /dev/null +++ b/test/box/errinj.test @@ -0,0 +1,15 @@ +# encoding: tarantool +# +import sys +# clear statistics: +server.stop() +server.deploy() + +exec admin "show injections" +exec admin "set injection some-injection on" +exec sql "select * from t0 where k0 = 222444" +exec admin "set injection ERRINJ_TESTING on" +exec sql "select * from t0 where k0 = 222444" +exec admin "set injection ERRINJ_TESTING off" + +# vim: syntax=python diff --git a/test/box/suite.ini b/test/box/suite.ini index ae4bde328a080541bcb84acc35210c39573e5727..f27570f1b9884f1b4d540fde533e2a0ebe37b202 100644 --- a/test/box/suite.ini +++ b/test/box/suite.ini @@ -5,3 +5,4 @@ config = tarantool.cfg #disabled = xlog.test # put disabled in valgrind test here valgrind_disabled = admin_coredump.test +release_disabled = errinj.test diff --git a/test/lib/admin_connection.py b/test/lib/admin_connection.py index 26cb244a4ea67ad66c898ff203fdaea9b5c4c222..ee22bc4fb273c53bdbe867c841676da69b74b9c4 100644 --- a/test/lib/admin_connection.py +++ b/test/lib/admin_connection.py @@ -27,7 +27,7 @@ import sys import re from tarantool_connection import TarantoolConnection -is_admin_re = re.compile("^\s*(show|save|lua|exit|reload|help)", re.I) +is_admin_re = re.compile("^\s*(show|set|save|lua|exit|reload|help)", re.I) ADMIN_SEPARATOR = '\n' diff --git a/test/lib/server.py b/test/lib/server.py index bd63f44f9d9b940894901eaf9b415e68715cd43c..ae5deb3b54ade14e267cec78ee1f8902226fd924 100644 --- a/test/lib/server.py +++ b/test/lib/server.py @@ -10,6 +10,7 @@ import time import daemon import glob import ConfigParser +import re def check_port(port): """Check if the port we're connecting to is available""" @@ -165,6 +166,7 @@ class Server(object): if start_and_exit != None: self.start_and_exit = start_and_exit if gdb != None: self.gdb = gdb if valgrind != None: self.valgrind = valgrind + self.debug = self.test_debug() if self.is_started: if not silent: @@ -214,7 +216,6 @@ class Server(object): self.kill_old_server() return - # kill process os.kill(self.read_pidfile(), signal.SIGTERM) #self.process.kill(signal.SIGTERM) @@ -250,14 +251,24 @@ class Server(object): self.stop(silent=True) self.start(silent=True) - def test_option(self, option_list_str): + def test_option_get(self, show, option_list_str): args = [self.binary] + option_list_str.split() - print " ".join([os.path.basename(self.binary)] + args[1:]) + if show: + print " ".join([os.path.basename(self.binary)] + args[1:]) output = subprocess.Popen(args, cwd = self.vardir, stdout = subprocess.PIPE, stderr = subprocess.STDOUT).stdout.read() - print output + return output + + def test_option(self, option_list_str): + print self.test_option_get(True, option_list_str) + + def test_debug(self): + output = self.test_option_get(False, "-V") + if re.search("-Debug", output): + return True + return False def kill_old_server(self, silent=True): """Kill old server instance if it exists.""" diff --git a/test/lib/sql_ast.py b/test/lib/sql_ast.py index 6e81abd6793bf517f045221100a69645c265bd66..0c76cd657bb15f73493134368c8812b12c7d6276 100644 --- a/test/lib/sql_ast.py +++ b/test/lib/sql_ast.py @@ -34,6 +34,7 @@ ER = { 6: "ER_TUPLE_IS_LOCKED" , 7: "ER_MEMORY_ISSUE" , 8: "ER_BAD_INTEGRITY" , + 9: "ER_INJECTION" , 10: "ER_UNSUPPORTED_COMMAND" , 24: "ER_CANNOT_REGISTER" , 26: "ER_CANNOT_INIT_ALERT_ID", diff --git a/test/lib/test_suite.py b/test/lib/test_suite.py index 69a2657bfa94ed5377e6f575b6a31a93ba1fe4dd..35d233615f1ad4b9c999add1d263c79b8bccc0c4 100644 --- a/test/lib/test_suite.py +++ b/test/lib/test_suite.py @@ -218,6 +218,11 @@ class TestSuite: else: self.ini["valgrind_disabled"] = dict() + if self.ini.has_key("release_disabled"): + self.ini["release_disabled"] = dict.fromkeys(self.ini["release_disabled"].split(" ")) + else: + self.ini["release_disabled"] = dict() + print "Collecting tests in \"" + suite_path + "\": " +\ self.ini["description"] + "." @@ -265,6 +270,8 @@ class TestSuite: test_name = os.path.basename(test.name) if test_name in self.ini["disabled"]: print "[ skip ]" + elif not server.debug and test_name in self.ini["release_disabled"]: + print "[ skip ]" elif self.args.valgrind and test_name in self.ini["valgrind_disabled"]: print "[ skip ]" else: