Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/google/cpu_features.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/cpuinfo_x86_test.cc')
-rw-r--r--test/cpuinfo_x86_test.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/cpuinfo_x86_test.cc b/test/cpuinfo_x86_test.cc
index 10b9624..8737c81 100644
--- a/test/cpuinfo_x86_test.cc
+++ b/test/cpuinfo_x86_test.cc
@@ -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;