Fix logging_striplog_test.sh in debug mode. Fixes issue 108.
author <hlsyounes@gmail.com> <>
Thu, 29 Dec 2011 12:36:09 +0000 (12:36 +0000)
committer <hlsyounes@gmail.com> <>
Thu, 29 Dec 2011 12:36:09 +0000 (12:36 +0000)
git-svn-id: https://google-glog.googlecode.com/svn/trunk@99 eb4d4688-79bd-11dd-afb4-1d65580434c0

src/logging_striplog_test.sh
src/logging_striptest_main.cc

index b9033b2..73492bd 100755 (executable)
@@ -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
 
index 17a582f..2e5d3b1 100644 (file)
@@ -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;