From df328888bca59d353964381e56d808c3c729d0c4 Mon Sep 17 00:00:00 2001 From: Reto Schneider Date: Mon, 5 Apr 2021 15:00:42 +0200 Subject: [PATCH] [GH-494] ci: Build and test on multiple architectures This also fixes the CMake build on big endian architectures and the unit tests on aarch64, s390x, ppc64le. This is more complex than it should be because... - Ubuntu 20.04 does not support many architectures, Debian does (e.g. ARMv5, MIPSel) - CMake versions before 3.19 are affected by https://gitlab.kitware.com/cmake/cmake/-/issues/20568 Signed-off-by: Reto Schneider --- .github/workflows/multiarch.yaml | 46 ++++++++++++++++++++++++++++++++ core/wakaama.cmake | 2 ++ tests/convert_numbers_test.c | 4 +-- 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/multiarch.yaml diff --git a/.github/workflows/multiarch.yaml b/.github/workflows/multiarch.yaml new file mode 100644 index 000000000..53cfd2823 --- /dev/null +++ b/.github/workflows/multiarch.yaml @@ -0,0 +1,46 @@ +name: Foreign architectures + +on: [push, pull_request] + +jobs: + multiarch: + runs-on: ubuntu-20.04 + env: + cmake_version: 3.20.0 + strategy: + fail-fast: false + matrix: + arch: ["armv6", "armv7", "aarch64", "s390x", "ppc64le"] + steps: + - name: Checkout code including full history and submodules + uses: actions/checkout@v2 + with: + submodules: true + fetch-depth: 0 + - name: Build and test + uses: uraimo/run-on-arch-action@v2.0.9 + id: runcmd + with: + arch: ${{ matrix.arch }} + distro: buster + githubToken: ${{ github.token }} + install: | + apt update + apt -qy --no-install-recommends install libcunit1-dev ninja-build unzip wget build-essential + # Workaround because of https://gitlab.kitware.com/cmake/cmake/-/issues/20568 + # Please remove once CMake 3.19 or newer is available in the repository + apt -qy --no-install-recommends install dirmngr gpg gpg-agent + echo deb-src http://archive.raspbian.org/raspbian buster main contrib non-free >> /etc/apt/sources.list + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 9165938D90FDDD2E + apt update + apt -qy --no-install-recommends build-dep cmake + wget https://github.com/Kitware/CMake/releases/download/v${{ env.cmake_version }}/cmake-${{ env.cmake_version }}.tar.gz + tar xf cmake-${{ env.cmake_version }}.tar.gz + cd cmake-${{ env.cmake_version }} + ./bootstrap -- -DCMAKE_USE_OPENSSL=OFF -DBUILD_TESTING=OFF + make -j $(nproc) + make install + cd .. + rm -r cmake-${{ env.cmake_version }} cmake-${{ env.cmake_version }}.tar.gz + run: | + tools/ci/run_ci.sh --build --run-tests diff --git a/core/wakaama.cmake b/core/wakaama.cmake index 8959104ca..154a3f10e 100644 --- a/core/wakaama.cmake +++ b/core/wakaama.cmake @@ -41,6 +41,8 @@ endif() if (LWM2M_LITTLE_ENDIAN) add_compile_definitions(LWM2M_LITTLE_ENDIAN) +else() + add_compile_definitions(LWM2M_BIG_ENDIAN) endif() # Set the LWM2M version diff --git a/tests/convert_numbers_test.c b/tests/convert_numbers_test.c index edc534079..b765d3be8 100644 --- a/tests/convert_numbers_test.c +++ b/tests/convert_numbers_test.c @@ -102,11 +102,11 @@ static void test_utils_textToFloat(void) { CU_ASSERT_DOUBLE_EQUAL(res, floats[i], floats[i]/1000000.0); if(fabs(res - floats[i]) > fabs(floats[i]/1000000.0)) - printf("%zu \"%s\" -> fail (%f)\n", i, floats_text[i], res); + printf("Entry #%zu, \"%s\" -> fail (%f)\n", i, floats_text[i], res); } else { - printf("%zu \"%s\" -> fail\n", i, floats_text[i]); + printf("Entry #%zu, \"%s\" could not be converted to \"%f\"-> fail\n", i, floats_text[i], floats[i]); } } }