-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: first step towards automated tests
- Loading branch information
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
project(OmnetppCmakeTests) | ||
cmake_minimum_required(VERSION 3.13) | ||
enable_testing() | ||
|
||
add_test(NAME FindOMNeT++ | ||
COMMAND ${CMAKE_COMMAND} | ||
-DBUILD_DIRECTORY=${PROJECT_BINARY_DIR} | ||
-DTEST_SUITE=find-omnetpp | ||
-P RunTestSuite.cmake | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
if(NOT TEST_SUITE) | ||
message(FATAL_ERROR "run_test: missing TEST_SUITE parameter") | ||
endif() | ||
if(NOT BUILD_DIRECTORY) | ||
message(FATAL_ERROR "run_test: missing BUILD_DIRECTORY parameter") | ||
endif() | ||
|
||
execute_process(COMMAND ${CMAKE_COMMAND} -S ${TEST_SUITE} -B ${BUILD_DIRECTORY}/${TEST_SUITE} | ||
RESULT_VARIABLE setup_test_suite) | ||
if(setup_test_suite) | ||
message(FATAL_ERROR "run_test: setting up test suite failed") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
set(OMNETPP_CMAKE_ROOT ${CMAKE_CURRENT_LIST_DIR}/..) | ||
|
||
macro(require_envvar) | ||
set(envvar_list "${ARGN}") | ||
foreach(envvar IN LISTS envvar_list) | ||
if(NOT DEFINED ENV{${envvar}}) | ||
message(FATAL_ERROR "require_envvar: ${envvar} is missing") | ||
endif() | ||
endforeach() | ||
endmacro() | ||
|
||
macro(expect_strequal expected actual) | ||
if(NOT DEFINED ${actual}) | ||
message(FATAL_ERROR "expect_strequal: variable ${actual} does not exist") | ||
endif() | ||
if(NOT "${expected}" STREQUAL "${${actual}}") | ||
message(FATAL_ERROR "Expected ${actual} to equal \"${expected}\", but it is \"${${actual}}\"") | ||
endif() | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
project(FindOmnetppTest) | ||
cmake_minimum_required(VERSION 3.13) | ||
include(${PROJECT_SOURCE_DIR}/../TestSuiteHelpers.cmake) | ||
set(CMAKE_MODULE_PATH ${OMNETPP_CMAKE_ROOT}) | ||
|
||
find_package(OmnetPP REQUIRED) | ||
|
||
require_envvar(EXPECTED_OMNETPP_ROOT EXPECTED_OMNETPP_VERSION) | ||
expect_strequal($ENV{EXPECTED_OMNETPP_ROOT} OMNETPP_ROOT) | ||
expect_strequal($ENV{EXPECTED_OMNETPP_VERSION} OMNETPP_VERSION) |