diff options
| author | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
| commit | be933ef2241d79558f91796cc5b3a161f72ebf9c (patch) | |
| tree | fe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/test/TestCPUInfo.cpp | |
| parent | 5f8335c1e49ce108ef3481863833c98efa00411b (diff) | |
| download | kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2 kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip | |
sync with upstream
Diffstat (limited to 'xbmc/utils/test/TestCPUInfo.cpp')
| -rw-r--r-- | xbmc/utils/test/TestCPUInfo.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/xbmc/utils/test/TestCPUInfo.cpp b/xbmc/utils/test/TestCPUInfo.cpp new file mode 100644 index 0000000..bd9572a --- /dev/null +++ b/xbmc/utils/test/TestCPUInfo.cpp | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #if defined(TARGET_WINDOWS) | ||
| 10 | # include <windows.h> | ||
| 11 | #endif | ||
| 12 | |||
| 13 | #include "ServiceBroker.h" | ||
| 14 | #include "settings/AdvancedSettings.h" | ||
| 15 | #include "settings/SettingsComponent.h" | ||
| 16 | #include "utils/CPUInfo.h" | ||
| 17 | #include "utils/Temperature.h" | ||
| 18 | #include "utils/XTimeUtils.h" | ||
| 19 | |||
| 20 | #include <gtest/gtest.h> | ||
| 21 | |||
| 22 | struct TestCPUInfo : public ::testing::Test | ||
| 23 | { | ||
| 24 | TestCPUInfo() { CServiceBroker::RegisterCPUInfo(CCPUInfo::GetCPUInfo()); } | ||
| 25 | |||
| 26 | ~TestCPUInfo() { CServiceBroker::UnregisterCPUInfo(); } | ||
| 27 | }; | ||
| 28 | |||
| 29 | TEST_F(TestCPUInfo, GetUsedPercentage) | ||
| 30 | { | ||
| 31 | EXPECT_GE(CServiceBroker::GetCPUInfo()->GetUsedPercentage(), 0); | ||
| 32 | } | ||
| 33 | |||
| 34 | TEST_F(TestCPUInfo, GetCPUCount) | ||
| 35 | { | ||
| 36 | EXPECT_GT(CServiceBroker::GetCPUInfo()->GetCPUCount(), 0); | ||
| 37 | } | ||
| 38 | |||
| 39 | TEST_F(TestCPUInfo, GetCPUFrequency) | ||
| 40 | { | ||
| 41 | EXPECT_GE(CServiceBroker::GetCPUInfo()->GetCPUFrequency(), 0.f); | ||
| 42 | } | ||
| 43 | |||
| 44 | #if defined(TARGET_WINDOWS) | ||
| 45 | TEST_F(TestCPUInfo, DISABLED_GetTemperature) | ||
| 46 | #else | ||
| 47 | TEST_F(TestCPUInfo, GetTemperature) | ||
| 48 | #endif | ||
| 49 | { | ||
| 50 | CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_cpuTempCmd = "echo '50 c'"; | ||
| 51 | CTemperature t; | ||
| 52 | EXPECT_TRUE(CServiceBroker::GetCPUInfo()->GetTemperature(t)); | ||
| 53 | EXPECT_TRUE(t.IsValid()); | ||
| 54 | } | ||
| 55 | |||
| 56 | TEST_F(TestCPUInfo, CoreInfo) | ||
| 57 | { | ||
| 58 | ASSERT_TRUE(CServiceBroker::GetCPUInfo()->HasCoreId(0)); | ||
| 59 | const CoreInfo c = CServiceBroker::GetCPUInfo()->GetCoreInfo(0); | ||
| 60 | EXPECT_TRUE(c.m_id == 0); | ||
| 61 | } | ||
| 62 | |||
| 63 | TEST_F(TestCPUInfo, GetCoresUsageString) | ||
| 64 | { | ||
| 65 | EXPECT_STRNE("", CServiceBroker::GetCPUInfo()->GetCoresUsageString().c_str()); | ||
| 66 | } | ||
| 67 | |||
| 68 | TEST_F(TestCPUInfo, GetCPUFeatures) | ||
| 69 | { | ||
| 70 | unsigned int a = CServiceBroker::GetCPUInfo()->GetCPUFeatures(); | ||
| 71 | (void)a; | ||
| 72 | } | ||
