Relax test for symbolize
[platform/upstream/glog.git] / src / symbolize_unittest.cc
index 77dfb29..26616e6 100644 (file)
 #include "googletest.h"
 #include "config.h"
 
+#ifdef HAVE_LIB_GFLAGS
+#include <gflags/gflags.h>
+using namespace GFLAGS_NAMESPACE;
+#endif
+
 using namespace std;
 using namespace GOOGLE_NAMESPACE;
 
@@ -94,7 +99,13 @@ TEST(Symbolize, Symbolize) {
 
   // Compilers should give us pointers to them.
   EXPECT_STREQ("nonstatic_func", TrySymbolize((void *)(&nonstatic_func)));
-  EXPECT_STREQ("static_func", TrySymbolize((void *)(&static_func)));
+
+  // The name of an internal linkage symbol is not specified; allow either a
+  // mangled or an unmangled name here.
+  const char *static_func_symbol = TrySymbolize((void *)(&static_func));
+  CHECK(NULL != static_func_symbol);
+  EXPECT_TRUE(strcmp("static_func", static_func_symbol) == 0 ||
+              strcmp("static_func()", static_func_symbol) == 0);
 
   EXPECT_TRUE(NULL == TrySymbolize(NULL));
 }
@@ -193,7 +204,8 @@ static const char *SymbolizeStackConsumption(void *pc, int *stack_consumed) {
   memset(altstack, kAlternateStackFillValue, kAlternateStackSize);
 
   // Set up the alt-signal-stack (and save the older one).
-  stack_t sigstk = {};  // Zero-clear.
+  stack_t sigstk;
+  memset(&sigstk, 0, sizeof(stack_t));
   stack_t old_sigstk;
   sigstk.ss_sp = altstack;
   sigstk.ss_size = kAlternateStackSize;
@@ -201,7 +213,8 @@ static const char *SymbolizeStackConsumption(void *pc, int *stack_consumed) {
   CHECK_ERR(sigaltstack(&sigstk, &old_sigstk));
 
   // Set up SIGUSR1 and SIGUSR2 signal handlers (and save the older ones).
-  struct sigaction sa = {};  // Zero-clear;
+  struct sigaction sa;
+  memset(&sa, 0, sizeof(struct sigaction));
   struct sigaction old_sa1, old_sa2;
   sigemptyset(&sa.sa_mask);
   sa.sa_flags = SA_ONSTACK;
@@ -260,9 +273,13 @@ TEST(Symbolize, SymbolizeStackConsumption) {
   EXPECT_GT(stack_consumed, 0);
   EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit);
 
+  // The name of an internal linkage symbol is not specified; allow either a
+  // mangled or an unmangled name here.
   symbol = SymbolizeStackConsumption((void *)(&static_func),
                                      &stack_consumed);
-  EXPECT_STREQ("static_func", symbol);
+  CHECK(NULL != symbol);
+  EXPECT_TRUE(strcmp("static_func", symbol) == 0 ||
+              strcmp("static_func()", symbol) == 0);
   EXPECT_GT(stack_consumed, 0);
   EXPECT_LT(stack_consumed, kStackConsumptionUpperLimit);
 }