xref: /aosp_15_r20/external/cpu_features/test/CMakeLists.txt (revision eca53ba6d2e951e174b64682eaf56a36b8204c89)
1*eca53ba6SRoland Levillain#
2*eca53ba6SRoland Levillain# libraries for tests
3*eca53ba6SRoland Levillain#
4*eca53ba6SRoland Levillain
5*eca53ba6SRoland Levillaininclude_directories(../include)
6*eca53ba6SRoland Levillainadd_definitions(-DCPU_FEATURES_TEST)
7*eca53ba6SRoland Levillain
8*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
9*eca53ba6SRoland Levillainadd_library(string_view ../src/string_view.c)
10*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
11*eca53ba6SRoland Levillainadd_library(filesystem_for_testing filesystem_for_testing.cc)
12*eca53ba6SRoland Levillaintarget_compile_definitions(filesystem_for_testing PUBLIC CPU_FEATURES_MOCK_FILESYSTEM)
13*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
14*eca53ba6SRoland Levillainadd_library(hwcaps_for_testing hwcaps_for_testing.cc)
15*eca53ba6SRoland Levillaintarget_link_libraries(hwcaps_for_testing filesystem_for_testing)
16*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
17*eca53ba6SRoland Levillainadd_library(stack_line_reader ../src/stack_line_reader.c)
18*eca53ba6SRoland Levillaintarget_compile_definitions(stack_line_reader PUBLIC STACK_LINE_READER_BUFFER_SIZE=1024)
19*eca53ba6SRoland Levillaintarget_link_libraries(stack_line_reader string_view)
20*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
21*eca53ba6SRoland Levillainadd_library(stack_line_reader_for_test ../src/stack_line_reader.c)
22*eca53ba6SRoland Levillaintarget_compile_definitions(stack_line_reader_for_test PUBLIC STACK_LINE_READER_BUFFER_SIZE=16)
23*eca53ba6SRoland Levillaintarget_link_libraries(stack_line_reader_for_test string_view filesystem_for_testing)
24*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
25*eca53ba6SRoland Levillainadd_library(all_libraries ../src/hwcaps.c  ../src/stack_line_reader.c)
26*eca53ba6SRoland Levillaintarget_link_libraries(all_libraries hwcaps_for_testing stack_line_reader string_view)
27*eca53ba6SRoland Levillain
28*eca53ba6SRoland Levillain#
29*eca53ba6SRoland Levillain# tests
30*eca53ba6SRoland Levillain#
31*eca53ba6SRoland Levillainlink_libraries(gtest gmock_main)
32*eca53ba6SRoland Levillain
33*eca53ba6SRoland Levillain## bit_utils_test
34*eca53ba6SRoland Levillainadd_executable(bit_utils_test bit_utils_test.cc)
35*eca53ba6SRoland Levillaintarget_link_libraries(bit_utils_test)
36*eca53ba6SRoland Levillainadd_test(NAME bit_utils_test COMMAND bit_utils_test)
37*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
38*eca53ba6SRoland Levillain## string_view_test
39*eca53ba6SRoland Levillainadd_executable(string_view_test string_view_test.cc ../src/string_view.c)
40*eca53ba6SRoland Levillaintarget_link_libraries(string_view_test string_view)
41*eca53ba6SRoland Levillainadd_test(NAME string_view_test COMMAND string_view_test)
42*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
43*eca53ba6SRoland Levillain## stack_line_reader_test
44*eca53ba6SRoland Levillainadd_executable(stack_line_reader_test stack_line_reader_test.cc)
45*eca53ba6SRoland Levillaintarget_link_libraries(stack_line_reader_test stack_line_reader_for_test)
46*eca53ba6SRoland Levillainadd_test(NAME stack_line_reader_test COMMAND stack_line_reader_test)
47*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
48*eca53ba6SRoland Levillain## cpuinfo_x86_test
49*eca53ba6SRoland Levillainif(PROCESSOR_IS_X86)
50*eca53ba6SRoland Levillain  add_executable(cpuinfo_x86_test
51*eca53ba6SRoland Levillain    cpuinfo_x86_test.cc
52*eca53ba6SRoland Levillain    ../src/impl_x86_freebsd.c
53*eca53ba6SRoland Levillain    ../src/impl_x86_linux_or_android.c
54*eca53ba6SRoland Levillain    ../src/impl_x86_macos.c
55*eca53ba6SRoland Levillain    ../src/impl_x86_windows.c
56*eca53ba6SRoland Levillain  )
57*eca53ba6SRoland Levillain  target_compile_definitions(cpuinfo_x86_test PUBLIC CPU_FEATURES_MOCK_CPUID_X86)
58*eca53ba6SRoland Levillain  if(APPLE)
59*eca53ba6SRoland Levillain    target_compile_definitions(cpuinfo_x86_test PRIVATE HAVE_SYSCTLBYNAME)
60*eca53ba6SRoland Levillain  endif()
61*eca53ba6SRoland Levillain  target_link_libraries(cpuinfo_x86_test all_libraries)
62*eca53ba6SRoland Levillain  add_test(NAME cpuinfo_x86_test COMMAND cpuinfo_x86_test)
63*eca53ba6SRoland Levillainendif()
64*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
65*eca53ba6SRoland Levillain## cpuinfo_arm_test
66*eca53ba6SRoland Levillainif(PROCESSOR_IS_ARM)
67*eca53ba6SRoland Levillain  add_executable(cpuinfo_arm_test cpuinfo_arm_test.cc ../src/impl_arm_linux_or_android.c)
68*eca53ba6SRoland Levillain  target_link_libraries(cpuinfo_arm_test all_libraries)
69*eca53ba6SRoland Levillain  add_test(NAME cpuinfo_arm_test COMMAND cpuinfo_arm_test)
70*eca53ba6SRoland Levillainendif()
71*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
72*eca53ba6SRoland Levillain## cpuinfo_aarch64_test
73*eca53ba6SRoland Levillainif(PROCESSOR_IS_AARCH64)
74*eca53ba6SRoland Levillain  add_executable(cpuinfo_aarch64_test
75*eca53ba6SRoland Levillain    cpuinfo_aarch64_test.cc
76*eca53ba6SRoland Levillain    ../src/impl_aarch64_linux_or_android.c
77*eca53ba6SRoland Levillain    ../src/impl_aarch64_windows.c
78*eca53ba6SRoland Levillain    ../src/impl_aarch64_macos_or_iphone.c
79*eca53ba6SRoland Levillain  )
80*eca53ba6SRoland Levillain  if(APPLE)
81*eca53ba6SRoland Levillain    target_compile_definitions(cpuinfo_aarch64_test PUBLIC CPU_FEATURES_MOCK_SYSCTL_AARCH64)
82*eca53ba6SRoland Levillain    target_compile_definitions(cpuinfo_aarch64_test PRIVATE HAVE_SYSCTLBYNAME)
83*eca53ba6SRoland Levillain  else()
84*eca53ba6SRoland Levillain    target_compile_definitions(cpuinfo_aarch64_test PUBLIC CPU_FEATURES_MOCK_CPUID_AARCH64)
85*eca53ba6SRoland Levillain  endif()
86*eca53ba6SRoland Levillain  target_link_libraries(cpuinfo_aarch64_test all_libraries)
87*eca53ba6SRoland Levillain  add_test(NAME cpuinfo_aarch64_test COMMAND cpuinfo_aarch64_test)
88*eca53ba6SRoland Levillainendif()
89*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
90*eca53ba6SRoland Levillain## cpuinfo_mips_test
91*eca53ba6SRoland Levillainif(PROCESSOR_IS_MIPS)
92*eca53ba6SRoland Levillain  add_executable(cpuinfo_mips_test cpuinfo_mips_test.cc  ../src/impl_mips_linux_or_android.c)
93*eca53ba6SRoland Levillain  target_link_libraries(cpuinfo_mips_test all_libraries)
94*eca53ba6SRoland Levillain  add_test(NAME cpuinfo_mips_test COMMAND cpuinfo_mips_test)
95*eca53ba6SRoland Levillainendif()
96*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
97*eca53ba6SRoland Levillain## cpuinfo_ppc_test
98*eca53ba6SRoland Levillainif(PROCESSOR_IS_POWER)
99*eca53ba6SRoland Levillain  add_executable(cpuinfo_ppc_test cpuinfo_ppc_test.cc  ../src/impl_ppc_linux.c)
100*eca53ba6SRoland Levillain  target_link_libraries(cpuinfo_ppc_test all_libraries)
101*eca53ba6SRoland Levillain  add_test(NAME cpuinfo_ppc_test COMMAND cpuinfo_ppc_test)
102*eca53ba6SRoland Levillainendif()
103*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
104*eca53ba6SRoland Levillain## cpuinfo_s390x_test
105*eca53ba6SRoland Levillainif(PROCESSOR_IS_S390X)
106*eca53ba6SRoland Levillain  add_executable(cpuinfo_s390x_test cpuinfo_s390x_test.cc  ../src/impl_s390x_linux.c)
107*eca53ba6SRoland Levillain  target_link_libraries(cpuinfo_s390x_test all_libraries)
108*eca53ba6SRoland Levillain  add_test(NAME cpuinfo_s390x_test COMMAND cpuinfo_s390x_test)
109*eca53ba6SRoland Levillainendif()
110*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
111*eca53ba6SRoland Levillain## cpuinfo_riscv_test
112*eca53ba6SRoland Levillainif(PROCESSOR_IS_RISCV)
113*eca53ba6SRoland Levillain  add_executable(cpuinfo_riscv_test cpuinfo_riscv_test.cc  ../src/impl_riscv_linux.c)
114*eca53ba6SRoland Levillain  target_link_libraries(cpuinfo_riscv_test all_libraries)
115*eca53ba6SRoland Levillain  add_test(NAME cpuinfo_riscv_test COMMAND cpuinfo_riscv_test)
116*eca53ba6SRoland Levillainendif()
117*eca53ba6SRoland Levillain##------------------------------------------------------------------------------
118*eca53ba6SRoland Levillain## cpuinfo_loongarch_test
119*eca53ba6SRoland Levillainif(PROCESSOR_IS_LOONGARCH)
120*eca53ba6SRoland Levillain  add_executable(cpuinfo_loongarch_test cpuinfo_loongarch_test.cc  ../src/impl_loongarch_linux.c)
121*eca53ba6SRoland Levillain  target_link_libraries(cpuinfo_loongarch_test all_libraries)
122*eca53ba6SRoland Levillain  add_test(NAME cpuinfo_loongarch_test COMMAND cpuinfo_loongarch_test)
123*eca53ba6SRoland Levillainendif()
124*eca53ba6SRoland Levillain
125