Skip to content

log_to_callback + unit-tests - #5584

Merged
maloel merged 5 commits into
realsenseai:developmentfrom
maloel:log
Feb 4, 2020
Merged

log_to_callback + unit-tests#5584
maloel merged 5 commits into
realsenseai:developmentfrom
maloel:log

Conversation

@maloel

@maloel maloel commented Jan 5, 2020

Copy link
Copy Markdown
Contributor
  • Fixed openvino test-cases in static (non-shared) builds
  • Fixed some of the warnings repeatedly given (from headers) during compilation
  • Travis "Linux - cpp" build is now "Linux - cpp - static" and uses static (non-shared; BUILD_SHARED_LIBS is off) compilation
  • Added unit-testing mechanism:
    • Any test-*.cpp (and, in future, test-*.py, etc.) under unit-tests/ is a unit-test
    • Tests can be nested inside directories
    • Each test creates its own project (in Visual Studio under Unit-Tests, with same nested structure) and thus its own executable
    • A script (unit-tests/run-unit-tests.py) runs all unit-tests and exits with status 1 or 0
    • Unit-tests can be specifically shared or static
  • Unit-tests are now run in Travis, in both shared and static builds
  • BUILD_SHARED_LIBS is now a compiler definition, too
  • Added rs2::log_to_callback, rs2_log_to_callback, rs2_log_to_callback_cpp
    • Minimum level can be set for a callback (e.g., warnings and above)
    • Added RS2_LOG_SEVERITY_ALL, same as _DEBUG, so it's easier to say "log all messages"
    • 21 unit-tests under unit-tests/log/

maloel added 3 commits January 5, 2020 12:08
* Travis "Linux - cpp" build is now "Linux - cpp -static" and uses static (non-shared; BUILD_SHARED_LIBS is off) compilation
* Added unit-testing mechanism:
  * Any test-*.cpp (and, in future, test-*.py, etc.) under unit-tests/ is a unit-test
  * Tests can be nested inside directories
  * Each test creates its own project (in Visual Studio under Unit-Tests, with same nested structure) and thus its own executable
  * A script (unit-tests/run-unit-tests.py) runs all unit-tests and exits with status 1 or 0
  * Unit-tests can be specifically shared or static
* Unit-tests are now run in Travis, in both shared and static builds
* BUILD_SHARED_LIBS is now a compiler definition, too
* Added rs2::log_to_callback, rs2_log_to_callback, rs2_log_to_callback_cpp
  * Minimum level can be set for a callback (e.g., warnings and above)
  * Added RS2_LOG_SEVERITY_ALL, same as _DEBUG, so it's easier to say "log all messages"
  * Logging to file now flushes immediately after each message (down from every 10 messages) mostly  so unit-testing works better)
  * 21 unit-tests under unit-tests/log/
@maloel
maloel requested a review from dorodnic January 5, 2020 10:30

@dorodnic dorodnic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, I have some questions on the python stuff

Comment thread include/librealsense2/h/rs_types.h Outdated
Comment thread include/librealsense2/h/rs_types.h Outdated
Comment thread include/librealsense2/rs.hpp Outdated
Comment thread src/log.h Outdated
Comment thread src/realsense.def
Comment thread tools/realsense-viewer/realsense-viewer.cpp Outdated
/* Return the number of lines in a file */
size_t count_lines( char const* filename )
{
FILE* pFile = fopen( filename, "r" );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why like this and not c++ style?

Comment thread unit-tests/log/test-c-all.cpp Outdated
Comment thread unit-tests/log/test-vs-LOG-static.cpp
- removed rs2_string and any related functions
- rs2_build_log_message -> rs2_get_full_log_message; messages are only built when first called
- C-style log callbacks now accept a void* argument
- restored original file-flush behavior; unit-tests now flush before checking files
- restored original realsense-viewer behavior (no callback logging for now)

@dorodnic dorodnic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maloel
maloel merged commit 769ff8a into realsenseai:development Feb 4, 2020
@maloel
maloel deleted the log branch February 4, 2020 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants