Skip to content

Commit cd67a9f

Browse files
committed
fix(ci): guard <cpuid.h> and raw CPUID test in test_cpu_features with DEGLIB_X86
1 parent f876b71 commit cd67a9f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

cpp/test/src/test_cpu_features.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <deglib.h>
55

6+
#if defined(DEGLIB_X86)
67
#if defined(_MSC_VER)
78
#include <intrin.h>
89
#else
@@ -17,8 +18,10 @@ static void get_cpuid(int leaf, int subleaf, int cpu_info[4]) {
1718
__cpuid_count(leaf, subleaf, cpu_info[0], cpu_info[1], cpu_info[2], cpu_info[3]);
1819
#endif
1920
}
21+
#endif
2022

2123
TEST(CPUFeaturesTest, CpuHelperFunctionsMatchRawCPUID) {
24+
#if defined(DEGLIB_X86)
2225
int cpu_info[4] = {0};
2326
get_cpuid(1, 0, cpu_info);
2427

@@ -38,4 +41,14 @@ TEST(CPUFeaturesTest, CpuHelperFunctionsMatchRawCPUID) {
3841
EXPECT_EQ(deglib::cpu::has_avx512(), hw_avx512f) << "deglib::cpu::has_avx512() does not match raw CPUID";
3942

4043
std::cout << "[CPU Test] deglib::cpu helper functions verified against raw CPUID" << std::endl;
44+
#else
45+
// On non-x86 architectures (e.g. ARM), x86 feature flags must all be false
46+
EXPECT_FALSE(deglib::cpu::has_sse42());
47+
EXPECT_FALSE(deglib::cpu::has_f16c());
48+
EXPECT_FALSE(deglib::cpu::has_avx());
49+
EXPECT_FALSE(deglib::cpu::has_avx2());
50+
EXPECT_FALSE(deglib::cpu::has_avx512());
51+
52+
std::cout << "[CPU Test] Non-x86 architecture detected: all x86 SIMD features set to false as expected" << std::endl;
53+
#endif
4154
}

0 commit comments

Comments
 (0)