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
edc1bc60
Unverified
Commit
edc1bc60
authored
Aug 17, 2018
by
Gennadiy Civil
Committed by
GitHub
Aug 17, 2018
Browse files
Merge branch 'master' into patch-1
parents
7e7e3a6f
02a8ca87
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
15 deletions
+93
-15
.gitignore
.gitignore
+11
-0
googlemock/CMakeLists.txt
googlemock/CMakeLists.txt
+14
-4
googlemock/include/gmock/gmock-more-matchers.h
googlemock/include/gmock/gmock-more-matchers.h
+3
-3
googletest/CMakeLists.txt
googletest/CMakeLists.txt
+19
-4
googletest/include/gtest/internal/gtest-port.h
googletest/include/gtest/internal/gtest-port.h
+2
-2
googletest/src/gtest-port.cc
googletest/src/gtest-port.cc
+44
-2
No files found.
.gitignore
View file @
edc1bc60
...
@@ -41,3 +41,14 @@ googletest/fused-src/
...
@@ -41,3 +41,14 @@ googletest/fused-src/
# macOS files
# macOS files
.DS_Store
.DS_Store
# Ignore cmake generated directories and files.
CMakeFiles
CTestTestfile.cmake
Makefile
cmake_install.cmake
googlemock/CMakeFiles
googlemock/CTestTestfile.cmake
googlemock/Makefile
googlemock/cmake_install.cmake
googlemock/gtest
googlemock/CMakeLists.txt
View file @
edc1bc60
...
@@ -5,10 +5,6 @@
...
@@ -5,10 +5,6 @@
# ctest. You can select which tests to run using 'ctest -R regex'.
# ctest. You can select which tests to run using 'ctest -R regex'.
# For more options, run 'ctest --help'.
# For more options, run 'ctest --help'.
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
# make it prominent in the GUI.
option
(
BUILD_SHARED_LIBS
"Build shared libraries (DLLs)."
OFF
)
option
(
gmock_build_tests
"Build all of Google Mock's own tests."
OFF
)
option
(
gmock_build_tests
"Build all of Google Mock's own tests."
OFF
)
# A directory to find Google Test sources.
# A directory to find Google Test sources.
...
@@ -55,6 +51,20 @@ endif()
...
@@ -55,6 +51,20 @@ endif()
# if they are the same (the default).
# if they are the same (the default).
add_subdirectory
(
"
${
gtest_dir
}
"
"
${
gmock_BINARY_DIR
}
/gtest"
)
add_subdirectory
(
"
${
gtest_dir
}
"
"
${
gmock_BINARY_DIR
}
/gtest"
)
# These commands only run if this is the main project
if
(
CMAKE_PROJECT_NAME STREQUAL
"gmock"
OR CMAKE_PROJECT_NAME STREQUAL
"googletest-distribution"
)
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
# make it prominent in the GUI.
option
(
BUILD_SHARED_LIBS
"Build shared libraries (DLLs)."
OFF
)
else
()
mark_as_advanced
(
gmock_build_tests
)
endif
()
# Although Google Test's CMakeLists.txt calls this function, the
# Although Google Test's CMakeLists.txt calls this function, the
# changes there don't affect the current scope. Therefore we have to
# changes there don't affect the current scope. Therefore we have to
# call it again here.
# call it again here.
...
...
googlemock/include/gmock/gmock-more-matchers.h
View file @
edc1bc60
...
@@ -37,8 +37,8 @@
...
@@ -37,8 +37,8 @@
// GOOGLETEST_CM0002 DO NOT DELETE
// GOOGLETEST_CM0002 DO NOT DELETE
#ifndef GMOCK_GMOCK_MORE_MATCHERS_H_
#ifndef GMOCK_
INCLUDE_
GMOCK_MORE_MATCHERS_H_
#define GMOCK_GMOCK_MORE_MATCHERS_H_
#define GMOCK_
INCLUDE_
GMOCK_MORE_MATCHERS_H_
#include "gmock/gmock-generated-matchers.h"
#include "gmock/gmock-generated-matchers.h"
...
@@ -89,4 +89,4 @@ MATCHER(IsFalse, negation ? "is true" : "is false") {
...
@@ -89,4 +89,4 @@ MATCHER(IsFalse, negation ? "is true" : "is false") {
}
// namespace testing
}
// namespace testing
#endif // GMOCK_GMOCK_MORE_MATCHERS_H_
#endif // GMOCK_
INCLUDE_
GMOCK_MORE_MATCHERS_H_
googletest/CMakeLists.txt
View file @
edc1bc60
...
@@ -5,10 +5,6 @@
...
@@ -5,10 +5,6 @@
# ctest. You can select which tests to run using 'ctest -R regex'.
# ctest. You can select which tests to run using 'ctest -R regex'.
# For more options, run 'ctest --help'.
# For more options, run 'ctest --help'.
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
# make it prominent in the GUI.
option
(
BUILD_SHARED_LIBS
"Build shared libraries (DLLs)."
OFF
)
# When other libraries are using a shared version of runtime libraries,
# When other libraries are using a shared version of runtime libraries,
# Google Test also has to use one.
# Google Test also has to use one.
option
(
option
(
...
@@ -60,6 +56,25 @@ if (COMMAND set_up_hermetic_build)
...
@@ -60,6 +56,25 @@ if (COMMAND set_up_hermetic_build)
set_up_hermetic_build
()
set_up_hermetic_build
()
endif
()
endif
()
# These commands only run if this is the main project
if
(
CMAKE_PROJECT_NAME STREQUAL
"gtest"
OR CMAKE_PROJECT_NAME STREQUAL
"googletest-distribution"
)
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
# make it prominent in the GUI.
option
(
BUILD_SHARED_LIBS
"Build shared libraries (DLLs)."
OFF
)
else
()
mark_as_advanced
(
gtest_force_shared_crt
gtest_build_tests
gtest_build_samples
gtest_disable_pthreads
gtest_hide_internal_symbols
)
endif
()
if
(
gtest_hide_internal_symbols
)
if
(
gtest_hide_internal_symbols
)
set
(
CMAKE_CXX_VISIBILITY_PRESET hidden
)
set
(
CMAKE_CXX_VISIBILITY_PRESET hidden
)
set
(
CMAKE_VISIBILITY_INLINES_HIDDEN 1
)
set
(
CMAKE_VISIBILITY_INLINES_HIDDEN 1
)
...
...
googletest/include/gtest/internal/gtest-port.h
View file @
edc1bc60
...
@@ -2107,8 +2107,8 @@ class MutexBase {
...
@@ -2107,8 +2107,8 @@ class MutexBase {
// particular, the owner_ field (a pthread_t) is not explicitly initialized.
// particular, the owner_ field (a pthread_t) is not explicitly initialized.
// This allows initialization to work whether pthread_t is a scalar or struct.
// This allows initialization to work whether pthread_t is a scalar or struct.
// The flag -Wmissing-field-initializers must not be specified for this to work.
// The flag -Wmissing-field-initializers must not be specified for this to work.
#
define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
::testing::internal::MutexBase mutex = {
PTHREAD_MUTEX_INITIALIZER, false
}
::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false
, 0
}
// The Mutex class can only be used for mutexes created at runtime. It
// The Mutex class can only be used for mutexes created at runtime. It
// shares its API with MutexBase otherwise.
// shares its API with MutexBase otherwise.
...
...
googletest/src/gtest-port.cc
View file @
edc1bc60
...
@@ -294,6 +294,43 @@ void Mutex::AssertHeld() {
...
@@ -294,6 +294,43 @@ void Mutex::AssertHeld() {
<<
"The current thread is not holding the mutex @"
<<
this
;
<<
"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.
// Initializes owner_thread_id_ and critical_section_ in static mutexes.
void
Mutex
::
ThreadSafeLazyInit
()
{
void
Mutex
::
ThreadSafeLazyInit
()
{
// Dynamic mutexes are initialized in the constructor.
// Dynamic mutexes are initialized in the constructor.
...
@@ -304,7 +341,11 @@ void Mutex::ThreadSafeLazyInit() {
...
@@ -304,7 +341,11 @@ void Mutex::ThreadSafeLazyInit() {
// If critical_section_init_phase_ was 0 before the exchange, we
// If critical_section_init_phase_ was 0 before the exchange, we
// are the first to test it and need to perform the initialization.
// are the first to test it and need to perform the initialization.
owner_thread_id_
=
0
;
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_
);
::
InitializeCriticalSection
(
critical_section_
);
// Updates the critical_section_init_phase_ to 2 to signal
// Updates the critical_section_init_phase_ to 2 to signal
// initialization complete.
// initialization complete.
...
@@ -546,7 +587,8 @@ class ThreadLocalRegistryImpl {
...
@@ -546,7 +587,8 @@ class ThreadLocalRegistryImpl {
// Returns map of thread local instances.
// Returns map of thread local instances.
static
ThreadIdToThreadLocals
*
GetThreadLocalsMapLocked
()
{
static
ThreadIdToThreadLocals
*
GetThreadLocalsMapLocked
()
{
mutex_
.
AssertHeld
();
mutex_
.
AssertHeld
();
static
ThreadIdToThreadLocals
*
map
=
new
ThreadIdToThreadLocals
;
MemoryIsNotDeallocated
memory_is_not_deallocated
;
static
ThreadIdToThreadLocals
*
map
=
new
ThreadIdToThreadLocals
();
return
map
;
return
map
;
}
}
...
...
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