1
0
mirror of https://github.com/google/cpu_features.git synced 2025-07-04 22:45:17 +02:00

Support disabling of extensions

Fixes #101
This commit is contained in:
Guillaume Chatelet
2020-01-17 16:53:37 +01:00
parent 24b8a1de17
commit eb59787849
5 changed files with 70 additions and 0 deletions

View File

@ -101,6 +101,26 @@ TEST(CpuidX86Test, SandyBridge) {
EXPECT_FALSE(features.rdrnd);
}
TEST(CpuidX86Test, ForgingCpuWithInterceptor) {
RegisterX86InfoInterceptor([](X86Info* info) {
memcpy(info->vendor, "TEST", sizeof("TEST"));
info->features = X86Features{};
info->features.erms = true;
});
const auto info = GetX86Info();
EXPECT_STREQ(info.vendor, "GenuineIntel");
const auto& features = info.features;
for (size_t i = 0; i < X86_LAST_; ++i)
if (i == X86_ERMS)
EXPECT_TRUE(GetX86FeaturesEnumValue(&features, (X86FeaturesEnum)i));
else
EXPECT_FALSE(GetX86FeaturesEnumValue(&features, (X86FeaturesEnum)i));
RegisterX86InfoInterceptor(NULL);
EXPECT_STREQ(GetX86Info().vendor, "GenuineIntel");
}
const int KiB = 1024;
const int MiB = 1024 * KiB;