~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/gtest/src/gtest-internal-inl.h

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
// This file contains purely Google Test's internal implementation.  Please
32
32
// DO NOT #INCLUDE IT IN A USER PROGRAM.
33
33
 
34
 
#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_
35
 
#define GTEST_SRC_GTEST_INTERNAL_INL_H_
 
34
#ifndef GOOGLETEST_SRC_GTEST_INTERNAL_INL_H_
 
35
#define GOOGLETEST_SRC_GTEST_INTERNAL_INL_H_
36
36
 
37
37
#ifndef _WIN32_WCE
38
 
# include <errno.h>
 
38
#include <errno.h>
39
39
#endif  // !_WIN32_WCE
40
40
#include <stddef.h>
41
41
#include <stdlib.h>  // For strtoll/_strtoul64/malloc/free.
42
42
#include <string.h>  // For memmove.
43
43
 
44
44
#include <algorithm>
 
45
#include <cstdint>
45
46
#include <memory>
 
47
#include <set>
46
48
#include <string>
47
49
#include <vector>
48
50
 
49
51
#include "gtest/internal/gtest-port.h"
50
52
 
51
53
#if GTEST_CAN_STREAM_RESULTS_
52
 
# include <arpa/inet.h>  // NOLINT
53
 
# include <netdb.h>  // NOLINT
 
54
#include <arpa/inet.h>  // NOLINT
 
55
#include <netdb.h>      // NOLINT
54
56
#endif
55
57
 
56
58
#if GTEST_OS_WINDOWS
57
 
# include <windows.h>  // NOLINT
58
 
#endif  // GTEST_OS_WINDOWS
 
59
#include <windows.h>  // NOLINT
 
60
#endif                // GTEST_OS_WINDOWS
59
61
 
 
62
#include "gtest/gtest-spi.h"
60
63
#include "gtest/gtest.h"
61
 
#include "gtest/gtest-spi.h"
62
64
 
63
65
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
64
66
/* class A needs to have dll-interface to be used by clients of class B */)
65
67
 
66
 
namespace testing {
67
 
 
68
68
// Declares the flags.
69
69
//
70
70
// We don't want the users to modify this flag in the code, but want
72
72
// declare it here as opposed to in gtest.h.
73
73
GTEST_DECLARE_bool_(death_test_use_fork);
74
74
 
 
75
namespace testing {
75
76
namespace internal {
76
77
 
77
78
// The value of GetTestTypeId() as seen from within the Google Test
78
79
// library.  This is solely for testing GetTestTypeId().
79
80
GTEST_API_ extern const TypeId kTestTypeIdInGoogleTest;
80
81
 
81
 
// Names of the flags (needed for parsing Google Test flags).
82
 
const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests";
83
 
const char kBreakOnFailureFlag[] = "break_on_failure";
84
 
const char kCatchExceptionsFlag[] = "catch_exceptions";
85
 
const char kColorFlag[] = "color";
86
 
const char kFilterFlag[] = "filter";
87
 
const char kListTestsFlag[] = "list_tests";
88
 
const char kOutputFlag[] = "output";
89
 
const char kPrintTimeFlag[] = "print_time";
90
 
const char kPrintUTF8Flag[] = "print_utf8";
91
 
const char kRandomSeedFlag[] = "random_seed";
92
 
const char kRepeatFlag[] = "repeat";
93
 
const char kShuffleFlag[] = "shuffle";
94
 
const char kStackTraceDepthFlag[] = "stack_trace_depth";
95
 
const char kStreamResultToFlag[] = "stream_result_to";
96
 
const char kThrowOnFailureFlag[] = "throw_on_failure";
97
 
const char kFlagfileFlag[] = "flagfile";
98
 
 
99
82
// A valid random seed must be in [1, kMaxRandomSeed].
100
83
const int kMaxRandomSeed = 99999;
101
84
 
122
105
//
123
106
// On success, stores the value of the flag in *value, and returns
124
107
// true.  On failure, returns false without changing *value.
125
 
GTEST_API_ bool ParseInt32Flag(
126
 
    const char* str, const char* flag, Int32* value);
 
108
GTEST_API_ bool ParseFlag(const char* str, const char* flag, int32_t* value);
127
109
 
128
110
// Returns a random seed in range [1, kMaxRandomSeed] based on the
129
111
// given --gtest_random_seed flag value.
130
 
inline int GetRandomSeedFromFlag(Int32 random_seed_flag) {
131
 
  const unsigned int raw_seed = (random_seed_flag == 0) ?
132
 
      static_cast<unsigned int>(GetTimeInMillis()) :
133
 
      static_cast<unsigned int>(random_seed_flag);
 
112
inline int GetRandomSeedFromFlag(int32_t random_seed_flag) {
 
113
  const unsigned int raw_seed =
 
114
      (random_seed_flag == 0) ? static_cast<unsigned int>(GetTimeInMillis())
 
115
                              : static_cast<unsigned int>(random_seed_flag);
134
116
 
135
117
  // Normalizes the actual seed to range [1, kMaxRandomSeed] such that
136
118
  // it's easy to type.
137
119
  const int normalized_seed =
138
120
      static_cast<int>((raw_seed - 1U) %
139
 
                       static_cast<unsigned int>(kMaxRandomSeed)) + 1;
 
121
                       static_cast<unsigned int>(kMaxRandomSeed)) +
 
122
      1;
140
123
  return normalized_seed;
141
124
}
142
125
 
157
140
 public:
158
141
  // The c'tor.
159
142
  GTestFlagSaver() {
160
 
    also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests);
161
 
    break_on_failure_ = GTEST_FLAG(break_on_failure);
162
 
    catch_exceptions_ = GTEST_FLAG(catch_exceptions);
163
 
    color_ = GTEST_FLAG(color);
164
 
    death_test_style_ = GTEST_FLAG(death_test_style);
165
 
    death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);
166
 
    filter_ = GTEST_FLAG(filter);
167
 
    internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);
168
 
    list_tests_ = GTEST_FLAG(list_tests);
169
 
    output_ = GTEST_FLAG(output);
170
 
    print_time_ = GTEST_FLAG(print_time);
171
 
    print_utf8_ = GTEST_FLAG(print_utf8);
172
 
    random_seed_ = GTEST_FLAG(random_seed);
173
 
    repeat_ = GTEST_FLAG(repeat);
174
 
    shuffle_ = GTEST_FLAG(shuffle);
175
 
    stack_trace_depth_ = GTEST_FLAG(stack_trace_depth);
176
 
    stream_result_to_ = GTEST_FLAG(stream_result_to);
177
 
    throw_on_failure_ = GTEST_FLAG(throw_on_failure);
 
143
    also_run_disabled_tests_ = GTEST_FLAG_GET(also_run_disabled_tests);
 
144
    break_on_failure_ = GTEST_FLAG_GET(break_on_failure);
 
145
    catch_exceptions_ = GTEST_FLAG_GET(catch_exceptions);
 
146
    color_ = GTEST_FLAG_GET(color);
 
147
    death_test_style_ = GTEST_FLAG_GET(death_test_style);
 
148
    death_test_use_fork_ = GTEST_FLAG_GET(death_test_use_fork);
 
149
    fail_fast_ = GTEST_FLAG_GET(fail_fast);
 
150
    filter_ = GTEST_FLAG_GET(filter);
 
151
    internal_run_death_test_ = GTEST_FLAG_GET(internal_run_death_test);
 
152
    list_tests_ = GTEST_FLAG_GET(list_tests);
 
153
    output_ = GTEST_FLAG_GET(output);
 
154
    brief_ = GTEST_FLAG_GET(brief);
 
155
    print_time_ = GTEST_FLAG_GET(print_time);
 
156
    print_utf8_ = GTEST_FLAG_GET(print_utf8);
 
157
    random_seed_ = GTEST_FLAG_GET(random_seed);
 
158
    repeat_ = GTEST_FLAG_GET(repeat);
 
159
    recreate_environments_when_repeating_ =
 
160
        GTEST_FLAG_GET(recreate_environments_when_repeating);
 
161
    shuffle_ = GTEST_FLAG_GET(shuffle);
 
162
    stack_trace_depth_ = GTEST_FLAG_GET(stack_trace_depth);
 
163
    stream_result_to_ = GTEST_FLAG_GET(stream_result_to);
 
164
    throw_on_failure_ = GTEST_FLAG_GET(throw_on_failure);
178
165
  }
179
166
 
180
167
  // The d'tor is not virtual.  DO NOT INHERIT FROM THIS CLASS.
181
168
  ~GTestFlagSaver() {
182
 
    GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_;
183
 
    GTEST_FLAG(break_on_failure) = break_on_failure_;
184
 
    GTEST_FLAG(catch_exceptions) = catch_exceptions_;
185
 
    GTEST_FLAG(color) = color_;
186
 
    GTEST_FLAG(death_test_style) = death_test_style_;
187
 
    GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;
188
 
    GTEST_FLAG(filter) = filter_;
189
 
    GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;
190
 
    GTEST_FLAG(list_tests) = list_tests_;
191
 
    GTEST_FLAG(output) = output_;
192
 
    GTEST_FLAG(print_time) = print_time_;
193
 
    GTEST_FLAG(print_utf8) = print_utf8_;
194
 
    GTEST_FLAG(random_seed) = random_seed_;
195
 
    GTEST_FLAG(repeat) = repeat_;
196
 
    GTEST_FLAG(shuffle) = shuffle_;
197
 
    GTEST_FLAG(stack_trace_depth) = stack_trace_depth_;
198
 
    GTEST_FLAG(stream_result_to) = stream_result_to_;
199
 
    GTEST_FLAG(throw_on_failure) = throw_on_failure_;
 
169
    GTEST_FLAG_SET(also_run_disabled_tests, also_run_disabled_tests_);
 
170
    GTEST_FLAG_SET(break_on_failure, break_on_failure_);
 
171
    GTEST_FLAG_SET(catch_exceptions, catch_exceptions_);
 
172
    GTEST_FLAG_SET(color, color_);
 
173
    GTEST_FLAG_SET(death_test_style, death_test_style_);
 
174
    GTEST_FLAG_SET(death_test_use_fork, death_test_use_fork_);
 
175
    GTEST_FLAG_SET(filter, filter_);
 
176
    GTEST_FLAG_SET(fail_fast, fail_fast_);
 
177
    GTEST_FLAG_SET(internal_run_death_test, internal_run_death_test_);
 
178
    GTEST_FLAG_SET(list_tests, list_tests_);
 
179
    GTEST_FLAG_SET(output, output_);
 
180
    GTEST_FLAG_SET(brief, brief_);
 
181
    GTEST_FLAG_SET(print_time, print_time_);
 
182
    GTEST_FLAG_SET(print_utf8, print_utf8_);
 
183
    GTEST_FLAG_SET(random_seed, random_seed_);
 
184
    GTEST_FLAG_SET(repeat, repeat_);
 
185
    GTEST_FLAG_SET(recreate_environments_when_repeating,
 
186
                   recreate_environments_when_repeating_);
 
187
    GTEST_FLAG_SET(shuffle, shuffle_);
 
188
    GTEST_FLAG_SET(stack_trace_depth, stack_trace_depth_);
 
189
    GTEST_FLAG_SET(stream_result_to, stream_result_to_);
 
190
    GTEST_FLAG_SET(throw_on_failure, throw_on_failure_);
200
191
  }
201
192
 
202
193
 private:
207
198
  std::string color_;
208
199
  std::string death_test_style_;
209
200
  bool death_test_use_fork_;
 
201
  bool fail_fast_;
210
202
  std::string filter_;
211
203
  std::string internal_run_death_test_;
212
204
  bool list_tests_;
213
205
  std::string output_;
 
206
  bool brief_;
214
207
  bool print_time_;
215
208
  bool print_utf8_;
216
 
  internal::Int32 random_seed_;
217
 
  internal::Int32 repeat_;
 
209
  int32_t random_seed_;
 
210
  int32_t repeat_;
 
211
  bool recreate_environments_when_repeating_;
218
212
  bool shuffle_;
219
 
  internal::Int32 stack_trace_depth_;
 
213
  int32_t stack_trace_depth_;
220
214
  std::string stream_result_to_;
221
215
  bool throw_on_failure_;
222
 
} GTEST_ATTRIBUTE_UNUSED_;
 
216
};
223
217
 
224
218
// Converts a Unicode code point to a narrow string in UTF-8 encoding.
225
219
// code_point parameter is of type UInt32 because wchar_t may not be
227
221
// If the code_point is not a valid Unicode code point
228
222
// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted
229
223
// to "(Invalid Unicode 0xXXXXXXXX)".
230
 
GTEST_API_ std::string CodePointToUtf8(UInt32 code_point);
 
224
GTEST_API_ std::string CodePointToUtf8(uint32_t code_point);
231
225
 
232
226
// Converts a wide string to a narrow string in UTF-8 encoding.
233
227
// The wide string is assumed to have the following encoding:
260
254
                            const char* shard_index_str,
261
255
                            bool in_subprocess_for_death_test);
262
256
 
263
 
// Parses the environment variable var as an Int32. If it is unset,
264
 
// returns default_val. If it is not an Int32, prints an error and
 
257
// Parses the environment variable var as a 32-bit integer. If it is unset,
 
258
// returns default_val. If it is not a 32-bit integer, prints an error and
265
259
// and aborts.
266
 
GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val);
 
260
GTEST_API_ int32_t Int32FromEnvOrDie(const char* env_var, int32_t default_val);
267
261
 
268
262
// Given the total number of shards, the shard index, and the test id,
269
263
// returns true if and only if the test should be run on this shard. The test id
270
264
// is some arbitrary but unique non-negative integer assigned to each test
271
265
// method. Assumes that 0 <= shard_index < total_shards.
272
 
GTEST_API_ bool ShouldRunTestOnShard(
273
 
    int total_shards, int shard_index, int test_id);
 
266
GTEST_API_ bool ShouldRunTestOnShard(int total_shards, int shard_index,
 
267
                                     int test_id);
274
268
 
275
269
// STL container utilities.
276
270
 
281
275
  // Implemented as an explicit loop since std::count_if() in libCstd on
282
276
  // Solaris has a non-standard signature.
283
277
  int count = 0;
284
 
  for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) {
285
 
    if (predicate(*it))
286
 
      ++count;
 
278
  for (auto it = c.begin(); it != c.end(); ++it) {
 
279
    if (predicate(*it)) ++count;
287
280
  }
288
281
  return count;
289
282
}
323
316
    const int last_in_range = begin + range_width - 1;
324
317
    const int selected =
325
318
        begin +
326
 
        static_cast<int>(random->Generate(static_cast<UInt32>(range_width)));
 
319
        static_cast<int>(random->Generate(static_cast<uint32_t>(range_width)));
327
320
    std::swap((*v)[static_cast<size_t>(selected)],
328
321
              (*v)[static_cast<size_t>(last_in_range)]);
329
322
  }
385
378
 
386
379
  // Functions for processing the gtest_filter flag.
387
380
 
388
 
  // Returns true if and only if the wildcard pattern matches the string.
389
 
  // The first ':' or '\0' character in pattern marks the end of it.
390
 
  //
391
 
  // This recursive algorithm isn't very efficient, but is clear and
392
 
  // works well enough for matching test names, which are short.
393
 
  static bool PatternMatchesString(const char *pattern, const char *str);
394
 
 
395
381
  // Returns true if and only if the user-specified filter matches the test
396
382
  // suite name and the test name.
397
383
  static bool FilterMatchesTest(const std::string& test_suite_name,
411
397
  static bool MatchesFilter(const std::string& name, const char* filter);
412
398
};
413
399
 
 
400
#if GTEST_HAS_FILE_SYSTEM
414
401
// Returns the current application's name, removing directory path if that
415
402
// is present.  Used by UnitTestOptions::GetOutputFile.
416
403
GTEST_API_ FilePath GetCurrentExecutableName();
 
404
#endif  // GTEST_HAS_FILE_SYSTEM
417
405
 
418
406
// The role interface for getting the OS stack trace as a string.
419
407
class OsStackTraceGetterInterface {
439
427
  static const char* const kElidedFramesMarker;
440
428
 
441
429
 private:
442
 
  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface);
 
430
  OsStackTraceGetterInterface(const OsStackTraceGetterInterface&) = delete;
 
431
  OsStackTraceGetterInterface& operator=(const OsStackTraceGetterInterface&) =
 
432
      delete;
443
433
};
444
434
 
445
435
// A working implementation of the OsStackTraceGetterInterface interface.
461
451
  void* caller_frame_ = nullptr;
462
452
#endif  // GTEST_HAS_ABSL
463
453
 
464
 
  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter);
 
454
  OsStackTraceGetter(const OsStackTraceGetter&) = delete;
 
455
  OsStackTraceGetter& operator=(const OsStackTraceGetter&) = delete;
465
456
};
466
457
 
467
458
// Information about a Google Test trace point.
474
465
// This is the default global test part result reporter used in UnitTestImpl.
475
466
// This class should only be used by UnitTestImpl.
476
467
class DefaultGlobalTestPartResultReporter
477
 
  : public TestPartResultReporterInterface {
 
468
    : public TestPartResultReporterInterface {
478
469
 public:
479
470
  explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);
480
471
  // Implements the TestPartResultReporterInterface. Reports the test part
484
475
 private:
485
476
  UnitTestImpl* const unit_test_;
486
477
 
487
 
  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter);
 
478
  DefaultGlobalTestPartResultReporter(
 
479
      const DefaultGlobalTestPartResultReporter&) = delete;
 
480
  DefaultGlobalTestPartResultReporter& operator=(
 
481
      const DefaultGlobalTestPartResultReporter&) = delete;
488
482
};
489
483
 
490
484
// This is the default per thread test part result reporter used in
500
494
 private:
501
495
  UnitTestImpl* const unit_test_;
502
496
 
503
 
  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter);
 
497
  DefaultPerThreadTestPartResultReporter(
 
498
      const DefaultPerThreadTestPartResultReporter&) = delete;
 
499
  DefaultPerThreadTestPartResultReporter& operator=(
 
500
      const DefaultPerThreadTestPartResultReporter&) = delete;
504
501
};
505
502
 
506
503
// The private implementation of the UnitTest class.  We don't protect
513
510
  virtual ~UnitTestImpl();
514
511
 
515
512
  // There are two different ways to register your own TestPartResultReporter.
516
 
  // You can register your own repoter to listen either only for test results
 
513
  // You can register your own reporter to listen either only for test results
517
514
  // from the current thread or for results from all threads.
518
 
  // By default, each per-thread test result repoter just passes a new
 
515
  // By default, each per-thread test result reporter just passes a new
519
516
  // TestPartResult to the global test result reporter, which registers the
520
517
  // test part result for the currently running test.
521
518
 
638
635
  // For example, if Foo() calls Bar(), which in turn calls
639
636
  // CurrentOsStackTraceExceptTop(1), Foo() will be included in the
640
637
  // trace but Bar() and CurrentOsStackTraceExceptTop() won't.
641
 
  std::string CurrentOsStackTraceExceptTop(int skip_count) GTEST_NO_INLINE_;
 
638
  std::string CurrentOsStackTraceExceptTop(int skip_count)
 
639
      GTEST_NO_INLINE_ GTEST_NO_TAIL_CALL_;
642
640
 
643
641
  // Finds and returns a TestSuite with the given name.  If one doesn't
644
642
  // exist, creates one and returns it.
646
644
  // Arguments:
647
645
  //
648
646
  //   test_suite_name: name of the test suite
649
 
  //   type_param:     the name of the test's type parameter, or NULL if
650
 
  //                   this is not a typed or a type-parameterized test.
651
 
  //   set_up_tc:      pointer to the function that sets up the test suite
652
 
  //   tear_down_tc:   pointer to the function that tears down the test suite
 
647
  //   type_param:      the name of the test's type parameter, or NULL if
 
648
  //                    this is not a typed or a type-parameterized test.
 
649
  //   set_up_tc:       pointer to the function that sets up the test suite
 
650
  //   tear_down_tc:    pointer to the function that tears down the test suite
653
651
  TestSuite* GetTestSuite(const char* test_suite_name, const char* type_param,
654
652
                          internal::SetUpTestSuiteFunc set_up_tc,
655
653
                          internal::TearDownTestSuiteFunc tear_down_tc);
673
671
  void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc,
674
672
                   internal::TearDownTestSuiteFunc tear_down_tc,
675
673
                   TestInfo* test_info) {
 
674
#if GTEST_HAS_DEATH_TEST
676
675
    // In order to support thread-safe death tests, we need to
677
676
    // remember the original working directory when the test program
678
677
    // was first invoked.  We cannot do this in RUN_ALL_TESTS(), as
685
684
      GTEST_CHECK_(!original_working_dir_.IsEmpty())
686
685
          << "Failed to get the current working directory.";
687
686
    }
 
687
#endif  // GTEST_HAS_DEATH_TEST
688
688
 
689
689
    GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
690
690
                 set_up_tc, tear_down_tc)
697
697
    return parameterized_test_registry_;
698
698
  }
699
699
 
 
700
  std::set<std::string>* ignored_parameterized_test_suites() {
 
701
    return &ignored_parameterized_test_suites_;
 
702
  }
 
703
 
 
704
  // Returns TypeParameterizedTestSuiteRegistry object used to keep track of
 
705
  // type-parameterized tests and instantiations of them.
 
706
  internal::TypeParameterizedTestSuiteRegistry&
 
707
  type_parameterized_test_registry() {
 
708
    return type_parameterized_test_registry_;
 
709
  }
 
710
 
700
711
  // Sets the TestSuite object for the test that's currently running.
701
712
  void set_current_test_suite(TestSuite* a_current_test_suite) {
702
713
    current_test_suite_ = a_current_test_suite;
729
740
  }
730
741
 
731
742
  // Clears the results of ad-hoc test assertions.
732
 
  void ClearAdHocTestResult() {
733
 
    ad_hoc_test_result_.Clear();
734
 
  }
 
743
  void ClearAdHocTestResult() { ad_hoc_test_result_.Clear(); }
735
744
 
736
745
  // Adds a TestProperty to the current TestResult object when invoked in a
737
746
  // context of a test or a test suite, or to the global property set. If the
739
748
  // updated.
740
749
  void RecordProperty(const TestProperty& test_property);
741
750
 
742
 
  enum ReactionToSharding {
743
 
    HONOR_SHARDING_PROTOCOL,
744
 
    IGNORE_SHARDING_PROTOCOL
745
 
  };
 
751
  enum ReactionToSharding { HONOR_SHARDING_PROTOCOL, IGNORE_SHARDING_PROTOCOL };
746
752
 
747
753
  // Matches the full name of each test against the user-specified
748
754
  // filter to decide whether the test should run, then records the
837
843
  // The UnitTest object that owns this implementation object.
838
844
  UnitTest* const parent_;
839
845
 
 
846
#if GTEST_HAS_FILE_SYSTEM
840
847
  // The working directory when the first TEST() or TEST_F() was
841
848
  // executed.
842
849
  internal::FilePath original_working_dir_;
 
850
#endif  // GTEST_HAS_FILE_SYSTEM
843
851
 
844
852
  // The default test part result reporters.
845
853
  DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_;
847
855
      default_per_thread_test_part_result_reporter_;
848
856
 
849
857
  // Points to (but doesn't own) the global test part result reporter.
850
 
  TestPartResultReporterInterface* global_test_part_result_repoter_;
 
858
  TestPartResultReporterInterface* global_test_part_result_reporter_;
851
859
 
852
860
  // Protects read and write access to global_test_part_result_reporter_.
853
861
  internal::Mutex global_test_part_result_reporter_mutex_;
873
881
  // ParameterizedTestRegistry object used to register value-parameterized
874
882
  // tests.
875
883
  internal::ParameterizedTestSuiteRegistry parameterized_test_registry_;
 
884
  internal::TypeParameterizedTestSuiteRegistry
 
885
      type_parameterized_test_registry_;
 
886
 
 
887
  // The set holding the name of parameterized
 
888
  // test suites that may go uninstantiated.
 
889
  std::set<std::string> ignored_parameterized_test_suites_;
876
890
 
877
891
  // Indicates whether RegisterParameterizedTests() has been called already.
878
892
  bool parameterized_tests_registered_;
942
956
  // starts.
943
957
  bool catch_exceptions_;
944
958
 
945
 
  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl);
 
959
  UnitTestImpl(const UnitTestImpl&) = delete;
 
960
  UnitTestImpl& operator=(const UnitTestImpl&) = delete;
946
961
};  // class UnitTestImpl
947
962
 
948
963
// Convenience function for accessing the global UnitTest
965
980
GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch);
966
981
GTEST_API_ bool ValidateRegex(const char* regex);
967
982
GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str);
968
 
GTEST_API_ bool MatchRepetitionAndRegexAtHead(
969
 
    bool escaped, char ch, char repeat, const char* regex, const char* str);
 
983
GTEST_API_ bool MatchRepetitionAndRegexAtHead(bool escaped, char ch,
 
984
                                              char repeat, const char* regex,
 
985
                                              const char* str);
970
986
GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);
971
987
 
972
988
#endif  // GTEST_USES_SIMPLE_RE
999
1015
  char* end;
1000
1016
  // BiggestConvertible is the largest integer type that system-provided
1001
1017
  // string-to-number conversion routines can return.
1002
 
 
1003
 
# if GTEST_OS_WINDOWS && !defined(__GNUC__)
1004
 
 
1005
 
  // MSVC and C++ Builder define __int64 instead of the standard long long.
1006
 
  typedef unsigned __int64 BiggestConvertible;
1007
 
  const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10);
1008
 
 
1009
 
# else
1010
 
 
1011
 
  typedef unsigned long long BiggestConvertible;  // NOLINT
1012
 
  const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);
1013
 
 
1014
 
# endif  // GTEST_OS_WINDOWS && !defined(__GNUC__)
1015
 
 
 
1018
  using BiggestConvertible = unsigned long long;  // NOLINT
 
1019
 
 
1020
  const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);  // NOLINT
1016
1021
  const bool parse_success = *end == '\0' && errno == 0;
1017
1022
 
1018
1023
  GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed));
1079
1084
    }
1080
1085
 
1081
1086
    ~SocketWriter() override {
1082
 
      if (sockfd_ != -1)
1083
 
        CloseConnection();
 
1087
      if (sockfd_ != -1) CloseConnection();
1084
1088
    }
1085
1089
 
1086
1090
    // Sends a string to the socket.
1090
1094
 
1091
1095
      const auto len = static_cast<size_t>(message.length());
1092
1096
      if (write(sockfd_, message.c_str(), len) != static_cast<ssize_t>(len)) {
1093
 
        GTEST_LOG_(WARNING)
1094
 
            << "stream_result_to: failed to stream to "
1095
 
            << host_name_ << ":" << port_num_;
 
1097
        GTEST_LOG_(WARNING) << "stream_result_to: failed to stream to "
 
1098
                            << host_name_ << ":" << port_num_;
1096
1099
      }
1097
1100
    }
1098
1101
 
1113
1116
    const std::string host_name_;
1114
1117
    const std::string port_num_;
1115
1118
 
1116
 
    GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter);
 
1119
    SocketWriter(const SocketWriter&) = delete;
 
1120
    SocketWriter& operator=(const SocketWriter&) = delete;
1117
1121
  };  // class SocketWriter
1118
1122
 
1119
1123
  // Escapes '=', '&', '%', and '\n' characters in str as "%xx".
1125
1129
  }
1126
1130
 
1127
1131
  explicit StreamingListener(AbstractSocketWriter* socket_writer)
1128
 
      : socket_writer_(socket_writer) { Start(); }
 
1132
      : socket_writer_(socket_writer) {
 
1133
    Start();
 
1134
  }
1129
1135
 
1130
1136
  void OnTestProgramStart(const UnitTest& /* unit_test */) override {
1131
1137
    SendLn("event=TestProgramStart");
1148
1154
 
1149
1155
  void OnTestIterationEnd(const UnitTest& unit_test,
1150
1156
                          int /* iteration */) override {
1151
 
    SendLn("event=TestIterationEnd&passed=" +
1152
 
           FormatBool(unit_test.Passed()) + "&elapsed_time=" +
1153
 
           StreamableToString(unit_test.elapsed_time()) + "ms");
 
1157
    SendLn("event=TestIterationEnd&passed=" + FormatBool(unit_test.Passed()) +
 
1158
           "&elapsed_time=" + StreamableToString(unit_test.elapsed_time()) +
 
1159
           "ms");
1154
1160
  }
1155
1161
 
1156
1162
  // Note that "event=TestCaseStart" is a wire format and has to remain
1157
 
  // "case" for compatibilty
1158
 
  void OnTestCaseStart(const TestCase& test_case) override {
1159
 
    SendLn(std::string("event=TestCaseStart&name=") + test_case.name());
 
1163
  // "case" for compatibility
 
1164
  void OnTestSuiteStart(const TestSuite& test_suite) override {
 
1165
    SendLn(std::string("event=TestCaseStart&name=") + test_suite.name());
1160
1166
  }
1161
1167
 
1162
1168
  // Note that "event=TestCaseEnd" is a wire format and has to remain
1163
 
  // "case" for compatibilty
1164
 
  void OnTestCaseEnd(const TestCase& test_case) override {
1165
 
    SendLn("event=TestCaseEnd&passed=" + FormatBool(test_case.Passed()) +
1166
 
           "&elapsed_time=" + StreamableToString(test_case.elapsed_time()) +
 
1169
  // "case" for compatibility
 
1170
  void OnTestSuiteEnd(const TestSuite& test_suite) override {
 
1171
    SendLn("event=TestCaseEnd&passed=" + FormatBool(test_suite.Passed()) +
 
1172
           "&elapsed_time=" + StreamableToString(test_suite.elapsed_time()) +
1167
1173
           "ms");
1168
1174
  }
1169
1175
 
1173
1179
 
1174
1180
  void OnTestEnd(const TestInfo& test_info) override {
1175
1181
    SendLn("event=TestEnd&passed=" +
1176
 
           FormatBool((test_info.result())->Passed()) +
1177
 
           "&elapsed_time=" +
 
1182
           FormatBool((test_info.result())->Passed()) + "&elapsed_time=" +
1178
1183
           StreamableToString((test_info.result())->elapsed_time()) + "ms");
1179
1184
  }
1180
1185
 
1198
1203
 
1199
1204
  const std::unique_ptr<AbstractSocketWriter> socket_writer_;
1200
1205
 
1201
 
  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener);
 
1206
  StreamingListener(const StreamingListener&) = delete;
 
1207
  StreamingListener& operator=(const StreamingListener&) = delete;
1202
1208
};  // class StreamingListener
1203
1209
 
1204
1210
#endif  // GTEST_CAN_STREAM_RESULTS_
1208
1214
 
1209
1215
GTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251
1210
1216
 
1211
 
#endif  // GTEST_SRC_GTEST_INTERNAL_INL_H_
 
1217
#endif  // GOOGLETEST_SRC_GTEST_INTERNAL_INL_H_