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::ItemData 44 * @tc.desc: Test ItemData 45 * @tc.type: FUNC 46 */ 47 HWTEST_F(SPdaemonLockFrequencyTest, ItemDataTestCase, TestSize.Level1) 48 { 49 std::map<std::string, std::string> result = LockFrequency::GetInstance().ItemData(); 50 EXPECT_EQ(result.size(), 0); 51 } 52 53 /** 54 * @tc.name: LockFrequency::LockingThread 55 * @tc.desc: Test LockingThread 56 * @tc.type: FUNC 57 */ 58 HWTEST_F(SPdaemonLockFrequencyTest, LockingThreadTestCase, TestSize.Level1) 59 { 60 LockFrequency::GetInstance().SetIsCollecting(true); __anon6e73598e0102() 61 std::thread lock = std::thread([this]() { 62 LockFrequency::GetInstance().LockingThread(); 63 }); 64 std::this_thread::sleep_for(std::chrono::milliseconds(2000)); 65 LockFrequency::GetInstance().SetIsCollecting(false); 66 lock.join(); 67 } 68 } 69 }