1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-19 05:33:02 +00:00

cpu_features: test enum macro consistency

This commit is contained in:
Carles Fernandez 2022-07-28 13:09:49 +02:00
parent 6ec452a7c0
commit 701306ab26
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
5 changed files with 95 additions and 10 deletions

View File

@ -135,6 +135,20 @@ void DisableHardwareCapabilities()
SetHardwareCapabilities(0, 0); SetHardwareCapabilities(0, 0);
} }
TEST(CpuinfoAarch64Test, Aarch64FeaturesEnum)
{
const char *last_name = GetAarch64FeaturesEnumName(AARCH64_LAST_);
EXPECT_STREQ(last_name, "unknown_feature");
for (int i = static_cast<int>(AARCH64_FP); i != static_cast<int>(AARCH64_LAST_); ++i)
{
const auto feature = static_cast<Aarch64FeaturesEnum>(i);
const char *name = GetAarch64FeaturesEnumName(feature);
ASSERT_FALSE(name == nullptr);
EXPECT_STRNE(name, "");
EXPECT_STRNE(name, last_name);
}
}
TEST(CpuinfoAarch64Test, FromHardwareCap) TEST(CpuinfoAarch64Test, FromHardwareCap)
{ {
ResetHwcaps(); ResetHwcaps();

View File

@ -10,6 +10,21 @@ namespace cpu_features
{ {
namespace namespace
{ {
TEST(CpuinfoArmTest, ArmFeaturesEnum)
{
const char* last_name = GetArmFeaturesEnumName(ARM_LAST_);
EXPECT_STREQ(last_name, "unknown_feature");
for (int i = static_cast<int>(ARM_SWP); i != static_cast<int>(ARM_LAST_); ++i)
{
const auto feature = static_cast<ArmFeaturesEnum>(i);
const char* name = GetArmFeaturesEnumName(feature);
ASSERT_FALSE(name == nullptr);
EXPECT_STRNE(name, "");
EXPECT_STRNE(name, last_name);
}
}
TEST(CpuinfoArmTest, FromHardwareCap) TEST(CpuinfoArmTest, FromHardwareCap)
{ {
ResetHwcaps(); ResetHwcaps();

View File

@ -12,6 +12,20 @@ namespace cpu_features
{ {
namespace namespace
{ {
TEST(CpuinfoMipsTest, MipsFeaturesEnum)
{
const char* last_name = GetMipsFeaturesEnumName(MIPS_LAST_);
EXPECT_STREQ(last_name, "unknown_feature");
for (int i = static_cast<int>(MIPS_MSA); i != static_cast<int>(MIPS_LAST_); ++i)
{
const auto feature = static_cast<MipsFeaturesEnum>(i);
const char* name = GetMipsFeaturesEnumName(feature);
ASSERT_FALSE(name == nullptr);
EXPECT_STRNE(name, "");
EXPECT_STRNE(name, last_name);
}
}
TEST(CpuinfoMipsTest, FromHardwareCapBoth) TEST(CpuinfoMipsTest, FromHardwareCapBoth)
{ {
ResetHwcaps(); ResetHwcaps();

View File

@ -11,6 +11,20 @@ namespace cpu_features
{ {
namespace namespace
{ {
TEST(CpustringsPPCTest, PPCFeaturesEnum)
{
const char* last_name = GetPPCFeaturesEnumName(PPC_LAST_);
EXPECT_STREQ(last_name, "unknown_feature");
for (int i = static_cast<int>(PPC_32); i != static_cast<int>(PPC_LAST_); ++i)
{
const auto feature = static_cast<PPCFeaturesEnum>(i);
const char* name = GetPPCFeaturesEnumName(feature);
ASSERT_FALSE(name == nullptr);
EXPECT_STRNE(name, "");
EXPECT_STRNE(name, last_name);
}
}
TEST(CpustringsPPCTest, FromHardwareCap) TEST(CpustringsPPCTest, FromHardwareCap)
{ {
ResetHwcaps(); ResetHwcaps();

View File

@ -124,6 +124,34 @@ protected:
} }
}; };
TEST_F(CpuidX86Test, X86MicroarchitectureEnum)
{
const char *last_name = GetX86MicroarchitectureName(X86_MICROARCHITECTURE_LAST_);
EXPECT_STREQ(last_name, "unknown microarchitecture");
for (int i = static_cast<int>(X86_UNKNOWN); i != static_cast<int>(X86_MICROARCHITECTURE_LAST_); ++i)
{
const auto micro = static_cast<X86Microarchitecture>(i);
const char *name = GetX86MicroarchitectureName(micro);
ASSERT_FALSE(name == nullptr);
EXPECT_STRNE(name, "");
EXPECT_STRNE(name, last_name);
}
}
TEST_F(CpuidX86Test, X86FeaturesEnum)
{
const char *last_name = GetX86FeaturesEnumName(X86_LAST_);
EXPECT_STREQ(last_name, "unknown_feature");
for (int i = static_cast<int>(X86_FPU); i != static_cast<int>(X86_LAST_); ++i)
{
const auto feature = static_cast<X86FeaturesEnum>(i);
const char *name = GetX86FeaturesEnumName(feature);
ASSERT_FALSE(name == nullptr);
EXPECT_STRNE(name, "");
EXPECT_STRNE(name, last_name);
}
}
TEST_F(CpuidX86Test, SandyBridge) TEST_F(CpuidX86Test, SandyBridge)
{ {
cpu().SetOsBackupsExtendedRegisters(true); cpu().SetOsBackupsExtendedRegisters(true);