Commit 62c3e3cd authored by Artem Dinaburg's avatar Artem Dinaburg Committed by NeroBurner

The %p format is implementation defined. Compare it via a special token,

just like the null pointer test.
parent 0301bfdd
......@@ -90,6 +90,8 @@ static const char TEST_SRC_DIR[] = "../..";
static const char TEST_SRC_DIR[] = ".";
#endif
static const uint32_t PTR_TEST_VALUE = 0x12345678;
DEFINE_string(test_tmpdir, GetTempDir(), "Dir we use for temp files");
DEFINE_string(test_srcdir, TEST_SRC_DIR,
"Source-dir root, needed to find glog_unittest_flagfile");
......@@ -447,10 +449,12 @@ static inline string Munge(const string& filename) {
while (fgets(buf, 4095, fp)) {
string line = MungeLine(buf);
char null_str[256];
char ptr_str[256];
sprintf(null_str, "%p", static_cast<void*>(NULL));
sprintf(ptr_str, "%p", reinterpret_cast<void*>(PTR_TEST_VALUE));
StringReplace(&line, "__NULLP__", null_str);
// Remove 0x prefix produced by %p. VC++ doesn't put the prefix.
StringReplace(&line, " 0x", " ");
StringReplace(&line, "__PTRTEST__", ptr_str);
StringReplace(&line, "__SUCCESS__", StrError(0));
StringReplace(&line, "__ENOENT__", StrError(ENOENT));
......
......@@ -323,7 +323,7 @@ void TestRawLogging() {
RAW_LOG(WARNING, "%s", s);
const char const_s[] = "const array";
RAW_LOG(INFO, "%s", const_s);
void* p = reinterpret_cast<void*>(0x12345678);
void* p = reinterpret_cast<void*>(PTR_TEST_VALUE);
RAW_LOG(INFO, "ptr %p", p);
p = NULL;
RAW_LOG(INFO, "ptr %p", p);
......
......@@ -80,7 +80,7 @@ no prefix
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo bar 10 3.400000
WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: array
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: const array
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: ptr 0x12345678
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: ptr __PTRTEST__
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: ptr __NULLP__
EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000 0000001000 3e8
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment