Skip to content

Commit

Permalink
Fixing OpenCyphal#254 with tests (OpenCyphal#256)
Browse files Browse the repository at this point in the history
* Fixing OpenCyphal#254 with tests

1. Adding explicit little-endian tests to CI
2. Fixing issues found by said tests.
3. Small documentation fixes and update to public_regulated_data_types
   submodule.

* fixing build
  • Loading branch information
thirtytwobits authored May 20, 2022
1 parent cbf871c commit 142d6d5
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 83 deletions.
49 changes: 26 additions & 23 deletions .github/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,30 +282,33 @@ def _make_parser() -> argparse.ArgumentParser:

def _apply_overrides(args: argparse.Namespace) -> argparse.Namespace:
if args.override is not None:
for override in args.override:
print(
textwrap.dedent(
"""
*****************************************************************
About to apply override file : {}
*****************************************************************
"""
).format(str(override))
)
for override_list in args.override:
for override in override_list:
if not pathlib.Path(override).exists():
raise RuntimeError('ini file "{}" does not exist.'.format(override))
print(
textwrap.dedent(
"""
*****************************************************************
About to apply override file : {}
*****************************************************************
"""
).format(override)
)

overrides = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
overrides.read(override)
if "overrides" not in overrides:
raise RuntimeError('ini file "{}" did not contain an overrides section.'.format(str(override)))
for key, value in overrides["overrides"].items():
corrected_key = key.replace("-", "_")
if value.lower() == "true" or value.lower() == "false":
setattr(args, corrected_key, bool(value))
else:
try:
setattr(args, corrected_key, int(value))
except ValueError:
setattr(args, corrected_key, value)
overrides = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
overrides.read(override)
if "overrides" not in overrides:
raise RuntimeError('ini file "{}" did not contain an overrides section.'.format(override))
for key, value in overrides["overrides"].items():
corrected_key = key.replace("-", "_")
if value.lower() == "true" or value.lower() == "false":
setattr(args, corrected_key, bool(value))
else:
try:
setattr(args, corrected_key, int(value))
except ValueError:
setattr(args, corrected_key, value)

return args

Expand Down
6 changes: 0 additions & 6 deletions .github/verify_c_clang_native32.ini

This file was deleted.

6 changes: 0 additions & 6 deletions .github/verify_c_clang_native64.ini

This file was deleted.

6 changes: 0 additions & 6 deletions .github/verify_c_gcc_native32.ini

This file was deleted.

6 changes: 0 additions & 6 deletions .github/verify_c_gcc_native64.ini

This file was deleted.

6 changes: 0 additions & 6 deletions .github/verify_cpp_clang_native32.ini

This file was deleted.

6 changes: 0 additions & 6 deletions .github/verify_cpp_clang_native64.ini

This file was deleted.

6 changes: 0 additions & 6 deletions .github/verify_cpp_gcc_native32.ini

This file was deleted.

6 changes: 0 additions & 6 deletions .github/verify_cpp_gcc_native64.ini

This file was deleted.

18 changes: 15 additions & 3 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ jobs:
build_type: [Debug, Release, MinSizeRel]
architecture: [native32, native64]
compiler: [gcc, clang]
endianness: [any, little]
flag: [--none, --enable-ovr-var-array, --disable-asserts]
exclude:
- build_type: Debug
Expand All @@ -156,8 +157,11 @@ jobs:
- name: verify
run: |
.github/verify.py --override .github/verify_global.ini \
--override .github/verify_c_${{ matrix.compiler }}_${{ matrix.architecture }}.ini \
--build-type ${{ matrix.build_type }} \
--language c \
--platform ${{ matrix.architecture }} \
--toolchain-family ${{ matrix.compiler }} \
--endianness ${{ matrix.endianness }} \
${{ matrix.flag }}
language-verification-cpp-14:
Expand All @@ -169,6 +173,7 @@ jobs:
build_type: [Debug, Release, MinSizeRel]
architecture: [native32, native64]
compiler: [gcc, clang]
endianness: [any, little]
flag: [--none, --enable-ovr-var-array, --disable-asserts]
exclude:
- build_type: Debug
Expand All @@ -183,9 +188,12 @@ jobs:
- name: verify
run: |
.github/verify.py --override .github/verify_global.ini \
--override .github/verify_cpp_${{ matrix.compiler }}_${{ matrix.architecture }}.ini \
--build-type ${{ matrix.build_type }} \
--language-standard c++14 \
--language cpp \
--platform ${{ matrix.architecture }} \
--toolchain-family ${{ matrix.compiler }} \
--endianness ${{ matrix.endianness }} \
${{ matrix.flag }}
language-verification-cpp-17:
Expand All @@ -197,6 +205,7 @@ jobs:
build_type: [Debug, Release, MinSizeRel]
architecture: [native32, native64]
compiler: [gcc, clang]
endianness: [any, little]
flag: [--none, --enable-ovr-var-array, --disable-asserts]
exclude:
- build_type: Debug
Expand All @@ -211,9 +220,12 @@ jobs:
- name: verify
run: |
.github/verify.py --override .github/verify_global.ini \
--override .github/verify_cpp_${{ matrix.compiler }}_${{ matrix.architecture }}.ini \
--build-type ${{ matrix.build_type }} \
--language-standard c++17 \
--language cpp \
--platform ${{ matrix.architecture }} \
--toolchain-family ${{ matrix.compiler }} \
--endianness ${{ matrix.endianness }} \
${{ matrix.flag }}
release:
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ skip the docker invocations and use ``tox -s``.

To run the language verification build you'll need to use a different docker container::

docker pull uavcan/c_cpp:ubuntu-18.04
docker run --rm -it -v $PWD:/repo uavcan/c_cpp:ubuntu-18.04
docker pull uavcan/c_cpp:ubuntu-20.04
docker run --rm -it -v $PWD:/repo uavcan/c_cpp:ubuntu-20.04
./.github/verify.py -l c
./.github/verify.py -l cpp

Expand Down
8 changes: 4 additions & 4 deletions src/nunavut/lang/cpp/support/serialization.j2
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,10 @@ public:
: data_(data.data(), data.size()), offset_bits_(offset_bits) {}

template<{{ typename_unsigned_length }} N>
const_bitspan(value_type (&data)[N], {{ typename_unsigned_bit_length }} offset_bits=0)
const_bitspan(const value_type (&data)[N], {{ typename_unsigned_bit_length }} offset_bits=0)
: data_(data, N), offset_bits_(offset_bits) {}

const_bitspan(value_type* ptr, {{ typename_unsigned_length }} size, {{ typename_unsigned_bit_length }} offset_bits=0)
const_bitspan(const value_type* ptr, {{ typename_unsigned_length }} size, {{ typename_unsigned_bit_length }} offset_bits=0)
: data_(ptr, size), offset_bits_(offset_bits) {}


Expand Down Expand Up @@ -440,7 +440,7 @@ public:
else
{
// The algorithm was originally designed by Ben Dyer for Libuavcan v0:
// https://github.com/OpenCyphal/libuavcan/blob/legacy-v0/libuavcan/src/marshal/uc_bit_array_copy.cpp
// https://github.com/OpenCyphal-garage/libuavcan/blob/legacy-v0/libuavcan/src/marshal/uc_bit_array_copy.cpp
// This version is modified for v1 where the bit order is the opposite.
{{ typename_unsigned_bit_length }} src_off = offset_bits_;
{{ typename_unsigned_bit_length }} dst_off = dst.offset_bits_;
Expand Down Expand Up @@ -752,7 +752,7 @@ inline VoidResult bitspan::setUxx(const uint64_t value, const uint8_t len_bits)
const {{ typename_unsigned_bit_length }} saturated_len_bits = std::min<{{ typename_unsigned_bit_length }}>({# -#}
len_bits, 64U);
{%- if options.target_endianness == 'little' %}
bitspan{ reinterpret_cast<const uint8_t*>(&value), sizeof(uint64_t) }.copyTo(*this, saturated_len_bits);
const_bitspan{ reinterpret_cast<const uint8_t*>(&value), sizeof(uint64_t) }.copyTo(*this, saturated_len_bits);
{%- elif options.target_endianness in ('any', 'big') %}
const std::array<const uint8_t, 8> tmp{
static_cast<uint8_t>((value >> 0U) & 0xFFU),
Expand Down
2 changes: 1 addition & 1 deletion src/nunavut/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.. autodata:: __version__
"""

__version__ = "1.8.0" #: The version number used in the release of nunavut to pypi.
__version__ = "1.8.1" #: The version number used in the release of nunavut to pypi.


__license__ = "MIT"
2 changes: 1 addition & 1 deletion submodules/public_regulated_data_types
2 changes: 1 addition & 1 deletion verification/.devcontainer/native.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM uavcan/c_cpp:ubuntu-18.04
FROM uavcan/c_cpp:ubuntu-20.04

RUN mkdir -p /root/.vscode-server/extensions

0 comments on commit 142d6d5

Please sign in to comment.