mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
Change-Id: I2014117a154fb2c1a61af5c31baa228b4fb3dbc2 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
/*
|
|
* Copyright (C) 2018-2020 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "gmock/gmock.h"
|
|
#include "gtest/gtest.h"
|
|
#include "segfault_helper.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
extern void generateSegfaultWithSafetyGuard(SegfaultHelper *segfaultHelper);
|
|
|
|
int main(int argc, char **argv) {
|
|
int retVal = 0;
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
retVal = RUN_ALL_TESTS();
|
|
|
|
return retVal;
|
|
}
|
|
|
|
void captureAndCheckStdOut() {
|
|
std::string callstack = ::testing::internal::GetCapturedStdout();
|
|
|
|
EXPECT_THAT(callstack, ::testing::HasSubstr(std::string("Callstack")));
|
|
EXPECT_THAT(callstack, ::testing::HasSubstr(std::string("cloc_segfault_test")));
|
|
EXPECT_THAT(callstack, ::testing::HasSubstr(std::string("generateSegfaultWithSafetyGuard")));
|
|
}
|
|
|
|
TEST(SegFault, givenCallWithSafetyGuardWhenSegfaultHappensThenCallstackIsPrintedToStdOut) {
|
|
#if !defined(SKIP_SEGFAULT_TEST)
|
|
::testing::internal::CaptureStdout();
|
|
SegfaultHelper segfault;
|
|
segfault.segfaultHandlerCallback = captureAndCheckStdOut;
|
|
|
|
generateSegfaultWithSafetyGuard(&segfault);
|
|
#endif
|
|
}
|