From a3289a558b2e88de4904a60c3a70f85d4c68ad33 Mon Sep 17 00:00:00 2001 From: Dmitry Simonenko <pmwkaa@gmail.com> Date: Mon, 13 Feb 2012 18:15:11 +0400 Subject: [PATCH] core-error-injection: server build flags output, release-debug test suite support - release_disabled test suite ini file option support - debug build only error-injection test, cmake build cleaner output - tarantool server version output with build flags --- CMakeLists.txt | 44 ++++++++------- core/admin.m | 124 +++++++++++++++++++---------------------- core/admin.rl | 13 +---- core/tarantool.m | 3 + include/config.h.cmake | 3 + test/box/admin.result | 4 +- test/box/args.result | 6 ++ test/box/args.test | 6 +- test/box/suite.ini | 1 + test/lib/server.py | 19 +++++-- test/lib/test_suite.py | 7 +++ 11 files changed, 124 insertions(+), 106 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ee9c0a774..cee5899a2c 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. @@ -205,23 +203,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() @@ -249,6 +239,16 @@ install (FILES README LICENSE doc/box-protocol.txt DESTINATION doc) 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. @@ -263,17 +263,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:") 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 "(Please check out CMakeCache.txt to view or modify configuration results)") message (STATUS "") + diff --git a/core/admin.m b/core/admin.m index 62f58b46f8..04c948a1dd 100644 --- a/core/admin.m +++ b/core/admin.m @@ -59,16 +59,14 @@ static const char *help = " - save coredump" CRLF " - save snapshot" CRLF " - lua command" CRLF - " - reload configuration" CRLF; - -static const char *help_debug = - " - show injections" CRLF - " - set injection <name> <state>" 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 72 "core/admin.m" +#line 70 "core/admin.m" static const int admin_start = 1; static const int admin_first_final = 135; static const int admin_error = 0; @@ -76,7 +74,7 @@ static const int admin_error = 0; static const int admin_en_main = 1; -#line 71 "core/admin.rl" +#line 69 "core/admin.rl" @@ -138,12 +136,12 @@ admin_dispatch(lua_State *L) p = fiber->rbuf->data; -#line 142 "core/admin.m" +#line 140 "core/admin.m" { cs = admin_start; } -#line 147 "core/admin.m" +#line 145 "core/admin.m" { if ( p == pe ) goto _test_eof; @@ -206,30 +204,25 @@ case 6: } goto st0; tr13: -#line 246 "core/admin.rl" +#line 239 "core/admin.rl" {slab_validate(); ok(out);} goto st135; tr20: -#line 234 "core/admin.rl" +#line 227 "core/admin.rl" {return 0;} goto st135; tr25: -#line 156 "core/admin.rl" +#line 154 "core/admin.rl" { start(out); tbuf_append(out, help, strlen(help)); -#ifndef NDEBUG - tbuf_append(out, help_debug, strlen(help_debug)); -#else - (void)help_debug; /* making compiler happy */ -#endif end(out); } goto st135; tr36: -#line 220 "core/admin.rl" +#line 213 "core/admin.rl" {strend = p;} -#line 167 "core/admin.rl" +#line 160 "core/admin.rl" { strstart[strend-strstart]='\0'; start(out); @@ -238,7 +231,7 @@ tr36: } goto st135; tr43: -#line 174 "core/admin.rl" +#line 167 "core/admin.rl" { if (reload_cfg(err)) fail(out, err); @@ -247,11 +240,11 @@ tr43: } goto st135; tr67: -#line 244 "core/admin.rl" +#line 237 "core/admin.rl" {coredump(60); ok(out);} goto st135; tr76: -#line 181 "core/admin.rl" +#line 174 "core/admin.rl" { int ret = snapshot(NULL, 0); @@ -266,9 +259,9 @@ tr76: } goto st135; tr98: -#line 230 "core/admin.rl" +#line 223 "core/admin.rl" { state = false; } -#line 194 "core/admin.rl" +#line 187 "core/admin.rl" { strstart[strend-strstart] = '\0'; if (errinj_set_byname(strstart, state)) { @@ -280,9 +273,9 @@ tr98: } goto st135; tr101: -#line 229 "core/admin.rl" +#line 222 "core/admin.rl" { state = true; } -#line 194 "core/admin.rl" +#line 187 "core/admin.rl" { strstart[strend-strstart] = '\0'; if (errinj_set_byname(strstart, state)) { @@ -294,7 +287,7 @@ tr101: } goto st135; tr117: -#line 132 "core/admin.rl" +#line 130 "core/admin.rl" { tarantool_cfg_iterator_t *i; char *key, *value; @@ -314,15 +307,15 @@ tr117: } goto st135; tr131: -#line 237 "core/admin.rl" +#line 230 "core/admin.rl" {start(out); fiber_info(out); end(out);} goto st135; tr137: -#line 236 "core/admin.rl" +#line 229 "core/admin.rl" {start(out); tarantool_info(out); end(out);} goto st135; tr146: -#line 150 "core/admin.rl" +#line 148 "core/admin.rl" { start(out); errinj_info(out); @@ -330,48 +323,43 @@ tr146: } goto st135; tr152: -#line 240 "core/admin.rl" +#line 233 "core/admin.rl" {start(out); palloc_stat(out); end(out);} goto st135; tr160: -#line 239 "core/admin.rl" +#line 232 "core/admin.rl" {start(out); slab_stat(out); end(out);} goto st135; tr164: -#line 241 "core/admin.rl" +#line 234 "core/admin.rl" {start(out); stat_print(out);end(out);} goto st135; st135: if ( ++p == pe ) goto _test_eof135; case 135: -#line 349 "core/admin.m" +#line 342 "core/admin.m" goto st0; tr14: -#line 246 "core/admin.rl" +#line 239 "core/admin.rl" {slab_validate(); ok(out);} goto st7; tr21: -#line 234 "core/admin.rl" +#line 227 "core/admin.rl" {return 0;} goto st7; tr26: -#line 156 "core/admin.rl" +#line 154 "core/admin.rl" { start(out); tbuf_append(out, help, strlen(help)); -#ifndef NDEBUG - tbuf_append(out, help_debug, strlen(help_debug)); -#else - (void)help_debug; /* making compiler happy */ -#endif end(out); } goto st7; tr37: -#line 220 "core/admin.rl" +#line 213 "core/admin.rl" {strend = p;} -#line 167 "core/admin.rl" +#line 160 "core/admin.rl" { strstart[strend-strstart]='\0'; start(out); @@ -380,7 +368,7 @@ tr37: } goto st7; tr44: -#line 174 "core/admin.rl" +#line 167 "core/admin.rl" { if (reload_cfg(err)) fail(out, err); @@ -389,11 +377,11 @@ tr44: } goto st7; tr68: -#line 244 "core/admin.rl" +#line 237 "core/admin.rl" {coredump(60); ok(out);} goto st7; tr77: -#line 181 "core/admin.rl" +#line 174 "core/admin.rl" { int ret = snapshot(NULL, 0); @@ -408,9 +396,9 @@ tr77: } goto st7; tr99: -#line 230 "core/admin.rl" +#line 223 "core/admin.rl" { state = false; } -#line 194 "core/admin.rl" +#line 187 "core/admin.rl" { strstart[strend-strstart] = '\0'; if (errinj_set_byname(strstart, state)) { @@ -422,9 +410,9 @@ tr99: } goto st7; tr102: -#line 229 "core/admin.rl" +#line 222 "core/admin.rl" { state = true; } -#line 194 "core/admin.rl" +#line 187 "core/admin.rl" { strstart[strend-strstart] = '\0'; if (errinj_set_byname(strstart, state)) { @@ -436,7 +424,7 @@ tr102: } goto st7; tr118: -#line 132 "core/admin.rl" +#line 130 "core/admin.rl" { tarantool_cfg_iterator_t *i; char *key, *value; @@ -456,15 +444,15 @@ tr118: } goto st7; tr132: -#line 237 "core/admin.rl" +#line 230 "core/admin.rl" {start(out); fiber_info(out); end(out);} goto st7; tr138: -#line 236 "core/admin.rl" +#line 229 "core/admin.rl" {start(out); tarantool_info(out); end(out);} goto st7; tr147: -#line 150 "core/admin.rl" +#line 148 "core/admin.rl" { start(out); errinj_info(out); @@ -472,22 +460,22 @@ tr147: } goto st7; tr153: -#line 240 "core/admin.rl" +#line 233 "core/admin.rl" {start(out); palloc_stat(out); end(out);} goto st7; tr161: -#line 239 "core/admin.rl" +#line 232 "core/admin.rl" {start(out); slab_stat(out); end(out);} goto st7; tr165: -#line 241 "core/admin.rl" +#line 234 "core/admin.rl" {start(out); stat_print(out);end(out);} goto st7; st7: if ( ++p == pe ) goto _test_eof7; case 7: -#line 491 "core/admin.m" +#line 479 "core/admin.m" if ( (*p) == 10 ) goto st135; goto st0; @@ -640,28 +628,28 @@ case 23: } goto tr33; tr33: -#line 220 "core/admin.rl" +#line 213 "core/admin.rl" {strstart = p;} goto st24; st24: if ( ++p == pe ) goto _test_eof24; case 24: -#line 651 "core/admin.m" +#line 639 "core/admin.m" switch( (*p) ) { case 10: goto tr36; case 13: goto tr37; } goto st24; tr34: -#line 220 "core/admin.rl" +#line 213 "core/admin.rl" {strstart = p;} goto st25; st25: if ( ++p == pe ) goto _test_eof25; case 25: -#line 665 "core/admin.m" +#line 653 "core/admin.m" switch( (*p) ) { case 10: goto tr36; case 13: goto tr37; @@ -1111,28 +1099,28 @@ case 73: goto tr91; goto st0; tr91: -#line 228 "core/admin.rl" +#line 221 "core/admin.rl" { strstart = p; } goto st74; st74: if ( ++p == pe ) goto _test_eof74; case 74: -#line 1122 "core/admin.m" +#line 1110 "core/admin.m" if ( (*p) == 32 ) goto tr92; if ( 33 <= (*p) && (*p) <= 126 ) goto st74; goto st0; tr92: -#line 228 "core/admin.rl" +#line 221 "core/admin.rl" { strend = p; } goto st75; st75: if ( ++p == pe ) goto _test_eof75; case 75: -#line 1136 "core/admin.m" +#line 1124 "core/admin.m" switch( (*p) ) { case 32: goto st75; case 111: goto st76; @@ -1824,7 +1812,7 @@ case 134: _out: {} } -#line 252 "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 79925f7e46..25b15e999c 100644 --- a/core/admin.rl +++ b/core/admin.rl @@ -57,11 +57,9 @@ static const char *help = " - save coredump" CRLF " - save snapshot" CRLF " - lua command" CRLF - " - reload configuration" CRLF; - -static const char *help_debug = - " - show injections" CRLF - " - set injection <name> <state>" 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; @@ -156,11 +154,6 @@ admin_dispatch(lua_State *L) action help { start(out); tbuf_append(out, help, strlen(help)); -#ifndef NDEBUG - tbuf_append(out, help_debug, strlen(help_debug)); -#else - (void)help_debug; /* making compiler happy */ -#endif end(out); } diff --git a/core/tarantool.m b/core/tarantool.m index f675125f00..fb5700cc55 100644 --- a/core/tarantool.m +++ b/core/tarantool.m @@ -449,6 +449,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 with: %s\n", BUILD_WITH); + printf("CFLAGS:%s\n", BUILD_CFLAGS); return 0; } diff --git a/include/config.h.cmake b/include/config.h.cmake index df255a5677..e3d10bb5f4 100644 --- a/include/config.h.cmake +++ b/include/config.h.cmake @@ -53,6 +53,9 @@ #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_WITH "cmake . @TARANTOOL_OPTIONS@" /* * vim: syntax=c */ diff --git a/test/box/admin.result b/test/box/admin.result index c610c7c32f..0bd780a395 100644 --- a/test/box/admin.result +++ b/test/box/admin.result @@ -23,8 +23,8 @@ available commands: - save snapshot - lua command - reload configuration - - show injections - - set injection <name> <state> + - 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 7bf5ec89e5..49b40e1a28 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 with: flags +CFLAGS: flags tarantool_box -V Tarantool/Box 1.minor.patch-<rev>-<commit> +Target: platform <build> +Build with: 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 f51766a25a..3647ac59bb 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 with: .*", "Build with: 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/suite.ini b/test/box/suite.ini index ebc1e935aa..cdee6da413 100644 --- a/test/box/suite.ini +++ b/test/box/suite.ini @@ -5,3 +5,4 @@ config = tarantool.cfg #disabled = sql.test # put disabled in valgrind test here valgrind_disabled = admin_coredump.test +release_disabled = errinj.test diff --git a/test/lib/server.py b/test/lib/server.py index bd63f44f9d..95b68ea47f 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/test_suite.py b/test/lib/test_suite.py index 3273a836a4..db7ab49394 100644 --- a/test/lib/test_suite.py +++ b/test/lib/test_suite.py @@ -217,6 +217,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"] + "." @@ -264,6 +269,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: -- GitLab