Skip to content

Commit 7a166a2

Browse files
nodejs-github-bottargos
authored andcommitted
deps: update googletest to 5197b1a
PR-URL: #51657 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Ulises Gascón <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 812dbd7 commit 7a166a2

File tree

8 files changed

+112
-101
lines changed

8 files changed

+112
-101
lines changed

deps/googletest/include/gtest/gtest-assertion-result.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ namespace testing {
129129
//
130130
// Expected: Foo() is even
131131
// Actual: it's 5
132-
//
132+
133133
class GTEST_API_ AssertionResult {
134134
public:
135135
// Copy constructor.

deps/googletest/include/gtest/internal/gtest-filepath.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class GTEST_API_ FilePath {
7171
public:
7272
FilePath() : pathname_("") {}
7373
FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {}
74-
FilePath(FilePath&& rhs) : pathname_(std::move(rhs.pathname_)) {}
74+
FilePath(FilePath&& rhs) noexcept : pathname_(std::move(rhs.pathname_)) {}
7575

7676
explicit FilePath(std::string pathname) : pathname_(std::move(pathname)) {
7777
Normalize();
@@ -81,7 +81,7 @@ class GTEST_API_ FilePath {
8181
Set(rhs);
8282
return *this;
8383
}
84-
FilePath& operator=(FilePath&& rhs) {
84+
FilePath& operator=(FilePath&& rhs) noexcept {
8585
pathname_ = std::move(rhs.pathname_);
8686
return *this;
8787
}

deps/googletest/include/gtest/internal/gtest-internal.h

+10-44
Original file line numberDiff line numberDiff line change
@@ -1137,40 +1137,6 @@ class NativeArray {
11371137
void (NativeArray::*clone_)(const Element*, size_t);
11381138
};
11391139

1140-
// Backport of std::index_sequence.
1141-
template <size_t... Is>
1142-
struct IndexSequence {
1143-
using type = IndexSequence;
1144-
};
1145-
1146-
// Double the IndexSequence, and one if plus_one is true.
1147-
template <bool plus_one, typename T, size_t sizeofT>
1148-
struct DoubleSequence;
1149-
template <size_t... I, size_t sizeofT>
1150-
struct DoubleSequence<true, IndexSequence<I...>, sizeofT> {
1151-
using type = IndexSequence<I..., (sizeofT + I)..., 2 * sizeofT>;
1152-
};
1153-
template <size_t... I, size_t sizeofT>
1154-
struct DoubleSequence<false, IndexSequence<I...>, sizeofT> {
1155-
using type = IndexSequence<I..., (sizeofT + I)...>;
1156-
};
1157-
1158-
// Backport of std::make_index_sequence.
1159-
// It uses O(ln(N)) instantiation depth.
1160-
template <size_t N>
1161-
struct MakeIndexSequenceImpl
1162-
: DoubleSequence<N % 2 == 1, typename MakeIndexSequenceImpl<N / 2>::type,
1163-
N / 2>::type {};
1164-
1165-
template <>
1166-
struct MakeIndexSequenceImpl<0> : IndexSequence<> {};
1167-
1168-
template <size_t N>
1169-
using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::type;
1170-
1171-
template <typename... T>
1172-
using IndexSequenceFor = typename MakeIndexSequence<sizeof...(T)>::type;
1173-
11741140
template <size_t>
11751141
struct Ignore {
11761142
Ignore(...); // NOLINT
@@ -1179,7 +1145,7 @@ struct Ignore {
11791145
template <typename>
11801146
struct ElemFromListImpl;
11811147
template <size_t... I>
1182-
struct ElemFromListImpl<IndexSequence<I...>> {
1148+
struct ElemFromListImpl<std::index_sequence<I...>> {
11831149
// We make Ignore a template to solve a problem with MSVC.
11841150
// A non-template Ignore would work fine with `decltype(Ignore(I))...`, but
11851151
// MSVC doesn't understand how to deal with that pack expansion.
@@ -1190,9 +1156,8 @@ struct ElemFromListImpl<IndexSequence<I...>> {
11901156

11911157
template <size_t N, typename... T>
11921158
struct ElemFromList {
1193-
using type =
1194-
decltype(ElemFromListImpl<typename MakeIndexSequence<N>::type>::Apply(
1195-
static_cast<T (*)()>(nullptr)...));
1159+
using type = decltype(ElemFromListImpl<std::make_index_sequence<N>>::Apply(
1160+
static_cast<T (*)()>(nullptr)...));
11961161
};
11971162

11981163
struct FlatTupleConstructTag {};
@@ -1217,9 +1182,9 @@ template <typename Derived, typename Idx>
12171182
struct FlatTupleBase;
12181183

12191184
template <size_t... Idx, typename... T>
1220-
struct FlatTupleBase<FlatTuple<T...>, IndexSequence<Idx...>>
1185+
struct FlatTupleBase<FlatTuple<T...>, std::index_sequence<Idx...>>
12211186
: FlatTupleElemBase<FlatTuple<T...>, Idx>... {
1222-
using Indices = IndexSequence<Idx...>;
1187+
using Indices = std::index_sequence<Idx...>;
12231188
FlatTupleBase() = default;
12241189
template <typename... Args>
12251190
explicit FlatTupleBase(FlatTupleConstructTag, Args&&... args)
@@ -1254,14 +1219,15 @@ struct FlatTupleBase<FlatTuple<T...>, IndexSequence<Idx...>>
12541219
// implementations.
12551220
// FlatTuple and ElemFromList are not recursive and have a fixed depth
12561221
// regardless of T...
1257-
// MakeIndexSequence, on the other hand, it is recursive but with an
1222+
// std::make_index_sequence, on the other hand, it is recursive but with an
12581223
// instantiation depth of O(ln(N)).
12591224
template <typename... T>
12601225
class FlatTuple
12611226
: private FlatTupleBase<FlatTuple<T...>,
1262-
typename MakeIndexSequence<sizeof...(T)>::type> {
1263-
using Indices = typename FlatTupleBase<
1264-
FlatTuple<T...>, typename MakeIndexSequence<sizeof...(T)>::type>::Indices;
1227+
std::make_index_sequence<sizeof...(T)>> {
1228+
using Indices =
1229+
typename FlatTupleBase<FlatTuple<T...>,
1230+
std::make_index_sequence<sizeof...(T)>>::Indices;
12651231

12661232
public:
12671233
FlatTuple() = default;

deps/googletest/include/gtest/internal/gtest-param-util.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -807,12 +807,12 @@ class ValueArray {
807807

808808
template <typename T>
809809
operator ParamGenerator<T>() const { // NOLINT
810-
return ValuesIn(MakeVector<T>(MakeIndexSequence<sizeof...(Ts)>()));
810+
return ValuesIn(MakeVector<T>(std::make_index_sequence<sizeof...(Ts)>()));
811811
}
812812

813813
private:
814814
template <typename T, size_t... I>
815-
std::vector<T> MakeVector(IndexSequence<I...>) const {
815+
std::vector<T> MakeVector(std::index_sequence<I...>) const {
816816
return std::vector<T>{static_cast<T>(v_.template Get<I>())...};
817817
}
818818

@@ -842,7 +842,7 @@ class CartesianProductGenerator
842842
template <class I>
843843
class IteratorImpl;
844844
template <size_t... I>
845-
class IteratorImpl<IndexSequence<I...>>
845+
class IteratorImpl<std::index_sequence<I...>>
846846
: public ParamIteratorInterface<ParamType> {
847847
public:
848848
IteratorImpl(const ParamGeneratorInterface<ParamType>* base,
@@ -933,7 +933,7 @@ class CartesianProductGenerator
933933
std::shared_ptr<ParamType> current_value_;
934934
};
935935

936-
using Iterator = IteratorImpl<typename MakeIndexSequence<sizeof...(T)>::type>;
936+
using Iterator = IteratorImpl<std::make_index_sequence<sizeof...(T)>>;
937937

938938
std::tuple<ParamGenerator<T>...> generators_;
939939
};

deps/googletest/include/gtest/internal/gtest-port-arch.h

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
5757
#define GTEST_OS_WINDOWS_PHONE 1
5858
#define GTEST_OS_WINDOWS_TV_TITLE 1
59+
#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_GAMES)
60+
#define GTEST_OS_WINDOWS_GAMES 1
5961
#else
6062
// WINAPI_FAMILY defined but no known partition matched.
6163
// Default to desktop.

deps/googletest/include/gtest/internal/gtest-port.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@
340340

341341
#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
342342
#define GTEST_INTERNAL_HAS_ABSL_FLAGS // Used only in this file.
343-
#include "absl/flags/flag.h"
344343
#include "absl/flags/declare.h"
344+
#include "absl/flags/flag.h"
345345
#include "absl/flags/reflection.h"
346346
#endif
347347

@@ -659,9 +659,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
659659
// platforms except known mobile / embedded ones. Also, if the port doesn't have
660660
// a file system, stream redirection is not supported.
661661
#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \
662-
defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) || \
663-
defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) || \
664-
!GTEST_HAS_FILE_SYSTEM
662+
defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_WINDOWS_GAMES) || \
663+
defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \
664+
defined(GTEST_OS_QURT) || !GTEST_HAS_FILE_SYSTEM
665665
#define GTEST_HAS_STREAM_REDIRECTION 0
666666
#else
667667
#define GTEST_HAS_STREAM_REDIRECTION 1
@@ -2108,8 +2108,9 @@ GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
21082108
// defined there.
21092109
#if GTEST_HAS_FILE_SYSTEM
21102110
#if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_PHONE) && \
2111-
!defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_ESP8266) && \
2112-
!defined(GTEST_OS_XTENSA) && !defined(GTEST_OS_QURT)
2111+
!defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_WINDOWS_GAMES) && \
2112+
!defined(GTEST_OS_ESP8266) && !defined(GTEST_OS_XTENSA) && \
2113+
!defined(GTEST_OS_QURT)
21132114
inline int ChDir(const char* dir) { return chdir(dir); }
21142115
#endif
21152116
inline FILE* FOpen(const char* path, const char* mode) {

deps/googletest/src/gtest-port.cc

+34-19
Original file line numberDiff line numberDiff line change
@@ -587,25 +587,32 @@ class ThreadLocalRegistryImpl {
587587
// thread's ID.
588588
typedef std::map<DWORD, ThreadLocalValues> ThreadIdToThreadLocals;
589589

590-
// Holds the thread id and thread handle that we pass from
591-
// StartWatcherThreadFor to WatcherThreadFunc.
592-
typedef std::pair<DWORD, HANDLE> ThreadIdAndHandle;
590+
struct WatcherThreadParams {
591+
DWORD thread_id;
592+
HANDLE handle;
593+
Notification has_initialized;
594+
};
593595

594596
static void StartWatcherThreadFor(DWORD thread_id) {
595597
// The returned handle will be kept in thread_map and closed by
596598
// watcher_thread in WatcherThreadFunc.
597599
HANDLE thread =
598600
::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION, FALSE, thread_id);
599601
GTEST_CHECK_(thread != nullptr);
602+
603+
WatcherThreadParams* watcher_thread_params = new WatcherThreadParams;
604+
watcher_thread_params->thread_id = thread_id;
605+
watcher_thread_params->handle = thread;
606+
600607
// We need to pass a valid thread ID pointer into CreateThread for it
601608
// to work correctly under Win98.
602609
DWORD watcher_thread_id;
603-
HANDLE watcher_thread = ::CreateThread(
604-
nullptr, // Default security.
605-
0, // Default stack size
606-
&ThreadLocalRegistryImpl::WatcherThreadFunc,
607-
reinterpret_cast<LPVOID>(new ThreadIdAndHandle(thread_id, thread)),
608-
CREATE_SUSPENDED, &watcher_thread_id);
610+
HANDLE watcher_thread =
611+
::CreateThread(nullptr, // Default security.
612+
0, // Default stack size
613+
&ThreadLocalRegistryImpl::WatcherThreadFunc,
614+
reinterpret_cast<LPVOID>(watcher_thread_params),
615+
CREATE_SUSPENDED, &watcher_thread_id);
609616
GTEST_CHECK_(watcher_thread != nullptr)
610617
<< "CreateThread failed with error " << ::GetLastError() << ".";
611618
// Give the watcher thread the same priority as ours to avoid being
@@ -614,17 +621,25 @@ class ThreadLocalRegistryImpl {
614621
::GetThreadPriority(::GetCurrentThread()));
615622
::ResumeThread(watcher_thread);
616623
::CloseHandle(watcher_thread);
624+
625+
// Wait for the watcher thread to start to avoid race conditions.
626+
// One specific race condition that can happen is that we have returned
627+
// from main and have started to tear down, the newly spawned watcher
628+
// thread may access already-freed variables, like global shared_ptrs.
629+
watcher_thread_params->has_initialized.WaitForNotification();
617630
}
618631

619632
// Monitors exit from a given thread and notifies those
620633
// ThreadIdToThreadLocals about thread termination.
621634
static DWORD WINAPI WatcherThreadFunc(LPVOID param) {
622-
const ThreadIdAndHandle* tah =
623-
reinterpret_cast<const ThreadIdAndHandle*>(param);
624-
GTEST_CHECK_(::WaitForSingleObject(tah->second, INFINITE) == WAIT_OBJECT_0);
625-
OnThreadExit(tah->first);
626-
::CloseHandle(tah->second);
627-
delete tah;
635+
WatcherThreadParams* watcher_thread_params =
636+
reinterpret_cast<WatcherThreadParams*>(param);
637+
watcher_thread_params->has_initialized.Notify();
638+
GTEST_CHECK_(::WaitForSingleObject(watcher_thread_params->handle,
639+
INFINITE) == WAIT_OBJECT_0);
640+
OnThreadExit(watcher_thread_params->thread_id);
641+
::CloseHandle(watcher_thread_params->handle);
642+
delete watcher_thread_params;
628643
return 0;
629644
}
630645

@@ -1033,12 +1048,12 @@ GTestLog::~GTestLog() {
10331048
}
10341049
}
10351050

1051+
#if GTEST_HAS_STREAM_REDIRECTION
1052+
10361053
// Disable Microsoft deprecation warnings for POSIX functions called from
10371054
// this class (creat, dup, dup2, and close)
10381055
GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
10391056

1040-
#if GTEST_HAS_STREAM_REDIRECTION
1041-
10421057
namespace {
10431058

10441059
#if defined(GTEST_OS_LINUX_ANDROID) || defined(GTEST_OS_IOS)
@@ -1333,8 +1348,8 @@ bool ParseInt32(const Message& src_text, const char* str, int32_t* value) {
13331348
) {
13341349
Message msg;
13351350
msg << "WARNING: " << src_text
1336-
<< " is expected to be a 32-bit integer, but actually"
1337-
<< " has value " << str << ", which overflows.\n";
1351+
<< " is expected to be a 32-bit integer, but actually" << " has value "
1352+
<< str << ", which overflows.\n";
13381353
printf("%s", msg.GetString().c_str());
13391354
fflush(stdout);
13401355
return false;

0 commit comments

Comments
 (0)