diff --git a/src/hwcaps.c b/src/hwcaps.c index 2bcac97..c1ac6e0 100644 --- a/src/hwcaps.c +++ b/src/hwcaps.c @@ -145,7 +145,7 @@ static uint32_t GetHardwareCapabilitiesFor(uint32_t type) { return hwcaps; } -HardwareCapabilities GetHardwareCapabilities(void) { +HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) { HardwareCapabilities capabilities; capabilities.hwcaps = GetHardwareCapabilitiesFor(AT_HWCAP); capabilities.hwcaps2 = GetHardwareCapabilitiesFor(AT_HWCAP2); diff --git a/test/filesystem_for_testing.cc b/test/filesystem_for_testing.cc index 886d510..7b05a88 100644 --- a/test/filesystem_for_testing.cc +++ b/test/filesystem_for_testing.cc @@ -81,7 +81,7 @@ FakeFilesystem& GetEmptyFilesystem() { return *kFilesystem; } -extern "C" int OpenFile(const char* filename) { +extern "C" int CpuFeatures_OpenFile(const char* filename) { auto* const file = kFilesystem->FindFileOrNull(filename); if (file) { file->Open(); @@ -90,11 +90,11 @@ extern "C" int OpenFile(const char* filename) { return -1; } -extern "C" void CloseFile(int file_descriptor) { +extern "C" void CpuFeatures_CloseFile(int file_descriptor) { kFilesystem->FindFileOrDie(file_descriptor)->Close(); } -extern "C" int ReadFile(int file_descriptor, void* buf, size_t count) { +extern "C" int CpuFeatures_ReadFile(int file_descriptor, void* buf, size_t count) { return kFilesystem->FindFileOrDie(file_descriptor) ->Read(file_descriptor, buf, count); } diff --git a/test/hwcaps_for_testing.cc b/test/hwcaps_for_testing.cc index f7e4729..0e78813 100644 --- a/test/hwcaps_for_testing.cc +++ b/test/hwcaps_for_testing.cc @@ -25,7 +25,7 @@ void SetHardwareCapabilities(uint32_t hwcaps, uint32_t hwcaps2) { g_hardware_capabilities->hwcaps2 = hwcaps2; } -HardwareCapabilities GetHardwareCapabilities(void) { +HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) { return *g_hardware_capabilities; } diff --git a/test/linux_features_aggregator_test.cc b/test/linux_features_aggregator_test.cc index 8410f63..7205d46 100644 --- a/test/linux_features_aggregator_test.cc +++ b/test/linux_features_aggregator_test.cc @@ -42,7 +42,7 @@ class LinuxFeatureAggregatorTest : public testing::Test { TEST_F(LinuxFeatureAggregatorTest, FromFlagsEmpty) { Features features; - SetFromFlags(kConfigs.size(), kConfigs.data(), str(""), &features); + CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str(""), &features); EXPECT_FALSE(features.a); EXPECT_FALSE(features.b); EXPECT_FALSE(features.c); @@ -50,7 +50,7 @@ TEST_F(LinuxFeatureAggregatorTest, FromFlagsEmpty) { TEST_F(LinuxFeatureAggregatorTest, FromFlagsAllSet) { Features features; - SetFromFlags(kConfigs.size(), kConfigs.data(), str("a c b"), &features); + CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str("a c b"), &features); EXPECT_TRUE(features.a); EXPECT_TRUE(features.b); EXPECT_TRUE(features.c); @@ -58,7 +58,7 @@ TEST_F(LinuxFeatureAggregatorTest, FromFlagsAllSet) { TEST_F(LinuxFeatureAggregatorTest, FromFlagsOnlyA) { Features features; - SetFromFlags(kConfigs.size(), kConfigs.data(), str("a"), &features); + CpuFeatures_SetFromFlags(kConfigs.size(), kConfigs.data(), str("a"), &features); EXPECT_TRUE(features.a); EXPECT_FALSE(features.b); EXPECT_FALSE(features.c); @@ -69,7 +69,7 @@ TEST_F(LinuxFeatureAggregatorTest, FromHwcapsNone) { capability.hwcaps = 0; // matches none capability.hwcaps2 = 0; // matches none Features features; - OverrideFromHwCaps(kConfigs.size(), kConfigs.data(), capability, &features); + CpuFeatures_OverrideFromHwCaps(kConfigs.size(), kConfigs.data(), capability, &features); EXPECT_FALSE(features.a); EXPECT_FALSE(features.b); EXPECT_FALSE(features.c); @@ -80,7 +80,7 @@ TEST_F(LinuxFeatureAggregatorTest, FromHwcapsSet) { capability.hwcaps = 0b0010; // matches b but not a capability.hwcaps2 = 0b1111; // matches c Features features; - OverrideFromHwCaps(kConfigs.size(), kConfigs.data(), capability, &features); + CpuFeatures_OverrideFromHwCaps(kConfigs.size(), kConfigs.data(), capability, &features); EXPECT_FALSE(features.a); EXPECT_TRUE(features.b); EXPECT_TRUE(features.c); diff --git a/test/stack_line_reader_test.cc b/test/stack_line_reader_test.cc index d255a9b..c8f9691 100644 --- a/test/stack_line_reader_test.cc +++ b/test/stack_line_reader_test.cc @@ -20,7 +20,7 @@ namespace cpu_features { bool operator==(const StringView& a, const StringView& b) { - return IsEquals(a, b); + return CpuFeatures_StringView_IsEquals(a, b); } namespace { diff --git a/test/string_view_test.cc b/test/string_view_test.cc index f9fa3da..a80c6ff 100644 --- a/test/string_view_test.cc +++ b/test/string_view_test.cc @@ -19,7 +19,7 @@ namespace cpu_features { bool operator==(const StringView& a, const StringView& b) { - return IsEquals(a, b); + return CpuFeatures_StringView_IsEquals(a, b); } namespace { @@ -35,95 +35,95 @@ TEST(StringViewTest, Build) { EXPECT_EQ(view.size, 4); } -TEST(StringViewTest, IndexOfChar) { +TEST(StringViewTest, CpuFeatures_StringView_IndexOfChar) { // Found. - EXPECT_EQ(IndexOfChar(str("test"), 'e'), 1); + EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(str("test"), 'e'), 1); // Not found. - EXPECT_EQ(IndexOfChar(str("test"), 'z'), -1); + EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(str("test"), 'z'), -1); // Empty. - EXPECT_EQ(IndexOfChar(kEmptyStringView, 'z'), -1); + EXPECT_EQ(CpuFeatures_StringView_IndexOfChar(kEmptyStringView, 'z'), -1); } -TEST(StringViewTest, IndexOf) { +TEST(StringViewTest, CpuFeatures_StringView_IndexOf) { // Found. - EXPECT_EQ(IndexOf(str("test"), str("es")), 1); + EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("test"), str("es")), 1); // Not found. - EXPECT_EQ(IndexOf(str("test"), str("aa")), -1); + EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("test"), str("aa")), -1); // Empty. - EXPECT_EQ(IndexOf(kEmptyStringView, str("aa")), -1); - EXPECT_EQ(IndexOf(str("aa"), kEmptyStringView), -1); + EXPECT_EQ(CpuFeatures_StringView_IndexOf(kEmptyStringView, str("aa")), -1); + EXPECT_EQ(CpuFeatures_StringView_IndexOf(str("aa"), kEmptyStringView), -1); } -TEST(StringViewTest, StartsWith) { - EXPECT_TRUE(StartsWith(str("test"), str("te"))); - EXPECT_FALSE(StartsWith(str("test"), str(""))); - EXPECT_FALSE(StartsWith(str("test"), kEmptyStringView)); - EXPECT_FALSE(StartsWith(kEmptyStringView, str("test"))); +TEST(StringViewTest, CpuFeatures_StringView_StartsWith) { + EXPECT_TRUE(CpuFeatures_StringView_StartsWith(str("test"), str("te"))); + EXPECT_FALSE(CpuFeatures_StringView_StartsWith(str("test"), str(""))); + EXPECT_FALSE(CpuFeatures_StringView_StartsWith(str("test"), kEmptyStringView)); + EXPECT_FALSE(CpuFeatures_StringView_StartsWith(kEmptyStringView, str("test"))); } -TEST(StringViewTest, IsEquals) { - EXPECT_TRUE(IsEquals(kEmptyStringView, kEmptyStringView)); - EXPECT_TRUE(IsEquals(kEmptyStringView, str(""))); - EXPECT_TRUE(IsEquals(str(""), kEmptyStringView)); - EXPECT_TRUE(IsEquals(str("a"), str("a"))); - EXPECT_FALSE(IsEquals(str("a"), str("b"))); - EXPECT_FALSE(IsEquals(str("a"), kEmptyStringView)); - EXPECT_FALSE(IsEquals(kEmptyStringView, str("a"))); +TEST(StringViewTest, CpuFeatures_StringView_IsEquals) { + EXPECT_TRUE(CpuFeatures_StringView_IsEquals(kEmptyStringView, kEmptyStringView)); + EXPECT_TRUE(CpuFeatures_StringView_IsEquals(kEmptyStringView, str(""))); + EXPECT_TRUE(CpuFeatures_StringView_IsEquals(str(""), kEmptyStringView)); + EXPECT_TRUE(CpuFeatures_StringView_IsEquals(str("a"), str("a"))); + EXPECT_FALSE(CpuFeatures_StringView_IsEquals(str("a"), str("b"))); + EXPECT_FALSE(CpuFeatures_StringView_IsEquals(str("a"), kEmptyStringView)); + EXPECT_FALSE(CpuFeatures_StringView_IsEquals(kEmptyStringView, str("a"))); } -TEST(StringViewTest, PopFront) { - EXPECT_EQ(PopFront(str("test"), 2), str("st")); - EXPECT_EQ(PopFront(str("test"), 0), str("test")); - EXPECT_EQ(PopFront(str("test"), 4), str("")); - EXPECT_EQ(PopFront(str("test"), 100), str("")); +TEST(StringViewTest, CpuFeatures_StringView_PopFront) { + EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 2), str("st")); + EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 0), str("test")); + EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 4), str("")); + EXPECT_EQ(CpuFeatures_StringView_PopFront(str("test"), 100), str("")); } -TEST(StringViewTest, ParsePositiveNumber) { - EXPECT_EQ(ParsePositiveNumber(str("42")), 42); - EXPECT_EQ(ParsePositiveNumber(str("0x2a")), 42); - EXPECT_EQ(ParsePositiveNumber(str("0x2A")), 42); +TEST(StringViewTest, CpuFeatures_StringView_ParsePositiveNumber) { + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("42")), 42); + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("0x2a")), 42); + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("0x2A")), 42); - EXPECT_EQ(ParsePositiveNumber(str("-0x2A")), -1); - EXPECT_EQ(ParsePositiveNumber(str("abc")), -1); - EXPECT_EQ(ParsePositiveNumber(str("")), -1); + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("-0x2A")), -1); + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("abc")), -1); + EXPECT_EQ(CpuFeatures_StringView_ParsePositiveNumber(str("")), -1); } -TEST(StringViewTest, CopyString) { +TEST(StringViewTest, CpuFeatures_StringView_CopyString) { char buf[4]; buf[0] = 'X'; // Empty - CopyString(str(""), buf, sizeof(buf)); + CpuFeatures_StringView_CopyString(str(""), buf, sizeof(buf)); EXPECT_STREQ(buf, ""); // Less - CopyString(str("a"), buf, sizeof(buf)); + CpuFeatures_StringView_CopyString(str("a"), buf, sizeof(buf)); EXPECT_STREQ(buf, "a"); // exact - CopyString(str("abc"), buf, sizeof(buf)); + CpuFeatures_StringView_CopyString(str("abc"), buf, sizeof(buf)); EXPECT_STREQ(buf, "abc"); // More - CopyString(str("abcd"), buf, sizeof(buf)); + CpuFeatures_StringView_CopyString(str("abcd"), buf, sizeof(buf)); EXPECT_STREQ(buf, "abc"); } -TEST(StringViewTest, HasWord) { +TEST(StringViewTest, CpuFeatures_StringView_HasWord) { // Find flags at beginning, middle and end. - EXPECT_TRUE(HasWord(str("first middle last"), "first")); - EXPECT_TRUE(HasWord(str("first middle last"), "middle")); - EXPECT_TRUE(HasWord(str("first middle last"), "last")); + EXPECT_TRUE(CpuFeatures_StringView_HasWord(str("first middle last"), "first")); + EXPECT_TRUE(CpuFeatures_StringView_HasWord(str("first middle last"), "middle")); + EXPECT_TRUE(CpuFeatures_StringView_HasWord(str("first middle last"), "last")); // Do not match partial flags - EXPECT_FALSE(HasWord(str("first middle last"), "irst")); - EXPECT_FALSE(HasWord(str("first middle last"), "mid")); - EXPECT_FALSE(HasWord(str("first middle last"), "las")); + EXPECT_FALSE(CpuFeatures_StringView_HasWord(str("first middle last"), "irst")); + EXPECT_FALSE(CpuFeatures_StringView_HasWord(str("first middle last"), "mid")); + EXPECT_FALSE(CpuFeatures_StringView_HasWord(str("first middle last"), "las")); } -TEST(StringViewTest, GetAttributeKeyValue) { +TEST(StringViewTest, CpuFeatures_StringView_GetAttributeKeyValue) { const StringView line = str(" key : first middle last "); StringView key, value; - EXPECT_TRUE(GetAttributeKeyValue(line, &key, &value)); + EXPECT_TRUE(CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)); EXPECT_EQ(key, str("key")); EXPECT_EQ(value, str("first middle last")); } @@ -131,7 +131,7 @@ TEST(StringViewTest, GetAttributeKeyValue) { TEST(StringViewTest, FailingGetAttributeKeyValue) { const StringView line = str("key first middle last"); StringView key, value; - EXPECT_FALSE(GetAttributeKeyValue(line, &key, &value)); + EXPECT_FALSE(CpuFeatures_StringView_GetAttributeKeyValue(line, &key, &value)); } } // namespace