BionicDeathTest.h revision 9df70403d95f5cfe6824e38a9a6c35f9b9bbc76a
19df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui/* 29df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * Copyright (C) 2014 The Android Open Source Project 39df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * 49df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * Licensed under the Apache License, Version 2.0 (the "License"); 59df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * you may not use this file except in compliance with the License. 69df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * You may obtain a copy of the License at 79df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * 89df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * http://www.apache.org/licenses/LICENSE-2.0 99df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * 109df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * Unless required by applicable law or agreed to in writing, software 119df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * distributed under the License is distributed on an "AS IS" BASIS, 129df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * See the License for the specific language governing permissions and 149df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui * limitations under the License. 159df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui */ 169df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui 179df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui#ifndef BIONIC_TESTS_BIONIC_DEATH_TEST_H_ 189df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui#define BIONIC_TESTS_BIONIC_DEATH_TEST_H_ 199df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui 209df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui#include <gtest/gtest.h> 219df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui 229df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui#include <sys/prctl.h> 239df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui 249df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cuiclass BionicDeathTest : public testing::Test { 259df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui protected: 269df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui virtual void SetUp() { 279df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui // Suppress debuggerd stack traces. Too slow. 289df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui old_dumpable_ = prctl(PR_GET_DUMPABLE, 0, 0, 0, 0); 299df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui prctl(PR_SET_DUMPABLE, 0, 0, 0, 0); 309df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui ::testing::FLAGS_gtest_death_test_style = "threadsafe"; 319df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui } 329df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui 339df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui virtual void TearDown() { 349df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui prctl(PR_SET_DUMPABLE, old_dumpable_, 0, 0, 0, 0); 359df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui } 369df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui 379df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui private: 389df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui int old_dumpable_; 399df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui}; 409df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui 419df70403d95f5cfe6824e38a9a6c35f9b9bbc76aYabin Cui#endif // BIONIC_TESTS_BIONIC_DEATH_TEST_H_ 42