Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent compiling backend tests if dependencies are not installed #4973

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
New optional parameter HINTS_DIRS added to CHECK_DEPENDECIES
- Intially the HINTS variable for find_libraries was hard coded.
- The path may change for different Operating Systems.
- The HINTS parameter can now be populated by the caller, and will only be used if provided.
- Minor Typos are also fixed.

Signed-off-by: Parth Shitole <f20212907@goa.bits-pilani.ac.in>
  • Loading branch information
ParthShitole committed Oct 24, 2024
commit 038dd22ff0089d9cdf6e3a33ef77b0d738d0dc8e
2 changes: 1 addition & 1 deletion backends/ebpf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ if(TEST_DEPENDENCY_PRESENT)
# We do not have support for dynamic addition of tables in the test framework
p4c_add_test_with_args("ebpf" ${EBPF_DRIVER_TEST} TRUE "testdata/p4_16_samples/ebpf_conntrack_extern.p4" "testdata/p4_16_samples/ebpf_conntrack_extern.p4" "--extern-file ${P4C_SOURCE_DIR}/testdata/extern_modules/extern-conntrack-ebpf.c" "")
else()
message(WARNING "Skipped adding Tests due to missing dependencies" "Please install the dependencies and try again")
message(WARNING "Skipped adding Tests due to missing dependencies" " Please install the dependencies and try again")
endif()

message(STATUS "Done with configuring BPF back end")
14 changes: 12 additions & 2 deletions cmake/P4CUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,11 @@ function(get_all_targets _result _dir)
set(${_result} ${${_result}} ${_sub_targets} PARENT_SCOPE)
endfunction()

# Checks for presence of programs and dependencies
# Checks for presence of programs and dependencies
# This function supports a optional parameter HINTS_DIRS.
# In case cmake is unable to find a library even if it is present,
# you can pass the exact directory path as the last parameter of this function.
# Eg. CHECK_DEPENDENCIES(VAR "${TEST_PROGRAMS}" "${TEST_LIBRARIES}" "${HINTS_DIRS}")
function(CHECK_DEPENDENCIES OUT_VAR TEST_DEPENDENCY_PROGRAMS TEST_DEPENDENCY_LIBRARIES)
set(ALL_FOUND TRUE)

Expand All @@ -437,7 +441,13 @@ function(CHECK_DEPENDENCIES OUT_VAR TEST_DEPENDENCY_PROGRAMS TEST_DEPENDENCY_LIB
endforeach()

foreach(LIB ${TEST_DEPENDENCY_LIBRARIES})
find_library(LIB_PATH ${LIB} HINTS "${CMAKE_CURRENT_SOURCE_DIR}/runtime/usr/lib64/")
if (ARGC GREATER 3)
set(HINTS_DIRS_ARG ${ARGV4})
find_library(LIB_PATH ${LIB} HINTS ${HINTS_DIRS})
ParthShitole marked this conversation as resolved.
Show resolved Hide resolved
else()
find_library(LIB_PATH ${LIB})
endif()

if (NOT LIB_PATH)
message(WARNING "Missing library ${LIB}."
" Please install ${LIB}.")
Expand Down
Loading