diff --git a/.github/workflows/buildsCI.yaml b/.github/workflows/buildsCI.yaml index 62c95f8cf2..4e465294a4 100644 --- a/.github/workflows/buildsCI.yaml +++ b/.github/workflows/buildsCI.yaml @@ -412,6 +412,47 @@ jobs: python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "dds linux" --tag dds + #-------------------------------------------------------------------------------- + U22_SH_Py_DDS_CI: # Ubuntu 2022, Shared, Python, DDS, LibCI without executables + runs-on: ubuntu-22.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + + - name: Prebuild + shell: bash + run: | + sudo apt-get update; + sudo apt-get install -qq build-essential xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev libglm-dev; + sudo apt-get install -qq libusb-1.0-0-dev; + sudo apt-get install -qq libgtk-3-dev; + sudo apt-get install libglfw3-dev libglfw3; + python3 -m pip install numpy + + - name: Check_API + shell: bash + run: | + cd scripts + ./api_check.sh + ./pr_check.sh + cd .. + mkdir build + + - name: Build + shell: bash + run: | + cd build + cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_RUN_CONFIG}} -DBUILD_SHARED_LIBS=true -DBUILD_EXAMPLES=false -DBUILD_TOOLS=false -DBUILD_UNIT_TESTS=false -DCHECK_FOR_UPDATES=false -DBUILD_WITH_DDS=true -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=$(which python3) + cmake --build . -- -j4 + + - name: LibCI + # Note: we specifically disable BUILD_UNIT_TESTS so the executable C++ unit-tests won't run + # This is to save time as DDS already lengthens the build... + shell: bash + run: | + python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "dds linux" --tag dds + + #-------------------------------------------------------------------------------- U22_SH_RSUSB_LiveTest: # Ubuntu 2022, Shared, Legacy live-tests runs-on: ubuntu-22.04 diff --git a/src/rs.cpp b/src/rs.cpp index fe3c4bc7f3..281922ca8f 100644 --- a/src/rs.cpp +++ b/src/rs.cpp @@ -3101,24 +3101,24 @@ void rs2_log(rs2_log_severity severity, const char * message, rs2_error ** error switch (severity) { case RS2_LOG_SEVERITY_DEBUG: - LOG_DEBUG(message); + LOG_DEBUG_STR(message); break; case RS2_LOG_SEVERITY_INFO: - LOG_INFO(message); + LOG_INFO_STR(message); break; case RS2_LOG_SEVERITY_WARN: - LOG_WARNING(message); + LOG_WARNING_STR(message); break; case RS2_LOG_SEVERITY_ERROR: - LOG_ERROR(message); + LOG_ERROR_STR(message); break; case RS2_LOG_SEVERITY_FATAL: - LOG_FATAL(message); + LOG_FATAL_STR(message); break; case RS2_LOG_SEVERITY_NONE: break; default: - LOG_INFO(message); + LOG_INFO_STR(message); } } HANDLE_EXCEPTIONS_AND_RETURN(, severity, message) diff --git a/third-party/realdds/include/realdds/dds-exceptions.h b/third-party/realdds/include/realdds/dds-exceptions.h index a21ad24cdb..fbabab788b 100644 --- a/third-party/realdds/include/realdds/dds-exceptions.h +++ b/third-party/realdds/include/realdds/dds-exceptions.h @@ -1,11 +1,9 @@ // License: Apache 2.0. See LICENSE file in root directory. -// Copyright(c) 2022 Intel Corporation. All Rights Reserved. - +// Copyright(c) 2022-4 Intel Corporation. All Rights Reserved. #pragma once #include #include -#include // E.g.: @@ -14,8 +12,11 @@ #define DDS_THROW( ERR_TYPE, WHAT ) \ do \ { \ - LOG_ERROR( "throwing: " << WHAT ); \ - throw realdds::dds_##ERR_TYPE( rsutils::string::from() << WHAT ); \ + std::ostringstream os__; \ + os__ << WHAT; \ + auto log_message__ = os__.str(); \ + LOG_ERROR_STR( "throwing: " << log_message__ ); \ + throw realdds::dds_##ERR_TYPE( std::move( log_message__ ) ); \ } \ while( 0 ) @@ -26,15 +27,7 @@ namespace realdds { class dds_runtime_error : public std::runtime_error { public: - dds_runtime_error( std::string const& str ) - : std::runtime_error( str ) - { - } - - dds_runtime_error( char const* lpsz ) - : std::runtime_error( lpsz ) - { - } + using std::runtime_error::runtime_error; }; diff --git a/third-party/realdds/src/dds-device-server.cpp b/third-party/realdds/src/dds-device-server.cpp index b10a327735..159ccf4f80 100644 --- a/third-party/realdds/src/dds-device-server.cpp +++ b/third-party/realdds/src/dds-device-server.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include using rsutils::json; diff --git a/third-party/realdds/src/dds-participant.cpp b/third-party/realdds/src/dds-participant.cpp index 3a75cbfabb..24d8444f89 100644 --- a/third-party/realdds/src/dds-participant.cpp +++ b/third-party/realdds/src/dds-participant.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include diff --git a/third-party/rsutils/include/rsutils/easylogging/easyloggingpp.h b/third-party/rsutils/include/rsutils/easylogging/easyloggingpp.h index 6f075ac8c0..d058a71068 100644 --- a/third-party/rsutils/include/rsutils/easylogging/easyloggingpp.h +++ b/third-party/rsutils/include/rsutils/easylogging/easyloggingpp.h @@ -1,6 +1,5 @@ // License: Apache 2.0. See LICENSE file in root directory. -// Copyright(c) 2021 Intel Corporation. All Rights Reserved. - +// Copyright(c) 2021-4 Intel Corporation. All Rights Reserved. #pragma once // When including this file outside LibRealSense you also need to: @@ -41,17 +40,65 @@ #define LOG_DEBUG(...) do { std::ostringstream ss; ss << __VA_ARGS__; __android_log_write( ANDROID_LOG_DEBUG, ANDROID_LOG_TAG, ss.str().c_str() ); } while(false) #endif +#define LOG_DEBUG_STR(STR) LOG_DEBUG( STR ) +#define LOG_INFO_STR(STR) LOG_INFO( STR ) +#define LOG_WARNING_STR(STR) LOG_WARNING( STR ) +#define LOG_ERROR_STR(STR) LOG_ERROR( STR ) +#define LOG_FATAL_STR(STR) LOG_FATAL( STR ) + #else //__ANDROID__ -#define LOG_DEBUG(...) do { CLOG(DEBUG , LIBREALSENSE_ELPP_ID) << __VA_ARGS__; } while(false) -#define LOG_INFO(...) do { CLOG(INFO , LIBREALSENSE_ELPP_ID) << __VA_ARGS__; } while(false) -#define LOG_WARNING(...) do { CLOG(WARNING , LIBREALSENSE_ELPP_ID) << __VA_ARGS__; } while(false) -#define LOG_ERROR(...) do { CLOG(ERROR , LIBREALSENSE_ELPP_ID) << __VA_ARGS__; } while(false) -#define LOG_FATAL(...) do { CLOG(FATAL , LIBREALSENSE_ELPP_ID) << __VA_ARGS__; } while(false) +// Direct log to ELPP, without conversion to string first; use this as an optimization, if you have simple string output +// +// We've seen cases where this fails in U22, causing weird effects with custom overloads/types (e.g., json) +#define LIBRS_LOG_STR_( LEVEL, STR ) \ + do \ + { \ + auto logger__ = el::Loggers::getLogger( rsutils::g_librealsense_elpp_id ); \ + if( logger__ && logger__->enabled( el::Level::LEVEL ) ) \ + { \ + el::base::Writer( el::Level::LEVEL, __FILE__, __LINE__, ELPP_FUNC, el::base::DispatchAction::NormalLog ) \ + .construct( logger__ ) \ + << STR; \ + } \ + } \ + while( false ) + +// Same, but first convert to string using usual mechanisms +#define LIBRS_LOG_( LEVEL, ... ) \ + do \ + { \ + auto logger__ = el::Loggers::getLogger( rsutils::g_librealsense_elpp_id ); \ + if( logger__ && logger__->enabled( el::Level::LEVEL ) ) \ + { \ + std::ostringstream os__; \ + os__ << __VA_ARGS__; \ + el::base::Writer( el::Level::LEVEL, __FILE__, __LINE__, ELPP_FUNC, el::base::DispatchAction::NormalLog ) \ + .construct( logger__ ) \ + << os__.str(); \ + } \ + } \ + while( false ) + +#define LOG_DEBUG(...) LIBRS_LOG_( Debug, __VA_ARGS__ ) +#define LOG_INFO(...) LIBRS_LOG_( Info, __VA_ARGS__ ) +#define LOG_WARNING(...) LIBRS_LOG_( Warning, __VA_ARGS__ ) +#define LOG_ERROR(...) LIBRS_LOG_( Error, __VA_ARGS__ ) +#define LOG_FATAL(...) LIBRS_LOG_( Fatal, __VA_ARGS__ ) + +#define LOG_DEBUG_STR(STR) LIBRS_LOG_STR_( Debug, STR ) +#define LOG_INFO_STR(STR) LIBRS_LOG_STR_( Info, STR ) +#define LOG_WARNING_STR(STR) LIBRS_LOG_STR_( Warning, STR ) +#define LOG_ERROR_STR(STR) LIBRS_LOG_STR_( Error, STR ) +#define LOG_FATAL_STR(STR) LIBRS_LOG_STR_( Fatal, STR ) namespace rsutils { +// This is a caching of LIBREALSENSE_ELPP_ID in a string, as a performance optimization +extern std::string const g_librealsense_elpp_id; + + // Configure the same logger as librealsense (by default), to disable/enable debug output void configure_elpp_logger( bool enable_debug = false, std::string const & nested_indent = "", @@ -73,5 +120,11 @@ void configure_elpp_logger( bool enable_debug = false, #define LOG_ERROR(...) do { ; } while(false) #define LOG_FATAL(...) do { ; } while(false) +#define LOG_DEBUG_STR(STR) do { ; } while(false) +#define LOG_INFO_STR(STR) do { ; } while(false) +#define LOG_WARNING_STR(STR) do { ; } while(false) +#define LOG_ERROR_STR(STR) do { ; } while(false) +#define LOG_FATAL_STR(STR) do { ; } while(false) + #endif // BUILD_EASYLOGGINGPP diff --git a/third-party/rsutils/src/configure-elpp-logger.cpp b/third-party/rsutils/src/configure-elpp-logger.cpp index 9f24ab52ac..6d2441bb41 100644 --- a/third-party/rsutils/src/configure-elpp-logger.cpp +++ b/third-party/rsutils/src/configure-elpp-logger.cpp @@ -4,9 +4,13 @@ #ifdef BUILD_EASYLOGGINGPP #include + namespace rsutils { +std::string const g_librealsense_elpp_id( LIBREALSENSE_ELPP_ID ); + + void configure_elpp_logger( bool enable_debug, std::string const & nested_indent, std::string const & logger_id ) { el::Configurations defaultConf; diff --git a/unit-tests/py/rspy/devices.py b/unit-tests/py/rspy/devices.py index cbf175ef51..9ce2e4bac6 100644 --- a/unit-tests/py/rspy/devices.py +++ b/unit-tests/py/rspy/devices.py @@ -698,7 +698,7 @@ def _get_usb_location( physical_port ): try: opts,args = getopt.getopt( sys.argv[1:], '', - longopts = [ 'help', 'recycle', 'all', 'none', 'list', 'port=', 'ports' ]) + longopts = [ 'help', 'recycle', 'all', 'none', 'list', 'port=', 'PORT=', 'ports' ]) except getopt.GetoptError as err: print( '-F-', err ) # something like "option -a not recognized" usage() @@ -718,7 +718,7 @@ def get_phys_port(dev): for opt,arg in opts: if opt in ('--list'): action = 'list' - elif opt in ('--port'): + elif opt in ('--port','--PORT'): if not hub: log.f( 'No hub available' ) all_ports = hub.all_ports() @@ -726,7 +726,11 @@ def get_phys_port(dev): ports = [int(port) for port in str_ports if port.isnumeric() and int(port) in all_ports] if len(ports) != len(str_ports): log.f( 'Invalid ports', str_ports ) - hub.enable_ports( ports, disable_other_ports=False ) + # With --port, leave other ports alone + # With --PORT, disable other ports + # This would otherwise require --none, wait, --port) + # Note that it does not recycle the port if it was already enabled + hub.enable_ports( ports, disable_other_ports=(opt == '--PORT') ) action = 'none' elif opt in ('--ports'): printer = get_phys_port