@@ -182,21 +182,8 @@ set (EBPF_ERRORS_SUITES
182
182
"${P4C_SOURCE_DIR} /testdata/p4_16_ebpf_errors/*.p4"
183
183
)
184
184
185
- # determine the kernel version
186
- execute_process (COMMAND uname -r
187
- OUTPUT_VARIABLE P4C_EBPF_KERNEL_VER
188
- OUTPUT_STRIP_TRAILING_WHITESPACE
189
- RESULT_VARIABLE rc)
190
- message (STATUS "Detected kernel version: ${P4C_EBPF_KERNEL_VER} " )
191
- # Check if the kernel version is new enough to support ebpf features
192
- set (MIN_KERNEL 4.15.0)
193
- string (REGEX MATCH "[0-9]+[^-]*" KERNEL_VER ${CMAKE_SYSTEM} )
194
- if (${KERNEL_VER} VERSION_LESS ${MIN_KERNEL} )
195
- MESSAGE (WARNING "Kernel version ${KERNEL_VER} too small, expected ${MIN_KERNEL} . Ignoring ebpf kernel tests..." )
196
- set (SUPPORTS_KERNEL False )
197
- else ()
198
- set (SUPPORTS_KERNEL True )
199
- endif ()
185
+ include (CheckLinuxKernel)
186
+ check_minimum_kernel_version("4.15.0" SUPPORTS_KERNEL)
200
187
201
188
# Check if we have the right llvm version
202
189
set (MIN_LLVM 3.7.1)
@@ -212,14 +199,14 @@ if (NOT LLVM_RET)
212
199
if (${LLVM_PACKAGE_VERSION} VERSION_LESS ${MIN_LLVM} )
213
200
message (WARNING "LLVM version ${LLVM_PACKAGE_VERSION} too small, expected ${MIN_LLVM} .
214
201
Ignoring ebpf tests..." )
215
- set (SUPPORTS_KERNEL False )
202
+ set (SUPPORTS_KERNEL FALSE )
216
203
endif ()
217
204
else ()
218
205
message (WARNING
219
206
"Did not find an LLVM version that can compile the eBPF kernel tests...\n "
220
207
"'llvm-config' reason: ${LLVM_PACKAGE_VERSION} \n "
221
208
"'llvm-config' return value: ${LLVM_RET} " )
222
- set (SUPPORTS_KERNEL False )
209
+ set (SUPPORTS_KERNEL FALSE )
223
210
endif ()
224
211
225
212
# check for the libbpf library
@@ -230,7 +217,7 @@ else()
230
217
message (WARNING "Missing the libbpf dependency, disabling kernel tests."
231
218
" You can install libbpf by running './build_libbpf' in the "
232
219
"${CMAKE_CURRENT_SOURCE_DIR} folder." )
233
- set (SUPPORTS_KERNEL False )
220
+ set (SUPPORTS_KERNEL FALSE )
234
221
endif ()
235
222
236
223
# Only add the kernel tests if the two requirements are met
0 commit comments