diff --git a/.travis.yml b/.travis.yml index 66ba9b2d81..163fb692b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,6 @@ before_install: - ./bootstrap.sh before_script: "mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug -DCONTINUOUS_INTEGRATION_BUILD=1" script: - - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TARGET}" == "native" ]; then make ; fi - - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TARGET}" == "lpc11c24" ]; then cd "$TRAVIS_BUILD_DIR/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24" && make all ; fi + - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TARGET}" == "native" ]; then make && make ARGS=-VV test; fi + - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TARGET}" == "lpc11c24" ]; then cd "$TRAVIS_BUILD_DIR/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24" && make all; fi - if [ "${COVERITY_SCAN_BRANCH}" != 1 ] && [ "${TARGET}" == "stm32" ]; then echo "TODO STM32 test environment is not configured"; fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d5968fac6..87d8f72b98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,6 @@ set(opts "CMAKE_BUILD_TYPE:STRING:RelWithDebInfo:Debug Release RelWithDebInfo MinSizeRel:Build type." "CMAKE_CXX_FLAGS:STRING:::C++ flags." "CMAKE_C_FLAGS:STRING:::C flags." - "UAVCAN_USE_CPP03:BOOL:OFF::Use C++03 standard." "UAVCAN_PLATFORM:STRING:generic:generic linux stm32:Platform." "CONTINUOUS_INTEGRATION_BUILD:BOOL:OFF::Disable error redirection and timing tests" "UAVCAN_CMAKE_VERBOSE:BOOL:OFF::Verbose CMake configure output" @@ -99,6 +98,8 @@ if( CMAKE_BUILD_TYPE STREQUAL "Debug" ) EXCLUDE_FROM_ALL) set(GTEST_FOUND ON) + set(BUILD_TESTING ON) + enable_testing() endif() endif() endif() diff --git a/README.md b/README.md index e8eb667a05..d0468ef26b 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ make -j8 ## Library development Despite the fact that the library itself can be used on virtually any platform that has a standard-compliant -C++03 or C++11 compiler, the library development process assumes that the host OS is Linux. +C++11 compiler, the library development process assumes that the host OS is Linux. Prerequisites: @@ -102,7 +102,8 @@ Building the debug version and running the unit tests: mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Debug -make +make -j8 +make ARGS=-VV test ``` Test outputs can be found in the build directory under `libuavcan`. diff --git a/libuavcan/CMakeLists.txt b/libuavcan/CMakeLists.txt index 0d0a096d27..2261ebcae3 100644 --- a/libuavcan/CMakeLists.txt +++ b/libuavcan/CMakeLists.txt @@ -56,13 +56,8 @@ include_directories(${DSDLC_OUTPUT}) # if (COMPILER_IS_GCC_COMPATIBLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wundef") - if (UAVCAN_USE_CPP03) - message(STATUS "Using C++03") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03 -Wno-variadic-macros -Wno-long-long") - else () - message(STATUS "Using C++11 (pass UAVCAN_USE_CPP03=1 to override)") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - endif () + message(STATUS "Using C++11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endif () if (DEBUG_BUILD) @@ -108,13 +103,13 @@ function(add_libuavcan_test name library flags) # Adds GTest executable and crea # If failing tests need to be investigated with debugger, use 'make --ignore-errors' if (CONTINUOUS_INTEGRATION_BUILD) # Don't redirect test output, and don't run tests suffixed with "RealTime" - add_custom_command(TARGET ${name} POST_BUILD - COMMAND ./${name} --gtest_filter=-*RealTime - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + add_test(NAME ${name} + COMMAND ${name} --gtest_filter=-*RealTime + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) else () - add_custom_command(TARGET ${name} POST_BUILD - COMMAND ./${name} 1>"${name}.log" 2>&1 - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + add_test(NAME ${name} + COMMAND ${name} 1>"${name}.log" 2>&1 + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif() endfunction() @@ -129,8 +124,6 @@ if (DEBUG_BUILD) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wzero-as-null-pointer-constant -Wnon-virtual-dtor") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wsign-promo -Wold-style-cast") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations") - #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++ -Wno-error=effc++") # Produces heaps of useless warnings - set(cpp03_flags "-std=c++03 -Wno-variadic-macros -Wno-long-long -Wno-zero-as-null-pointer-constant") set(optim_flags "-O3 -DNDEBUG -g0") else () message(STATUS "Compiler ID: ${CMAKE_CXX_COMPILER_ID}") @@ -138,9 +131,6 @@ if (DEBUG_BUILD) endif () # Additional flavours of the library - add_library(uavcan_cpp03 STATIC ${LIBUAVCAN_CXX_FILES}) - set_target_properties(uavcan_cpp03 PROPERTIES COMPILE_FLAGS ${cpp03_flags}) - add_dependencies(uavcan_cpp03 libuavcan_dsdlc) add_library(uavcan_optim STATIC ${LIBUAVCAN_CXX_FILES}) set_target_properties(uavcan_optim PROPERTIES COMPILE_FLAGS ${optim_flags}) @@ -149,7 +139,6 @@ if (DEBUG_BUILD) if (GTEST_FOUND) message(STATUS "GTest found, tests will be built and run.") add_libuavcan_test(libuavcan_test uavcan "") # Default - add_libuavcan_test(libuavcan_test_cpp03 uavcan_cpp03 "${cpp03_flags}") # C++03 add_libuavcan_test(libuavcan_test_optim uavcan_optim "${optim_flags}") # Max optimization else (GTEST_FOUND) message(STATUS "GTest was not found, tests will not be built") diff --git a/libuavcan/test/node/test_node.hpp b/libuavcan/test/node/test_node.hpp index 889b9d928b..a8e6fc84fb 100644 --- a/libuavcan/test/node/test_node.hpp +++ b/libuavcan/test/node/test_node.hpp @@ -5,8 +5,6 @@ #pragma once #if __GNUC__ -// We need auto_ptr for compatibility reasons -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #endif @@ -217,7 +215,7 @@ struct TestNetwork { } }; - std::auto_ptr nodes[NumNodes]; + std::unique_ptr nodes[NumNodes]; TestNetwork(uavcan::uint8_t first_node_id = 1) { diff --git a/libuavcan/test/protocol/data_type_info_provider.cpp b/libuavcan/test/protocol/data_type_info_provider.cpp index 85141de7cf..75e704b86c 100644 --- a/libuavcan/test/protocol/data_type_info_provider.cpp +++ b/libuavcan/test/protocol/data_type_info_provider.cpp @@ -18,7 +18,7 @@ using uavcan::DefaultDataTypeRegistrator; using uavcan::MonotonicDuration; template -static bool validateDataTypeInfoResponse(const std::auto_ptr::Result>& resp, +static bool validateDataTypeInfoResponse(const std::unique_ptr::Result>& resp, unsigned flags) { if (!resp.get()) diff --git a/libuavcan/test/protocol/dynamic_node_id_server/distributed/server.cpp b/libuavcan/test/protocol/dynamic_node_id_server/distributed/server.cpp index 488b905514..e09fadda52 100644 --- a/libuavcan/test/protocol/dynamic_node_id_server/distributed/server.cpp +++ b/libuavcan/test/protocol/dynamic_node_id_server/distributed/server.cpp @@ -3,8 +3,6 @@ */ #if __GNUC__ -// We need auto_ptr for compatibility reasons -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #endif @@ -57,8 +55,8 @@ TEST(dynamic_node_id_server_RaftCore, Basic) InterlinkedTestNodesWithSysClock nodes; - std::auto_ptr raft_a(new RaftCore(nodes.a, storage_a, tracer_a, commit_handler_a)); - std::auto_ptr raft_b(new RaftCore(nodes.b, storage_b, tracer_b, commit_handler_b)); + std::unique_ptr raft_a(new RaftCore(nodes.a, storage_a, tracer_a, commit_handler_a)); + std::unique_ptr raft_b(new RaftCore(nodes.b, storage_b, tracer_b, commit_handler_b)); /* * Initialization diff --git a/libuavcan/test/protocol/dynamic_node_id_server/node_discoverer.cpp b/libuavcan/test/protocol/dynamic_node_id_server/node_discoverer.cpp index 06780809b2..64df33baec 100644 --- a/libuavcan/test/protocol/dynamic_node_id_server/node_discoverer.cpp +++ b/libuavcan/test/protocol/dynamic_node_id_server/node_discoverer.cpp @@ -3,8 +3,6 @@ */ #if __GNUC__ -// We need auto_ptr for compatibility reasons -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #endif diff --git a/libuavcan/test/protocol/firmware_update_trigger.cpp b/libuavcan/test/protocol/firmware_update_trigger.cpp index cd8f112c39..a17e92c442 100644 --- a/libuavcan/test/protocol/firmware_update_trigger.cpp +++ b/libuavcan/test/protocol/firmware_update_trigger.cpp @@ -107,7 +107,7 @@ TEST(FirmwareUpdateTrigger, Basic) uavcan::FirmwareUpdateTrigger trigger(nodes.a, checker); std::cout << "sizeof(uavcan::FirmwareUpdateTrigger): " << sizeof(uavcan::FirmwareUpdateTrigger) << std::endl; - std::auto_ptr provider(new uavcan::NodeStatusProvider(nodes.b)); // Other node + std::unique_ptr provider(new uavcan::NodeStatusProvider(nodes.b)); // Other node /* * Initializing @@ -235,10 +235,10 @@ TEST(FirmwareUpdateTrigger, MultiNode) uavcan::FirmwareUpdateTrigger trigger(nodes[0], checker); // The client nodes - std::auto_ptr provider_a(new uavcan::NodeStatusProvider(nodes[1])); - std::auto_ptr provider_b(new uavcan::NodeStatusProvider(nodes[2])); - std::auto_ptr provider_c(new uavcan::NodeStatusProvider(nodes[3])); - std::auto_ptr provider_d(new uavcan::NodeStatusProvider(nodes[4])); + std::unique_ptr provider_a(new uavcan::NodeStatusProvider(nodes[1])); + std::unique_ptr provider_b(new uavcan::NodeStatusProvider(nodes[2])); + std::unique_ptr provider_c(new uavcan::NodeStatusProvider(nodes[3])); + std::unique_ptr provider_d(new uavcan::NodeStatusProvider(nodes[4])); uavcan::protocol::HardwareVersion hwver; diff --git a/libuavcan/test/protocol/helpers.hpp b/libuavcan/test/protocol/helpers.hpp index b1d2f97157..e399b483b5 100644 --- a/libuavcan/test/protocol/helpers.hpp +++ b/libuavcan/test/protocol/helpers.hpp @@ -20,7 +20,7 @@ class SubscriptionCollector : uavcan::Noncopyable } public: - std::auto_ptr msg; + std::unique_ptr msg; typedef uavcan::MethodBinder Binder; @@ -85,7 +85,7 @@ private: } public: - std::auto_ptr result; + std::unique_ptr result; typedef uavcan::MethodBinder&)> diff --git a/libuavcan/test/protocol/node_info_retriever.cpp b/libuavcan/test/protocol/node_info_retriever.cpp index e7baa78c3d..f0f1b5a9b4 100644 --- a/libuavcan/test/protocol/node_info_retriever.cpp +++ b/libuavcan/test/protocol/node_info_retriever.cpp @@ -3,8 +3,6 @@ */ #if __GNUC__ -// We need auto_ptr for compatibility reasons -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #endif @@ -27,7 +25,7 @@ static void publishNodeStatus(PairableCanDriver& can, uavcan::NodeID node_id, struct NodeInfoListener : public uavcan::INodeInfoListener { - std::auto_ptr last_node_info; + std::unique_ptr last_node_info; uavcan::NodeID last_node_id; unsigned status_message_cnt; unsigned status_change_cnt; @@ -82,7 +80,7 @@ TEST(NodeInfoRetriever, Basic) std::cout << "sizeof(uavcan::ServiceClient): " << sizeof(uavcan::ServiceClient) << std::endl; - std::auto_ptr provider(new uavcan::NodeStatusProvider(nodes.b)); + std::unique_ptr provider(new uavcan::NodeStatusProvider(nodes.b)); NodeInfoListener listener; diff --git a/libuavcan/test/transport/dispatcher.cpp b/libuavcan/test/transport/dispatcher.cpp index 621ccf8972..aa39a31282 100644 --- a/libuavcan/test/transport/dispatcher.cpp +++ b/libuavcan/test/transport/dispatcher.cpp @@ -84,7 +84,7 @@ TEST(Dispatcher, Reception) makeDataType(uavcan::DataTypeKindService, 1) }; - typedef std::auto_ptr TestListenerPtr; + typedef std::unique_ptr TestListenerPtr; static const int MaxBufSize = 512; static const int NumSubscribers = 6; TestListenerPtr subscribers[NumSubscribers] = diff --git a/libuavcan/test/transport/transfer_buffer.cpp b/libuavcan/test/transport/transfer_buffer.cpp index 9ed74bc7ba..1a4ac031fb 100644 --- a/libuavcan/test/transport/transfer_buffer.cpp +++ b/libuavcan/test/transport/transfer_buffer.cpp @@ -3,8 +3,6 @@ */ #if __GNUC__ -// We need auto_ptr for compatibility reasons -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #endif @@ -238,7 +236,7 @@ TEST(TransferBufferManager, Basic) static const int POOL_BLOCKS = 100; uavcan::PoolAllocator pool; - std::auto_ptr mgr(new TransferBufferManager(MGR_MAX_BUFFER_SIZE, pool)); + std::unique_ptr mgr(new TransferBufferManager(MGR_MAX_BUFFER_SIZE, pool)); // Empty ASSERT_FALSE(mgr->access(TransferBufferManagerKey(0, uavcan::TransferTypeMessageBroadcast))); diff --git a/libuavcan/test/util/map.cpp b/libuavcan/test/util/map.cpp index 4dd2d25221..89c2faf816 100644 --- a/libuavcan/test/util/map.cpp +++ b/libuavcan/test/util/map.cpp @@ -3,8 +3,6 @@ */ #if __GNUC__ -// We need auto_ptr for compatibility reasons -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #endif @@ -59,7 +57,7 @@ TEST(Map, Basic) uavcan::PoolAllocator pool; typedef Map MapType; - std::auto_ptr map(new MapType(pool)); + std::unique_ptr map(new MapType(pool)); // Empty ASSERT_FALSE(map->access("hi")); @@ -198,7 +196,7 @@ TEST(Map, PrimitiveKey) uavcan::PoolAllocator pool; typedef Map MapType; - std::auto_ptr map(new MapType(pool)); + std::unique_ptr map(new MapType(pool)); // Empty ASSERT_FALSE(map->access(1)); diff --git a/libuavcan/test/util/multiset.cpp b/libuavcan/test/util/multiset.cpp index 4d4212f7c3..c3f227f865 100644 --- a/libuavcan/test/util/multiset.cpp +++ b/libuavcan/test/util/multiset.cpp @@ -3,8 +3,6 @@ */ #if __GNUC__ -// We need auto_ptr for compatibility reasons -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #endif @@ -78,7 +76,7 @@ TEST(Multiset, Basic) uavcan::PoolAllocator pool; typedef Multiset MultisetType; - std::auto_ptr mset(new MultisetType(pool)); + std::unique_ptr mset(new MultisetType(pool)); typedef SummationOperator StringConcatenationOperator; @@ -199,7 +197,7 @@ TEST(Multiset, PrimitiveKey) uavcan::PoolAllocator pool; typedef Multiset MultisetType; - std::auto_ptr mset(new MultisetType(pool)); + std::unique_ptr mset(new MultisetType(pool)); // Empty mset->removeFirst(8); @@ -239,7 +237,7 @@ TEST(Multiset, NoncopyableWithCounter) uavcan::PoolAllocator pool; typedef Multiset MultisetType; - std::auto_ptr mset(new MultisetType(pool)); + std::unique_ptr mset(new MultisetType(pool)); ASSERT_EQ(0, NoncopyableWithCounter::num_objects); ASSERT_EQ(0, mset->emplace()->value);