Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
steps:
- label: ':hammer: native build and :mag: test'
command: "./ci/native-build-and-test.sh"
id: native-gcc-build-and-test
command: "./ci/native-gcc-build-and-test.sh"
artifact_paths:
- "build_ci_native/libuavcan"
- "build_ci_native/docs/**/*"
- "build_ci_native_gcc/libuavcan"
- "build_ci_native_gcc/docs/**/*"
plugins:
- docker#v3.1.0:
workdir: /repo
Expand All @@ -12,7 +13,21 @@ steps:
VERBOSE: 1
agents:
queue: 'default'
timeout_in_minutes: 15
- label: ':hammer: native build using clang'
id: native-clang-build
command: "./ci/native-clang-build.sh"
plugins:
- docker#v3.1.0:
workdir: /repo
image: "uavcan/libuavcan:latest"
env:
VERBOSE: 1
agents:
queue: 'default'
timeout_in_minutes: 15
- label: ':hammer: s32k build'
id: ontarget-s32k-build
command: "./ci/ontarget-s32k-build.sh"
artifact_paths:
- "build_ci_ontarget_s32k/**/*.log"
Expand All @@ -28,6 +43,7 @@ steps:
VERBOSE: 1
agents:
queue: 'default'
timeout_in_minutes: 15
- wait
- label: ":mag: ontarget testing"
command: "./ci/ontarget-s32k-test.sh"
Expand Down
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ file(MAKE_DIRECTORY ${EXTERNAL_PROJECT_DIRECTORY})

set(LIBUAVCAN_INCLUDE "${CMAKE_SOURCE_DIR}/libuavcan/include")
set(LIBUAVCAN_INCLUDE_GENERATED "${CMAKE_CURRENT_BINARY_DIR}/dsdl")
set(LIBUAVCAN_INCLUDE_LVS_PTEST "${CMAKE_SOURCE_DIR}/libuavcan_validation_suite/include")

include_directories(
${LIBUAVCAN_INCLUDE}
${LIBUAVCAN_INCLUDE_GENERATED}
${LIBUAVCAN_INCLUDE_LVS_PTEST}
)

if(NOT LIBUAVCAN_FLAG_SET)
Expand Down Expand Up @@ -55,11 +57,6 @@ find_package(public_regulated_data_types REQUIRED)
#
find_package(gtest REQUIRED)

#
# We generate coverage reports. Please look at them.
#
find_package(lcov REQUIRED)

#
# Finds programs needed to build the libuavcan documentation
#
Expand Down Expand Up @@ -99,10 +96,15 @@ add_dependencies(format-generated dsdl-regulated)
create_check_style_target(format-check ON "${LIBUAVCAN_INCLUDE}/**/*.hpp")

# +---------------------------------------------------------------------------+
# | BUILD AND RUN UNIT TESTS
# | BUILD UNIT TESTS
# +---------------------------------------------------------------------------+
include(${LIBUAVCAN_TESTBUILD})

# +---------------------------------------------------------------------------+
# | DEFINE COMPILE-TIME TESTS
# +---------------------------------------------------------------------------+
include(${CMAKE_SOURCE_DIR}/test/compile/compile_tests.cmake)

# +---------------------------------------------------------------------------+
# | DOCUMENTATION GENERATION
# +---------------------------------------------------------------------------+
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ The reason we opted for a complete rewrite is that so much is changing. Between

**/test/ontarget** - Tests cross-compiled for specific hardware* and run on a set of dedicated test devices. These tests may have strict timing constraints and may require specific physical or virtual busses and other test apparatuses be present. Each on-target test will fully document its requirements to enable anyone with access to the appropriate hardware to reproduce the tests. Furthermore, these tests must be inherently automateable having clear pass/fail criteria reducible to a boolean condition.

**/test/compile** – Tests that run in the compiler. Most of these will be tests that pass if they fail to compile. For example, some tests will purposefully define template parameters that will cause static_asserts to fail. Tests that pass if they do compile are less interesting here since such happy paths are normally covered by unit-tests.

**/example** - Contains a set of example applications providing real, practical, and tested uses of libuavcan.

**/commons** - Reference implementations for parts of the libuavcan library. These implementations are optional but are provided as a convenience to accelerate evaluation and integration of libuavcan.
Expand Down Expand Up @@ -128,7 +130,7 @@ To use visual studio code to debug ontarget tests for the S32K146EVB you'll need
```
{
"cwd": "${workspaceRoot}",
"executable": "build/test_bus.elf",
"executable": "build/test_util_math.elf",
"name": "On-target unit test.",
"request": "launch",
"type": "cortex-debug",
Expand Down
16 changes: 8 additions & 8 deletions ci/native-build-and-test.sh → ci/native-clang-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ set -o pipefail
# | deploy (i.e. There's really no 'I' going on).
# +----------------------------------------------------------+

mkdir -p build_ci_native
pushd build_ci_native
# We build native tests using clang since we use gcc for
# cross-compiling. This gives us coverage by two different
# compilers.
mkdir -p build_ci_native_clang
pushd build_ci_native_clang
# We ensure we can build using clang but we rely on GCC for testing
# since clang's coverage metrics have been broken for the last
# several years.
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/clang-native.cmake \
-DLIBUAVCAN_EXT_FOLDER=build_ci_ext \
-DLIBUAVCAN_EXT_FOLDER=build_ci_ext_clang \
..

make -j4

# We use ctest to run our compile tests.
ctest -VV

make docs

popd
53 changes: 53 additions & 0 deletions ci/native-gcc-build-and-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

# +----------------------------------------------------------+
# | BASH : Modifying Shell Behaviour
# | (https://www.gnu.org/software/bash/manual)
# +----------------------------------------------------------+
# Treat unset variables and parameters other than the special
# parameters ‘@’ or ‘*’ as an error when performing parameter
# expansion. An error message will be written to the standard
# error, and a non-interactive shell will exit.
set -o nounset

# Exit immediately if a pipeline returns a non-zero status.
set -o errexit

# If set, the return value of a pipeline is the value of the
# last (rightmost) command to exit with a non-zero status, or
# zero if all commands in the pipeline exit successfully.
set -o pipefail

# +----------------------------------------------------------+
# | This script is one of the common set of commands run as
# | part of a continuous integration build pipeline.
# | These scrips are named using the following scheme:
# |
# | [build_type]-[(optional)build_type qualifier]-[build|test|report|upload].sh
# |
# | Of course, libuavcan is a header-only distribution so
# | CI is used to verify and test rather than package and
# | deploy (i.e. There's really no 'I' going on).
# +----------------------------------------------------------+

mkdir -p build_ci_native_gcc
pushd build_ci_native_gcc
# GCC is our reference compiler since it does a better job with
# coverage metrics.
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/gcc-native.cmake \
-DLIBUAVCAN_EXT_FOLDER=build_ci_ext_gcc \
..

make -j4

# We use ctest to run our compile tests.
ctest -VV

# This builds, runs, and reports on our native unit tests.
# TODO: when we integrate with coveralls or codacity run make cov_info
# instead to skip the genhtml step.
make cov_all

make docs

popd
3 changes: 3 additions & 0 deletions ci/ontarget-s32k-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/gcc-arm-none-eabi.cmake \

make -j4

# We use ctest to run our compile tests.
ctest -VV

popd
6 changes: 5 additions & 1 deletion cmake/modules/Findlcov.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@


find_program(LCOV lcov)
find_program(GENHTML genhtml)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(lcov
LCOV_FOUND
)

find_package_handle_standard_args(genhtml
GENHTML_FOUND
)
6 changes: 6 additions & 0 deletions cmake/toolchains/clang-native.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_ASM_COMPILER clang)

# Signal to unit tests that the coverage data will be generated by
# clang so they should try to use llvm-cov if it's available.
# Things are weird between gcov and llvm-cov right now but this
# seems to work in our Ubuntu 18 Docker container, so...?
set(LIBUAVCAN_USE_LLVM_COV ON)
8 changes: 8 additions & 0 deletions cmake/toolchains/gcc-native.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Toolchain for using gcc on what-ever-platform-this-is (aka "native").
#
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_ASM_COMPILER gcc)
103 changes: 0 additions & 103 deletions libuavcan/include/libuavcan/bus/can.hpp

This file was deleted.

14 changes: 7 additions & 7 deletions libuavcan/include/libuavcan/introspection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
__attribute__((format(printf, 2, 3)))
# endif
static void
UAVCAN_TRACE(const char* src, const char* fmt, ...)
LIBUAVCAN_TRACE(const char* src, const char* fmt, ...)
{
va_list args;
(void) std::printf("UAVCAN: %s: ", src);
(void) std::printf("LIBUAVCAN: %s: ", src);
va_start(args, fmt);
(void) std::vprintf(fmt, args);
va_end(args);
Expand All @@ -46,18 +46,18 @@ UAVCAN_TRACE(const char* src, const char* fmt, ...)

#else

# define UAVCAN_TRACE(...) ((void) 0)
# define LIBUAVCAN_TRACE(...) ((void) 0)

#endif

#if LIBUAVCAN_INTROSPECTION_ENABLE_ASSERT
# include <cassert>
# define UAVCAN_ASSERT(statement) \
{ \
assert(statement); \
# define LIBUAVCAN_ASSERT(statement) \
{ \
assert(statement); \
}
#else
# define UAVCAN_ASSERT(...) ((void) 0)
# define LIBUAVCAN_ASSERT(...) ((void) 0)
#endif

#endif // LIBUAVCAN_INTROSPECTION_HPP_INCLUDED
Loading