googletest/googletest/src/gtest-internal-inl.h
Go to the documentation of this file.
1 // Copyright 2005, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 // Utility functions and classes used by the Google C++ testing framework.//
31 // This file contains purely Google Test's internal implementation. Please
32 // DO NOT #INCLUDE IT IN A USER PROGRAM.
33 
34 #ifndef GOOGLETEST_SRC_GTEST_INTERNAL_INL_H_
35 #define GOOGLETEST_SRC_GTEST_INTERNAL_INL_H_
36 
37 #ifndef _WIN32_WCE
38 # include <errno.h>
39 #endif // !_WIN32_WCE
40 #include <stddef.h>
41 #include <stdlib.h> // For strtoll/_strtoul64/malloc/free.
42 #include <string.h> // For memmove.
43 
44 #include <algorithm>
45 #include <cstdint>
46 #include <memory>
47 #include <string>
48 #include <vector>
49 
50 #include "gtest/internal/gtest-port.h"
51 
52 #if GTEST_CAN_STREAM_RESULTS_
53 # include <arpa/inet.h> // NOLINT
54 # include <netdb.h> // NOLINT
55 #endif
56 
57 #if GTEST_OS_WINDOWS
58 # include <windows.h> // NOLINT
59 #endif // GTEST_OS_WINDOWS
60 
61 #include "gtest/gtest.h"
62 #include "gtest/gtest-spi.h"
63 
65 /* class A needs to have dll-interface to be used by clients of class B */)
66 
67 // Declares the flags.
68 //
69 // We don't want the users to modify this flag in the code, but want
70 // Google Test's own unit tests to be able to access it. Therefore we
71 // declare it here as opposed to in gtest.h.
72 GTEST_DECLARE_bool_(death_test_use_fork);
73 
75 namespace internal {
76 
77 // The value of GetTestTypeId() as seen from within the Google Test
78 // library. This is solely for testing GetTestTypeId().
80 
81 // A valid random seed must be in [1, kMaxRandomSeed].
82 const int kMaxRandomSeed = 99999;
83 
84 // g_help_flag is true if and only if the --help flag or an equivalent form
85 // is specified on the command line.
86 GTEST_API_ extern bool g_help_flag;
87 
88 // Returns the current time in milliseconds.
90 
91 // Returns true if and only if Google Test should use colors in the output.
92 GTEST_API_ bool ShouldUseColor(bool stdout_is_tty);
93 
94 // Formats the given time in milliseconds as seconds.
96 
97 // Converts the given time in milliseconds to a date string in the ISO 8601
98 // format, without the timezone information. N.B.: due to the use the
99 // non-reentrant localtime() function, this function is not thread safe. Do
100 // not use it in any code that can be called from multiple threads.
102 
103 // Parses a string for an Int32 flag, in the form of "--flag=value".
104 //
105 // On success, stores the value of the flag in *value, and returns
106 // true. On failure, returns false without changing *value.
107 GTEST_API_ bool ParseFlag(const char* str, const char* flag, int32_t* value);
108 
109 // Returns a random seed in range [1, kMaxRandomSeed] based on the
110 // given --gtest_random_seed flag value.
111 inline int GetRandomSeedFromFlag(int32_t random_seed_flag) {
112  const unsigned int raw_seed = (random_seed_flag == 0) ?
113  static_cast<unsigned int>(GetTimeInMillis()) :
114  static_cast<unsigned int>(random_seed_flag);
115 
116  // Normalizes the actual seed to range [1, kMaxRandomSeed] such that
117  // it's easy to type.
118  const int normalized_seed =
119  static_cast<int>((raw_seed - 1U) %
120  static_cast<unsigned int>(kMaxRandomSeed)) + 1;
121  return normalized_seed;
122 }
123 
124 // Returns the first valid random seed after 'seed'. The behavior is
125 // undefined if 'seed' is invalid. The seed after kMaxRandomSeed is
126 // considered to be 1.
127 inline int GetNextRandomSeed(int seed) {
129  << "Invalid random seed " << seed << " - must be in [1, "
130  << kMaxRandomSeed << "].";
131  const int next_seed = seed + 1;
132  return (next_seed > kMaxRandomSeed) ? 1 : next_seed;
133 }
134 
135 // This class saves the values of all Google Test flags in its c'tor, and
136 // restores them in its d'tor.
137 class GTestFlagSaver {
138  public:
139  // The c'tor.
141  also_run_disabled_tests_ = GTEST_FLAG_GET(also_run_disabled_tests);
142  break_on_failure_ = GTEST_FLAG_GET(break_on_failure);
143  catch_exceptions_ = GTEST_FLAG_GET(catch_exceptions);
144  color_ = GTEST_FLAG_GET(color);
145  death_test_style_ = GTEST_FLAG_GET(death_test_style);
146  death_test_use_fork_ = GTEST_FLAG_GET(death_test_use_fork);
147  fail_fast_ = GTEST_FLAG_GET(fail_fast);
148  filter_ = GTEST_FLAG_GET(filter);
149  internal_run_death_test_ = GTEST_FLAG_GET(internal_run_death_test);
150  list_tests_ = GTEST_FLAG_GET(list_tests);
152  brief_ = GTEST_FLAG_GET(brief);
153  print_time_ = GTEST_FLAG_GET(print_time);
154  print_utf8_ = GTEST_FLAG_GET(print_utf8);
155  random_seed_ = GTEST_FLAG_GET(random_seed);
156  repeat_ = GTEST_FLAG_GET(repeat);
157  recreate_environments_when_repeating_ =
158  GTEST_FLAG_GET(recreate_environments_when_repeating);
159  shuffle_ = GTEST_FLAG_GET(shuffle);
160  stack_trace_depth_ = GTEST_FLAG_GET(stack_trace_depth);
161  stream_result_to_ = GTEST_FLAG_GET(stream_result_to);
162  throw_on_failure_ = GTEST_FLAG_GET(throw_on_failure);
163  }
164 
165  // The d'tor is not virtual. DO NOT INHERIT FROM THIS CLASS.
167  GTEST_FLAG_SET(also_run_disabled_tests, also_run_disabled_tests_);
168  GTEST_FLAG_SET(break_on_failure, break_on_failure_);
169  GTEST_FLAG_SET(catch_exceptions, catch_exceptions_);
170  GTEST_FLAG_SET(color, color_);
171  GTEST_FLAG_SET(death_test_style, death_test_style_);
172  GTEST_FLAG_SET(death_test_use_fork, death_test_use_fork_);
173  GTEST_FLAG_SET(filter, filter_);
174  GTEST_FLAG_SET(fail_fast, fail_fast_);
175  GTEST_FLAG_SET(internal_run_death_test, internal_run_death_test_);
176  GTEST_FLAG_SET(list_tests, list_tests_);
178  GTEST_FLAG_SET(brief, brief_);
179  GTEST_FLAG_SET(print_time, print_time_);
180  GTEST_FLAG_SET(print_utf8, print_utf8_);
181  GTEST_FLAG_SET(random_seed, random_seed_);
182  GTEST_FLAG_SET(repeat, repeat_);
183  GTEST_FLAG_SET(recreate_environments_when_repeating,
184  recreate_environments_when_repeating_);
185  GTEST_FLAG_SET(shuffle, shuffle_);
186  GTEST_FLAG_SET(stack_trace_depth, stack_trace_depth_);
187  GTEST_FLAG_SET(stream_result_to, stream_result_to_);
188  GTEST_FLAG_SET(throw_on_failure, throw_on_failure_);
189  }
190 
191  private:
192  // Fields for saving the original values of flags.
193  bool also_run_disabled_tests_;
194  bool break_on_failure_;
195  bool catch_exceptions_;
196  std::string color_;
197  std::string death_test_style_;
198  bool death_test_use_fork_;
200  std::string filter_;
201  std::string internal_run_death_test_;
202  bool list_tests_;
204  bool brief_;
205  bool print_time_;
210  bool shuffle_;
212  std::string stream_result_to_;
213  bool throw_on_failure_;
215 
216 // Converts a Unicode code point to a narrow string in UTF-8 encoding.
217 // code_point parameter is of type UInt32 because wchar_t may not be
218 // wide enough to contain a code point.
219 // If the code_point is not a valid Unicode code point
220 // (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted
221 // to "(Invalid Unicode 0xXXXXXXXX)".
223 
224 // Converts a wide string to a narrow string in UTF-8 encoding.
225 // The wide string is assumed to have the following encoding:
226 // UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin)
227 // UTF-32 if sizeof(wchar_t) == 4 (on Linux)
228 // Parameter str points to a null-terminated wide string.
229 // Parameter num_chars may additionally limit the number
230 // of wchar_t characters processed. -1 is used when the entire string
231 // should be processed.
232 // If the string contains code points that are not valid Unicode code points
233 // (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output
234 // as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding
235 // and contains invalid UTF-16 surrogate pairs, values in those pairs
236 // will be encoded as individual Unicode characters from Basic Normal Plane.
237 GTEST_API_ std::string WideStringToUtf8(const wchar_t* str, int num_chars);
238 
239 // Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file
240 // if the variable is present. If a file already exists at this location, this
241 // function will write over it. If the variable is present, but the file cannot
242 // be created, prints an error and exits.
244 
245 // Checks whether sharding is enabled by examining the relevant
246 // environment variable values. If the variables are present,
247 // but inconsistent (e.g., shard_index >= total_shards), prints
248 // an error and exits. If in_subprocess_for_death_test, sharding is
249 // disabled because it must only be applied to the original test
250 // process. Otherwise, we could filter out death tests we intended to execute.
251 GTEST_API_ bool ShouldShard(const char* total_shards_str,
252  const char* shard_index_str,
253  bool in_subprocess_for_death_test);
254 
255 // Parses the environment variable var as a 32-bit integer. If it is unset,
256 // returns default_val. If it is not a 32-bit integer, prints an error and
257 // and aborts.
258 GTEST_API_ int32_t Int32FromEnvOrDie(const char* env_var, int32_t default_val);
259 
260 // Given the total number of shards, the shard index, and the test id,
261 // returns true if and only if the test should be run on this shard. The test id
262 // is some arbitrary but unique non-negative integer assigned to each test
263 // method. Assumes that 0 <= shard_index < total_shards.
265  int total_shards, int shard_index, int test_id);
266 
267 // STL container utilities.
268 
269 // Returns the number of elements in the given container that satisfy
270 // the given predicate.
271 template <class Container, typename Predicate>
272 inline int CountIf(const Container& c, Predicate predicate) {
273  // Implemented as an explicit loop since std::count_if() in libCstd on
274  // Solaris has a non-standard signature.
275  int count = 0;
276  for (auto it = c.begin(); it != c.end(); ++it) {
277  if (predicate(*it))
278  ++count;
279  }
280  return count;
281 }
282 
283 // Applies a function/functor to each element in the container.
284 template <class Container, typename Functor>
285 void ForEach(const Container& c, Functor functor) {
286  std::for_each(c.begin(), c.end(), functor);
287 }
288 
289 // Returns the i-th element of the vector, or default_value if i is not
290 // in range [0, v.size()).
291 template <typename E>
292 inline E GetElementOr(const std::vector<E>& v, int i, E default_value) {
293  return (i < 0 || i >= static_cast<int>(v.size())) ? default_value
294  : v[static_cast<size_t>(i)];
295 }
296 
297 // Performs an in-place shuffle of a range of the vector's elements.
298 // 'begin' and 'end' are element indices as an STL-style range;
299 // i.e. [begin, end) are shuffled, where 'end' == size() means to
300 // shuffle to the end of the vector.
301 template <typename E>
302 void ShuffleRange(internal::Random* random, int begin, int end,
303  std::vector<E>* v) {
304  const int size = static_cast<int>(v->size());
305  GTEST_CHECK_(0 <= begin && begin <= size)
306  << "Invalid shuffle range start " << begin << ": must be in range [0, "
307  << size << "].";
308  GTEST_CHECK_(begin <= end && end <= size)
309  << "Invalid shuffle range finish " << end << ": must be in range ["
310  << begin << ", " << size << "].";
311 
312  // Fisher-Yates shuffle, from
313  // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle
314  for (int range_width = end - begin; range_width >= 2; range_width--) {
315  const int last_in_range = begin + range_width - 1;
316  const int selected =
317  begin +
318  static_cast<int>(random->Generate(static_cast<uint32_t>(range_width)));
319  std::swap((*v)[static_cast<size_t>(selected)],
320  (*v)[static_cast<size_t>(last_in_range)]);
321  }
322 }
323 
324 // Performs an in-place shuffle of the vector's elements.
325 template <typename E>
326 inline void Shuffle(internal::Random* random, std::vector<E>* v) {
327  ShuffleRange(random, 0, static_cast<int>(v->size()), v);
328 }
329 
330 // A function for deleting an object. Handy for being used as a
331 // functor.
332 template <typename T>
333 static void Delete(T* x) {
334  delete x;
335 }
336 
337 // A predicate that checks the key of a TestProperty against a known key.
338 //
339 // TestPropertyKeyIs is copyable.
340 class TestPropertyKeyIs {
341  public:
342  // Constructor.
343  //
344  // TestPropertyKeyIs has NO default constructor.
345  explicit TestPropertyKeyIs(const std::string& key) : key_(key) {}
346 
347  // Returns true if and only if the test name of test property matches on key_.
348  bool operator()(const TestProperty& test_property) const {
349  return test_property.key() == key_;
350  }
351 
352  private:
354 };
355 
356 // Class UnitTestOptions.
357 //
358 // This class contains functions for processing options the user
359 // specifies when running the tests. It has only static members.
360 //
361 // In most cases, the user can specify an option using either an
362 // environment variable or a command line flag. E.g. you can set the
363 // test filter using either GTEST_FILTER or --gtest_filter. If both
364 // the variable and the flag are present, the latter overrides the
365 // former.
366 class GTEST_API_ UnitTestOptions {
367  public:
368  // Functions for processing the gtest_output flag.
369 
370  // Returns the output format, or "" for normal printed output.
371  static std::string GetOutputFormat();
372 
373  // Returns the absolute path of the requested output file, or the
374  // default (test_detail.xml in the original working directory) if
375  // none was explicitly specified.
376  static std::string GetAbsolutePathToOutputFile();
377 
378  // Functions for processing the gtest_filter flag.
379 
380  // Returns true if and only if the user-specified filter matches the test
381  // suite name and the test name.
382  static bool FilterMatchesTest(const std::string& test_suite_name,
383  const std::string& test_name);
384 
385 #if GTEST_OS_WINDOWS
386  // Function for supporting the gtest_catch_exception flag.
387 
388  // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
389  // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
390  // This function is useful as an __except condition.
391  static int GTestShouldProcessSEH(DWORD exception_code);
392 #endif // GTEST_OS_WINDOWS
393 
394  // Returns true if "name" matches the ':' separated list of glob-style
395  // filters in "filter".
396  static bool MatchesFilter(const std::string& name, const char* filter);
397 };
398 
399 // Returns the current application's name, removing directory path if that
400 // is present. Used by UnitTestOptions::GetOutputFile.
402 
403 // The role interface for getting the OS stack trace as a string.
404 class OsStackTraceGetterInterface {
405  public:
408 
409  // Returns the current OS stack trace as an std::string. Parameters:
410  //
411  // max_depth - the maximum number of stack frames to be included
412  // in the trace.
413  // skip_count - the number of top frames to be skipped; doesn't count
414  // against max_depth.
415  virtual std::string CurrentStackTrace(int max_depth, int skip_count) = 0;
416 
417  // UponLeavingGTest() should be called immediately before Google Test calls
418  // user code. It saves some information about the current stack that
419  // CurrentStackTrace() will use to find and hide Google Test stack frames.
420  virtual void UponLeavingGTest() = 0;
421 
422  // This string is inserted in place of stack frames that are part of
423  // Google Test's implementation.
424  static const char* const kElidedFramesMarker;
425 
426  private:
428 };
429 
430 // A working implementation of the OsStackTraceGetterInterface interface.
431 class OsStackTraceGetter : public OsStackTraceGetterInterface {
432  public:
434 
435  std::string CurrentStackTrace(int max_depth, int skip_count) override;
436  void UponLeavingGTest() override;
437 
438  private:
439 #if GTEST_HAS_ABSL
440  Mutex mutex_; // Protects all internal state.
441 
442  // We save the stack frame below the frame that calls user code.
443  // We do this because the address of the frame immediately below
444  // the user code changes between the call to UponLeavingGTest()
445  // and any calls to the stack trace code from within the user code.
446  void* caller_frame_ = nullptr;
447 #endif // GTEST_HAS_ABSL
448 
450 };
451 
452 // Information about a Google Test trace point.
453 struct TraceInfo {
454  const char* file;
455  int line;
457 };
458 
459 // This is the default global test part result reporter used in UnitTestImpl.
460 // This class should only be used by UnitTestImpl.
461 class DefaultGlobalTestPartResultReporter
462  : public TestPartResultReporterInterface {
463  public:
464  explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);
465  // Implements the TestPartResultReporterInterface. Reports the test part
466  // result in the current test.
467  void ReportTestPartResult(const TestPartResult& result) override;
468 
469  private:
470  UnitTestImpl* const unit_test_;
471 
472  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter);
473 };
474 
475 // This is the default per thread test part result reporter used in
476 // UnitTestImpl. This class should only be used by UnitTestImpl.
477 class DefaultPerThreadTestPartResultReporter
478  : public TestPartResultReporterInterface {
479  public:
480  explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);
481  // Implements the TestPartResultReporterInterface. The implementation just
482  // delegates to the current global test part result reporter of *unit_test_.
483  void ReportTestPartResult(const TestPartResult& result) override;
484 
485  private:
486  UnitTestImpl* const unit_test_;
487 
488  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter);
489 };
490 
491 // The private implementation of the UnitTest class. We don't protect
492 // the methods under a mutex, as this class is not accessible by a
493 // user and the UnitTest class that delegates work to this class does
494 // proper locking.
495 class GTEST_API_ UnitTestImpl {
496  public:
497  explicit UnitTestImpl(UnitTest* parent);
498  virtual ~UnitTestImpl();
499 
500  // There are two different ways to register your own TestPartResultReporter.
501  // You can register your own repoter to listen either only for test results
502  // from the current thread or for results from all threads.
503  // By default, each per-thread test result repoter just passes a new
504  // TestPartResult to the global test result reporter, which registers the
505  // test part result for the currently running test.
506 
507  // Returns the global test part result reporter.
508  TestPartResultReporterInterface* GetGlobalTestPartResultReporter();
509 
510  // Sets the global test part result reporter.
511  void SetGlobalTestPartResultReporter(
512  TestPartResultReporterInterface* reporter);
513 
514  // Returns the test part result reporter for the current thread.
515  TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread();
516 
517  // Sets the test part result reporter for the current thread.
518  void SetTestPartResultReporterForCurrentThread(
519  TestPartResultReporterInterface* reporter);
520 
521  // Gets the number of successful test suites.
522  int successful_test_suite_count() const;
523 
524  // Gets the number of failed test suites.
525  int failed_test_suite_count() const;
526 
527  // Gets the number of all test suites.
528  int total_test_suite_count() const;
529 
530  // Gets the number of all test suites that contain at least one test
531  // that should run.
532  int test_suite_to_run_count() const;
533 
534  // Gets the number of successful tests.
535  int successful_test_count() const;
536 
537  // Gets the number of skipped tests.
538  int skipped_test_count() const;
539 
540  // Gets the number of failed tests.
541  int failed_test_count() const;
542 
543  // Gets the number of disabled tests that will be reported in the XML report.
544  int reportable_disabled_test_count() const;
545 
546  // Gets the number of disabled tests.
547  int disabled_test_count() const;
548 
549  // Gets the number of tests to be printed in the XML report.
550  int reportable_test_count() const;
551 
552  // Gets the number of all tests.
553  int total_test_count() const;
554 
555  // Gets the number of tests that should run.
556  int test_to_run_count() const;
557 
558  // Gets the time of the test program start, in ms from the start of the
559  // UNIX epoch.
560  TimeInMillis start_timestamp() const { return start_timestamp_; }
561 
562  // Gets the elapsed time, in milliseconds.
563  TimeInMillis elapsed_time() const { return elapsed_time_; }
564 
565  // Returns true if and only if the unit test passed (i.e. all test suites
566  // passed).
567  bool Passed() const { return !Failed(); }
568 
569  // Returns true if and only if the unit test failed (i.e. some test suite
570  // failed or something outside of all tests failed).
571  bool Failed() const {
572  return failed_test_suite_count() > 0 || ad_hoc_test_result()->Failed();
573  }
574 
575  // Gets the i-th test suite among all the test suites. i can range from 0 to
576  // total_test_suite_count() - 1. If i is not in that range, returns NULL.
577  const TestSuite* GetTestSuite(int i) const {
578  const int index = GetElementOr(test_suite_indices_, i, -1);
579  return index < 0 ? nullptr : test_suites_[static_cast<size_t>(i)];
580  }
581 
582  // Legacy API is deprecated but still available
583 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
584  const TestCase* GetTestCase(int i) const { return GetTestSuite(i); }
585 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
586 
587  // Gets the i-th test suite among all the test suites. i can range from 0 to
588  // total_test_suite_count() - 1. If i is not in that range, returns NULL.
590  const int index = GetElementOr(test_suite_indices_, i, -1);
591  return index < 0 ? nullptr : test_suites_[static_cast<size_t>(index)];
592  }
593 
594  // Provides access to the event listener list.
595  TestEventListeners* listeners() { return &listeners_; }
596 
597  // Returns the TestResult for the test that's currently running, or
598  // the TestResult for the ad hoc test if no test is running.
599  TestResult* current_test_result();
600 
601  // Returns the TestResult for the ad hoc test.
602  const TestResult* ad_hoc_test_result() const { return &ad_hoc_test_result_; }
603 
604  // Sets the OS stack trace getter.
605  //
606  // Does nothing if the input and the current OS stack trace getter
607  // are the same; otherwise, deletes the old getter and makes the
608  // input the current getter.
609  void set_os_stack_trace_getter(OsStackTraceGetterInterface* getter);
610 
611  // Returns the current OS stack trace getter if it is not NULL;
612  // otherwise, creates an OsStackTraceGetter, makes it the current
613  // getter, and returns it.
614  OsStackTraceGetterInterface* os_stack_trace_getter();
615 
616  // Returns the current OS stack trace as an std::string.
617  //
618  // The maximum number of stack frames to be included is specified by
619  // the gtest_stack_trace_depth flag. The skip_count parameter
620  // specifies the number of top frames to be skipped, which doesn't
621  // count against the number of frames to be included.
622  //
623  // For example, if Foo() calls Bar(), which in turn calls
624  // CurrentOsStackTraceExceptTop(1), Foo() will be included in the
625  // trace but Bar() and CurrentOsStackTraceExceptTop() won't.
626  std::string CurrentOsStackTraceExceptTop(int skip_count)
628 
629  // Finds and returns a TestSuite with the given name. If one doesn't
630  // exist, creates one and returns it.
631  //
632  // Arguments:
633  //
634  // test_suite_name: name of the test suite
635  // type_param: the name of the test's type parameter, or NULL if
636  // this is not a typed or a type-parameterized test.
637  // set_up_tc: pointer to the function that sets up the test suite
638  // tear_down_tc: pointer to the function that tears down the test suite
639  TestSuite* GetTestSuite(const char* test_suite_name, const char* type_param,
641  internal::TearDownTestSuiteFunc tear_down_tc);
642 
643 // Legacy API is deprecated but still available
644 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
645  TestCase* GetTestCase(const char* test_case_name, const char* type_param,
647  internal::TearDownTestSuiteFunc tear_down_tc) {
648  return GetTestSuite(test_case_name, type_param, set_up_tc, tear_down_tc);
649  }
650 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
651 
652  // Adds a TestInfo to the unit test.
653  //
654  // Arguments:
655  //
656  // set_up_tc: pointer to the function that sets up the test suite
657  // tear_down_tc: pointer to the function that tears down the test suite
658  // test_info: the TestInfo object
660  internal::TearDownTestSuiteFunc tear_down_tc,
661  TestInfo* test_info) {
662 #if GTEST_HAS_DEATH_TEST
663  // In order to support thread-safe death tests, we need to
664  // remember the original working directory when the test program
665  // was first invoked. We cannot do this in RUN_ALL_TESTS(), as
666  // the user may have changed the current directory before calling
667  // RUN_ALL_TESTS(). Therefore we capture the current directory in
668  // AddTestInfo(), which is called to register a TEST or TEST_F
669  // before main() is reached.
670  if (original_working_dir_.IsEmpty()) {
671  original_working_dir_.Set(FilePath::GetCurrentDir());
673  << "Failed to get the current working directory.";
674  }
675 #endif // GTEST_HAS_DEATH_TEST
676 
677  GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
678  set_up_tc, tear_down_tc)
679  ->AddTestInfo(test_info);
680  }
681 
682  // Returns ParameterizedTestSuiteRegistry object used to keep track of
683  // value-parameterized tests and instantiate and register them.
685  return parameterized_test_registry_;
686  }
687 
688  std::set<std::string>* ignored_parameterized_test_suites() {
689  return &ignored_parameterized_test_suites_;
690  }
691 
692  // Returns TypeParameterizedTestSuiteRegistry object used to keep track of
693  // type-parameterized tests and instantiations of them.
696  return type_parameterized_test_registry_;
697  }
698 
699  // Sets the TestSuite object for the test that's currently running.
700  void set_current_test_suite(TestSuite* a_current_test_suite) {
701  current_test_suite_ = a_current_test_suite;
702  }
703 
704  // Sets the TestInfo object for the test that's currently running. If
705  // current_test_info is NULL, the assertion results will be stored in
706  // ad_hoc_test_result_.
707  void set_current_test_info(TestInfo* a_current_test_info) {
708  current_test_info_ = a_current_test_info;
709  }
710 
711  // Registers all parameterized tests defined using TEST_P and
712  // INSTANTIATE_TEST_SUITE_P, creating regular tests for each test/parameter
713  // combination. This method can be called more then once; it has guards
714  // protecting from registering the tests more then once. If
715  // value-parameterized tests are disabled, RegisterParameterizedTests is
716  // present but does nothing.
717  void RegisterParameterizedTests();
718 
719  // Runs all tests in this UnitTest object, prints the result, and
720  // returns true if all tests are successful. If any exception is
721  // thrown during a test, this test is considered to be failed, but
722  // the rest of the tests will still be run.
723  bool RunAllTests();
724 
725  // Clears the results of all tests, except the ad hoc tests.
727  ForEach(test_suites_, TestSuite::ClearTestSuiteResult);
728  }
729 
730  // Clears the results of ad-hoc test assertions.
732  ad_hoc_test_result_.Clear();
733  }
734 
735  // Adds a TestProperty to the current TestResult object when invoked in a
736  // context of a test or a test suite, or to the global property set. If the
737  // result already contains a property with the same key, the value will be
738  // updated.
739  void RecordProperty(const TestProperty& test_property);
740 
742  HONOR_SHARDING_PROTOCOL,
743  IGNORE_SHARDING_PROTOCOL
744  };
745 
746  // Matches the full name of each test against the user-specified
747  // filter to decide whether the test should run, then records the
748  // result in each TestSuite and TestInfo object.
749  // If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests
750  // based on sharding variables in the environment.
751  // Returns the number of tests that should run.
752  int FilterTests(ReactionToSharding shard_tests);
753 
754  // Prints the names of the tests matching the user-specified filter flag.
755  void ListTestsMatchingFilter();
756 
757  const TestSuite* current_test_suite() const { return current_test_suite_; }
758  TestInfo* current_test_info() { return current_test_info_; }
759  const TestInfo* current_test_info() const { return current_test_info_; }
760 
761  // Returns the vector of environments that need to be set-up/torn-down
762  // before/after the tests are run.
763  std::vector<Environment*>& environments() { return environments_; }
764 
765  // Getters for the per-thread Google Test trace stack.
766  std::vector<TraceInfo>& gtest_trace_stack() {
767  return *(gtest_trace_stack_.pointer());
768  }
769  const std::vector<TraceInfo>& gtest_trace_stack() const {
770  return gtest_trace_stack_.get();
771  }
772 
773 #if GTEST_HAS_DEATH_TEST
774  void InitDeathTestSubprocessControlInfo() {
775  internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag());
776  }
777  // Returns a pointer to the parsed --gtest_internal_run_death_test
778  // flag, or NULL if that flag was not specified.
779  // This information is useful only in a death test child process.
780  // Must not be called before a call to InitGoogleTest.
781  const InternalRunDeathTestFlag* internal_run_death_test_flag() const {
782  return internal_run_death_test_flag_.get();
783  }
784 
785  // Returns a pointer to the current death test factory.
786  internal::DeathTestFactory* death_test_factory() {
787  return death_test_factory_.get();
788  }
789 
790  void SuppressTestEventsIfInSubprocess();
791 
792  friend class ReplaceDeathTestFactory;
793 #endif // GTEST_HAS_DEATH_TEST
794 
795  // Initializes the event listener performing XML output as specified by
796  // UnitTestOptions. Must not be called before InitGoogleTest.
797  void ConfigureXmlOutput();
798 
799 #if GTEST_CAN_STREAM_RESULTS_
800  // Initializes the event listener for streaming test results to a socket.
801  // Must not be called before InitGoogleTest.
802  void ConfigureStreamingOutput();
803 #endif
804 
805  // Performs initialization dependent upon flag values obtained in
806  // ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to
807  // ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest
808  // this function is also called from RunAllTests. Since this function can be
809  // called more than once, it has to be idempotent.
810  void PostFlagParsingInit();
811 
812  // Gets the random seed used at the start of the current test iteration.
813  int random_seed() const { return random_seed_; }
814 
815  // Gets the random number generator.
816  internal::Random* random() { return &random_; }
817 
818  // Shuffles all test suites, and the tests within each test suite,
819  // making sure that death tests are still run first.
820  void ShuffleTests();
821 
822  // Restores the test suites and tests to their order before the first shuffle.
823  void UnshuffleTests();
824 
825  // Returns the value of GTEST_FLAG(catch_exceptions) at the moment
826  // UnitTest::Run() starts.
827  bool catch_exceptions() const { return catch_exceptions_; }
828 
829  private:
830  friend class ::testing::UnitTest;
831 
832  // Used by UnitTest::Run() to capture the state of
833  // GTEST_FLAG(catch_exceptions) at the moment it starts.
834  void set_catch_exceptions(bool value) { catch_exceptions_ = value; }
835 
836  // The UnitTest object that owns this implementation object.
837  UnitTest* const parent_;
838 
839  // The working directory when the first TEST() or TEST_F() was
840  // executed.
842 
843  // The default test part result reporters.
844  DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_;
846  default_per_thread_test_part_result_reporter_;
847 
848  // Points to (but doesn't own) the global test part result reporter.
849  TestPartResultReporterInterface* global_test_part_result_repoter_;
850 
851  // Protects read and write access to global_test_part_result_reporter_.
852  internal::Mutex global_test_part_result_reporter_mutex_;
853 
854  // Points to (but doesn't own) the per-thread test part result reporter.
856  per_thread_test_part_result_reporter_;
857 
858  // The vector of environments that need to be set-up/torn-down
859  // before/after the tests are run.
860  std::vector<Environment*> environments_;
861 
862  // The vector of TestSuites in their original order. It owns the
863  // elements in the vector.
864  std::vector<TestSuite*> test_suites_;
865 
866  // Provides a level of indirection for the test suite list to allow
867  // easy shuffling and restoring the test suite order. The i-th
868  // element of this vector is the index of the i-th test suite in the
869  // shuffled order.
870  std::vector<int> test_suite_indices_;
871 
872  // ParameterizedTestRegistry object used to register value-parameterized
873  // tests.
877 
878  // The set holding the name of parameterized
879  // test suites that may go uninstantiated.
880  std::set<std::string> ignored_parameterized_test_suites_;
881 
882  // Indicates whether RegisterParameterizedTests() has been called already.
883  bool parameterized_tests_registered_;
884 
885  // Index of the last death test suite registered. Initially -1.
887 
888  // This points to the TestSuite for the currently running test. It
889  // changes as Google Test goes through one test suite after another.
890  // When no test is running, this is set to NULL and Google Test
891  // stores assertion results in ad_hoc_test_result_. Initially NULL.
893 
894  // This points to the TestInfo for the currently running test. It
895  // changes as Google Test goes through one test after another. When
896  // no test is running, this is set to NULL and Google Test stores
897  // assertion results in ad_hoc_test_result_. Initially NULL.
898  TestInfo* current_test_info_;
899 
900  // Normally, a user only writes assertions inside a TEST or TEST_F,
901  // or inside a function called by a TEST or TEST_F. Since Google
902  // Test keeps track of which test is current running, it can
903  // associate such an assertion with the test it belongs to.
904  //
905  // If an assertion is encountered when no TEST or TEST_F is running,
906  // Google Test attributes the assertion result to an imaginary "ad hoc"
907  // test, and records the result in ad_hoc_test_result_.
908  TestResult ad_hoc_test_result_;
909 
910  // The list of event listeners that can be used to track events inside
911  // Google Test.
912  TestEventListeners listeners_;
913 
914  // The OS stack trace getter. Will be deleted when the UnitTest
915  // object is destructed. By default, an OsStackTraceGetter is used,
916  // but the user can set this field to use a custom getter if that is
917  // desired.
918  OsStackTraceGetterInterface* os_stack_trace_getter_;
919 
920  // True if and only if PostFlagParsingInit() has been called.
921  bool post_flag_parse_init_performed_;
922 
923  // The random number seed used at the beginning of the test run.
924  int random_seed_;
925 
926  // Our random number generator.
927  internal::Random random_;
928 
929  // The time of the test program start, in ms from the start of the
930  // UNIX epoch.
931  TimeInMillis start_timestamp_;
932 
933  // How long the test took to run, in milliseconds.
934  TimeInMillis elapsed_time_;
935 
936 #if GTEST_HAS_DEATH_TEST
937  // The decomposed components of the gtest_internal_run_death_test flag,
938  // parsed when RUN_ALL_TESTS is called.
939  std::unique_ptr<InternalRunDeathTestFlag> internal_run_death_test_flag_;
940  std::unique_ptr<internal::DeathTestFactory> death_test_factory_;
941 #endif // GTEST_HAS_DEATH_TEST
942 
943  // A per-thread stack of traces created by the SCOPED_TRACE() macro.
945 
946  // The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests()
947  // starts.
948  bool catch_exceptions_;
949 
951 }; // class UnitTestImpl
952 
953 // Convenience function for accessing the global UnitTest
954 // implementation object.
955 inline UnitTestImpl* GetUnitTestImpl() {
956  return UnitTest::GetInstance()->impl();
957 }
958 
959 #if GTEST_USES_SIMPLE_RE
960 
961 // Internal helper functions for implementing the simple regular
962 // expression matcher.
963 GTEST_API_ bool IsInSet(char ch, const char* str);
964 GTEST_API_ bool IsAsciiDigit(char ch);
965 GTEST_API_ bool IsAsciiPunct(char ch);
966 GTEST_API_ bool IsRepeat(char ch);
967 GTEST_API_ bool IsAsciiWhiteSpace(char ch);
968 GTEST_API_ bool IsAsciiWordChar(char ch);
969 GTEST_API_ bool IsValidEscape(char ch);
970 GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch);
971 GTEST_API_ bool ValidateRegex(const char* regex);
972 GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str);
973 GTEST_API_ bool MatchRepetitionAndRegexAtHead(
974  bool escaped, char ch, char repeat, const char* regex, const char* str);
975 GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);
976 
977 #endif // GTEST_USES_SIMPLE_RE
978 
979 // Parses the command line for Google Test flags, without initializing
980 // other parts of Google Test.
981 GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv);
982 GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);
983 
984 #if GTEST_HAS_DEATH_TEST
985 
986 // Returns the message describing the last system error, regardless of the
987 // platform.
988 GTEST_API_ std::string GetLastErrnoDescription();
989 
990 // Attempts to parse a string into a positive integer pointed to by the
991 // number parameter. Returns true if that is possible.
992 // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use
993 // it here.
994 template <typename Integer>
995 bool ParseNaturalNumber(const ::std::string& str, Integer* number) {
996  // Fail fast if the given string does not begin with a digit;
997  // this bypasses strtoXXX's "optional leading whitespace and plus
998  // or minus sign" semantics, which are undesirable here.
999  if (str.empty() || !IsDigit(str[0])) {
1000  return false;
1001  }
1002  errno = 0;
1003 
1004  char* end;
1005  // BiggestConvertible is the largest integer type that system-provided
1006  // string-to-number conversion routines can return.
1007  using BiggestConvertible = unsigned long long; // NOLINT
1008 
1009  const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10); // NOLINT
1010  const bool parse_success = *end == '\0' && errno == 0;
1011 
1012  GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed));
1013 
1014  const Integer result = static_cast<Integer>(parsed);
1015  if (parse_success && static_cast<BiggestConvertible>(result) == parsed) {
1016  *number = result;
1017  return true;
1018  }
1019  return false;
1020 }
1021 #endif // GTEST_HAS_DEATH_TEST
1022 
1023 // TestResult contains some private methods that should be hidden from
1024 // Google Test user but are required for testing. This class allow our tests
1025 // to access them.
1026 //
1027 // This class is supplied only for the purpose of testing Google Test's own
1028 // constructs. Do not use it in user tests, either directly or indirectly.
1029 class TestResultAccessor {
1030  public:
1032  const std::string& xml_element,
1033  const TestProperty& property) {
1034  test_result->RecordProperty(xml_element, property);
1035  }
1036 
1038  test_result->ClearTestPartResults();
1039  }
1040 
1041  static const std::vector<testing::TestPartResult>& test_part_results(
1042  const TestResult& test_result) {
1043  return test_result.test_part_results();
1044  }
1045 };
1046 
1047 #if GTEST_CAN_STREAM_RESULTS_
1048 
1049 // Streams test results to the given port on the given host machine.
1050 class StreamingListener : public EmptyTestEventListener {
1051  public:
1052  // Abstract base class for writing strings to a socket.
1053  class AbstractSocketWriter {
1054  public:
1055  virtual ~AbstractSocketWriter() {}
1056 
1057  // Sends a string to the socket.
1058  virtual void Send(const std::string& message) = 0;
1059 
1060  // Closes the socket.
1061  virtual void CloseConnection() {}
1062 
1063  // Sends a string and a newline to the socket.
1064  void SendLn(const std::string& message) { Send(message + "\n"); }
1065  };
1066 
1067  // Concrete class for actually writing strings to a socket.
1068  class SocketWriter : public AbstractSocketWriter {
1069  public:
1070  SocketWriter(const std::string& host, const std::string& port)
1071  : sockfd_(-1), host_name_(host), port_num_(port) {
1072  MakeConnection();
1073  }
1074 
1075  ~SocketWriter() override {
1076  if (sockfd_ != -1)
1077  CloseConnection();
1078  }
1079 
1080  // Sends a string to the socket.
1081  void Send(const std::string& message) override {
1082  GTEST_CHECK_(sockfd_ != -1)
1083  << "Send() can be called only when there is a connection.";
1084 
1085  const auto len = static_cast<size_t>(message.length());
1086  if (write(sockfd_, message.c_str(), len) != static_cast<ssize_t>(len)) {
1088  << "stream_result_to: failed to stream to "
1089  << host_name_ << ":" << port_num_;
1090  }
1091  }
1092 
1093  private:
1094  // Creates a client socket and connects to the server.
1095  void MakeConnection();
1096 
1097  // Closes the socket.
1098  void CloseConnection() override {
1099  GTEST_CHECK_(sockfd_ != -1)
1100  << "CloseConnection() can be called only when there is a connection.";
1101 
1102  close(sockfd_);
1103  sockfd_ = -1;
1104  }
1105 
1106  int sockfd_; // socket file descriptor
1107  const std::string host_name_;
1108  const std::string port_num_;
1109 
1110  GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter);
1111  }; // class SocketWriter
1112 
1113  // Escapes '=', '&', '%', and '\n' characters in str as "%xx".
1114  static std::string UrlEncode(const char* str);
1115 
1116  StreamingListener(const std::string& host, const std::string& port)
1117  : socket_writer_(new SocketWriter(host, port)) {
1118  Start();
1119  }
1120 
1121  explicit StreamingListener(AbstractSocketWriter* socket_writer)
1122  : socket_writer_(socket_writer) { Start(); }
1123 
1124  void OnTestProgramStart(const UnitTest& /* unit_test */) override {
1125  SendLn("event=TestProgramStart");
1126  }
1127 
1128  void OnTestProgramEnd(const UnitTest& unit_test) override {
1129  // Note that Google Test current only report elapsed time for each
1130  // test iteration, not for the entire test program.
1131  SendLn("event=TestProgramEnd&passed=" + FormatBool(unit_test.Passed()));
1132 
1133  // Notify the streaming server to stop.
1134  socket_writer_->CloseConnection();
1135  }
1136 
1137  void OnTestIterationStart(const UnitTest& /* unit_test */,
1138  int iteration) override {
1139  SendLn("event=TestIterationStart&iteration=" +
1140  StreamableToString(iteration));
1141  }
1142 
1143  void OnTestIterationEnd(const UnitTest& unit_test,
1144  int /* iteration */) override {
1145  SendLn("event=TestIterationEnd&passed=" +
1146  FormatBool(unit_test.Passed()) + "&elapsed_time=" +
1147  StreamableToString(unit_test.elapsed_time()) + "ms");
1148  }
1149 
1150  // Note that "event=TestCaseStart" is a wire format and has to remain
1151  // "case" for compatibility
1152  void OnTestSuiteStart(const TestSuite& test_suite) override {
1153  SendLn(std::string("event=TestCaseStart&name=") + test_suite.name());
1154  }
1155 
1156  // Note that "event=TestCaseEnd" is a wire format and has to remain
1157  // "case" for compatibility
1158  void OnTestSuiteEnd(const TestSuite& test_suite) override {
1159  SendLn("event=TestCaseEnd&passed=" + FormatBool(test_suite.Passed()) +
1160  "&elapsed_time=" + StreamableToString(test_suite.elapsed_time()) +
1161  "ms");
1162  }
1163 
1164  void OnTestStart(const TestInfo& test_info) override {
1165  SendLn(std::string("event=TestStart&name=") + test_info.name());
1166  }
1167 
1168  void OnTestEnd(const TestInfo& test_info) override {
1169  SendLn("event=TestEnd&passed=" +
1170  FormatBool((test_info.result())->Passed()) +
1171  "&elapsed_time=" +
1172  StreamableToString((test_info.result())->elapsed_time()) + "ms");
1173  }
1174 
1175  void OnTestPartResult(const TestPartResult& test_part_result) override {
1176  const char* file_name = test_part_result.file_name();
1177  if (file_name == nullptr) file_name = "";
1178  SendLn("event=TestPartResult&file=" + UrlEncode(file_name) +
1179  "&line=" + StreamableToString(test_part_result.line_number()) +
1180  "&message=" + UrlEncode(test_part_result.message()));
1181  }
1182 
1183  private:
1184  // Sends the given message and a newline to the socket.
1185  void SendLn(const std::string& message) { socket_writer_->SendLn(message); }
1186 
1187  // Called at the start of streaming to notify the receiver what
1188  // protocol we are using.
1189  void Start() { SendLn("gtest_streaming_protocol_version=1.0"); }
1190 
1191  std::string FormatBool(bool value) { return value ? "1" : "0"; }
1192 
1193  const std::unique_ptr<AbstractSocketWriter> socket_writer_;
1194 
1195  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener);
1196 }; // class StreamingListener
1197 
1198 #endif // GTEST_CAN_STREAM_RESULTS_
1199 
1200 } // namespace internal
1201 } // namespace testing
1202 
1204 
1205 #endif // GOOGLETEST_SRC_GTEST_INTERNAL_INL_H_
xds_interop_client.str
str
Definition: xds_interop_client.py:487
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
flag
uint32_t flag
Definition: ssl_versions.cc:162
testing
Definition: aws_request_signer_test.cc:25
testing::internal::DefaultGlobalTestPartResultReporter
Definition: gmock-gtest-all.cc:872
GTEST_FLAG_SET
#define GTEST_FLAG_SET(name, value)
Definition: googletest/googletest/include/gtest/internal/gtest-port.h:2219
absl::FormatConversionChar::E
@ E
testing::internal::UnitTestImpl::ClearNonAdHocTestResult
void ClearNonAdHocTestResult()
Definition: googletest/googletest/src/gtest-internal-inl.h:726
testing::TestInfo
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:695
regen-readme.it
it
Definition: regen-readme.py:15
env_var
Definition: win/process.c:40
testing::internal::UnitTestImpl::ignored_parameterized_test_suites_
std::set< std::string > ignored_parameterized_test_suites_
Definition: googletest/googletest/src/gtest-internal-inl.h:880
testing::internal::UnitTestImpl::set_current_test_suite
void set_current_test_suite(TestSuite *a_current_test_suite)
Definition: googletest/googletest/src/gtest-internal-inl.h:700
testing::internal::ShouldRunTestOnShard
bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5485
testing::internal::Mutex
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:1852
testing::internal::DefaultPerThreadTestPartResultReporter
Definition: gmock-gtest-all.cc:888
check_tracer_sanity.pattern
pattern
Definition: check_tracer_sanity.py:25
testing::internal::UnitTestImpl::listeners
TestEventListeners * listeners()
Definition: googletest/googletest/src/gtest-internal-inl.h:595
file
const grpc_generator::File * file
Definition: python_private_generator.h:38
testing::internal::OsStackTraceGetter::OsStackTraceGetter
OsStackTraceGetter()
Definition: googletest/googletest/src/gtest-internal-inl.h:433
RunAllTests
int RunAllTests()
Definition: bloaty/third_party/googletest/googletest/test/googletest-output-test_.cc:362
testing::internal::GTestFlagSaver::fail_fast_
bool fail_fast_
Definition: googletest/googletest/src/gtest-internal-inl.h:199
GTEST_API_
#define GTEST_API_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:754
begin
char * begin
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1007
testing::TestResult
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:562
write
#define write
Definition: test-fs.c:47
testing::internal::ParameterizedTestSuiteRegistry
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-param-util.h:657
testing::internal::TearDownTestSuiteFunc
void(*)() TearDownTestSuiteFunc
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:478
testing::internal::TypeParameterizedTestSuiteRegistry
Definition: boringssl-with-bazel/src/third_party/googletest/include/gtest/internal/gtest-param-util.h:750
string.h
GTEST_DISABLE_MSC_WARNINGS_PUSH_
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251) GTEST_DECLARE_bool_(death_test_use_fork)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-cardinalities.h:48
seed
static const uint8_t seed[20]
Definition: dsa_test.cc:79
testing::internal::GetUnitTestImpl
UnitTestImpl * GetUnitTestImpl()
Definition: gmock-gtest-all.cc:1334
testing::internal::UnitTestImpl::gtest_trace_stack
const std::vector< TraceInfo > & gtest_trace_stack() const
Definition: googletest/googletest/src/gtest-internal-inl.h:769
testing::internal::TypeId
const typedef void * TypeId
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:405
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
testing::internal::TestResultAccessor::RecordProperty
static void RecordProperty(TestResult *test_result, const std::string &xml_element, const TestProperty &property)
Definition: googletest/googletest/src/gtest-internal-inl.h:1031
testing::internal::GetNextRandomSeed
int GetNextRandomSeed(int seed)
Definition: gmock-gtest-all.cc:559
testing::internal::GTestFlagSaver::recreate_environments_when_repeating_
bool recreate_environments_when_repeating_
Definition: googletest/googletest/src/gtest-internal-inl.h:209
testing::internal::GTestFlagSaver::brief_
bool brief_
Definition: googletest/googletest/src/gtest-internal-inl.h:204
setup.name
name
Definition: setup.py:542
testing::internal::OsStackTraceGetterInterface
Definition: gmock-gtest-all.cc:825
grpc_core::ForEach
for_each_detail::ForEach< Reader, Action > ForEach(Reader reader, Action action)
For each item acquired by calling Reader::Next, run the promise Action.
Definition: for_each.h:133
testing::internal::OsStackTraceGetterInterface::~OsStackTraceGetterInterface
virtual ~OsStackTraceGetterInterface()
Definition: googletest/googletest/src/gtest-internal-inl.h:407
testing::TestEventListeners
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1170
original_working_dir_
FilePath original_working_dir_
Definition: bloaty/third_party/googletest/googletest/test/googletest-options-test.cc:140
testing::TestInfo::type_param
const char * type_param() const
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:714
grpc::testing::test_result
test_result
Definition: h2_ssl_cert_test.cc:201
env.new
def new
Definition: env.py:51
testing::internal::GetElementOr
E GetElementOr(const std::vector< E > &v, int i, E default_value)
Definition: gmock-gtest-all.cc:710
testing::internal::UnitTestImpl::catch_exceptions
bool catch_exceptions() const
Definition: googletest/googletest/src/gtest-internal-inl.h:827
testing::internal::ThreadLocal
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:1878
message
char * message
Definition: libuv/docs/code/tty-gravity/main.c:12
GTEST_NO_INLINE_
#define GTEST_NO_INLINE_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:765
T
#define T(upbtypeconst, upbtype, ctype, default_value)
namespace
Definition: namespace.py:1
testing::internal::ShouldUseColor
bool ShouldUseColor(bool stdout_is_tty)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:2996
testing::internal::ShouldShard
bool ShouldShard(const char *total_shards_env, const char *shard_index_env, bool in_subprocess_for_death_test)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5422
GTEST_LOG_
#define GTEST_LOG_(severity)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:975
testing::internal::UnitTestImpl::gtest_trace_stack
std::vector< TraceInfo > & gtest_trace_stack()
Definition: googletest/googletest/src/gtest-internal-inl.h:766
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
testing::internal::UnitTestImpl::parameterized_test_registry_
internal::ParameterizedTestSuiteRegistry parameterized_test_registry_
Definition: googletest/googletest/src/gtest-internal-inl.h:874
testing::internal::StreamableToString
std::string StreamableToString(const T &streamable)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest-message.h:209
absl::debugging_internal::IsDigit
static bool IsDigit(char c)
Definition: abseil-cpp/absl/debugging/internal/demangle.cc:383
GTEST_ATTRIBUTE_UNUSED_
#define GTEST_ATTRIBUTE_UNUSED_
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:655
testing::internal::OsStackTraceGetterInterface::OsStackTraceGetterInterface
OsStackTraceGetterInterface()
Definition: googletest/googletest/src/gtest-internal-inl.h:406
ssize_t
intptr_t ssize_t
Definition: win.h:27
testing::TestCase
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:19377
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
testing::internal::UnitTestImpl::environments
std::vector< Environment * > & environments()
Definition: googletest/googletest/src/gtest-internal-inl.h:763
testing::internal::kTestTypeIdInGoogleTest
const TypeId kTestTypeIdInGoogleTest
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/src/gtest.cc:653
testing::internal::TestResultAccessor::test_part_results
static const std::vector< testing::TestPartResult > & test_part_results(const TestResult &test_result)
Definition: googletest/googletest/src/gtest-internal-inl.h:1041
testing::internal::GTestFlagSaver::random_seed_
int32_t random_seed_
Definition: googletest/googletest/src/gtest-internal-inl.h:207
testing::internal::UnitTestImpl::current_test_suite
const TestSuite * current_test_suite() const
Definition: googletest/googletest/src/gtest-internal-inl.h:757
testing::internal::UnitTestImpl::random
internal::Random * random()
Definition: googletest/googletest/src/gtest-internal-inl.h:816
testing::internal::FormatTimeInMillisAsSeconds
std::string FormatTimeInMillisAsSeconds(TimeInMillis ms)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3715
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
testing::internal::CodePointToUtf8
std::string CodePointToUtf8(UInt32 code_point)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1770
setup.v
v
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
testing::internal::UnitTestImpl::GetTestCase
TestCase * GetTestCase(const char *test_case_name, const char *type_param, internal::SetUpTestSuiteFunc set_up_tc, internal::TearDownTestSuiteFunc tear_down_tc)
Definition: googletest/googletest/src/gtest-internal-inl.h:645
testing::internal::UnitTestImpl::Passed
bool Passed() const
Definition: googletest/googletest/src/gtest-internal-inl.h:567
testing::internal::UnitTestImpl::current_test_suite_
TestSuite * current_test_suite_
Definition: googletest/googletest/src/gtest-internal-inl.h:892
GTEST_NO_TAIL_CALL_
#define GTEST_NO_TAIL_CALL_
Definition: googletest/googletest/include/gtest/internal/gtest-port.h:803
testing::internal::GTestFlagSaver::GTestFlagSaver
GTestFlagSaver()
Definition: googletest/googletest/src/gtest-internal-inl.h:140
testing::internal::UnitTestImpl::Failed
bool Failed() const
Definition: googletest/googletest/src/gtest-internal-inl.h:571
testing::internal::UnitTestImpl::random_seed
int random_seed() const
Definition: googletest/googletest/src/gtest-internal-inl.h:813
testing::internal::WideStringToUtf8
std::string WideStringToUtf8(const wchar_t *str, int num_chars)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:1837
number
int32_t number
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
testing::internal::UnitTestImpl::set_catch_exceptions
void set_catch_exceptions(bool value)
Definition: googletest/googletest/src/gtest-internal-inl.h:834
std::swap
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:1226
close
#define close
Definition: test-fs.c:48
testing::TimeInMillis
internal::TimeInMillis TimeInMillis
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:519
testing::TestProperty
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:525
testing::TestProperty::key
const char * key() const
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:535
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
testing::internal::Int32FromEnvOrDie
Int32 Int32FromEnvOrDie(const char *var, Int32 default_val)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5467
testing::internal::UnitTestImpl::ignored_parameterized_test_suites
std::set< std::string > * ignored_parameterized_test_suites()
Definition: googletest/googletest/src/gtest-internal-inl.h:688
key_
RlsLb::RequestKey key_
Definition: rls.cc:659
google::protobuf::WARNING
static const LogLevel WARNING
Definition: bloaty/third_party/protobuf/src/google/protobuf/testing/googletest.h:71
testing::internal::Random
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:833
testing::internal::UnitTestImpl::test_suites_
std::vector< TestSuite * > test_suites_
Definition: googletest/googletest/src/gtest-internal-inl.h:864
TestSuite
Definition: cavp_main.cc:32
Delete
void Delete(T *t)
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:208
testing::internal::GetCurrentExecutableName
FilePath GetCurrentExecutableName()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:429
testing::internal::GetTimeInMillis
TimeInMillis GetTimeInMillis()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:836
testing::internal::UnitTestImpl::current_test_info
TestInfo * current_test_info()
Definition: googletest/googletest/src/gtest-internal-inl.h:758
testing::internal::TestPropertyKeyIs::TestPropertyKeyIs
TestPropertyKeyIs(const std::string &key)
Definition: googletest/googletest/src/gtest-internal-inl.h:345
testing::internal::UnitTestImpl::parameterized_test_registry
internal::ParameterizedTestSuiteRegistry & parameterized_test_registry()
Definition: googletest/googletest/src/gtest-internal-inl.h:684
testing::internal::ParseGoogleTestFlagsOnly
void ParseGoogleTestFlagsOnly(int *argc, char **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6053
testing::TestPartResultReporterInterface
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:18371
GTEST_DISALLOW_COPY_AND_ASSIGN_
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:683
tests.unit._exit_scenarios.port
port
Definition: _exit_scenarios.py:179
testing::internal::GTestFlagSaver::stack_trace_depth_
int32_t stack_trace_depth_
Definition: googletest/googletest/src/gtest-internal-inl.h:211
testing::internal::UnitTestImpl::current_test_info
const TestInfo * current_test_info() const
Definition: googletest/googletest/src/gtest-internal-inl.h:759
testing::internal::ParseFlag
GTEST_API_ bool ParseFlag(const char *str, const char *flag, int32_t *value)
Definition: googletest/googletest/src/gtest.cc:6409
value
const char * value
Definition: hpack_parser_table.cc:165
testing::internal::UnitTestImpl::type_parameterized_test_registry
internal::TypeParameterizedTestSuiteRegistry & type_parameterized_test_registry()
Definition: googletest/googletest/src/gtest-internal-inl.h:695
testing::internal::UnitTestImpl
Definition: gmock-gtest-all.cc:906
output_
std::string output_
Definition: json_writer.cc:76
testing::internal::GTestFlagSaver::print_utf8_
bool print_utf8_
Definition: googletest/googletest/src/gtest-internal-inl.h:206
testing::internal::UnitTestImpl::AddTestInfo
void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc, internal::TearDownTestSuiteFunc tear_down_tc, TestInfo *test_info)
Definition: googletest/googletest/src/gtest-internal-inl.h:659
GTEST_CHECK_
#define GTEST_CHECK_(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:999
key
const char * key
Definition: hpack_parser_table.cc:164
testing::internal::UnitTestImpl::GetMutableSuiteCase
TestSuite * GetMutableSuiteCase(int i)
Definition: googletest/googletest/src/gtest-internal-inl.h:589
testing::internal::OsStackTraceGetter
Definition: gmock-gtest-all.cc:852
testing::internal::Shuffle
void Shuffle(internal::Random *random, std::vector< E > *v)
Definition: gmock-gtest-all.cc:740
testing::internal::FilePath
Definition: cares/cares/test/gmock-1.8.0/gtest/gtest.h:4324
testing::internal::UnitTestImpl::test_suite_indices_
std::vector< int > test_suite_indices_
Definition: googletest/googletest/src/gtest-internal-inl.h:870
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
testing::internal::UnitTestImpl::start_timestamp
TimeInMillis start_timestamp() const
Definition: googletest/googletest/src/gtest-internal-inl.h:560
testing::internal::kMaxRandomSeed
const int kMaxRandomSeed
Definition: gmock-gtest-all.cc:513
testing::UnitTest
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1257
testing::internal::ShuffleRange
void ShuffleRange(internal::Random *random, int begin, int end, std::vector< E > *v)
Definition: gmock-gtest-all.cc:719
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
testing::internal::SetUpTestSuiteFunc
void(*)() SetUpTestSuiteFunc
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:477
testing::internal::TestResultAccessor::ClearTestPartResults
static void ClearTestPartResults(TestResult *test_result)
Definition: googletest/googletest/src/gtest-internal-inl.h:1037
testing::internal::GTestFlagSaver::repeat_
int32_t repeat_
Definition: googletest/googletest/src/gtest-internal-inl.h:208
testing::internal::UnitTestImpl::ClearAdHocTestResult
void ClearAdHocTestResult()
Definition: googletest/googletest/src/gtest-internal-inl.h:731
testing::internal::UnitTestImpl::set_current_test_info
void set_current_test_info(TestInfo *a_current_test_info)
Definition: googletest/googletest/src/gtest-internal-inl.h:707
regen-readme.line
line
Definition: regen-readme.py:30
testing::internal::UnitTestImpl::elapsed_time
TimeInMillis elapsed_time() const
Definition: googletest/googletest/src/gtest-internal-inl.h:563
testing::EmptyTestEventListener
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1141
absl::base_internal::Random
static int Random(uint32_t *state)
Definition: abseil-cpp/absl/base/internal/low_level_alloc.cc:122
GTEST_DISABLE_MSC_WARNINGS_POP_
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:309
testing::internal::TimeInMillis
TypeWithSize< 8 >::Int TimeInMillis
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2163
GTEST_FLAG_GET
#define GTEST_FLAG_GET(name)
Definition: googletest/googletest/include/gtest/internal/gtest-port.h:2218
testing::internal::CountIf
int CountIf(const Container &c, Predicate predicate)
Definition: gmock-gtest-all.cc:690
internal
Definition: benchmark/test/output_test_helper.cc:20
GTEST_DECLARE_bool_
#define GTEST_DECLARE_bool_(name)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:2180
mutex_
internal::WrappedMutex mutex_
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.cc:569
ch
char ch
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3621
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
testing::internal::UnitTestImpl::ad_hoc_test_result
const TestResult * ad_hoc_test_result() const
Definition: googletest/googletest/src/gtest-internal-inl.h:602
parent_
RefCountedPtr< GrpcLb > parent_
Definition: grpclb.cc:438
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
testing::internal::FormatEpochTimeInMillisAsIso8601
std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:3738
testing::TestInfo::test_suite_name
const char * test_suite_name() const
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:702
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
testing::internal::UnitTestImpl::GetTestCase
const TestCase * GetTestCase(int i) const
Definition: googletest/googletest/src/gtest-internal-inl.h:584
google::protobuf::compiler::objectivec::FilePath
string FilePath(const FileDescriptor *file)
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc:404
testing::internal::GetRandomSeedFromFlag
int GetRandomSeedFromFlag(int32_t random_seed_flag)
Definition: googletest/googletest/src/gtest-internal-inl.h:111
testing::internal::WriteToShardStatusFileIfNeeded
void WriteToShardStatusFileIfNeeded()
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:5400
testing::internal::UnitTestImpl::last_death_test_suite_
int last_death_test_suite_
Definition: googletest/googletest/src/gtest-internal-inl.h:886
testing::internal::UnitTestImpl::type_parameterized_test_registry_
internal::TypeParameterizedTestSuiteRegistry type_parameterized_test_registry_
Definition: googletest/googletest/src/gtest-internal-inl.h:876
testing::internal::g_help_flag
bool g_help_flag
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:182
errno.h
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
testing::internal::TestPropertyKeyIs::operator()
bool operator()(const TestProperty &test_property) const
Definition: googletest/googletest/src/gtest-internal-inl.h:348
testing::internal::UnitTestImpl::ReactionToSharding
ReactionToSharding
Definition: gmock-gtest-all.cc:1124
setup.test_suite
test_suite
Definition: src/python/grpcio_tests/setup.py:108
testing::internal::GTestFlagSaver::~GTestFlagSaver
~GTestFlagSaver()
Definition: googletest/googletest/src/gtest-internal-inl.h:166
testing::TestSuite
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:830
google::protobuf.internal.decoder.long
long
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/decoder.py:89
testing::internal::UnitTestImpl::GetTestSuite
const TestSuite * GetTestSuite(int i) const
Definition: googletest/googletest/src/gtest-internal-inl.h:577


grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:46