Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
glog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
glog
Commits
3267f3e1
Unverified
Commit
3267f3e1
authored
Jun 29, 2018
by
Sergiu Deitsch
Committed by
GitHub
Jun 29, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #331 from NeroBurner/fix_windows_logging_ut
Fix windows logging ut
parents
c72907c4
f39f78c7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
5 deletions
+21
-5
googletest.h
src/googletest.h
+10
-2
logging_unittest.cc
src/logging_unittest.cc
+1
-1
logging_unittest.err
src/logging_unittest.err
+1
-1
port.h
src/windows/port.h
+9
-1
No files found.
src/googletest.h
View file @
3267f3e1
...
@@ -90,6 +90,8 @@ static const char TEST_SRC_DIR[] = "../..";
...
@@ -90,6 +90,8 @@ static const char TEST_SRC_DIR[] = "../..";
static
const
char
TEST_SRC_DIR
[]
=
"."
;
static
const
char
TEST_SRC_DIR
[]
=
"."
;
#endif
#endif
static
const
uint32_t
PTR_TEST_VALUE
=
0x12345678
;
DEFINE_string
(
test_tmpdir
,
GetTempDir
(),
"Dir we use for temp files"
);
DEFINE_string
(
test_tmpdir
,
GetTempDir
(),
"Dir we use for temp files"
);
DEFINE_string
(
test_srcdir
,
TEST_SRC_DIR
,
DEFINE_string
(
test_srcdir
,
TEST_SRC_DIR
,
"Source-dir root, needed to find glog_unittest_flagfile"
);
"Source-dir root, needed to find glog_unittest_flagfile"
);
...
@@ -447,10 +449,12 @@ static inline string Munge(const string& filename) {
...
@@ -447,10 +449,12 @@ static inline string Munge(const string& filename) {
while
(
fgets
(
buf
,
4095
,
fp
))
{
while
(
fgets
(
buf
,
4095
,
fp
))
{
string
line
=
MungeLine
(
buf
);
string
line
=
MungeLine
(
buf
);
char
null_str
[
256
];
char
null_str
[
256
];
char
ptr_str
[
256
];
sprintf
(
null_str
,
"%p"
,
static_cast
<
void
*>
(
NULL
));
sprintf
(
null_str
,
"%p"
,
static_cast
<
void
*>
(
NULL
));
sprintf
(
ptr_str
,
"%p"
,
reinterpret_cast
<
void
*>
(
PTR_TEST_VALUE
));
StringReplace
(
&
line
,
"__NULLP__"
,
null_str
);
StringReplace
(
&
line
,
"__NULLP__"
,
null_str
);
// Remove 0x prefix produced by %p. VC++ doesn't put the prefix.
StringReplace
(
&
line
,
"__PTRTEST__"
,
ptr_str
);
StringReplace
(
&
line
,
" 0x"
,
" "
);
StringReplace
(
&
line
,
"__SUCCESS__"
,
StrError
(
0
));
StringReplace
(
&
line
,
"__SUCCESS__"
,
StrError
(
0
));
StringReplace
(
&
line
,
"__ENOENT__"
,
StrError
(
ENOENT
));
StringReplace
(
&
line
,
"__ENOENT__"
,
StrError
(
ENOENT
));
...
@@ -485,7 +489,11 @@ static inline bool MungeAndDiffTestStderr(const string& golden_filename) {
...
@@ -485,7 +489,11 @@ static inline bool MungeAndDiffTestStderr(const string& golden_filename) {
WriteToFile
(
golden
,
munged_golden
);
WriteToFile
(
golden
,
munged_golden
);
string
munged_captured
=
cap
->
filename
()
+
".munged"
;
string
munged_captured
=
cap
->
filename
()
+
".munged"
;
WriteToFile
(
captured
,
munged_captured
);
WriteToFile
(
captured
,
munged_captured
);
#ifdef OS_WINDOWS
string
diffcmd
(
"fc "
+
munged_golden
+
" "
+
munged_captured
);
#else
string
diffcmd
(
"diff -u "
+
munged_golden
+
" "
+
munged_captured
);
string
diffcmd
(
"diff -u "
+
munged_golden
+
" "
+
munged_captured
);
#endif
if
(
system
(
diffcmd
.
c_str
())
!=
0
)
{
if
(
system
(
diffcmd
.
c_str
())
!=
0
)
{
fprintf
(
stderr
,
"diff command was failed.
\n
"
);
fprintf
(
stderr
,
"diff command was failed.
\n
"
);
}
}
...
...
src/logging_unittest.cc
View file @
3267f3e1
...
@@ -323,7 +323,7 @@ void TestRawLogging() {
...
@@ -323,7 +323,7 @@ void TestRawLogging() {
RAW_LOG
(
WARNING
,
"%s"
,
s
);
RAW_LOG
(
WARNING
,
"%s"
,
s
);
const
char
const_s
[]
=
"const array"
;
const
char
const_s
[]
=
"const array"
;
RAW_LOG
(
INFO
,
"%s"
,
const_s
);
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
);
RAW_LOG
(
INFO
,
"ptr %p"
,
p
);
p
=
NULL
;
p
=
NULL
;
RAW_LOG
(
INFO
,
"ptr %p"
,
p
);
RAW_LOG
(
INFO
,
"ptr %p"
,
p
);
...
...
src/logging_unittest.err
View file @
3267f3e1
...
@@ -80,7 +80,7 @@ no prefix
...
@@ -80,7 +80,7 @@ no prefix
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo bar 10 3.400000
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo bar 10 3.400000
WDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: array
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: 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__
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: ptr __NULLP__
EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000 0000001000 3e8
EDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000 0000001000 3e8
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000
IDATE TIME__ THREADID logging_unittest.cc:LINE] RAW: foo 1000
...
...
src/windows/port.h
View file @
3267f3e1
...
@@ -70,8 +70,11 @@
...
@@ -70,8 +70,11 @@
* 4715: for some reason VC++ stopped realizing you can't return after abort()
* 4715: for some reason VC++ stopped realizing you can't return after abort()
* 4800: we know we're casting ints/char*'s to bools, and we're ok with that
* 4800: we know we're casting ints/char*'s to bools, and we're ok with that
* 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror()
* 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror()
* 4312: Converting uint32_t to a pointer when testing %p
* 4267: also subtracting two size_t to int
* 4722: Destructor never returns due to abort()
*/
*/
#pragma warning(disable:4244 4251 4355 4715 4800 4996)
#pragma warning(disable:4244 4251 4355 4715 4800 4996
4267 4312 4722
)
/* file I/O */
/* file I/O */
#define PATH_MAX 1024
#define PATH_MAX 1024
...
@@ -86,6 +89,11 @@
...
@@ -86,6 +89,11 @@
#define pclose _pclose
#define pclose _pclose
#define R_OK 04
/* read-only (for access()) */
#define R_OK 04
/* read-only (for access()) */
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define O_WRONLY _O_WRONLY
#define O_CREAT _O_CREAT
#define O_EXCL _O_EXCL
#ifndef __MINGW32__
#ifndef __MINGW32__
enum
{
STDIN_FILENO
=
0
,
STDOUT_FILENO
=
1
,
STDERR_FILENO
=
2
};
enum
{
STDIN_FILENO
=
0
,
STDOUT_FILENO
=
1
,
STDERR_FILENO
=
2
};
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment