blob: 3e8d7b231c1cc97d23c4217f9043b143b425dcdd [file] [log] [blame]
Yabin Cui9df70402014-11-05 18:01:01 -08001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef BIONIC_TESTS_BIONIC_DEATH_TEST_H_
18#define BIONIC_TESTS_BIONIC_DEATH_TEST_H_
19
Josh Gao084f6ec2017-10-12 13:32:45 -070020#include <signal.h>
Yabin Cui9df70402014-11-05 18:01:01 -080021
Josh Gao084f6ec2017-10-12 13:32:45 -070022#include <gtest/gtest.h>
Yabin Cui9df70402014-11-05 18:01:01 -080023
24class BionicDeathTest : public testing::Test {
25 protected:
26 virtual void SetUp() {
27 // Suppress debuggerd stack traces. Too slow.
Josh Gao084f6ec2017-10-12 13:32:45 -070028 for (int signo : { SIGABRT, SIGBUS, SIGSEGV, SIGSYS }) {
29 struct sigaction action = {};
30 action.sa_handler = SIG_DFL;
31 sigaction(signo, &action, &previous_);
32 }
Yabin Cui9df70402014-11-05 18:01:01 -080033 }
34
35 virtual void TearDown() {
Josh Gao084f6ec2017-10-12 13:32:45 -070036 for (int signo : { SIGABRT, SIGBUS, SIGSEGV, SIGSYS }) {
37 sigaction(signo, &previous_, nullptr);
38 }
Yabin Cui9df70402014-11-05 18:01:01 -080039 }
40
41 private:
Josh Gao084f6ec2017-10-12 13:32:45 -070042 struct sigaction previous_;
Yabin Cui9df70402014-11-05 18:01:01 -080043};
44
45#endif // BIONIC_TESTS_BIONIC_DEATH_TEST_H_