Skip to content

Commit

Permalink
Merge pull request ethz-asl#50 from ethz-asl/feature/unit_tests_msf_c…
Browse files Browse the repository at this point in the history
…ore_state_accessors

Added unit tests for msf_core state accessors
  • Loading branch information
simonlynen committed Mar 25, 2014
2 parents b7c84ed + 5c18a6b commit 1018ec3
Show file tree
Hide file tree
Showing 6 changed files with 242 additions and 149 deletions.
19 changes: 12 additions & 7 deletions msf_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ project(msf_core)
# MinSizeRel : w/o debug symbols, w/ optimization, stripped binaries
set(CMAKE_BUILD_TYPE Release)

find_package(catkin REQUIRED COMPONENTS roscpp sensor_msgs dynamic_reconfigure msf_timing tf)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/)

find_package(catkin REQUIRED COMPONENTS sensor_msgs dynamic_reconfigure msf_timing tf)
find_package(Eigen REQUIRED)
find_package(GLog REQUIRED)

include_directories(include ${Eigen_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})

Expand All @@ -27,15 +30,16 @@ add_definitions (-DENABLE_MSF_TIMING)
generate_dynamic_reconfigure_options(cfg/MSF_Core.cfg)

catkin_package(
DEPENDS eigen
DEPENDS eigen GLog
CATKIN_DEPENDS roscpp sensor_msgs dynamic_reconfigure msf_timing tf
INCLUDE_DIRS include ${Eigen_INCLUDE_DIRS}
LIBRARIES msf_core similaritytransform
CFG_EXTRAS export_flags.cmake
CFG_EXTRAS export_flags.cmake FindGLog.cmake
)

add_library(msf_core src/lib/msf_tools.cc src/lib/falsecolor.cc src/lib/gps_conversion.cc)
target_link_libraries(msf_core ${catkin_LIBRARIES})
add_library(${PROJECT_NAME} src/lib/msf_tools.cc src/lib/falsecolor.cc
src/lib/gps_conversion.cc)
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${GLOG_LIBRARY})
add_dependencies(msf_core ${PROJECT_NAME}_gencfg)

add_library(similaritytransform src/similaritytransform.cc)
Expand All @@ -44,5 +48,6 @@ target_link_libraries(similaritytransform ${catkin_LIBRARIES})
add_executable(test_similaritytransform src/test/test_similaritytransform.cc)
target_link_libraries(test_similaritytransform similaritytransform)

# in case anything here depends on the dynreconf file
# add_dependencies(example_node ${${PROJECT_NAME}_EXPORTED_TARGETS})
catkin_add_gtest(test_static_statelist src/test/test_staticstatelist.cc)
target_link_libraries(test_static_statelist pthread ${PROJECT_NAME} ${GLOG_LIBRARY})

104 changes: 104 additions & 0 deletions msf_core/cmake/FindGLog.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# - Try to find the Google Glog library
#
# This module defines the following variables
#
# GLOG_FOUND - Was Glog found
# GLOG_INCLUDE_DIRS - the Glog include directories
# GLOG_LIBRARIES - Link to this
#
# This module accepts the following variables
#
# GLOG_ROOT - Can be set to Glog install path or Windows build path
#
#=============================================================================
# FindGlog.cmake, adapted from FindBullet.cmake which has the following
# copyright -
#-----------------------------------------------------------------------------
# Copyright 2009 Kitware, Inc.
# Copyright 2009 Philip Lowman <[email protected]>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)

if (NOT DEFINED GLOG_ROOT)
set (GLOG_ROOT /usr /usr/local)
endif (NOT DEFINED GLOG_ROOT)

if(MSVC)
set(LIB_PATHS ${GLOG_ROOT} ${GLOG_ROOT}/Release)
else(MSVC)
set (LIB_PATHS ${GLOG_ROOT} ${GLOG_ROOT}/lib)
endif(MSVC)

macro(_FIND_GLOG_LIBRARY _var)
find_library(${_var}
NAMES
${ARGN}
PATHS
${LIB_PATHS}
PATH_SUFFIXES lib
)
mark_as_advanced(${_var})
endmacro()

macro(_GLOG_APPEND_LIBRARIES _list _release)
set(_debug ${_release}_DEBUG)
if(${_debug})
set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
else()
set(${_list} ${${_list}} ${${_release}})
endif()
endmacro()

if(MSVC)
find_path(GLOG_INCLUDE_DIR NAMES raw_logging.h
PATHS
${GLOG_ROOT}/src/windows
${GLOG_ROOT}/src/windows/glog
)
else(MSVC)
# Linux/OS X builds
find_path(GLOG_INCLUDE_DIR NAMES raw_logging.h
PATHS
${GLOG_ROOT}/include/glog
)
endif(MSVC)

# Find the libraries
if(MSVC)
_FIND_GLOG_LIBRARY(GLOG_LIBRARY libglog.lib)
else(MSVC)
# Linux/OS X builds
_FIND_GLOG_LIBRARY(GLOG_LIBRARY libglog.so)
endif(MSVC)

message("glog library = " ${GLOG_LIBRARY})

# handle the QUIETLY and REQUIRED arguments and set GLOG_FOUND to TRUE if
# all listed variables are TRUE
include("${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Glog DEFAULT_MSG
GLOG_LIBRARY)

if(MSVC)
string(REGEX REPLACE "/glog$" "" VAR_WITHOUT ${GLOG_INCLUDE_DIR})
string(REGEX REPLACE "/windows$" "" VAR_WITHOUT ${VAR_WITHOUT})
set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIRS} "${VAR_WITHOUT}")
string(REGEX REPLACE "/libglog.lib" "" GLOG_LIBRARY_DIR ${GLOG_LIBRARY})
else(MSVC)
# Linux/OS X builds
set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
string(REGEX REPLACE "/libglog.so" "" GLOG_LIBRARY_DIR ${GLOG_LIBRARY})
endif(MSVC)

if(GLOG_FOUND)
_GLOG_APPEND_LIBRARIES(GLOG GLOG_LIBRARY)
endif()

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2013 Simon Lynen, ASL, ETH Zurich, Switzerland
* Copyright (C) 2014 Simon Lynen, ASL, ETH Zurich, Switzerland
* You can contact the author at <slynen at ethz dot ch>
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,7 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <ros/ros.h>
#include <msf_core/msf_core.h>
int main(int argc, char** argv) { }

#ifndef TESTING_ENTRYPOINT_H_
#define TESTING_ENTRYPOINT_H_

#include <gtest/gtest.h>
#include <glog/logging.h>

// Let the Eclipse parser see the macro.
#ifndef TEST
#define TEST(a, b) int Test_##a##_##b()
#endif

#define MSF_UNITTEST_ENTRYPOINT\
int main(int argc, char** argv) {\
::testing::InitGoogleTest(&argc, argv);\
google::InitGoogleLogging(argv[0]);\
return RUN_ALL_TESTS();\
}

#endif // TESTING_ENTRYPOINT_H_
3 changes: 2 additions & 1 deletion msf_core/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@
<buildtool_depend>catkin</buildtool_depend>

<!-- Dependencies needed to compile this package. -->
<build_depend>roscpp</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>dynamic_reconfigure</build_depend>
<build_depend>msf_timing</build_depend>
<build_depend>tf</build_depend>
<build_depend>GLog</build_depend>

<!-- Dependencies needed after this package is compiled. -->
<run_depend>roscpp</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>dynamic_reconfigure</run_depend>
<run_depend>msf_timing</run_depend>
<run_depend>tf</run_depend>
<run_depend>GLog</run_depend>
</package>
Loading

0 comments on commit 1018ec3

Please sign in to comment.