• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 #include <exception>
16 #include <iostream>
17 #include <string>
18 #include <thread>
19 #include <gtest/gtest.h>
20 #include <unistd.h>
21 #include <cstring>
22 #include <cstdint>
23 #include <cstdio>
24 #include <functional>
25 #include <chrono>
26 #include "lock_frequency.h"
27 #include "GpuCounter.h"
28 
29 using namespace testing::ext;
30 using namespace std;
31 
32 namespace OHOS {
33 namespace SmartPerf {
34 class SPdaemonLockFrequencyTest : public testing::Test {
35 public:
SetUpTestCase()36     static void SetUpTestCase() {}
TearDownTestCase()37     static void TearDownTestCase() {}
SetUp()38     void SetUp() {}
TearDown()39     void TearDown() {}
40 };
41 
42 /**
43  * @tc.name: LockFrequency::LockingThread
44  * @tc.desc: Test LockingThread
45  * @tc.type: FUNC
46  */
47 HWTEST_F(SPdaemonLockFrequencyTest, LockingThreadTestCase, TestSize.Level1)
48 {
49     LockFrequency::GetInstance().SetIsCollecting(true);
__anon6702d0be0102() 50     std::thread lock = std::thread([this]() {
51         LockFrequency::GetInstance().LockingThread();
52     });
53     std::this_thread::sleep_for(std::chrono::milliseconds(2000));
54     LockFrequency::GetInstance().SetIsCollecting(false);
55     lock.join();
56 }
57 }
58 }