diff --git a/.ci/bindings-cache.cmake b/.ci/bindings-cache.cmake index ea39f1effaf..a39e79c384c 100644 --- a/.ci/bindings-cache.cmake +++ b/.ci/bindings-cache.cmake @@ -9,4 +9,4 @@ set(CREATE_TCL ON CACHE BOOL "") set(CREATE_JAVA ON CACHE BOOL "") set(CREATE_CSHARP ON CACHE BOOL "") set(CREATE_PERL ON CACHE BOOL "") -set(CREATE_OCTAVE ON CACHE BOOL "") +set(CREATE_OCTAVE OFF CACHE BOOL "") diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea9f90a2ffe..521ab791d00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: select_environment: name: 'Prepare Environment' - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 outputs: timestamp: ${{ steps.select.outputs.timestamp }} repository_owner: ${{ steps.select.outputs.repository_owner }} @@ -102,7 +102,7 @@ jobs: check-license: name: 'Check License' needs: select_environment - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Clone repository uses: actions/checkout@v3 @@ -123,7 +123,7 @@ jobs: check-style: name: 'Check Style' needs: select_environment - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Clone repository uses: actions/checkout@v3 @@ -165,16 +165,11 @@ jobs: run-cmake: name: 'Run CMake [CMake ${{ matrix.config.cmake_version }} (${{ matrix.config.cmake_generator }}), YCM ${{ matrix.config.ycm_version }}]' needs: [select_environment, check-license, check-style] - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: config: - - { - cmake_version: "3.16.*", - cmake_generator: "Unix Makefiles", - ycm_version: "0.15.3", - } - { cmake_version: "3.17.*", cmake_generator: "Unix Makefiles", @@ -290,7 +285,7 @@ jobs: config: - { id: '01', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", cc: "gcc", cxx: "g++", @@ -300,10 +295,10 @@ jobs: } - { id: '02', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", - cc: "clang", - cxx: "clang++", + cc: "clang-17", + cxx: "clang++-17", cmake_generator: "Unix Makefiles", cmake_initial_cache_file: ".ci/initial-cache.gh.linux.cmake", test_external_bindings: true, @@ -311,7 +306,7 @@ jobs: - { id: '03', description: 'No ACE', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", cc: "gcc", cxx: "g++", @@ -324,10 +319,10 @@ jobs: - { id: '04', description: 'No ACE', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", - cc: "clang", - cxx: "clang++", + cc: "clang-17", + cxx: "clang++-17", cmake_generator: "Unix Makefiles", cmake_initial_cache_file: ".ci/initial-cache.gh.linux.cmake", cmake_extra_options: "-DCMAKE_DISABLE_FIND_PACKAGE_ACE:BOOL=ON @@ -337,7 +332,7 @@ jobs: - { id: '05', description: 'No YARP_math (bindings disabled)', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", cc: "gcc", cxx: "g++", @@ -351,10 +346,10 @@ jobs: - { id: '06', description: 'No YARP_math (bindings disabled)', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", - cc: "clang", - cxx: "clang++", + cc: "clang-17", + cxx: "clang++-17", cmake_generator: "Unix Makefiles", cmake_initial_cache_file: ".ci/initial-cache.gh.linux.cmake", cmake_extra_options: "-DCMAKE_DISABLE_FIND_PACKAGE_Eigen:BOOL=ON @@ -365,7 +360,7 @@ jobs: - { id: '07', description: 'CLEAN_API (unit tests and bindings disabled)', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", cc: "gcc", cxx: "g++", @@ -378,10 +373,10 @@ jobs: - { id: '08', description: 'CLEAN_API (unit tests and bindings disabled)', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", - cc: "clang", - cxx: "clang++", + cc: "clang-17", + cxx: "clang++-17", cmake_generator: "Unix Makefiles", cmake_initial_cache_file: ".ci/initial-cache.gh.linux.cmake", cmake_extra_options: "-DYARP_CLEAN_API:BOOL=ON @@ -391,7 +386,7 @@ jobs: - { id: '09', description: 'Static', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", cc: "gcc", cxx: "g++", @@ -402,10 +397,10 @@ jobs: - { id: '10', description: 'Static', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", - cc: "clang", - cxx: "clang++", + cc: "clang-17", + cxx: "clang++-17", cmake_generator: "Unix Makefiles", cmake_initial_cache_file: ".ci/initial-cache.gh.linux.cmake", cmake_extra_options: "-DBUILD_SHARED_LIBS:BOOL=OFF", @@ -413,7 +408,7 @@ jobs: - { id: '11', description: 'Static, no ACE (bindings disabled)', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", cc: "gcc", cxx: "g++", @@ -427,10 +422,10 @@ jobs: - { id: '12', description: 'Static, no ACE (bindings disabled)', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", - cc: "clang", - cxx: "clang++", + cc: "clang-17", + cxx: "clang++-17", cmake_generator: "Unix Makefiles", cmake_initial_cache_file: ".ci/initial-cache.gh.linux.cmake", cmake_extra_options: "-DBUILD_SHARED_LIBS:BOOL=OFF @@ -441,7 +436,7 @@ jobs: - { id: '13', description: 'No deprecated', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", cc: "gcc", cxx: "g++", @@ -452,10 +447,10 @@ jobs: - { id: '14', description: 'No deprecated', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", - cc: "clang", - cxx: "clang++", + cc: "clang-17", + cxx: "clang++-17", cmake_generator: "Unix Makefiles", cmake_initial_cache_file: ".ci/initial-cache.gh.linux.cmake", cmake_extra_options: "-DYARP_NO_DEPRECATED:BOOL=ON", @@ -463,7 +458,7 @@ jobs: - { id: '15', description: 'No executables (unit tests disabled)', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", cc: "gcc", cxx: "g++", @@ -475,10 +470,10 @@ jobs: - { id: '16', description: 'No executables (unit tests disabled)', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", - cc: "clang", - cxx: "clang++", + cc: "clang-17", + cxx: "clang++-17", cmake_generator: "Unix Makefiles", cmake_initial_cache_file: ".ci/initial-cache.gh.linux.cmake", cmake_extra_options: "-DYARP_COMPILE_EXECUTABLES:BOOL=OFF @@ -487,7 +482,7 @@ jobs: - { id: '17', description: 'Build extern dependencies', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", cc: "gcc", cxx: "g++", @@ -500,10 +495,10 @@ jobs: - { id: '18', description: 'Build extern dependencies', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", - cc: "clang", - cxx: "clang++", + cc: "clang-17", + cxx: "clang++-17", cmake_generator: "Unix Makefiles", cmake_initial_cache_file: ".ci/initial-cache.gh.linux.cmake", cmake_extra_options: "-DCMAKE_DISABLE_FIND_PACKAGE_SQLite:BOOL=ON @@ -512,7 +507,7 @@ jobs: } - { id: '19', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", cc: "gcc", cxx: "g++", @@ -521,17 +516,17 @@ jobs: } - { id: '20', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Release", - cc: "clang", - cxx: "clang++", + cc: "clang-17", + cxx: "clang++-17", cmake_generator: "Ninja", cmake_initial_cache_file: ".ci/initial-cache.gh.linux.cmake", } - { id: '21', description: 'Valgrind (bindings, failing tests, guis and examples as tests disabled)', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Debug", cc: "gcc", cxx: "g++", @@ -543,12 +538,18 @@ jobs: -DYARP_ENABLE_EXAMPLES_AS_TESTS:BOOL=OFF -DYARP_COMPILE_BINDINGS:BOOL=OFF -DCMAKE_DISABLE_FIND_PACKAGE_FFMPEG=ON - -DYARP_COMPILE_GUIS:BOOL=OFF", + -DYARP_COMPILE_GUIS:BOOL=OFF + -DENABLE_yarpmod_usbCamera:BOOL=OFF + -DENABLE_yarpmod_usbCameraRaw:BOOL=OFF + -DENABLE_yarpmod_portaudio:BOOL=OFF + -DENABLE_yarpmod_portaudioPlayer:BOOL=OFF + -DENABLE_yarpmod_portaudioRecorder:BOOL=OFF + -DENABLE_yarpmod_opencv_grabber:BOOL=OFF", } - { id: '22', description: 'Valgrind, No ACE (bindings, failing tests, guis and examples as tests disabled)', - os: ubuntu-20.04, + os: ubuntu-22.04, build_type: "Debug", cc: "gcc", cxx: "g++", @@ -562,7 +563,13 @@ jobs: -DYARP_ENABLE_EXAMPLES_AS_TESTS:BOOL=OFF -DYARP_COMPILE_BINDINGS:BOOL=OFF -DCMAKE_DISABLE_FIND_PACKAGE_FFMPEG=ON - -DYARP_COMPILE_GUIS:BOOL=OFF", + -DYARP_COMPILE_GUIS:BOOL=OFF + -DENABLE_yarpmod_usbCamera:BOOL=OFF + -DENABLE_yarpmod_usbCameraRaw:BOOL=OFF + -DENABLE_yarpmod_portaudio:BOOL=OFF + -DENABLE_yarpmod_portaudioPlayer:BOOL=OFF + -DENABLE_yarpmod_portaudioRecorder:BOOL=OFF + -DENABLE_yarpmod_opencv_grabber:BOOL=OFF", } - { id: '23', @@ -699,9 +706,20 @@ jobs: if: runner.os == 'Linux' shell: bash run: | + # Install dep for gstreamer. It must be the first one. + sudo apt-get update + sudo apt-get install -y libunwind-dev + + #Install clang 17 + sudo apt-get purge -y llvm* clang* + wget -nv https://apt.llvm.org/llvm.sh + sudo chmod +x llvm.sh + sudo ./llvm.sh 17 + # Install Robotology dependencies from robotology ppa sudo apt-add-repository -y ppa:robotology/ppa sudo apt-get install -qq -y librobottestingframework-dev + sudo apt-get update # Install cmake sudo apt-get install -qq -y cmake @@ -718,9 +736,9 @@ jobs: ninja-build \ valgrind - sudo apt-get install -y libace-dev \ + sudo apt-get install -y libace-dev - sudo apt-get install -qq -y libsqlite3-dev \ + sudo apt-get install -y libsqlite3-dev \ libtinyxml-dev \ libedit-dev \ qtbase5-dev \ @@ -731,8 +749,6 @@ jobs: libopencv-dev \ libeigen3-dev \ libgraphviz-dev \ - libgstreamer1.0-dev \ - libgstreamer-plugins-base1.0-dev \ libpng-dev \ libv4l-dev \ libavcodec-dev \ @@ -748,6 +764,9 @@ jobs: libpcl-dev \ libsoxr-dev + sudo apt-get install -y libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev + # Install SWIG and bindings dependencies sudo apt-get install -qq -y swig \ mono-mcs \ @@ -769,8 +788,6 @@ jobs: gcovr \ wget \ curl \ - clang-11 \ - clang-tidy-11 \ xsltproc \ libxml2-utils \ source-highlight @@ -882,7 +899,7 @@ jobs: if("${{ matrix.config.cc }}" MATCHES "gcc") file(APPEND "${_env_script}" "set(ENV{CFLAGS} -fdiagnostics-color=always)\n") file(APPEND "${_env_script}" "set(ENV{CXXFLAGS} -fdiagnostics-color=always)\n") - elseif("${{ matrix.config.cc }}" MATCHES "clang") + elseif("${{ matrix.config.cc }}" MATCHES "^clang.*") file(APPEND "${_env_script}" "set(ENV{CFLAGS} -fcolor-diagnostics)\n") file(APPEND "${_env_script}" "set(ENV{CXXFLAGS} -fcolor-diagnostics)\n") endif() @@ -1369,7 +1386,7 @@ jobs: environment: code-analysis name: 'Codacy - clang-tidy' needs: [select_environment, run-cmake] - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Clone repository uses: actions/checkout@v3 @@ -1383,6 +1400,10 @@ jobs: if: runner.os == 'Linux' shell: bash run: | + # Install dep for gstreamer. It must be the first one. + sudo apt-get update + sudo apt-get install -y libunwind-dev + # Install Robotology dependencies from robotology ppa sudo apt-add-repository -y ppa:robotology/ppa sudo apt-get install -qq -y librobottestingframework-dev @@ -1416,8 +1437,6 @@ jobs: libopencv-dev \ libeigen3-dev \ libgraphviz-dev \ - libgstreamer1.0-dev \ - libgstreamer-plugins-base1.0-dev \ libpng-dev \ libv4l-dev \ libavcodec-dev \ @@ -1432,6 +1451,9 @@ jobs: libjpeg-dev \ libpcl-dev + sudo apt-get install -y libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev + # Install SWIG and bindings dependencies sudo apt-get install -qq -y swig \ mono-mcs \ @@ -1453,8 +1475,6 @@ jobs: gcovr \ wget \ curl \ - clang-11 \ - clang-tidy-11 \ xsltproc \ libxml2-utils \ source-highlight @@ -1465,8 +1485,8 @@ jobs: - name: Prepare environment env: CODACY_TOKEN: ${{ secrets.CODACY_TOKEN }} - CLANG_VERSION: 10 - CODACY_CLANG_TIDY_VERSION: 1.2.1 + CLANG_VERSION: 17 + CODACY_CLANG_TIDY_VERSION: 1.3.8 run: | echo "CLANG_VERSION=${CLANG_VERSION}" >> $GITHUB_ENV echo "CC=/usr/bin/clang-${CLANG_VERSION}" >> $GITHUB_ENV @@ -1488,12 +1508,14 @@ jobs: if: runner.os == 'Linux' shell: bash run: | - # Download extra packages required - sudo apt-get install -qq -y clang-${CLANG_VERSION} \ - clang-tidy-${CLANG_VERSION} + #Install clang 17. `all` option is required for clang-tidy + sudo apt-get purge -y llvm* clang* + wget -nv https://apt.llvm.org/llvm.sh + sudo chmod +x llvm.sh + sudo ./llvm.sh 17 all # Download codacy-clang-tidy - sudo wget https://github.com/codacy/codacy-clang-tidy/releases/download/${CODACY_CLANG_TIDY_VERSION}/codacy-clang-tidy-${CODACY_CLANG_TIDY_VERSION} -O /usr/local/bin/codacy-clang-tidy-${CODACY_CLANG_TIDY_VERSION} + sudo wget https://github.com/codacy/codacy-clang-tidy/releases/download/${CODACY_CLANG_TIDY_VERSION}/codacy-clang-tidy-linux-${CODACY_CLANG_TIDY_VERSION} -O /usr/local/bin/codacy-clang-tidy-${CODACY_CLANG_TIDY_VERSION} sudo chmod -v +x /usr/local/bin/codacy-clang-tidy-${CODACY_CLANG_TIDY_VERSION} - name: Run CMake @@ -1557,7 +1579,7 @@ jobs: environment: code-analysis name: 'Codacy - coverage' needs: [select_environment, run-cmake] - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Clone repository uses: actions/checkout@v3 @@ -1571,6 +1593,10 @@ jobs: if: runner.os == 'Linux' shell: bash run: | + # Install dep for gstreamer. It must be the first one. + sudo apt-get update + sudo apt-get install -y libunwind-dev + # Install Robotology dependencies from robotology ppa sudo apt-add-repository -y ppa:robotology/ppa sudo apt-get install -qq -y librobottestingframework-dev @@ -1641,8 +1667,6 @@ jobs: gcovr \ wget \ curl \ - clang-11 \ - clang-tidy-11 \ xsltproc \ libxml2-utils \ source-highlight @@ -1689,7 +1713,7 @@ jobs: environment: code-analysis name: 'SonarCloud' needs: [select_environment, run-cmake] - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Clone repository uses: actions/checkout@v3 @@ -1779,6 +1803,10 @@ jobs: if: runner.os == 'Linux' shell: bash run: | + # Install dep for gstreamer. It must be the first one. + sudo apt-get update + sudo apt-get install -y libunwind-dev + # Install Robotology dependencies from robotology ppa sudo apt-add-repository -y ppa:robotology/ppa sudo apt-get install -qq -y librobottestingframework-dev @@ -1849,8 +1877,6 @@ jobs: gcovr \ wget \ curl \ - clang-11 \ - clang-tidy-11 \ xsltproc \ libxml2-utils \ source-highlight diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index fc60178dd84..1eaa001e130 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -9,8 +9,10 @@ set(CMAKE_C_FLAGS "-w ${_USER_CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "-w ${_USER_CMAKE_CXX_FLAGS}") # Catch2 +if(YARP_COMPILE_TESTS) add_subdirectory(catch2) - +endif() + # TinyXML if(YARP_BUILD_TinyXML) add_subdirectory(tinyxml) diff --git a/extern/catch2/CMakeLists.txt b/extern/catch2/CMakeLists.txt index f61cd9d1da2..5de4dc67434 100644 --- a/extern/catch2/CMakeLists.txt +++ b/extern/catch2/CMakeLists.txt @@ -3,6 +3,10 @@ project(YARP_catch2) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + add_library(YARP_catch2 STATIC) add_library(YARP::YARP_catch2 ALIAS YARP_catch2) diff --git a/src/carriers/mjpeg_carrier/tests/mjpeg.cpp b/src/carriers/mjpeg_carrier/tests/mjpeg.cpp index 5c82ffe1771..6c55c70462e 100644 --- a/src/carriers/mjpeg_carrier/tests/mjpeg.cpp +++ b/src/carriers/mjpeg_carrier/tests/mjpeg.cpp @@ -17,6 +17,10 @@ TEST_CASE("carriers::mjpeg", "[carriers]") { YARP_REQUIRE_PLUGIN("mjpeg", "carrier"); +#if defined(DISABLE_FAILING_VALGRIND_TESTS) + YARP_SKIP_TEST("Skipping failing tests under valgrind") +#endif + Network::setLocalMode(true); SECTION("test compression-decompression") @@ -31,8 +35,8 @@ TEST_CASE("carriers::mjpeg", "[carriers]") REQUIRE(out.open(outName)); REQUIRE(Network::connect(out.getName(), in.getName(), "mjpeg")); - size_t width {320}; - size_t height {240}; + size_t width {160}; + size_t height {120}; ImageOf& outImg = out.prepare(); outImg.resize(width, height); diff --git a/src/devices/fakeLaserWithMotor/fakeLaserWithMotor_motors.cpp b/src/devices/fakeLaserWithMotor/fakeLaserWithMotor_motors.cpp index 424272fafcc..fc81dbe449b 100644 --- a/src/devices/fakeLaserWithMotor/fakeLaserWithMotor_motors.cpp +++ b/src/devices/fakeLaserWithMotor/fakeLaserWithMotor_motors.cpp @@ -121,7 +121,7 @@ bool FakeLaserWithMotor::relativeMoveRaw(int j, double delta) yCError(FAKE_LASER_MOTORS) << "relativeMoveRaw: skipping command because joint " << j << " is not in VOCAB_CM_POSITION mode"; } _posCtrl_references[j] += delta; - return false; + return true; } bool FakeLaserWithMotor::relativeMoveRaw(const double* deltas) @@ -138,7 +138,7 @@ bool FakeLaserWithMotor::relativeMoveRaw(const double* deltas) bool FakeLaserWithMotor::checkMotionDoneRaw(int j, bool* flag) { *flag = false; - return false; + return true; } bool FakeLaserWithMotor::checkMotionDoneRaw(bool* flag) @@ -148,7 +148,7 @@ bool FakeLaserWithMotor::checkMotionDoneRaw(bool* flag) for (int j = 0, index = 0; j < m_njoints; j++, index++) { - ret &= checkMotionDoneRaw(&val); + ret &= checkMotionDoneRaw(j, &val); tot_res &= val; } *flag = tot_res; @@ -244,7 +244,7 @@ bool FakeLaserWithMotor::getRefAccelerationsRaw(double* accs) bool FakeLaserWithMotor::stopRaw(int j) { - return false; + return true; } bool FakeLaserWithMotor::stopRaw() diff --git a/src/devices/fakeMotionControl/fakeMotionControl.cpp b/src/devices/fakeMotionControl/fakeMotionControl.cpp index d65e8250954..83e21a426ba 100644 --- a/src/devices/fakeMotionControl/fakeMotionControl.cpp +++ b/src/devices/fakeMotionControl/fakeMotionControl.cpp @@ -2002,7 +2002,7 @@ bool FakeMotionControl::relativeMoveRaw(int j, double delta) yCError(FAKEMOTIONCONTROL) << "relativeMoveRaw: skipping command because joint " << j << " is not in VOCAB_CM_POSITION mode"; } _posCtrl_references[j] += delta; - return false; + return true; } bool FakeMotionControl::relativeMoveRaw(const double *deltas) @@ -2027,7 +2027,7 @@ bool FakeMotionControl::checkMotionDoneRaw(int j, bool *flag) } *flag = false; - return false; + return true; } bool FakeMotionControl::checkMotionDoneRaw(bool *flag) @@ -2041,7 +2041,7 @@ bool FakeMotionControl::checkMotionDoneRaw(bool *flag) for(int j=0, index=0; j< _njoints; j++, index++) { - ret &= checkMotionDoneRaw(&val); + ret &= checkMotionDoneRaw(j, &val); tot_res &= val; } *flag = tot_res; diff --git a/src/devices/usbCamera/common/USBcamera.h b/src/devices/usbCamera/common/USBcamera.h index a9bbe2a0a4a..0109966b956 100644 --- a/src/devices/usbCamera/common/USBcamera.h +++ b/src/devices/usbCamera/common/USBcamera.h @@ -58,26 +58,12 @@ class USBCameraDriver : */ ~USBCameraDriver() override; - /** - * Open the device driver. - * @param config configuration for the device driver - * @return returns true on success, false on failure. - */ bool open(yarp::os::Searchable& config) override; - - /** - * Closes the device driver. - * @return returns true/false on success/failure. - */ bool close() override; int height() const; int width() const; - /** - * Implements the IPreciselyTimed interface. - * @return the yarp::os::Stamp of the last image acquired - */ yarp::os::Stamp getLastInputStamp() override; /** @@ -100,85 +86,16 @@ class USBCameraDriver : bool setMode(int feature, FeatureMode mode) override; bool getMode(int feature, FeatureMode* mode) override; bool setOnePush(int feature) override; - /** - * Return the height of each frame. - * @return rgb image height - */ - int getRgbHeight() override; - /** - * Return the width of each frame. - * @return rgb image width - */ + int getRgbHeight() override; int getRgbWidth() override; - - /** - * Get the possible configurations of the camera - * @param configurations list of camera supported configurations as CameraConfig type - * @return true on success - */ - bool getRgbSupportedConfigurations(yarp::sig::VectorOf& configurations) override; - /** - * Get the resolution of the rgb image from the camera - * @param width image width - * @param height image height - * @return true on success - */ - bool getRgbResolution(int& width, int& height) override; - - /** - * Set the resolution of the rgb image from the camera - * @param width image width - * @param height image height - * @return true on success - */ - bool setRgbResolution(int width, int height) override; - - /** - * Get the field of view (FOV) of the rgb camera. - * - * @param horizontalFov will return the value of the horizontal fov in degrees - * @param verticalFov will return the value of the vertical fov in degrees - * @return true on success - */ bool getRgbFOV(double& horizontalFov, double& verticalFov) override; - - /** - * Set the field of view (FOV) of the rgb camera. - * - * @param horizontalFov will set the value of the horizontal fov in degrees - * @param verticalFov will set the value of the vertical fov in degrees - * @return true on success - */ bool setRgbFOV(double horizontalFov, double verticalFov) override; - - /** - * Get the intrinsic parameters of the rgb camera - * @param intrinsic return a Property containing intrinsic parameters - * of the optical model of the camera. - * @return true if success - * - * Look at IVisualParams.h for more details - */ bool getRgbIntrinsicParam(yarp::os::Property& intrinsic) override; - - /** - * Get the mirroring setting of the sensor - * - * @param mirror: true if image is mirrored, false otherwise - * @return true if success - */ bool getRgbMirroring(bool& mirror) override; - - /** - * Set the mirroring setting of the sensor - * - * @param mirror: true if image should be mirrored, false otherwise - * @return true if success - */ bool setRgbMirroring(bool mirror) override; }; @@ -196,33 +113,9 @@ class USBCameraDriverRgb : USBCameraDriverRgb(); ~USBCameraDriverRgb() override; - /** - * FrameGrabber image interface, returns the last acquired frame as - * an rgb image. A demosaicking method is applied to - * reconstuct the color from the Bayer pattern of the sensor. - * @param image that will store the last frame. - * @return true/false upon success/failure - */ bool getImage(yarp::sig::ImageOf& image) override; - - /** - * FrameGrabber image interface, returns the last acquired frame as - * a raw image. - * @param image that will store the last frame. - * @return true/false upon success/failure - */ bool getImage(yarp::sig::ImageOf& image) override; - - /** - * Return the height of each frame. - * @return image height - */ int height() const override; - - /** - * Return the width of each frame. - * @return image width - */ int width() const override; }; @@ -243,25 +136,8 @@ class USBCameraDriverRaw : USBCameraDriverRaw(); ~USBCameraDriverRaw() override; - /** - * FrameGrabber image interface, returns the last acquired frame as - * an rgb image. A demosaicking method is applied to - * reconstuct the color from the Bayer pattern of the sensor. - * @param image that will store the last frame. - * @return true/false upon success/failure - */ bool getImage(yarp::sig::ImageOf& image) override; - - /** - * Return the height of each frame. - * @return image height - */ int height() const override; - - /** - * Return the width of each frame. - * @return image width - */ int width() const override; }; diff --git a/src/libYARP_dev/CMakeLists.txt b/src/libYARP_dev/CMakeLists.txt index 2646ab94665..edd998af007 100644 --- a/src/libYARP_dev/CMakeLists.txt +++ b/src/libYARP_dev/CMakeLists.txt @@ -11,11 +11,6 @@ yarp_install_basic_package_files(YARP_dev PRIVATE_DEPENDENCIES ${YARP_dev_PRIVATE_DEPS} ) -yarp_install_basic_package_files(YARP_dev_tests - DEPENDENCIES ${YARP_dev_tests_PUBLIC_DEPS} - PRIVATE_DEPENDENCIES ${YARP_dev_tests_PRIVATE_DEPS} -) - if(YARP_COMPILE_TESTS) add_subdirectory(tests) endif() diff --git a/src/libYARP_dev/src/CMakeLists.txt b/src/libYARP_dev/src/CMakeLists.txt index b471293461e..959ce26d58d 100644 --- a/src/libYARP_dev/src/CMakeLists.txt +++ b/src/libYARP_dev/src/CMakeLists.txt @@ -402,138 +402,6 @@ set(YARP_dev_PRIVATE_DEPS ${YARP_dev_PRIVATE_DEPS} PARENT_SCOPE) ################################################################### -add_library(YARP_dev_tests) -add_library(YARP::YARP_dev_tests ALIAS YARP_dev_tests) - -set(YARP_dev_test_HDRS - yarp/dev/tests/IDummyTest.h - yarp/dev/tests/IEncodersTimedTest.h - yarp/dev/tests/IPositionControlTest.h - yarp/dev/tests/ITorqueControlTest.h - yarp/dev/tests/IAxisInfoTest.h - yarp/dev/tests/IRGBDSensorTest.h - yarp/dev/tests/IBatteryTest.h - yarp/dev/tests/IJoypadControllerTest.h - yarp/dev/tests/ILLMTest.h - yarp/dev/tests/IChatBotTest.h - yarp/dev/tests/IVelocityControlTest.h - yarp/dev/tests/IControlModeTest.h - yarp/dev/tests/IInteractionModeTest.h - yarp/dev/tests/ICurrentControlTest.h - yarp/dev/tests/IPWMControlTest.h - yarp/dev/tests/IPidControlTest.h - yarp/dev/tests/IMotorTest.h - yarp/dev/tests/IMotorEncodersTest.h - yarp/dev/tests/IRemoteCalibratorTest.h -) - -set(YARP_dev_test_SRCS - yarp/dev/tests/IDummyTest.cpp - yarp/dev/tests/IEncodersTimedTest.cpp - yarp/dev/tests/IPositionControlTest.cpp - yarp/dev/tests/ITorqueControlTest.cpp - yarp/dev/tests/IAxisInfoTest.cpp - yarp/dev/tests/IRGBDSensorTest.cpp - yarp/dev/tests/IBatteryTest.cpp - yarp/dev/tests/IJoypadControllerTest.cpp - yarp/dev/tests/ILLMTest.cpp - yarp/dev/tests/IChatBotTest.cpp - yarp/dev/tests/IVelocityControlTest.cpp - yarp/dev/tests/IControlModeTest.cpp - yarp/dev/tests/IInteractionModeTest.cpp - yarp/dev/tests/ICurrentControlTest.cpp - yarp/dev/tests/IPWMControlTest.cpp - yarp/dev/tests/IPidControlTest.cpp - yarp/dev/tests/IMotorTest.cpp - yarp/dev/tests/IMotorEncodersTest.cpp - yarp/dev/tests/IRemoteCalibratorTest.cpp -) - -if(TARGET YARP::YARP_math) - list(APPEND YARP_dev_test_HDRS - yarp/dev/tests/IFrameGrabberImageTest.h - yarp/dev/tests/IRgbVisualParamsTest.h - yarp/dev/tests/IFrameTransformTest.h - yarp/dev/tests/IMap2DTest.h - yarp/dev/tests/INavigation2DTest.h - yarp/dev/tests/IDummyTest.h - yarp/dev/tests/IRangefinder2DTest.h - yarp/dev/tests/IPositionControlTest.h - yarp/dev/tests/ITorqueControlTest.h - yarp/dev/tests/IAxisInfoTest.h - yarp/dev/tests/IPositionSensorsTest.h - yarp/dev/tests/IOrientationSensorsTest.h - yarp/dev/tests/IOdometry2DTest.h - yarp/dev/tests/IRGBDSensorTest.h - yarp/dev/tests/ILocalization2DTest.h - yarp/dev/tests/IFrameTransformStorageTest.h - ) - list(APPEND YARP_dev_test_SRCS - yarp/dev/tests/IFrameGrabberImageTest.cpp - yarp/dev/tests/IRgbVisualParamsTest.cpp - yarp/dev/tests/IFrameTransformTest.cpp - yarp/dev/tests/INavigation2DTest.cpp - yarp/dev/tests/IDummyTest.cpp - yarp/dev/tests/IRangefinder2DTest.cpp - yarp/dev/tests/IPositionControlTest.cpp - yarp/dev/tests/ITorqueControlTest.cpp - yarp/dev/tests/IAxisInfoTest.cpp - yarp/dev/tests/IPositionSensorsTest.cpp - yarp/dev/tests/IOrientationSensorsTest.cpp - yarp/dev/tests/IOdometry2DTest.cpp - yarp/dev/tests/IRGBDSensorTest.cpp - yarp/dev/tests/IMap2DTest.cpp - yarp/dev/tests/ILocalization2DTest.cpp - yarp/dev/tests/IFrameTransformStorageTest.cpp - ) +if(YARP_COMPILE_TESTS) + add_subdirectory(yarp/dev/tests) endif() - -target_sources(YARP_dev_tests - PRIVATE - ${YARP_dev_test_SRCS} - ${YARP_dev_test_HDRS} -) - -target_compile_definitions(YARP_dev_tests PUBLIC YARP_dev_EXPORTS=1) - -target_link_libraries (YARP_dev_tests - PRIVATE - YARP::YARP_dev - YARP::YARP_catch2) - -target_compile_features(YARP_dev_tests PRIVATE cxx_std_17) - -set_property ( - TARGET YARP_dev_tests - PROPERTY FOLDER "Test" -) - -set_property( - TARGET YARP_dev_tests - PROPERTY - PUBLIC_HEADER - ${YARP_dev_HDRS} - ${YARP_dev_test_HDRS} -) - -set_property(TARGET YARP_dev_tests PROPERTY VERSION ${YARP_VERSION_SHORT}) -set_property(TARGET YARP_dev_tests PROPERTY SOVERSION ${YARP_SOVERSION}) -set_property(TARGET YARP_dev_tests PROPERTY FOLDER "Test") - - install( - TARGETS YARP_dev_tests - EXPORT YARP_dev_tests - RUNTIME - DESTINATION "${CMAKE_INSTALL_BINDIR}" - COMPONENT YARP_dev_tests - LIBRARY - DESTINATION "${CMAKE_INSTALL_LIBDIR}" - COMPONENT YARP_dev_tests - NAMELINK_COMPONENT YARP_dev_tests-dev - ARCHIVE - DESTINATION "${CMAKE_INSTALL_LIBDIR}" - COMPONENT YARP_dev_tests-dev - PUBLIC_HEADER - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/yarp/dev/tests" - COMPONENT YARP_dev_tests-dev -) diff --git a/src/libYARP_dev/src/yarp/dev/tests/CMakeLists.txt b/src/libYARP_dev/src/yarp/dev/tests/CMakeLists.txt new file mode 100644 index 00000000000..d90dccaa90d --- /dev/null +++ b/src/libYARP_dev/src/yarp/dev/tests/CMakeLists.txt @@ -0,0 +1,142 @@ +# SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) +# SPDX-License-Identifier: BSD-3-Clause + +add_library(YARP_dev_tests) +add_library(YARP::YARP_dev_tests ALIAS YARP_dev_tests) + +set(YARP_dev_test_HDRS + IDummyTest.h + IEncodersTimedTest.h + IPositionControlTest.h + ITorqueControlTest.h + IAxisInfoTest.h + IRGBDSensorTest.h + IBatteryTest.h + IJoypadControllerTest.h + ILLMTest.h + IChatBotTest.h + IVelocityControlTest.h + IControlModeTest.h + IInteractionModeTest.h + ICurrentControlTest.h + IPWMControlTest.h + IPidControlTest.h + IMotorTest.h + IMotorEncodersTest.h + IRemoteCalibratorTest.h +) + +set(YARP_dev_test_SRCS + IDummyTest.cpp + IEncodersTimedTest.cpp + IPositionControlTest.cpp + ITorqueControlTest.cpp + IAxisInfoTest.cpp + IRGBDSensorTest.cpp + IBatteryTest.cpp + IJoypadControllerTest.cpp + ILLMTest.cpp + IChatBotTest.cpp + IVelocityControlTest.cpp + IControlModeTest.cpp + IInteractionModeTest.cpp + ICurrentControlTest.cpp + IPWMControlTest.cpp + IPidControlTest.cpp + IMotorTest.cpp + IMotorEncodersTest.cpp + IRemoteCalibratorTest.cpp +) + +if(TARGET YARP::YARP_math) + list(APPEND YARP_dev_test_HDRS + IFrameGrabberImageTest.h + IRgbVisualParamsTest.h + IFrameTransformTest.h + IMap2DTest.h + INavigation2DTest.h + IDummyTest.h + IRangefinder2DTest.h + IPositionControlTest.h + ITorqueControlTest.h + IAxisInfoTest.h + IPositionSensorsTest.h + IOrientationSensorsTest.h + IOdometry2DTest.h + IRGBDSensorTest.h + ILocalization2DTest.h + IFrameTransformStorageTest.h + ) + list(APPEND YARP_dev_test_SRCS + IFrameGrabberImageTest.cpp + IRgbVisualParamsTest.cpp + IFrameTransformTest.cpp + INavigation2DTest.cpp + IDummyTest.cpp + IRangefinder2DTest.cpp + IPositionControlTest.cpp + ITorqueControlTest.cpp + IAxisInfoTest.cpp + IPositionSensorsTest.cpp + IOrientationSensorsTest.cpp + IOdometry2DTest.cpp + IRGBDSensorTest.cpp + IMap2DTest.cpp + ILocalization2DTest.cpp + IFrameTransformStorageTest.cpp + ) +endif() + +target_sources(YARP_dev_tests + PRIVATE + ${YARP_dev_test_SRCS} + ${YARP_dev_test_HDRS} +) + +target_compile_definitions(YARP_dev_tests PUBLIC YARP_dev_EXPORTS=1) + +target_link_libraries (YARP_dev_tests + PRIVATE + YARP::YARP_dev + YARP::YARP_catch2) + +target_compile_features(YARP_dev_tests PRIVATE cxx_std_17) + +set_property ( + TARGET YARP_dev_tests + PROPERTY FOLDER "Test" +) + +set_property( + TARGET YARP_dev_tests + PROPERTY + PUBLIC_HEADER + ${YARP_dev_test_HDRS} +) + +set_property(TARGET YARP_dev_tests PROPERTY VERSION ${YARP_VERSION_SHORT}) +set_property(TARGET YARP_dev_tests PROPERTY SOVERSION ${YARP_SOVERSION}) +set_property(TARGET YARP_dev_tests PROPERTY FOLDER "Test") + + install( + TARGETS YARP_dev_tests + EXPORT YARP_dev_tests + RUNTIME + DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT YARP_dev_tests + LIBRARY + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT YARP_dev_tests + NAMELINK_COMPONENT YARP_dev_tests-dev + ARCHIVE + DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT YARP_dev_tests-dev + PUBLIC_HEADER + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/yarp/dev/tests" + COMPONENT YARP_dev_tests-dev +) + +yarp_install_basic_package_files(YARP_dev_tests + DEPENDENCIES ${YARP_dev_tests_PUBLIC_DEPS} + PRIVATE_DEPENDENCIES ${YARP_dev_tests_PRIVATE_DEPS} +) diff --git a/src/libYARP_dev/src/yarp/dev/tests/IControlModeTest.h b/src/libYARP_dev/src/yarp/dev/tests/IControlModeTest.h index caf1a816096..3f8017f8603 100644 --- a/src/libYARP_dev/src/yarp/dev/tests/IControlModeTest.h +++ b/src/libYARP_dev/src/yarp/dev/tests/IControlModeTest.h @@ -14,13 +14,15 @@ using namespace yarp::dev; using namespace yarp::os; +#define COMMAND_DELAY 1.0 + void test_single_joint(IControlMode* icmd, IAxisInfo* iinfo, int mode) { REQUIRE(icmd != nullptr); bool b = false; b = icmd->setControlMode(0, mode); CHECK(b); - yarp::os::SystemClock::delaySystem(0.1); + yarp::os::SystemClock::delaySystem(COMMAND_DELAY); int ret=0; b = icmd->getControlMode(0, &ret); CHECK(b); @@ -42,7 +44,7 @@ void test_all_joints(IControlMode* icmd, IAxisInfo* iinfo, int mode) modes[1]=mode; b = icmd->setControlModes(modes); CHECK(b); - yarp::os::SystemClock::delaySystem(0.1); + yarp::os::SystemClock::delaySystem(COMMAND_DELAY); int rets[2] = {0,-0}; b = icmd->getControlModes(rets); CHECK(b); @@ -68,7 +70,7 @@ void test_multi_joint(IControlMode* icmd, IAxisInfo* iinfo, int mode) joints[1] = 1; b = icmd->setControlModes(2,joints,modes); CHECK(b); - yarp::os::SystemClock::delaySystem(0.1); + yarp::os::SystemClock::delaySystem(COMMAND_DELAY); int rets[2] = { 0,-0 }; b = icmd->getControlModes(2,joints,rets); CHECK(b); diff --git a/src/libYARP_dev/src/yarp/dev/tests/IPositionControlTest.h b/src/libYARP_dev/src/yarp/dev/tests/IPositionControlTest.h index bd01369789e..1930f3488e2 100644 --- a/src/libYARP_dev/src/yarp/dev/tests/IPositionControlTest.h +++ b/src/libYARP_dev/src/yarp/dev/tests/IPositionControlTest.h @@ -6,6 +6,10 @@ #ifndef IPOSITIONCONTROLTEST_H #define IPOSITIONCONTROLTEST_H +#include +#include +#include + #include #include #include @@ -33,15 +37,107 @@ namespace yarp::dev::tests CHECK(b); } - double ref = 0; - b = ipos->getRefSpeed(0,&ref); - CHECK(b); + { + double ref = 0; + auto refs = std::vector(ax); + auto joints = std::vector(ax); + std::iota(joints.begin(), joints.end(), 0); - b = ipos->getRefAcceleration(0, &ref); - CHECK(b); + b = ipos->setRefSpeed(0, ref); + CHECK(b); - b = ipos->getTargetPosition(0, &ref); - CHECK(b); + b = ipos->setRefSpeeds(refs.data()); + CHECK(b); + + b = ipos->setRefSpeeds(ax, joints.data(), refs.data()); + CHECK(b); + + b = ipos->setRefAcceleration(0, ref); + CHECK(b); + + b = ipos->setRefAccelerations(refs.data()); + CHECK(b); + + b = ipos->setRefAccelerations(ax, joints.data(), refs.data()); + CHECK(b); + } + { + double ref = 0; + auto refs = std::vector(ax); + auto joints = std::vector(ax); + std::iota(joints.begin(), joints.end(), 0); + + b = ipos->getRefSpeed(0,&ref); + CHECK(b); + + b = ipos->getRefSpeeds(refs.data()); + CHECK(b); + + b = ipos->getRefSpeeds(ax, joints.data(), refs.data()); + CHECK(b); + + b = ipos->getRefAcceleration(0, &ref); + CHECK(b); + + b = ipos->getRefAccelerations(refs.data()); + CHECK(b); + + b = ipos->getRefAccelerations(ax, joints.data(), refs.data()); + CHECK(b); + + b = ipos->getTargetPosition(0, &ref); + CHECK(b); + + b = ipos->getTargetPositions(refs.data()); + CHECK(b); + + b = ipos->getTargetPositions(ax, joints.data(), refs.data()); + CHECK(b); + } + + { + double ref = 0; + auto refs = std::vector(ax); + auto joints = std::vector(ax); + std::iota(joints.begin(), joints.end(), 0); + b = ipos->positionMove(0, ref); + CHECK(b); + + b = ipos->positionMove(refs.data()); + CHECK(b); + + b = ipos->positionMove(ax, joints.data(), refs.data()); + CHECK(b); + + b = ipos->relativeMove(0, ref); + CHECK(b); + + b = ipos->relativeMove(refs.data()); + CHECK(b); + + b = ipos->relativeMove(ax, joints.data(), refs.data()); + CHECK(b); + } + + { + bool flag; + auto flags = std::make_unique(ax); + auto joints = std::vector(ax); + std::iota(joints.begin(), joints.end(), 0); + b = ipos->checkMotionDone(0,&flag); + CHECK(b); + + b = ipos->checkMotionDone(flags.get()); + CHECK(b); + + b = ipos->checkMotionDone(ax,joints.data(),flags.get()); + CHECK(b); + } + + { + b = ipos->stop(); + CHECK(b); + } } inline void exec_iPositionControl_test_unimplemented_interface(IPositionControl* ipos, IControlMode* icmd) diff --git a/src/libYARP_dev/src/yarp/dev/tests/ITorqueControlTest.h b/src/libYARP_dev/src/yarp/dev/tests/ITorqueControlTest.h index 187ec64ca24..9727de223d3 100644 --- a/src/libYARP_dev/src/yarp/dev/tests/ITorqueControlTest.h +++ b/src/libYARP_dev/src/yarp/dev/tests/ITorqueControlTest.h @@ -6,6 +6,9 @@ #ifndef ITORQUECONTROLTEST_H #define ITORQUECONTROLTEST_H +#include +#include + #include #include #include @@ -80,10 +83,10 @@ namespace yarp::dev::tests //CHECK(b); //this will fail } - double* vals = new double [ax]; - double* refvals = new double[ax]; - double* vals1 = new double[ax]; - double* vals2 = new double[ax]; + auto vals = std::vector(ax); + auto refvals = std::vector(ax); + auto vals1 = std::vector(ax); + auto vals2 = std::vector(ax); b = itrq->setMotorTorqueParams(0, param); CHECK(!b); @@ -94,7 +97,7 @@ namespace yarp::dev::tests b = itrq->getRefTorque(0, &val); CHECK(!b); - b = itrq->getRefTorques(refvals); + b = itrq->getRefTorques(refvals.data()); CHECK(!b); b = itrq->getTorque(0,&val); @@ -103,22 +106,18 @@ namespace yarp::dev::tests b = itrq->getTorqueRange(0, &val1, &val2); CHECK(!b); - b = itrq->getTorqueRanges(vals1, vals2); + b = itrq->getTorqueRanges(vals1.data(), vals2.data()); CHECK(!b); - b = itrq->getTorques(vals); //streaming + b = itrq->getTorques(vals.data()); //streaming // CHECK(!b); //this is streaming, it will return true if data is arrived in time b = itrq->setRefTorque(0,val); //streaming // CHECK(!b); //this is streaming, it will return true always - b = itrq->setRefTorques(refvals); //streaming + b = itrq->setRefTorques(refvals.data()); //streaming // CHECK(!b); //this is streaming, it will return true always - delete[] vals; - delete[] refvals; - delete[] vals1; - delete[] vals2; } } diff --git a/src/libYARP_dev/src/yarp/dev/tests/IVelocityControlTest.h b/src/libYARP_dev/src/yarp/dev/tests/IVelocityControlTest.h index dbc4d53c18f..6f01bf55bca 100644 --- a/src/libYARP_dev/src/yarp/dev/tests/IVelocityControlTest.h +++ b/src/libYARP_dev/src/yarp/dev/tests/IVelocityControlTest.h @@ -6,6 +6,9 @@ #ifndef IVELOCITYCONTROLTEST_H #define IVELOCITYCONTROLTEST_H +#include +#include + #include #include #include @@ -60,13 +63,13 @@ namespace yarp::dev::tests bool b; int ax; - double ref = 0; - double refs [1] = {0.0}; - b = ivel->getAxes(&ax); CHECK(b); REQUIRE(ax > 0); + double ref = 0; + auto refs = std::vector(ax); + for (size_t i = 0; i < ax; i++) { b = icmd->setControlMode(i, VOCAB_CM_VELOCITY); @@ -77,9 +80,9 @@ namespace yarp::dev::tests CHECK(!b); b = ivel->getRefAcceleration(0, &ref); CHECK(!b); - b = ivel->setRefAccelerations( refs); + b = ivel->setRefAccelerations( refs.data()); CHECK(!b); - b = ivel->getRefAccelerations( refs); + b = ivel->getRefAccelerations( refs.data()); CHECK(!b); b = ivel->velocityMove(0, ref); @@ -87,7 +90,7 @@ namespace yarp::dev::tests b = ivel->getRefVelocity(0, &ref); CHECK(!b); - b = ivel->getRefVelocities(refs); + b = ivel->getRefVelocities(refs.data()); CHECK(!b); b = ivel->stop(); diff --git a/src/libYARP_os/tests/CMakeLists.txt b/src/libYARP_os/tests/CMakeLists.txt index 35ea768c7a0..95405be88f5 100644 --- a/src/libYARP_os/tests/CMakeLists.txt +++ b/src/libYARP_os/tests/CMakeLists.txt @@ -9,7 +9,8 @@ target_sources(harness_os PRIVATE BinPortableTest.cpp BottleTest.cpp ListCarriersTest.cpp - ListPluginsTest.cpp + ListPluginsAndOpenTest.cpp + ListPluginsOnlyTest.cpp ContactTest.cpp ElectionTest.cpp EventTest.cpp diff --git a/src/libYARP_os/tests/ListPluginsTest.cpp b/src/libYARP_os/tests/ListPluginsAndOpenTest.cpp similarity index 89% rename from src/libYARP_os/tests/ListPluginsTest.cpp rename to src/libYARP_os/tests/ListPluginsAndOpenTest.cpp index 901eddf492d..0c20b167843 100644 --- a/src/libYARP_os/tests/ListPluginsTest.cpp +++ b/src/libYARP_os/tests/ListPluginsAndOpenTest.cpp @@ -11,7 +11,7 @@ #include using namespace yarp::os; -TEST_CASE("os::ListPluginsTest", "[yarp::os]") +TEST_CASE("os::ListPluginsAndOpenTest", "[yarp::os]") { NetworkBase::setLocalMode(true); @@ -40,6 +40,9 @@ TEST_CASE("os::ListPluginsTest", "[yarp::os]") //CHECK(b); b = settings.readFromSearchable(options, name); //CHECK(b); + + //Beware: a leaky dynamic library may cause valgrind to fail this test. + //Check also `ListPluginsOnlyTest`. SharedLibraryFactory lib; b = settings.open(lib); CHECK(b); diff --git a/src/libYARP_os/tests/ListPluginsOnlyTest.cpp b/src/libYARP_os/tests/ListPluginsOnlyTest.cpp new file mode 100644 index 00000000000..eb0a987cdcf --- /dev/null +++ b/src/libYARP_os/tests/ListPluginsOnlyTest.cpp @@ -0,0 +1,60 @@ +/* + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include + +#include +#include + +using namespace yarp::os; +TEST_CASE("os::ListPluginsOnlyTest", "[yarp::os]") +{ + NetworkBase::setLocalMode(true); + + SECTION("Checking generic plugin methods") + { +#ifdef YARP_IS_STATIC + //The following code is copied from command: yarp plugin --all + YarpPluginSelector selector; + selector.scan(); + Bottle lst = selector.getSelectedPlugins(); + CHECK(lst.size() == 0); +#else + //The following code is copied from command: yarp plugin --all + YarpPluginSelector selector; + selector.scan(); + Bottle lst = selector.getSelectedPlugins(); + Bottle search_path = selector.getSearchPath(); + CHECK (lst.size()!=0); + for (size_t i = 0; i < lst.size(); i++) + { + Value& options = lst.get(i); + std::string name = options.check("name", Value("untitled")).asString(); + std::string type = options.check("type", Value("unknown type")).asString(); + yarp::os::YarpPluginSettings settings; + bool b; + b = settings.setSelector(selector); + yarp::os::YarpPluginSelector* selector2 = settings.getSelector(); + //CHECK(b); + b = settings.readFromSearchable(options, name); + //CHECK(b); + + //Here I am not intentionally opening the plugin in order + //to have a 'pure' valgrind test where leaky dynamic libraries are not involved. + //Check also the test ListPluginsAndOpenTest. + std::string baseClassName = settings.getBaseClassName(); + std::string ClassName = settings.getClassName(); + std::string LibraryName = settings.getLibraryName(); + std::string MethodName = settings.getMethodName(); + std::string PluginName = settings.getPluginName(); + std::string WrapperName = settings.getWrapperName(); + } +#endif + } + + NetworkBase::setLocalMode(false); +}