Skip to content

Commit

Permalink
tets
Browse files Browse the repository at this point in the history
  • Loading branch information
cmuhammedrafi committed Sep 24, 2024
1 parent 4c196f9 commit 64c9bbf
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/rdk_unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ jobs:
-DCMAKE_CXX_FLAGS="
-I ${{github.workspace}}/networkmanager/Tests/headers
-I ${{github.workspace}}/networkmanager/Tests/headers/rdk/iarmbus
-I ${{github.workspace}}/networkmanager/Tests/mocks"
-I ${{github.workspace}}/networkmanager/Tests/mocks
-include ${{github.workspace}}/networkmanager/Tests/headers/rdk/iarmbus/libIARM.h
-include ${{github.workspace}}/networkmanager/Tests/headers/rdk/iarmbus/libIBus.h
-I ${{github.workspace}}/networkmanager/Tests/mocks/Iarm.h
"
-DENABLE_NETWORKMANAGER_UNIT_TEST=ON
-DENABLE_GNOME_NETWORKMANAGER=OFF
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
&&
cmake --build build/RDKNetworkmanager -j16
&&
Expand Down
47 changes: 47 additions & 0 deletions cmake/UnitTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
message("Building for unit tests...")

message("Generating empty headers to suppress compiler errors")

file(GLOB BASEDIR Tests)
set(BASEDIR ${BASEDIR}/headers)
set(EMPTY_HEADERS_DIRS
${BASEDIR}
${BASEDIR}/rdk/iarmbus
${BASEDIR}/network
)

set(EMPTY_HEADERS
${BASEDIR}/rdk/iarmbus/libIARM.h
${BASEDIR}/rdk/iarmbus/libIBus.h
)

file(MAKE_DIRECTORY ${EMPTY_HEADERS_DIRS})

file(GLOB_RECURSE EMPTY_HEADERS_AVAILABLE "${BASEDIR}/*")
if (EMPTY_HEADERS_AVAILABLE)
message("Skip already generated headers to avoid rebuild")
list(REMOVE_ITEM EMPTY_HEADERS ${EMPTY_HEADERS_AVAILABLE})
endif ()
if (EMPTY_HEADERS)
file(TOUCH ${EMPTY_HEADERS})
endif ()

include_directories(${EMPTY_HEADERS_DIRS})

message("Adding compiler and linker options for all targets")

file(GLOB BASEDIR Tests/mocks)
set(FAKE_HEADERS
${BASEDIR}/Iarm.h
)

foreach (file ${FAKE_HEADERS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${file}")
endforeach ()

add_compile_options(-Wall -Werror)

add_link_options(-Wl,-wrap,system -Wl,-wrap,popen -Wl,-wrap,syslog -Wl,-wrap,pclose -Wl,-wrap,getmntent -Wl,-wrap,setmntent -Wl,-wrap,v_secure_popen -Wl,-wrap,v_secure_pclose -Wl,-wrap,v_secure_system)

message("Setting build options")
set(CMAKE_DISABLE_FIND_PACKAGE_IARMBus ON)

0 comments on commit 64c9bbf

Please sign in to comment.