Fixing test build on gcc
This commit is contained in:
@@ -28,12 +28,12 @@
|
|||||||
cmake_minimum_required (VERSION 2.8.8)
|
cmake_minimum_required (VERSION 2.8.8)
|
||||||
|
|
||||||
project(EPANET)
|
project(EPANET)
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
# Append local dir to module search path
|
# Append local dir to module search path
|
||||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
|
|
||||||
option(BUILD_TESTS "Build unit tests (requires Boost test)" OFF)
|
|
||||||
option(BUILD_PY_LIB "Build library for Python wrapper" OFF)
|
option(BUILD_PY_LIB "Build library for Python wrapper" OFF)
|
||||||
option(BUILD_COVERAGE "Build library for coverage" OFF)
|
option(BUILD_COVERAGE "Build library for coverage" OFF)
|
||||||
|
|
||||||
@@ -43,10 +43,12 @@ IF (NOT BUILD_PY_LIB)
|
|||||||
ENDIF (NOT BUILD_PY_LIB)
|
ENDIF (NOT BUILD_PY_LIB)
|
||||||
add_subdirectory(src/outfile)
|
add_subdirectory(src/outfile)
|
||||||
|
|
||||||
IF (BUILD_TESTS)
|
IF (BUILD_TESTING)
|
||||||
|
enable_testing()
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
add_subdirectory(tests/outfile)
|
add_subdirectory(tests/outfile)
|
||||||
ENDIF (BUILD_TESTS)
|
add_subdirectory(tests/util)
|
||||||
|
ENDIF (BUILD_TESTING)
|
||||||
|
|
||||||
|
|
||||||
# Sets for output directory for executables and libraries.
|
# Sets for output directory for executables and libraries.
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ environment:
|
|||||||
GENERATOR: "Visual Studio 15 2017"
|
GENERATOR: "Visual Studio 15 2017"
|
||||||
GROUP: "SUPPORTED"
|
GROUP: "SUPPORTED"
|
||||||
BOOST_ROOT: "C:/Libraries/boost_1_67_0"
|
BOOST_ROOT: "C:/Libraries/boost_1_67_0"
|
||||||
|
|
||||||
PLATFORM: "win32"
|
PLATFORM: "win32"
|
||||||
REF_BUILD_ID: "220dev5"
|
REF_BUILD_ID: "220dev5"
|
||||||
# New build on Visual Studio 15 2017
|
# New build on Visual Studio 15 2017
|
||||||
@@ -37,6 +38,7 @@ init:
|
|||||||
- set EPANET_HOME=%APPVEYOR_BUILD_FOLDER%
|
- set EPANET_HOME=%APPVEYOR_BUILD_FOLDER%
|
||||||
- set BUILD_HOME=buildprod
|
- set BUILD_HOME=buildprod
|
||||||
- set TEST_HOME=nrtestsuite
|
- set TEST_HOME=nrtestsuite
|
||||||
|
- set PATH=%PATH%;%BOOST_ROOT%/
|
||||||
|
|
||||||
# See values set
|
# See values set
|
||||||
- echo %APPVEYOR_BUILD_WORKER_IMAGE%
|
- echo %APPVEYOR_BUILD_WORKER_IMAGE%
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#Setup CMake to run tests
|
#Setup CMake to run tests
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
|
|
||||||
# Sets for output directory for executables and libraries.
|
# Sets for output directory for executables and libraries.
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
@@ -25,6 +24,7 @@ IF(MSVC)
|
|||||||
set(Boost_DEBUG OFF)
|
set(Boost_DEBUG OFF)
|
||||||
set(Boost_DETAILED_FAILURE_MSG OFF)
|
set(Boost_DETAILED_FAILURE_MSG OFF)
|
||||||
set(Boost_USE_STATIC_LIBS OFF)
|
set(Boost_USE_STATIC_LIBS OFF)
|
||||||
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
|
||||||
set(Boost_THREAD_FOUND OFF)
|
set(Boost_THREAD_FOUND OFF)
|
||||||
|
|||||||
@@ -9,11 +9,19 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
|
|
||||||
|
|
||||||
set (Boost_USE_STATIC_LIBS OFF)
|
if (MSVC)
|
||||||
|
set (Boost_USE_STATIC_LIBS OFF)
|
||||||
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
||||||
|
endif(MSVC)
|
||||||
|
|
||||||
find_package(Boost COMPONENTS unit_test_framework)
|
find_package(Boost COMPONENTS unit_test_framework)
|
||||||
include_directories (${Boost_INCLUDE_DIRS} ../../src/outfile/include)
|
include_directories (${Boost_INCLUDE_DIRS} ../../src/outfile/include)
|
||||||
|
|
||||||
|
|
||||||
add_executable(test_errormanager test_output.cpp)
|
add_executable(test_output test_output.cpp)
|
||||||
|
|
||||||
target_link_libraries(test_errormanager ${Boost_LIBRARIES} epanet-output)
|
target_link_libraries(test_output ${Boost_LIBRARIES} epanet-output)
|
||||||
|
|
||||||
|
add_test(NAME test_output
|
||||||
|
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_output
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
||||||
|
|||||||
BIN
tests/outfile/data/example1.out
Normal file
BIN
tests/outfile/data/example1.out
Normal file
Binary file not shown.
@@ -8,13 +8,7 @@
|
|||||||
* Unit testing for EPANET Output API.
|
* Unit testing for EPANET Output API.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// NOTE: Travis installs libboost test version 1.5.4
|
|
||||||
// NOTE: Can not dyn link boost using Visual Studio 10 2010
|
|
||||||
//#define BOOST_TEST_DYN_LINK
|
|
||||||
|
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE "output"
|
#define BOOST_TEST_MODULE "output"
|
||||||
#define BOOST_TEST_DYN_LINK
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
//#define BOOST_ALL_DYN_LINK
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "test_toolkit.hpp"
|
#include "test_toolkit.hpp"
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ nodes and links from a project. Deletion can be conditional on
|
|||||||
node or link appearing in any simple or rule-based controls.
|
node or link appearing in any simple or rule-based controls.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "test_toolkit.hpp"
|
#include "test_toolkit.hpp"
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "test_toolkit.hpp"
|
#include "test_toolkit.hpp"
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "test_toolkit.hpp"
|
#include "test_toolkit.hpp"
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "test_toolkit.hpp"
|
#include "test_toolkit.hpp"
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "test_toolkit.hpp"
|
#include "test_toolkit.hpp"
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "test_toolkit.hpp"
|
#include "test_toolkit.hpp"
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "test_toolkit.hpp"
|
#include "test_toolkit.hpp"
|
||||||
|
|||||||
@@ -11,13 +11,12 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <boost/thread.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/thread.hpp>
|
|
||||||
|
|
||||||
#include "epanet2_2.h"
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
#define NUM_THREADS 2
|
#define NUM_THREADS 2
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "test_toolkit.hpp"
|
#include "test_toolkit.hpp"
|
||||||
|
|||||||
@@ -11,9 +11,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE toolkit
|
#define BOOST_TEST_MODULE toolkit
|
||||||
#define BOOST_ALL_DYN_LINK
|
|
||||||
|
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.12)
|
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
set (Boost_USE_STATIC_LIBS OFF)
|
# Sets for output directory for executables and libraries
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
|
|
||||||
|
|
||||||
|
IF(MSVC)
|
||||||
|
set (Boost_USE_STATIC_LIBS OFF)
|
||||||
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
||||||
|
ENDIF(MSVC)
|
||||||
|
|
||||||
|
|
||||||
find_package(Boost COMPONENTS unit_test_framework)
|
find_package(Boost COMPONENTS unit_test_framework)
|
||||||
include_directories (${Boost_INCLUDE_DIRS} ../../src/)
|
include_directories (${Boost_INCLUDE_DIRS} ../../src/)
|
||||||
|
|
||||||
@@ -16,3 +26,6 @@ set (test_source
|
|||||||
add_executable(test_errormanager ${test_source})
|
add_executable(test_errormanager ${test_source})
|
||||||
|
|
||||||
target_link_libraries(test_errormanager ${Boost_LIBRARIES})
|
target_link_libraries(test_errormanager ${Boost_LIBRARIES})
|
||||||
|
|
||||||
|
add_test(NAME test_errormanager
|
||||||
|
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_errormanager)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE errormanager
|
#define BOOST_TEST_MODULE errormanager
|
||||||
#define BOOST_TEST_DYN_LINK
|
//#define BOOST_TEST_DYN_LINK
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
#include "util/errormanager.h"
|
#include "util/errormanager.h"
|
||||||
@@ -37,19 +37,19 @@ BOOST_AUTO_TEST_SUITE(test_errormanager)
|
|||||||
BOOST_AUTO_TEST_CASE (test_create_destroy)
|
BOOST_AUTO_TEST_CASE (test_create_destroy)
|
||||||
{
|
{
|
||||||
error_handle_t *error_handle = NULL;
|
error_handle_t *error_handle = NULL;
|
||||||
error_handle = error_new_manager(&mock_lookup);
|
error_handle = create_error_manager(&mock_lookup);
|
||||||
|
|
||||||
error_dst_manager(error_handle);
|
delete_error_manager(error_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Fixture{
|
struct Fixture{
|
||||||
Fixture() {
|
Fixture() {
|
||||||
error_message = NULL;
|
error_message = NULL;
|
||||||
error_handle = error_new_manager(&mock_lookup);
|
error_handle = create_error_manager(&mock_lookup);
|
||||||
}
|
}
|
||||||
~Fixture() {
|
~Fixture() {
|
||||||
error_dst_manager(error_handle);
|
delete_error_manager(error_handle);
|
||||||
free(error_message);
|
free(error_message);
|
||||||
}
|
}
|
||||||
int error;
|
int error;
|
||||||
@@ -60,21 +60,21 @@ struct Fixture{
|
|||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE (test_set_clear, Fixture)
|
BOOST_FIXTURE_TEST_CASE (test_set_clear, Fixture)
|
||||||
{
|
{
|
||||||
error = error_set(error_handle, 100);
|
error = set_error(error_handle, 100);
|
||||||
BOOST_CHECK(error == 100);
|
BOOST_CHECK(error == 100);
|
||||||
|
|
||||||
error_clear(error_handle);
|
clear_error(error_handle);
|
||||||
error = error_check(error_handle, &error_message);
|
error = check_error(error_handle, &error_message);
|
||||||
BOOST_CHECK(error == 0);
|
BOOST_CHECK(error == 0);
|
||||||
BOOST_CHECK(error_message == NULL);
|
BOOST_CHECK(error_message == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FIXTURE_TEST_CASE(test_set_check, Fixture)
|
BOOST_FIXTURE_TEST_CASE(test_set_check, Fixture)
|
||||||
{
|
{
|
||||||
error = error_set(error_handle, 100);
|
error = set_error(error_handle, 100);
|
||||||
BOOST_CHECK(error == 100);
|
BOOST_CHECK(error == 100);
|
||||||
|
|
||||||
error = error_check(error_handle, &error_message);
|
error = check_error(error_handle, &error_message);
|
||||||
BOOST_CHECK(check_string(error_message, MESSAGE_STRING));
|
BOOST_CHECK(check_string(error_message, MESSAGE_STRING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user