From cc15e9308aeb6256a8bd2087ecfb3a2064529d73 Mon Sep 17 00:00:00 2001 From: Jari Sundell Date: Thu, 4 Jun 2026 10:16:47 +0200 Subject: [PATCH] Fixed xmlrpc-c build errors and added better github workflow for unit-tests. --- .github/workflows/unit-tests.yml | 90 ++++++++++++++++++++++---------- src/rpc/xmlrpc_c.cc | 6 +-- 2 files changed, 66 insertions(+), 30 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index ca4c62f3..fc7cd652 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -4,9 +4,8 @@ on: pull_request jobs: - unit-tests: + ubuntu-base: runs-on: ubuntu-22.04 - steps: - name: Update Packages run: | @@ -23,43 +22,80 @@ jobs: - name: Build libtorrent run: | cd libtorrent - libtoolize - aclocal -I scripts - autoconf -i - autoheader - automake --add-missing + autoreconf -fiv ./configure make - sudo make install - cd .. - rm -rf libtorrent - - uses: actions/checkout@v4 + sudo make install DESTDIR=$GITHUB_WORKSPACE/libtorrent-dist + - name: Upload Build Artifacts + uses: actions/upload-artifact@v4 with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - - name: Fetch base branch + name: installed-libtorrent + path: libtorrent-dist/ + + + unit-tests-default: + runs-on: ubuntu-22.04 + needs: ubuntu-base + steps: + - name: Install Dependencies run: | - git remote add upstream "https://github.com/${{ github.event.pull_request.base.repo.full_name }}" - git fetch --no-tags --no-recurse-submodules upstream "${{ github.event.pull_request.base.ref }}" + sudo apt-get install -y \ + libcppunit-dev \ + zlib1g-dev \ + libcurl4-openssl-dev + - name: Download Libtorrent Artifacts + uses: actions/download-artifact@v4 + with: + name: installed-libtorrent + path: ./libtorrent-dist + - name: Move Artifacts to System Path + run: | + # Elevate permissions with sudo to safely place the files + sudo cp -r ./libtorrent-dist/usr/local/* /usr/local/ + rm -rf ./libtorrent-dist + - uses: actions/checkout@v4 - name: Configure Project run: | - libtoolize - aclocal -I scripts - autoconf -i - autoheader - automake --add-missing + autoreconf -fiv ./configure - - name: Build Project - run: | make - - name: Run Unit Tests - run: | ls /usr/local/lib/ - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" - make check + LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" make check - name: Archive test/test-suite.log if: success() || failure() uses: actions/upload-artifact@v4 with: name: test-suite.log path: test/test-suite.log + + unit-tests-variants: + runs-on: ubuntu-22.04 + needs: unit-tests-default + strategy: + matrix: + config_flag: ["--with-xmlrpc-c", "--with-xmlrpc-tinyxml2"] + steps: + - name: Install Dependencies + run: | + sudo apt-get install -y \ + libcppunit-dev \ + zlib1g-dev \ + libcurl4-openssl-dev \ + libxmlrpc-c++8-dev + - name: Download Libtorrent Artifacts + uses: actions/download-artifact@v4 + with: + name: installed-libtorrent + path: ./libtorrent-dist + - name: Move Artifacts to System Path + run: | + sudo cp -r ./libtorrent-dist/usr/local/* /usr/local/ + rm -rf ./libtorrent-dist + - uses: actions/checkout@v4 + - name: Configure Project + run: | + autoreconf -fiv + ./configure ${{ matrix.config_flag }} + make + ls /usr/local/lib/ + LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" make check diff --git a/src/rpc/xmlrpc_c.cc b/src/rpc/xmlrpc_c.cc index 8d511f9f..83efae78 100644 --- a/src/rpc/xmlrpc_c.cc +++ b/src/rpc/xmlrpc_c.cc @@ -278,7 +278,7 @@ object_to_xmlrpc(xmlrpc_env* env, const torrent::Object& object) { case torrent::Object::TYPE_STRING: { - if (object.flags() & torrent::Object::flag_binary) { + if (object.flags() & torrent::Object::flag_as_binary) { // This causes decode-and-reencode for base64, as XMLRPC-C doesn't allow us to pass base64 strings. if (object.flags() & torrent::Object::flag_base64) { @@ -287,10 +287,10 @@ object_to_xmlrpc(xmlrpc_env* env, const torrent::Object& object) { if (!binary_data.has_value()) throw torrent::input_error("invalid base64 string in base64-as-binary object"); - return xmlrpc_base64_new(env, (const char*)binary_data->data(), binary_data->size()); + return xmlrpc_base64_new(env, binary_data->size(), reinterpret_cast(binary_data->data())); } - return xmlrpc_base64_new(env, object.as_string().c_str(), object.as_string().size()); + return xmlrpc_base64_new(env, object.as_string().size(), reinterpret_cast(object.as_string().c_str())); } #ifdef XMLRPC_HAVE_I8