blob: f70839a0f4d3b8cd14cb3b9f0f47a8c341cb0236 [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
Elliott Hughesd63ea562021-02-18 17:15:25 -080017#pragma once
Yabin Cui9df70402014-11-05 18:01:01 -080018
Josh Gao084f6ec2017-10-12 13:32:45 -070019#include <signal.h>
Yabin Cui9df70402014-11-05 18:01:01 -080020
Josh Gao084f6ec2017-10-12 13:32:45 -070021#include <gtest/gtest.h>
Yabin Cui9df70402014-11-05 18:01:01 -080022
Elliott Hughes3e235912018-02-01 14:21:51 -080023#if !defined(__BIONIC__)
24#define sigaction64 sigaction
25#endif
26
Yabin Cui9df70402014-11-05 18:01:01 -080027class BionicDeathTest : public testing::Test {
28 protected:
29 virtual void SetUp() {
30 // Suppress debuggerd stack traces. Too slow.
Josh Gao084f6ec2017-10-12 13:32:45 -070031 for (int signo : { SIGABRT, SIGBUS, SIGSEGV, SIGSYS }) {
Elliott Hughes3e235912018-02-01 14:21:51 -080032 struct sigaction64 action = { .sa_handler = SIG_DFL };
33 sigaction64(signo, &action, &previous_);
Josh Gao084f6ec2017-10-12 13:32:45 -070034 }
Yabin Cui9df70402014-11-05 18:01:01 -080035 }
36
37 virtual void TearDown() {
Josh Gao084f6ec2017-10-12 13:32:45 -070038 for (int signo : { SIGABRT, SIGBUS, SIGSEGV, SIGSYS }) {
Elliott Hughes3e235912018-02-01 14:21:51 -080039 sigaction64(signo, &previous_, nullptr);
Josh Gao084f6ec2017-10-12 13:32:45 -070040 }
Yabin Cui9df70402014-11-05 18:01:01 -080041 }
42
43 private:
Elliott Hughes3e235912018-02-01 14:21:51 -080044 struct sigaction64 previous_;
Yabin Cui9df70402014-11-05 18:01:01 -080045};