From 744cf6f8abcf71477c461f399effb4b9f3650931 Mon Sep 17 00:00:00 2001 From: Eran Date: Sat, 28 Oct 2023 13:15:36 +0300 Subject: [PATCH] fixup! add rs-all-client test in GHA --- .github/workflows/buildsCI.yaml | 22 +++++--- .../workflows/rs-all-client/CMakeLists.txt | 14 ++++- .github/workflows/rs-all-client/main.cpp | 54 +++++++++++-------- 3 files changed, 59 insertions(+), 31 deletions(-) diff --git a/.github/workflows/buildsCI.yaml b/.github/workflows/buildsCI.yaml index 642f0e4d043..482c63d1f6e 100644 --- a/.github/workflows/buildsCI.yaml +++ b/.github/workflows/buildsCI.yaml @@ -154,15 +154,14 @@ jobs: run: | python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "windows" ${{env.WIN_BUILD_DIR}}/Release - - name: Libraries - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + - name: Client for realsense2-all shell: bash - run: | + run: | mkdir ${{env.WIN_BUILD_DIR}}/rs-all-client cd ${{env.WIN_BUILD_DIR}}/rs-all-client cmake $GITHUB_WORKSPACE/.github/workflows/rs-all-client -G "Visual Studio 16 2019" cmake --build . --config Release -- -m + ./Release/rs-all-client #-------------------------------------------------------------------------------- @@ -392,7 +391,7 @@ jobs: run: | cd build cmake .. -DCMAKE_BUILD_TYPE=${{env.LRS_RUN_CONFIG}} -DBUILD_SHARED_LIBS=false -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) -DFORCE_RSUSB_BACKEND=true - cmake --build . -- -j4 + cmake --build . -- -j4 - name: LibCI # Note: we specifically disable BUILD_UNIT_TESTS so the executable C++ unit-tests won't run @@ -400,16 +399,25 @@ jobs: shell: bash run: | python3 unit-tests/run-unit-tests.py --no-color --debug --stdout --not-live --context "dds linux" --tag dds + + - name: Client for realsense2-all + shell: bash + run: | + mkdir build/rs-all-client + cd build/rs-all-client + cmake ../../.github/workflows/rs-all-client -DBUILD_WITH_DDS=ON + cmake --build . -- -j4 + ./rs-all-client #-------------------------------------------------------------------------------- U22_SH_RSUSB_LiveTest: # Ubuntu 2022, Shared, Legacy live-tests - runs-on: ubuntu-22.04 + runs-on: ubuntu-22.04 timeout-minutes: 60 env: LRS_BUILD_NODEJS: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - name: Check_API shell: bash diff --git a/.github/workflows/rs-all-client/CMakeLists.txt b/.github/workflows/rs-all-client/CMakeLists.txt index f373be63ede..d6b43d606f8 100644 --- a/.github/workflows/rs-all-client/CMakeLists.txt +++ b/.github/workflows/rs-all-client/CMakeLists.txt @@ -29,12 +29,22 @@ endif() add_executable( ${PROJECT_NAME} main.cpp ) set_target_properties( ${PROJECT_NAME} PROPERTIES CXX_STANDARD 14 - MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug> # New in version 3.15 + MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug> # New in version 3.15; ignored in Linux ) -target_include_directories( ${PROJECT_NAME} PRIVATE ../../../include ) +target_include_directories( ${PROJECT_NAME} PRIVATE + ../../../include + ../../../third-party/rsutils/include + ) target_link_directories( ${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/../Release ) +if( NOT WIN32 ) + find_library( LIBUSB NAMES usb-1.0 ) + target_link_libraries( ${PROJECT_NAME} PRIVATE realsense2-all udev pthread ${LIBUSB} ) + if( BUILD_WITH_DDS ) + target_link_libraries( ${PROJECT_NAME} PRIVATE ssl crypto rt ) + endif() +endif() # target_link_libraries( ${PROJECT_NAME} PRIVATE realsense2-all ) diff --git a/.github/workflows/rs-all-client/main.cpp b/.github/workflows/rs-all-client/main.cpp index a515f7fd5a1..6f0be73d395 100644 --- a/.github/workflows/rs-all-client/main.cpp +++ b/.github/workflows/rs-all-client/main.cpp @@ -2,34 +2,44 @@ // Copyright(c) 2023 Intel Corporation. All Rights Reserved. #include // Include RealSense Cross Platform API + +#include #include // for cout +#include +#include -// This is the Hello RealSense example int main(int argc, char * argv[]) try { - // Create a Pipeline - this serves as a top-level API for streaming and processing frames - rs2::pipeline p; - - // Configure and start the pipeline - p.start(); + rs2::log_to_console( RS2_LOG_SEVERITY_DEBUG ); - while (true) + rs2::context context; + auto devices = context.query_devices(); + if( devices.size() ) { - // Block program until frames arrive - rs2::frameset frames = p.wait_for_frames(); - - // Try to get a frame of a depth image - rs2::depth_frame depth = frames.get_depth_frame(); - - // Get the depth frame's dimensions - auto width = depth.get_width(); - auto height = depth.get_height(); - - // Query the distance from the camera to the object in the center of the image - float dist_to_center = depth.get_distance(width / 2, height / 2); - - // Print the distance - std::cout << "The camera is facing an object " << dist_to_center << " meters away \r"; + // This can run under GHA, too -- so we don't always have devices + // Run for just a little bit, count the frames + size_t n_frames = 0; + { + rs2::pipeline p( context ); + auto profile = p.start(); + auto device = profile.get_device(); + std::cout << "Streaming on " << device.get_info( RS2_CAMERA_INFO_NAME ) << std::endl; + + rsutils::time::timer timer( std::chrono::seconds( 3 ) ); + while( ! timer.has_expired() ) + { + // Block program until frames arrive + rs2::frameset frames = p.wait_for_frames(); + ++n_frames; + } + } + + std::cout << "Got " << n_frames << " frames" << std::endl; + } + else + { + // Allow enough time for DDS enumeration + std::this_thread::sleep_for( std::chrono::seconds( 3 ) ); } return EXIT_SUCCESS;