1 /* 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * All rights reserved. 4 * 5 * This source code is licensed under the BSD-style license found in the 6 * LICENSE file in the root directory of this source tree. 7 */ 8 9 /** 10 * @file 11 * Death test utility macros. 12 */ 13 14 #pragma once 15 16 #include <gtest/gtest.h> 17 18 #if ET_BUILD_MODE_COV 19 20 /** 21 * TODO(T124640221): Work around a seg fault when running death tests in 22 * @mode/dbgo-cov. If the root cause of that bug is fixed, remove this 23 * ET_EXPECT_DEATH wrapper and go back to calling EXPECT_DEATH directly from 24 * tests. 25 */ 26 #define ET_EXPECT_DEATH(_statement, _matcher) ((void)0) 27 28 #else // ET_BUILD_MODE_COV 29 30 /** 31 * Ensure the executable will abort when `_statement` is executed. 32 * 33 * @param _statement Statement to execute. 34 * @param _matcher Regex or matcher to match against the stderr output of 35 * the dying process. If this does not match, the test will fail. 36 */ 37 #define ET_EXPECT_DEATH(_statement, _matcher) \ 38 EXPECT_DEATH_IF_SUPPORTED(_statement, _matcher) 39 40 #endif // ET_BUILD_MODE_COV 41