Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
a6e7ba27
Unverified
Commit
a6e7ba27
authored
Aug 20, 2018
by
Gennadiy Civil
Committed by
GitHub
Aug 20, 2018
Browse files
Merge branch 'master' into josh/fix_scoped_class2
parents
21e51855
735bd75f
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
4 deletions
+68
-4
googletest/src/gtest-internal-inl.h
googletest/src/gtest-internal-inl.h
+5
-0
googletest/src/gtest-port.cc
googletest/src/gtest-port.cc
+44
-2
googletest/src/gtest.cc
googletest/src/gtest.cc
+19
-2
No files found.
googletest/src/gtest-internal-inl.h
View file @
a6e7ba27
...
...
@@ -59,6 +59,9 @@
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
GTEST_DISABLE_MSC_WARNINGS_PUSH_
(
4251
\
/* class A needs to have dll-interface to be used by clients of class B */
)
namespace
testing
{
// Declares the flags.
...
...
@@ -1179,4 +1182,6 @@ class StreamingListener : public EmptyTestEventListener {
}
// namespace internal
}
// namespace testing
GTEST_DISABLE_MSC_WARNINGS_POP_
()
// 4251
#endif // GTEST_SRC_GTEST_INTERNAL_INL_H_
googletest/src/gtest-port.cc
View file @
a6e7ba27
...
...
@@ -294,6 +294,43 @@ void Mutex::AssertHeld() {
<<
"The current thread is not holding the mutex @"
<<
this
;
}
namespace
{
// Use the RAII idiom to flag mem allocs that are intentionally never
// deallocated. The motivation is to silence the false positive mem leaks
// that are reported by the debug version of MS's CRT which can only detect
// if an alloc is missing a matching deallocation.
// Example:
// MemoryIsNotDeallocated memory_is_not_deallocated;
// critical_section_ = new CRITICAL_SECTION;
//
class
MemoryIsNotDeallocated
{
public:
MemoryIsNotDeallocated
()
:
old_crtdbg_flag_
(
0
)
{
#ifdef _MSC_VER
old_crtdbg_flag_
=
_CrtSetDbgFlag
(
_CRTDBG_REPORT_FLAG
);
// Set heap allocation block type to _IGNORE_BLOCK so that MS debug CRT
// doesn't report mem leak if there's no matching deallocation.
_CrtSetDbgFlag
(
old_crtdbg_flag_
&
~
_CRTDBG_ALLOC_MEM_DF
);
#endif // _MSC_VER
}
~
MemoryIsNotDeallocated
()
{
#ifdef _MSC_VER
// Restore the original _CRTDBG_ALLOC_MEM_DF flag
_CrtSetDbgFlag
(
old_crtdbg_flag_
);
#endif // _MSC_VER
}
private:
int
old_crtdbg_flag_
;
GTEST_DISALLOW_COPY_AND_ASSIGN_
(
MemoryIsNotDeallocated
);
};
}
// namespace
// Initializes owner_thread_id_ and critical_section_ in static mutexes.
void
Mutex
::
ThreadSafeLazyInit
()
{
// Dynamic mutexes are initialized in the constructor.
...
...
@@ -304,7 +341,11 @@ void Mutex::ThreadSafeLazyInit() {
// If critical_section_init_phase_ was 0 before the exchange, we
// are the first to test it and need to perform the initialization.
owner_thread_id_
=
0
;
critical_section_
=
new
CRITICAL_SECTION
;
{
// Use RAII to flag that following mem alloc is never deallocated.
MemoryIsNotDeallocated
memory_is_not_deallocated
;
critical_section_
=
new
CRITICAL_SECTION
;
}
::
InitializeCriticalSection
(
critical_section_
);
// Updates the critical_section_init_phase_ to 2 to signal
// initialization complete.
...
...
@@ -546,7 +587,8 @@ class ThreadLocalRegistryImpl {
// Returns map of thread local instances.
static
ThreadIdToThreadLocals
*
GetThreadLocalsMapLocked
()
{
mutex_
.
AssertHeld
();
static
ThreadIdToThreadLocals
*
map
=
new
ThreadIdToThreadLocals
;
MemoryIsNotDeallocated
memory_is_not_deallocated
;
static
ThreadIdToThreadLocals
*
map
=
new
ThreadIdToThreadLocals
();
return
map
;
}
...
...
googletest/src/gtest.cc
View file @
a6e7ba27
...
...
@@ -138,6 +138,12 @@
# define vsnprintf _vsnprintf
#endif // GTEST_OS_WINDOWS
#if GTEST_OS_MAC
#ifndef GTEST_OS_IOS
#include <crt_externs.h>
#endif
#endif
#if GTEST_HAS_ABSL
#include "absl/debugging/failure_signal_handler.h"
#include "absl/debugging/stacktrace.h"
...
...
@@ -4692,7 +4698,7 @@ int UnitTest::Run() {
// used for the duration of the program.
impl
()
->
set_catch_exceptions
(
GTEST_FLAG
(
catch_exceptions
));
#if GTEST_
HAS_SEH
#if GTEST_
OS_WINDOWS
// Either the user wants Google Test to catch exceptions thrown by the
// tests or this is executing in the context of death test child
// process. In either case the user does not want to see pop-up dialogs
...
...
@@ -4729,7 +4735,7 @@ int UnitTest::Run() {
_WRITE_ABORT_MSG
|
_CALL_REPORTFAULT
);
// pop-up window, core dump.
# endif
}
#endif // GTEST_
HAS_SEH
#endif // GTEST_
OS_WINDOWS
return
internal
::
HandleExceptionsInMethodIfSupported
(
impl
(),
...
...
@@ -5825,6 +5831,17 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
// other parts of Google Test.
void
ParseGoogleTestFlagsOnly
(
int
*
argc
,
char
**
argv
)
{
ParseGoogleTestFlagsOnlyImpl
(
argc
,
argv
);
// Fix the value of *_NSGetArgc() on macOS, but iff
// *_NSGetArgv() == argv
// Only applicable to char** version of argv
#if GTEST_OS_MAC
#ifndef GTEST_OS_IOS
if
(
*
_NSGetArgv
()
==
argv
)
{
*
_NSGetArgc
()
=
*
argc
;
}
#endif
#endif
}
void
ParseGoogleTestFlagsOnly
(
int
*
argc
,
wchar_t
**
argv
)
{
ParseGoogleTestFlagsOnlyImpl
(
argc
,
argv
);
...
...
Prev
1
2
Next
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