eProsima / Micro-XRCE-DDS-Client

Micro XRCE-DDS Client repository. Looking for commercial support? Contact info@eprosima.com
Apache License 2.0
130 stars 82 forks source link

Bugfix/blocking uxr create session #351

Open Ryanf55 opened 1 year ago

Ryanf55 commented 1 year ago

Here's my fix to the blocking nature of uxr_create_session.

  1. Add asserts for developing that will prevent poor behavior if the user's uxr_millis() function is not working correctly, or the time source is frozen, stuck at zero, or jumps backwards.
  2. Increase const correctness to the internal implementation
  3. Help prevent misconfiguration through cmake of the cmake defines
  4. Add asserts during the narrowing conversion
  5. Improve documentation in the public header.

This closes #350

In CMakeCache, one can see when NDEBUG is set, which would remove the asserts.

ryan@ryan-m93p:~/Documents/ardu_ws/src/ardupilot/modules/Micro-XRCE-DDS-Client$ cat build/microxrcedds_client/CMakeCache.txt | grep NDEBUG
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG

Since asserts aren't used yet in the library, it would be nice to add some documentation for library implementers to ensure they are disabled in production releases, but can be on during development.

richiprosima commented 1 year ago

Build status:

Ryanf55 commented 1 year ago

Build status:

  • Linux Build Status
  • Windows Build Status

I can't see any reason the build is failing. Let me know what I am missing. Searched for errors in the logs, all tests pass. Thanks!

Since CI only builds in release mode by default, if you want me to add tests for the new lines of code, the gtest tests will need to be run in debug mode and check for assertion failures when you supply bad time or misconfiguration to that function.

pablogs9 commented 1 year ago

I can't see any reason the build is failing. Let me know what I am missing. Searched for errors in the logs, all tests pass. Thanks!

Probably uncrustify is failing, try:

curl -l https://raw.githubusercontent.com/eProsima/cpp-style/master/uncrustify.cfg -o uncrustify.cfg
find src test include examples \( -name "*.cpp" -o -name "*.c" -o -name "*.h" -o -name "*.hpp" \) -exec uncrustify -c uncrustify.cfg --check {} +