11cb0ef41Sopenharmony_ci// Copyright 2005, Google Inc.
21cb0ef41Sopenharmony_ci// All rights reserved.
31cb0ef41Sopenharmony_ci//
41cb0ef41Sopenharmony_ci// Redistribution and use in source and binary forms, with or without
51cb0ef41Sopenharmony_ci// modification, are permitted provided that the following conditions are
61cb0ef41Sopenharmony_ci// met:
71cb0ef41Sopenharmony_ci//
81cb0ef41Sopenharmony_ci//     * Redistributions of source code must retain the above copyright
91cb0ef41Sopenharmony_ci// notice, this list of conditions and the following disclaimer.
101cb0ef41Sopenharmony_ci//     * Redistributions in binary form must reproduce the above
111cb0ef41Sopenharmony_ci// copyright notice, this list of conditions and the following disclaimer
121cb0ef41Sopenharmony_ci// in the documentation and/or other materials provided with the
131cb0ef41Sopenharmony_ci// distribution.
141cb0ef41Sopenharmony_ci//     * Neither the name of Google Inc. nor the names of its
151cb0ef41Sopenharmony_ci// contributors may be used to endorse or promote products derived from
161cb0ef41Sopenharmony_ci// this software without specific prior written permission.
171cb0ef41Sopenharmony_ci//
181cb0ef41Sopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
191cb0ef41Sopenharmony_ci// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
201cb0ef41Sopenharmony_ci// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
211cb0ef41Sopenharmony_ci// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
221cb0ef41Sopenharmony_ci// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
231cb0ef41Sopenharmony_ci// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
241cb0ef41Sopenharmony_ci// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
251cb0ef41Sopenharmony_ci// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
261cb0ef41Sopenharmony_ci// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
271cb0ef41Sopenharmony_ci// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
281cb0ef41Sopenharmony_ci// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci// The Google C++ Testing and Mocking Framework (Google Test)
311cb0ef41Sopenharmony_ci//
321cb0ef41Sopenharmony_ci// This header file defines internal utilities needed for implementing
331cb0ef41Sopenharmony_ci// death tests.  They are subject to change without notice.
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci// IWYU pragma: private, include "gtest/gtest.h"
361cb0ef41Sopenharmony_ci// IWYU pragma: friend gtest/.*
371cb0ef41Sopenharmony_ci// IWYU pragma: friend gmock/.*
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci#ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
401cb0ef41Sopenharmony_ci#define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci#include <stdio.h>
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci#include <memory>
451cb0ef41Sopenharmony_ci#include <string>
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci#include "gtest/gtest-matchers.h"
481cb0ef41Sopenharmony_ci#include "gtest/internal/gtest-internal.h"
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ciGTEST_DECLARE_string_(internal_run_death_test);
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_cinamespace testing {
531cb0ef41Sopenharmony_cinamespace internal {
541cb0ef41Sopenharmony_ci
551cb0ef41Sopenharmony_ci// Names of the flags (needed for parsing Google Test flags).
561cb0ef41Sopenharmony_ciconst char kDeathTestStyleFlag[] = "death_test_style";
571cb0ef41Sopenharmony_ciconst char kDeathTestUseFork[] = "death_test_use_fork";
581cb0ef41Sopenharmony_ciconst char kInternalRunDeathTestFlag[] = "internal_run_death_test";
591cb0ef41Sopenharmony_ci
601cb0ef41Sopenharmony_ci#ifdef GTEST_HAS_DEATH_TEST
611cb0ef41Sopenharmony_ci
621cb0ef41Sopenharmony_ciGTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
631cb0ef41Sopenharmony_ci/* class A needs to have dll-interface to be used by clients of class B */)
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ci// DeathTest is a class that hides much of the complexity of the
661cb0ef41Sopenharmony_ci// GTEST_DEATH_TEST_ macro.  It is abstract; its static Create method
671cb0ef41Sopenharmony_ci// returns a concrete class that depends on the prevailing death test
681cb0ef41Sopenharmony_ci// style, as defined by the --gtest_death_test_style and/or
691cb0ef41Sopenharmony_ci// --gtest_internal_run_death_test flags.
701cb0ef41Sopenharmony_ci
711cb0ef41Sopenharmony_ci// In describing the results of death tests, these terms are used with
721cb0ef41Sopenharmony_ci// the corresponding definitions:
731cb0ef41Sopenharmony_ci//
741cb0ef41Sopenharmony_ci// exit status:  The integer exit information in the format specified
751cb0ef41Sopenharmony_ci//               by wait(2)
761cb0ef41Sopenharmony_ci// exit code:    The integer code passed to exit(3), _exit(2), or
771cb0ef41Sopenharmony_ci//               returned from main()
781cb0ef41Sopenharmony_ciclass GTEST_API_ DeathTest {
791cb0ef41Sopenharmony_ci public:
801cb0ef41Sopenharmony_ci  // Create returns false if there was an error determining the
811cb0ef41Sopenharmony_ci  // appropriate action to take for the current death test; for example,
821cb0ef41Sopenharmony_ci  // if the gtest_death_test_style flag is set to an invalid value.
831cb0ef41Sopenharmony_ci  // The LastMessage method will return a more detailed message in that
841cb0ef41Sopenharmony_ci  // case.  Otherwise, the DeathTest pointer pointed to by the "test"
851cb0ef41Sopenharmony_ci  // argument is set.  If the death test should be skipped, the pointer
861cb0ef41Sopenharmony_ci  // is set to NULL; otherwise, it is set to the address of a new concrete
871cb0ef41Sopenharmony_ci  // DeathTest object that controls the execution of the current test.
881cb0ef41Sopenharmony_ci  static bool Create(const char* statement, Matcher<const std::string&> matcher,
891cb0ef41Sopenharmony_ci                     const char* file, int line, DeathTest** test);
901cb0ef41Sopenharmony_ci  DeathTest();
911cb0ef41Sopenharmony_ci  virtual ~DeathTest() = default;
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci  // A helper class that aborts a death test when it's deleted.
941cb0ef41Sopenharmony_ci  class ReturnSentinel {
951cb0ef41Sopenharmony_ci   public:
961cb0ef41Sopenharmony_ci    explicit ReturnSentinel(DeathTest* test) : test_(test) {}
971cb0ef41Sopenharmony_ci    ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }
981cb0ef41Sopenharmony_ci
991cb0ef41Sopenharmony_ci   private:
1001cb0ef41Sopenharmony_ci    DeathTest* const test_;
1011cb0ef41Sopenharmony_ci    ReturnSentinel(const ReturnSentinel&) = delete;
1021cb0ef41Sopenharmony_ci    ReturnSentinel& operator=(const ReturnSentinel&) = delete;
1031cb0ef41Sopenharmony_ci  };
1041cb0ef41Sopenharmony_ci
1051cb0ef41Sopenharmony_ci  // An enumeration of possible roles that may be taken when a death
1061cb0ef41Sopenharmony_ci  // test is encountered.  EXECUTE means that the death test logic should
1071cb0ef41Sopenharmony_ci  // be executed immediately.  OVERSEE means that the program should prepare
1081cb0ef41Sopenharmony_ci  // the appropriate environment for a child process to execute the death
1091cb0ef41Sopenharmony_ci  // test, then wait for it to complete.
1101cb0ef41Sopenharmony_ci  enum TestRole { OVERSEE_TEST, EXECUTE_TEST };
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ci  // An enumeration of the three reasons that a test might be aborted.
1131cb0ef41Sopenharmony_ci  enum AbortReason {
1141cb0ef41Sopenharmony_ci    TEST_ENCOUNTERED_RETURN_STATEMENT,
1151cb0ef41Sopenharmony_ci    TEST_THREW_EXCEPTION,
1161cb0ef41Sopenharmony_ci    TEST_DID_NOT_DIE
1171cb0ef41Sopenharmony_ci  };
1181cb0ef41Sopenharmony_ci
1191cb0ef41Sopenharmony_ci  // Assumes one of the above roles.
1201cb0ef41Sopenharmony_ci  virtual TestRole AssumeRole() = 0;
1211cb0ef41Sopenharmony_ci
1221cb0ef41Sopenharmony_ci  // Waits for the death test to finish and returns its status.
1231cb0ef41Sopenharmony_ci  virtual int Wait() = 0;
1241cb0ef41Sopenharmony_ci
1251cb0ef41Sopenharmony_ci  // Returns true if the death test passed; that is, the test process
1261cb0ef41Sopenharmony_ci  // exited during the test, its exit status matches a user-supplied
1271cb0ef41Sopenharmony_ci  // predicate, and its stderr output matches a user-supplied regular
1281cb0ef41Sopenharmony_ci  // expression.
1291cb0ef41Sopenharmony_ci  // The user-supplied predicate may be a macro expression rather
1301cb0ef41Sopenharmony_ci  // than a function pointer or functor, or else Wait and Passed could
1311cb0ef41Sopenharmony_ci  // be combined.
1321cb0ef41Sopenharmony_ci  virtual bool Passed(bool exit_status_ok) = 0;
1331cb0ef41Sopenharmony_ci
1341cb0ef41Sopenharmony_ci  // Signals that the death test did not die as expected.
1351cb0ef41Sopenharmony_ci  virtual void Abort(AbortReason reason) = 0;
1361cb0ef41Sopenharmony_ci
1371cb0ef41Sopenharmony_ci  // Returns a human-readable outcome message regarding the outcome of
1381cb0ef41Sopenharmony_ci  // the last death test.
1391cb0ef41Sopenharmony_ci  static const char* LastMessage();
1401cb0ef41Sopenharmony_ci
1411cb0ef41Sopenharmony_ci  static void set_last_death_test_message(const std::string& message);
1421cb0ef41Sopenharmony_ci
1431cb0ef41Sopenharmony_ci private:
1441cb0ef41Sopenharmony_ci  // A string containing a description of the outcome of the last death test.
1451cb0ef41Sopenharmony_ci  static std::string last_death_test_message_;
1461cb0ef41Sopenharmony_ci
1471cb0ef41Sopenharmony_ci  DeathTest(const DeathTest&) = delete;
1481cb0ef41Sopenharmony_ci  DeathTest& operator=(const DeathTest&) = delete;
1491cb0ef41Sopenharmony_ci};
1501cb0ef41Sopenharmony_ci
1511cb0ef41Sopenharmony_ciGTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251
1521cb0ef41Sopenharmony_ci
1531cb0ef41Sopenharmony_ci// Factory interface for death tests.  May be mocked out for testing.
1541cb0ef41Sopenharmony_ciclass DeathTestFactory {
1551cb0ef41Sopenharmony_ci public:
1561cb0ef41Sopenharmony_ci  virtual ~DeathTestFactory() = default;
1571cb0ef41Sopenharmony_ci  virtual bool Create(const char* statement,
1581cb0ef41Sopenharmony_ci                      Matcher<const std::string&> matcher, const char* file,
1591cb0ef41Sopenharmony_ci                      int line, DeathTest** test) = 0;
1601cb0ef41Sopenharmony_ci};
1611cb0ef41Sopenharmony_ci
1621cb0ef41Sopenharmony_ci// A concrete DeathTestFactory implementation for normal use.
1631cb0ef41Sopenharmony_ciclass DefaultDeathTestFactory : public DeathTestFactory {
1641cb0ef41Sopenharmony_ci public:
1651cb0ef41Sopenharmony_ci  bool Create(const char* statement, Matcher<const std::string&> matcher,
1661cb0ef41Sopenharmony_ci              const char* file, int line, DeathTest** test) override;
1671cb0ef41Sopenharmony_ci};
1681cb0ef41Sopenharmony_ci
1691cb0ef41Sopenharmony_ci// Returns true if exit_status describes a process that was terminated
1701cb0ef41Sopenharmony_ci// by a signal, or exited normally with a nonzero exit code.
1711cb0ef41Sopenharmony_ciGTEST_API_ bool ExitedUnsuccessfully(int exit_status);
1721cb0ef41Sopenharmony_ci
1731cb0ef41Sopenharmony_ci// A string passed to EXPECT_DEATH (etc.) is caught by one of these overloads
1741cb0ef41Sopenharmony_ci// and interpreted as a regex (rather than an Eq matcher) for legacy
1751cb0ef41Sopenharmony_ci// compatibility.
1761cb0ef41Sopenharmony_ciinline Matcher<const ::std::string&> MakeDeathTestMatcher(
1771cb0ef41Sopenharmony_ci    ::testing::internal::RE regex) {
1781cb0ef41Sopenharmony_ci  return ContainsRegex(regex.pattern());
1791cb0ef41Sopenharmony_ci}
1801cb0ef41Sopenharmony_ciinline Matcher<const ::std::string&> MakeDeathTestMatcher(const char* regex) {
1811cb0ef41Sopenharmony_ci  return ContainsRegex(regex);
1821cb0ef41Sopenharmony_ci}
1831cb0ef41Sopenharmony_ciinline Matcher<const ::std::string&> MakeDeathTestMatcher(
1841cb0ef41Sopenharmony_ci    const ::std::string& regex) {
1851cb0ef41Sopenharmony_ci  return ContainsRegex(regex);
1861cb0ef41Sopenharmony_ci}
1871cb0ef41Sopenharmony_ci
1881cb0ef41Sopenharmony_ci// If a Matcher<const ::std::string&> is passed to EXPECT_DEATH (etc.), it's
1891cb0ef41Sopenharmony_ci// used directly.
1901cb0ef41Sopenharmony_ciinline Matcher<const ::std::string&> MakeDeathTestMatcher(
1911cb0ef41Sopenharmony_ci    Matcher<const ::std::string&> matcher) {
1921cb0ef41Sopenharmony_ci  return matcher;
1931cb0ef41Sopenharmony_ci}
1941cb0ef41Sopenharmony_ci
1951cb0ef41Sopenharmony_ci// Traps C++ exceptions escaping statement and reports them as test
1961cb0ef41Sopenharmony_ci// failures. Note that trapping SEH exceptions is not implemented here.
1971cb0ef41Sopenharmony_ci#if GTEST_HAS_EXCEPTIONS
1981cb0ef41Sopenharmony_ci#define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test)           \
1991cb0ef41Sopenharmony_ci  try {                                                                      \
2001cb0ef41Sopenharmony_ci    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement);               \
2011cb0ef41Sopenharmony_ci  } catch (const ::std::exception& gtest_exception) {                        \
2021cb0ef41Sopenharmony_ci    fprintf(                                                                 \
2031cb0ef41Sopenharmony_ci        stderr,                                                              \
2041cb0ef41Sopenharmony_ci        "\n%s: Caught std::exception-derived exception escaping the "        \
2051cb0ef41Sopenharmony_ci        "death test statement. Exception message: %s\n",                     \
2061cb0ef41Sopenharmony_ci        ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \
2071cb0ef41Sopenharmony_ci        gtest_exception.what());                                             \
2081cb0ef41Sopenharmony_ci    fflush(stderr);                                                          \
2091cb0ef41Sopenharmony_ci    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
2101cb0ef41Sopenharmony_ci  } catch (...) {                                                            \
2111cb0ef41Sopenharmony_ci    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \
2121cb0ef41Sopenharmony_ci  }
2131cb0ef41Sopenharmony_ci
2141cb0ef41Sopenharmony_ci#else
2151cb0ef41Sopenharmony_ci#define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \
2161cb0ef41Sopenharmony_ci  GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
2171cb0ef41Sopenharmony_ci
2181cb0ef41Sopenharmony_ci#endif
2191cb0ef41Sopenharmony_ci
2201cb0ef41Sopenharmony_ci// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,
2211cb0ef41Sopenharmony_ci// ASSERT_EXIT*, and EXPECT_EXIT*.
2221cb0ef41Sopenharmony_ci#define GTEST_DEATH_TEST_(statement, predicate, regex_or_matcher, fail)        \
2231cb0ef41Sopenharmony_ci  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                                \
2241cb0ef41Sopenharmony_ci  if (::testing::internal::AlwaysTrue()) {                                     \
2251cb0ef41Sopenharmony_ci    ::testing::internal::DeathTest* gtest_dt;                                  \
2261cb0ef41Sopenharmony_ci    if (!::testing::internal::DeathTest::Create(                               \
2271cb0ef41Sopenharmony_ci            #statement,                                                        \
2281cb0ef41Sopenharmony_ci            ::testing::internal::MakeDeathTestMatcher(regex_or_matcher),       \
2291cb0ef41Sopenharmony_ci            __FILE__, __LINE__, &gtest_dt)) {                                  \
2301cb0ef41Sopenharmony_ci      goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__);                        \
2311cb0ef41Sopenharmony_ci    }                                                                          \
2321cb0ef41Sopenharmony_ci    if (gtest_dt != nullptr) {                                                 \
2331cb0ef41Sopenharmony_ci      std::unique_ptr< ::testing::internal::DeathTest> gtest_dt_ptr(gtest_dt); \
2341cb0ef41Sopenharmony_ci      switch (gtest_dt->AssumeRole()) {                                        \
2351cb0ef41Sopenharmony_ci        case ::testing::internal::DeathTest::OVERSEE_TEST:                     \
2361cb0ef41Sopenharmony_ci          if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) {                \
2371cb0ef41Sopenharmony_ci            goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__);                  \
2381cb0ef41Sopenharmony_ci          }                                                                    \
2391cb0ef41Sopenharmony_ci          break;                                                               \
2401cb0ef41Sopenharmony_ci        case ::testing::internal::DeathTest::EXECUTE_TEST: {                   \
2411cb0ef41Sopenharmony_ci          const ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \
2421cb0ef41Sopenharmony_ci              gtest_dt);                                                       \
2431cb0ef41Sopenharmony_ci          GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt);            \
2441cb0ef41Sopenharmony_ci          gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE);   \
2451cb0ef41Sopenharmony_ci          break;                                                               \
2461cb0ef41Sopenharmony_ci        }                                                                      \
2471cb0ef41Sopenharmony_ci      }                                                                        \
2481cb0ef41Sopenharmony_ci    }                                                                          \
2491cb0ef41Sopenharmony_ci  } else                                                                       \
2501cb0ef41Sopenharmony_ci    GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__)                                \
2511cb0ef41Sopenharmony_ci        : fail(::testing::internal::DeathTest::LastMessage())
2521cb0ef41Sopenharmony_ci// The symbol "fail" here expands to something into which a message
2531cb0ef41Sopenharmony_ci// can be streamed.
2541cb0ef41Sopenharmony_ci
2551cb0ef41Sopenharmony_ci// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
2561cb0ef41Sopenharmony_ci// NDEBUG mode. In this case we need the statements to be executed and the macro
2571cb0ef41Sopenharmony_ci// must accept a streamed message even though the message is never printed.
2581cb0ef41Sopenharmony_ci// The regex object is not evaluated, but it is used to prevent "unused"
2591cb0ef41Sopenharmony_ci// warnings and to avoid an expression that doesn't compile in debug mode.
2601cb0ef41Sopenharmony_ci#define GTEST_EXECUTE_STATEMENT_(statement, regex_or_matcher)    \
2611cb0ef41Sopenharmony_ci  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                  \
2621cb0ef41Sopenharmony_ci  if (::testing::internal::AlwaysTrue()) {                       \
2631cb0ef41Sopenharmony_ci    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement);   \
2641cb0ef41Sopenharmony_ci  } else if (!::testing::internal::AlwaysTrue()) {               \
2651cb0ef41Sopenharmony_ci    ::testing::internal::MakeDeathTestMatcher(regex_or_matcher); \
2661cb0ef41Sopenharmony_ci  } else                                                         \
2671cb0ef41Sopenharmony_ci    ::testing::Message()
2681cb0ef41Sopenharmony_ci
2691cb0ef41Sopenharmony_ci// A class representing the parsed contents of the
2701cb0ef41Sopenharmony_ci// --gtest_internal_run_death_test flag, as it existed when
2711cb0ef41Sopenharmony_ci// RUN_ALL_TESTS was called.
2721cb0ef41Sopenharmony_ciclass InternalRunDeathTestFlag {
2731cb0ef41Sopenharmony_ci public:
2741cb0ef41Sopenharmony_ci  InternalRunDeathTestFlag(const std::string& a_file, int a_line, int an_index,
2751cb0ef41Sopenharmony_ci                           int a_write_fd)
2761cb0ef41Sopenharmony_ci      : file_(a_file), line_(a_line), index_(an_index), write_fd_(a_write_fd) {}
2771cb0ef41Sopenharmony_ci
2781cb0ef41Sopenharmony_ci  ~InternalRunDeathTestFlag() {
2791cb0ef41Sopenharmony_ci    if (write_fd_ >= 0) posix::Close(write_fd_);
2801cb0ef41Sopenharmony_ci  }
2811cb0ef41Sopenharmony_ci
2821cb0ef41Sopenharmony_ci  const std::string& file() const { return file_; }
2831cb0ef41Sopenharmony_ci  int line() const { return line_; }
2841cb0ef41Sopenharmony_ci  int index() const { return index_; }
2851cb0ef41Sopenharmony_ci  int write_fd() const { return write_fd_; }
2861cb0ef41Sopenharmony_ci
2871cb0ef41Sopenharmony_ci private:
2881cb0ef41Sopenharmony_ci  std::string file_;
2891cb0ef41Sopenharmony_ci  int line_;
2901cb0ef41Sopenharmony_ci  int index_;
2911cb0ef41Sopenharmony_ci  int write_fd_;
2921cb0ef41Sopenharmony_ci
2931cb0ef41Sopenharmony_ci  InternalRunDeathTestFlag(const InternalRunDeathTestFlag&) = delete;
2941cb0ef41Sopenharmony_ci  InternalRunDeathTestFlag& operator=(const InternalRunDeathTestFlag&) = delete;
2951cb0ef41Sopenharmony_ci};
2961cb0ef41Sopenharmony_ci
2971cb0ef41Sopenharmony_ci// Returns a newly created InternalRunDeathTestFlag object with fields
2981cb0ef41Sopenharmony_ci// initialized from the GTEST_FLAG(internal_run_death_test) flag if
2991cb0ef41Sopenharmony_ci// the flag is specified; otherwise returns NULL.
3001cb0ef41Sopenharmony_ciInternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();
3011cb0ef41Sopenharmony_ci
3021cb0ef41Sopenharmony_ci#endif  // GTEST_HAS_DEATH_TEST
3031cb0ef41Sopenharmony_ci
3041cb0ef41Sopenharmony_ci}  // namespace internal
3051cb0ef41Sopenharmony_ci}  // namespace testing
3061cb0ef41Sopenharmony_ci
3071cb0ef41Sopenharmony_ci#endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_
308