1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RELIABILITY_MAIN_THREAD_SAMPLER_TEST_H 17 #define RELIABILITY_MAIN_THREAD_SAMPLER_TEST_H 18 19 #include <gtest/gtest.h> 20 21 namespace OHOS { 22 namespace HiviewDFX { 23 typedef int (*ThreadSamplerInitFunc)(int); 24 typedef int32_t (*ThreadSamplerSampleFunc)(); 25 typedef int (*ThreadSamplerCollectFunc)(char*, size_t, int); 26 typedef int (*ThreadSamplerDeinitFunc)(); 27 typedef void (*SigActionType)(int, siginfo_t*, void*); 28 29 class ThreadSamplerTest : public testing::Test { 30 public: 31 static void SetUpTestCase(void); 32 static void TearDownTestCase(void); 33 void SetUp(); 34 void TearDown(); 35 36 bool InitThreadSamplerFuncs(); 37 static void ThreadSamplerSigHandler(int sig, siginfo_t* si, void* context); 38 bool InstallThreadSamplerSignal(); 39 void UninstallThreadSamplerSignal(); 40 bool InitThreadSampler(); 41 42 void* threadSamplerFuncHandler_ {nullptr}; 43 ThreadSamplerInitFunc threadSamplerInitFunc_ {nullptr}; 44 ThreadSamplerSampleFunc threadSamplerSampleFunc_ {nullptr}; 45 ThreadSamplerCollectFunc threadSamplerCollectFunc_ {nullptr}; 46 ThreadSamplerDeinitFunc threadSamplerDeinitFunc_ {nullptr}; 47 48 static SigActionType threadSamplerSigHandler_; 49 }; 50 } // end of namespace HiviewDFX 51 } // end of namespace OHOS 52 #endif 53