• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 XCOLLIE_CHECKER_TEST_H
17 #define XCOLLIE_CHECKER_TEST_H
18 
19 #include <memory>
20 #include <string>
21 #include <thread>
22 
23 #include "xcollie_checker.h"
24 
25 namespace OHOS {
26 namespace HiviewDFX {
27 class XCollieCheckerTest : public XCollieChecker {
28 public:
29     explicit XCollieCheckerTest(const std::string name);
30     ~XCollieCheckerTest();
31 
32     void CheckLock();
33     void CheckThreadBlock();
SetBlockTime(int time)34     void SetBlockTime(int time)
35     {
36         timeout_ = time;
37     }
38     void SetThreadBlockComplete();
GetTestLockNumber()39     int GetTestLockNumber() const
40     {
41         return testLockNumber_;
42     }
GetTestThreadNumber()43     int GetTestThreadNumber() const
44     {
45         return testThreadNumber_;
46     }
47 private:
48     int timeout_;
49     int testLockNumber_;
50     int testThreadNumber_;
51     bool threadEnd_;
52     std::unique_ptr<std::thread> thread_;
53 };
54 } // end of namespace HiviewDFX
55 } // end of namespace OHOS
56 #endif
57 
58