diff --git a/src/logging_striplog_test.sh b/src/logging_striplog_test.sh index b9033b2..73492bd 100755 --- a/src/logging_striplog_test.sh +++ b/src/logging_striplog_test.sh @@ -60,9 +60,16 @@ die () { # Check that the string literals are appropriately stripped. This will # not be the case in debug mode. -check_eq "`get_strings logging_striptest0`" "COND ERROR FATAL INFO WARNING " -check_eq "`get_strings logging_striptest2`" "COND ERROR FATAL " -check_eq "`get_strings logging_striptest10`" "" +mode=`GLOG_check_mode=1 ./logging_striptest0 2> /dev/null` +if [ "$mode" = "opt" ]; +then + echo "In OPT mode" + check_eq "`get_strings logging_striptest0`" "COND ERROR FATAL INFO USAGE WARNING " + check_eq "`get_strings logging_striptest2`" "COND ERROR FATAL USAGE " + check_eq "`get_strings logging_striptest10`" "" +else + echo "In DBG mode; not checking strings" +fi # Check that LOG(FATAL) aborts even for large STRIP_LOG diff --git a/src/logging_striptest_main.cc b/src/logging_striptest_main.cc index 17a582f..2e5d3b1 100644 --- a/src/logging_striptest_main.cc +++ b/src/logging_striptest_main.cc @@ -39,6 +39,7 @@ #include "config.h" DECLARE_bool(logtostderr); +GLOG_DEFINE_bool(check_mode, false, "Prints 'opt' or 'dbg'"); using std::string; using namespace GOOGLE_NAMESPACE; @@ -58,6 +59,10 @@ std::ostream &operator<<(std::ostream &str, const A&) {return str;} int main(int argc, char* argv[]) { FLAGS_logtostderr = true; InitGoogleLogging(argv[0]); + if (FLAGS_check_mode) { + printf("%s\n", DEBUG_MODE ? "dbg" : "opt"); + return 0; + } LOG(INFO) << "TESTMESSAGE INFO"; LOG(WARNING) << 2 << "something" << "TESTMESSAGE WARNING" << 1 << 'c' << A() << std::endl;