From d86ad8d8d28c520c27f0ad06b2d52481a280b0c4 Mon Sep 17 00:00:00 2001 From: Jean-Roland Gosse Date: Thu, 9 Nov 2023 17:24:10 +0100 Subject: [PATCH] CI improvements (#273) --- .clang-format | 2 + .github/workflows/arduino_esp32.yaml | 2 +- .github/workflows/build-check.yaml | 27 ++++++- .github/workflows/build-shared.yaml | 6 +- .github/workflows/build-static.yaml | 4 +- .github/workflows/codacy-analysis.yml | 2 +- .github/workflows/emscripten.yaml | 8 +- .github/workflows/espidf.yaml | 2 +- .github/workflows/freertos_plus_tcp.yaml | 2 +- .github/workflows/integration.yaml | 4 +- .github/workflows/mbed.yaml | 2 +- .github/workflows/multicast.yaml | 2 +- .github/workflows/release.yml | 6 +- .github/workflows/zephyr.yaml | 2 +- CMakeLists.txt | 2 +- examples/arduino/z_get.ino | 1 + examples/arduino/z_pub.ino | 1 + examples/arduino/z_pull.ino | 1 + examples/arduino/z_queryable.ino | 1 + examples/arduino/z_sub.ino | 3 +- examples/espidf/z_get.c | 2 +- examples/espidf/z_pull.c | 2 +- examples/espidf/z_sub.c | 2 +- .../include/FreeRTOSIPConfig.h | 2 +- examples/freertos_plus_tcp/z_get.c | 2 +- examples/freertos_plus_tcp/z_queryable.c | 2 +- examples/mbed/z_get.cpp | 2 +- examples/mbed/z_pub.cpp | 2 +- examples/mbed/z_pull.cpp | 2 +- examples/mbed/z_queryable.cpp | 2 +- examples/mbed/z_sub.cpp | 2 +- examples/unix/c11/z_get.c | 5 +- examples/unix/c11/z_ping.c | 2 +- examples/unix/c11/z_pong.c | 2 +- examples/unix/c11/z_pub_st.c | 2 +- examples/unix/c11/z_pull.c | 5 +- examples/unix/c11/z_put.c | 2 +- examples/unix/c11/z_queryable.c | 5 +- examples/unix/c11/z_sub.c | 5 +- examples/unix/c11/z_sub_st.c | 2 +- examples/unix/c99/z_get.c | 2 +- examples/unix/c99/z_ping.c | 2 +- examples/unix/c99/z_pong.c | 11 +-- examples/unix/c99/z_pub.c | 2 +- examples/unix/c99/z_pub_st.c | 2 +- examples/unix/c99/z_pull.c | 2 +- examples/unix/c99/z_put.c | 2 +- examples/unix/c99/z_queryable.c | 2 +- examples/unix/c99/z_sub.c | 2 +- examples/unix/c99/z_sub_st.c | 2 +- examples/windows/z_get.c | 2 +- examples/windows/z_ping.c | 2 +- examples/windows/z_pong.c | 2 +- examples/windows/z_pub_st.c | 2 +- examples/windows/z_pull.c | 2 +- examples/windows/z_put.c | 2 +- examples/windows/z_queryable.c | 2 +- examples/windows/z_sub.c | 2 +- examples/windows/z_sub_st.c | 2 +- examples/zephyr/z_get.c | 2 +- examples/zephyr/z_pub.c | 2 +- examples/zephyr/z_pull.c | 2 +- examples/zephyr/z_queryable.c | 2 +- examples/zephyr/z_sub.c | 2 +- tests/modularity.py | 80 +++++++++++++------ tests/z_msgcodec_test.c | 2 +- 66 files changed, 162 insertions(+), 109 deletions(-) diff --git a/.clang-format b/.clang-format index f36aab3ab..79e492438 100644 --- a/.clang-format +++ b/.clang-format @@ -1,3 +1,5 @@ +--- +Language: Cpp BasedOnStyle: Google IndentWidth: 4 ColumnLimit: 120 diff --git a/.github/workflows/arduino_esp32.yaml b/.github/workflows/arduino_esp32.yaml index 0e1865973..bd347aec6 100644 --- a/.github/workflows/arduino_esp32.yaml +++ b/.github/workflows/arduino_esp32.yaml @@ -29,7 +29,7 @@ jobs: os: [ubuntu-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install requirements run: | diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index b8a13d880..8ea2af629 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -20,6 +20,28 @@ on: branches: [ '**' ] jobs: + run_tests: + name: Run unit tests on ubuntu-latest + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build & run tests + run: | + sudo apt install -y ninja-build + CMAKE_GENERATOR=Ninja make test + + check_format: + name: Check codebase format with clang-format + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run clang-format dry-run + run: find include/ src/ tests/ examples/ -iname "*.ino" -o -iname "*.h" -o -iname "*.c" | xargs clang-format -n -Werror + modular_build: name: Modular build on ubuntu-latest runs-on: ubuntu-latest @@ -38,7 +60,8 @@ jobs: - name: Build project run: | - make all + sudo apt install -y ninja-build + CMAKE_GENERATOR=Ninja make python3 ./build/tests/modularity.py --pub $Z_FEATURE_PUBLICATION --sub $Z_FEATURE_SUBSCRIPTION --queryable $Z_FEATURE_QUERYABLE --query $Z_FEATURE_QUERY timeout-minutes: 5 env: @@ -51,4 +74,4 @@ jobs: if: always() run: | docker stop zenoh_router - docker rm zenoh_router \ No newline at end of file + docker rm zenoh_router diff --git a/.github/workflows/build-shared.yaml b/.github/workflows/build-shared.yaml index a5b6d2a52..bc07b2a7c 100644 --- a/.github/workflows/build-shared.yaml +++ b/.github/workflows/build-shared.yaml @@ -28,7 +28,7 @@ jobs: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Compile debug run: make all env: @@ -44,10 +44,10 @@ jobs: name: Build on ubuntu-latest runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Crosscompile debug run: make crossbuilds env: BUILD_TYPE: Debug BUILD_SHARED_LIBS: ON - ZENOH_DEBUG: 3 \ No newline at end of file + ZENOH_DEBUG: 3 diff --git a/.github/workflows/build-static.yaml b/.github/workflows/build-static.yaml index 9b08df766..4b853c7a7 100644 --- a/.github/workflows/build-static.yaml +++ b/.github/workflows/build-static.yaml @@ -28,7 +28,7 @@ jobs: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Compile debug run: make all env: @@ -44,7 +44,7 @@ jobs: name: Build on ubuntu-latest runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Crosscompile debug run: make crossbuilds env: diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml index f480f2db2..056e81353 100644 --- a/.github/workflows/codacy-analysis.yml +++ b/.github/workflows/codacy-analysis.yml @@ -21,7 +21,7 @@ jobs: steps: # Checkout the repository to the GitHub Actions runner - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis - name: Run Codacy Analysis CLI diff --git a/.github/workflows/emscripten.yaml b/.github/workflows/emscripten.yaml index 7080b5579..a240c7188 100644 --- a/.github/workflows/emscripten.yaml +++ b/.github/workflows/emscripten.yaml @@ -28,13 +28,11 @@ jobs: matrix: os: [ubuntu-latest] steps: - - uses: actions/checkout@v2 - - uses: jwlawson/actions-setup-cmake@v1.13 - - uses: mymindstorm/setup-emsdk@v11 + - uses: actions/checkout@v4 + - uses: jwlawson/actions-setup-cmake@v1.14 + - uses: mymindstorm/setup-emsdk@v12 - name: Compile debug run: | mkdir build emcmake cmake -E env CFLAGS="-DZ_FEATURE_LINK_WS=1 -DZ_FEATURE_LINK_TCP=0 -DZ_FEATURE_LINK_UDP_MULTICAST=0 -DZ_FEATURE_LINK_UDP_UNICAST=0 -DZ_FEATURE_SCOUTING_UDP=0" cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_STANDARD=11 -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=OFF -DBUILD_MULTICAST=OFF -DBUILD_INTEGRATION=OFF -DBUILD_TOOLS=OFF -DZENOH_DEBUG=3 -H. -Bbuild make -C build - - diff --git a/.github/workflows/espidf.yaml b/.github/workflows/espidf.yaml index 6f46eb0e4..e0685732d 100644 --- a/.github/workflows/espidf.yaml +++ b/.github/workflows/espidf.yaml @@ -29,7 +29,7 @@ jobs: os: [ubuntu-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install requirements run: | diff --git a/.github/workflows/freertos_plus_tcp.yaml b/.github/workflows/freertos_plus_tcp.yaml index 65231e75f..c3e56e62b 100644 --- a/.github/workflows/freertos_plus_tcp.yaml +++ b/.github/workflows/freertos_plus_tcp.yaml @@ -28,7 +28,7 @@ jobs: matrix: os: [ubuntu-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: jwlawson/actions-setup-cmake@v1.13 - name: Install requirements run: | diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 9818f6f94..d6b3a0205 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -32,10 +32,10 @@ jobs: os: [ ubuntu-latest, macOS-latest ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install latest stable - uses: actions-rs/toolchain@v1 + uses: actions-rs/toolchain@v1.0.7 with: toolchain: stable override: true diff --git a/.github/workflows/mbed.yaml b/.github/workflows/mbed.yaml index 5bfbf4d94..60c74ecb7 100644 --- a/.github/workflows/mbed.yaml +++ b/.github/workflows/mbed.yaml @@ -29,7 +29,7 @@ jobs: os: [ubuntu-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install requirements run: | diff --git a/.github/workflows/multicast.yaml b/.github/workflows/multicast.yaml index 1d7af5533..b1b57b38c 100644 --- a/.github/workflows/multicast.yaml +++ b/.github/workflows/multicast.yaml @@ -31,7 +31,7 @@ jobs: os: [macOS-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Compile debug run: make all diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ae7a1b625..cb9276179 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: name: Preparation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Environment setup id: env shell: bash @@ -73,7 +73,7 @@ jobs: needs: preps runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: MacOS build run: make env: @@ -108,7 +108,7 @@ jobs: fail-fast: false matrix: ${{fromJson(needs.preps.outputs.TARGET_MATRIX)}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: make for ${{ matrix.target }} env: BUILD_TYPE: RELEASE diff --git a/.github/workflows/zephyr.yaml b/.github/workflows/zephyr.yaml index c7df7ecaa..338a86dce 100644 --- a/.github/workflows/zephyr.yaml +++ b/.github/workflows/zephyr.yaml @@ -29,7 +29,7 @@ jobs: os: [ubuntu-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install requirements run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index ecb5e68cf..ac9c77c5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,7 +138,7 @@ endif() if(CMAKE_BUILD_TYPE MATCHES "DEBUG") if(UNIX) - add_compile_options(-c -Wall -Wextra -Werror -Wunused -Wstrict-prototypes -pipe -g -O0) + add_compile_options(-c -Wall -Wextra -Werror -Wshadow -Wpedantic -Wunused -Wstrict-prototypes -pipe -g -O0) elseif(MSVC) add_compile_options(/W4 /WX /Od) elseif(CMAKE_SYSTEM_NAME MATCHES "Generic") diff --git a/examples/arduino/z_get.ino b/examples/arduino/z_get.ino index 7ae75175f..ddd607641 100644 --- a/examples/arduino/z_get.ino +++ b/examples/arduino/z_get.ino @@ -122,6 +122,7 @@ void loop() { #else void setup() { Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it."); + return; } void loop() {} #endif diff --git a/examples/arduino/z_pub.ino b/examples/arduino/z_pub.ino index 763d69ee2..c7e60d62e 100644 --- a/examples/arduino/z_pub.ino +++ b/examples/arduino/z_pub.ino @@ -111,6 +111,7 @@ void loop() { #else void setup() { Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it."); + return; } void loop() {} #endif diff --git a/examples/arduino/z_pull.ino b/examples/arduino/z_pull.ino index c1ffd7865..7dc5600e8 100644 --- a/examples/arduino/z_pull.ino +++ b/examples/arduino/z_pull.ino @@ -112,6 +112,7 @@ void loop() { #else void setup() { Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it."); + return; } void loop() {} #endif diff --git a/examples/arduino/z_queryable.ino b/examples/arduino/z_queryable.ino index edde751ae..772f60a0a 100644 --- a/examples/arduino/z_queryable.ino +++ b/examples/arduino/z_queryable.ino @@ -111,6 +111,7 @@ void loop() { delay(5000); } #else void setup() { Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it."); + return; } void loop() {} #endif diff --git a/examples/arduino/z_sub.ino b/examples/arduino/z_sub.ino index b07ca70c0..1a3302f55 100644 --- a/examples/arduino/z_sub.ino +++ b/examples/arduino/z_sub.ino @@ -109,6 +109,7 @@ void loop() { delay(5000); } #else void setup() { Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it."); + return; } void loop() {} -#endif \ No newline at end of file +#endif diff --git a/examples/espidf/z_get.c b/examples/espidf/z_get.c index 884dfc2a4..a8e06549f 100644 --- a/examples/espidf/z_get.c +++ b/examples/espidf/z_get.c @@ -175,4 +175,4 @@ void app_main() { } #else void app_main() { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n"); } -#endif \ No newline at end of file +#endif diff --git a/examples/espidf/z_pull.c b/examples/espidf/z_pull.c index 03175c898..5f42b2852 100644 --- a/examples/espidf/z_pull.c +++ b/examples/espidf/z_pull.c @@ -173,4 +173,4 @@ void app_main() { void app_main() { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); } -#endif \ No newline at end of file +#endif diff --git a/examples/espidf/z_sub.c b/examples/espidf/z_sub.c index 01272c46e..33f01548b 100644 --- a/examples/espidf/z_sub.c +++ b/examples/espidf/z_sub.c @@ -171,4 +171,4 @@ void app_main() { void app_main() { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); } -#endif \ No newline at end of file +#endif diff --git a/examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h b/examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h index 430e92b4d..161585f0a 100644 --- a/examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h +++ b/examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h @@ -51,4 +51,4 @@ #define ipconfigBUFFER_PADDING 14U #endif -#endif /* FREERTOS_IP_CONFIG_H */ \ No newline at end of file +#endif /* FREERTOS_IP_CONFIG_H */ diff --git a/examples/freertos_plus_tcp/z_get.c b/examples/freertos_plus_tcp/z_get.c index 3a95518c1..9da9bb624 100644 --- a/examples/freertos_plus_tcp/z_get.c +++ b/examples/freertos_plus_tcp/z_get.c @@ -98,4 +98,4 @@ void app_main(void) { void app_main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n"); } -#endif \ No newline at end of file +#endif diff --git a/examples/freertos_plus_tcp/z_queryable.c b/examples/freertos_plus_tcp/z_queryable.c index de60b9c53..19f960eac 100644 --- a/examples/freertos_plus_tcp/z_queryable.c +++ b/examples/freertos_plus_tcp/z_queryable.c @@ -94,4 +94,4 @@ void app_main(void) { void app_main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n"); } -#endif \ No newline at end of file +#endif diff --git a/examples/mbed/z_get.cpp b/examples/mbed/z_get.cpp index 283dd8f43..905ac4e1c 100644 --- a/examples/mbed/z_get.cpp +++ b/examples/mbed/z_get.cpp @@ -100,4 +100,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/mbed/z_pub.cpp b/examples/mbed/z_pub.cpp index 309cb3d7b..0fb939071 100644 --- a/examples/mbed/z_pub.cpp +++ b/examples/mbed/z_pub.cpp @@ -91,4 +91,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/mbed/z_pull.cpp b/examples/mbed/z_pull.cpp index c54c83ad6..d6b82c1d0 100644 --- a/examples/mbed/z_pull.cpp +++ b/examples/mbed/z_pull.cpp @@ -97,4 +97,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/mbed/z_queryable.cpp b/examples/mbed/z_queryable.cpp index fa8b8046b..08ade9084 100644 --- a/examples/mbed/z_queryable.cpp +++ b/examples/mbed/z_queryable.cpp @@ -100,4 +100,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/mbed/z_sub.cpp b/examples/mbed/z_sub.cpp index 51699f9ca..0b3cbdd47 100644 --- a/examples/mbed/z_sub.cpp +++ b/examples/mbed/z_sub.cpp @@ -95,4 +95,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index b72ea0e9f..e2aa07e9c 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -105,7 +105,8 @@ int main(int argc, char **argv) { char c = '\0'; while (1) { fflush(stdin); - scanf("%c", &c); + int ret = scanf("%c", &c); + (void)ret; // Remove unused result warning if (c == 'q') { break; } @@ -135,4 +136,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c11/z_ping.c b/examples/unix/c11/z_ping.c index 379ff6dcf..6e0369574 100644 --- a/examples/unix/c11/z_ping.c +++ b/examples/unix/c11/z_ping.c @@ -179,4 +179,4 @@ int main(void) { "requires them.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c11/z_pong.c b/examples/unix/c11/z_pong.c index 6202b38b1..8991729e9 100644 --- a/examples/unix/c11/z_pong.c +++ b/examples/unix/c11/z_pong.c @@ -76,4 +76,4 @@ int main(void) { "requires them.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c11/z_pub_st.c b/examples/unix/c11/z_pub_st.c index ae152104b..b53bc346e 100644 --- a/examples/unix/c11/z_pub_st.c +++ b/examples/unix/c11/z_pub_st.c @@ -109,4 +109,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c11/z_pull.c b/examples/unix/c11/z_pull.c index 4ed568f76..c39f19c52 100644 --- a/examples/unix/c11/z_pull.c +++ b/examples/unix/c11/z_pull.c @@ -82,7 +82,8 @@ int main(int argc, char **argv) { char c = '\0'; while (1) { fflush(stdin); - scanf("%c", &c); + int ret = scanf("%c", &c); + (void)ret; // Remove unused result warning if (c == 'q') { break; } @@ -104,4 +105,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c11/z_put.c b/examples/unix/c11/z_put.c index 70838a062..089615618 100644 --- a/examples/unix/c11/z_put.c +++ b/examples/unix/c11/z_put.c @@ -107,4 +107,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index 92f13c652..d9bb7c74a 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -112,7 +112,8 @@ int main(int argc, char **argv) { char c = '\0'; while (c != 'q') { fflush(stdin); - scanf("%c", &c); + int ret = scanf("%c", &c); + (void)ret; // Remove unused result warning } z_undeclare_queryable(z_move(qable)); @@ -130,4 +131,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index 0f1d07c6f..af42950c3 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -95,7 +95,8 @@ int main(int argc, char **argv) { char c = '\0'; while (c != 'q') { fflush(stdin); - scanf("%c", &c); + int ret = scanf("%c", &c); + (void)ret; // Remove unused result warning } z_undeclare_subscriber(z_move(sub)); @@ -113,4 +114,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c11/z_sub_st.c b/examples/unix/c11/z_sub_st.c index a95e93188..1afa9bed6 100644 --- a/examples/unix/c11/z_sub_st.c +++ b/examples/unix/c11/z_sub_st.c @@ -102,4 +102,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c99/z_get.c b/examples/unix/c99/z_get.c index 766cca309..e45bfe0fe 100644 --- a/examples/unix/c99/z_get.c +++ b/examples/unix/c99/z_get.c @@ -135,4 +135,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c99/z_ping.c b/examples/unix/c99/z_ping.c index 6528bfdd7..a3b4bcea2 100644 --- a/examples/unix/c99/z_ping.c +++ b/examples/unix/c99/z_ping.c @@ -179,4 +179,4 @@ int main(void) { "requires them.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c99/z_pong.c b/examples/unix/c99/z_pong.c index 2614f7bc9..73570e138 100644 --- a/examples/unix/c99/z_pong.c +++ b/examples/unix/c99/z_pong.c @@ -45,14 +45,7 @@ int main(int argc, char** argv) { printf("Unable to start read and lease tasks"); return -1; } -#else -int main(void) { - printf( - "ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION or Z_FEATURE_PUBLICATION but this example " - "requires them.\n"); - return -1; -} -#endif + z_keyexpr_t pong = z_keyexpr_unchecked("test/pong"); z_owned_publisher_t pub = z_declare_publisher(z_session_loan(&session), pong, NULL); if (!z_publisher_check(&pub)) { @@ -86,4 +79,4 @@ int main(void) { "requires them.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c99/z_pub.c b/examples/unix/c99/z_pub.c index a1c12adda..a03b0cc2c 100644 --- a/examples/unix/c99/z_pub.c +++ b/examples/unix/c99/z_pub.c @@ -112,4 +112,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c99/z_pub_st.c b/examples/unix/c99/z_pub_st.c index 07680e557..785ffe01c 100644 --- a/examples/unix/c99/z_pub_st.c +++ b/examples/unix/c99/z_pub_st.c @@ -109,4 +109,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c99/z_pull.c b/examples/unix/c99/z_pull.c index c2a1ecd2f..b809dadff 100644 --- a/examples/unix/c99/z_pull.c +++ b/examples/unix/c99/z_pull.c @@ -105,4 +105,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c99/z_put.c b/examples/unix/c99/z_put.c index 15273aecd..528db3785 100644 --- a/examples/unix/c99/z_put.c +++ b/examples/unix/c99/z_put.c @@ -107,4 +107,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c99/z_queryable.c b/examples/unix/c99/z_queryable.c index f5093d370..d7d543789 100644 --- a/examples/unix/c99/z_queryable.c +++ b/examples/unix/c99/z_queryable.c @@ -126,4 +126,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c99/z_sub.c b/examples/unix/c99/z_sub.c index 2a1cd2aee..cc738e908 100644 --- a/examples/unix/c99/z_sub.c +++ b/examples/unix/c99/z_sub.c @@ -114,4 +114,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/unix/c99/z_sub_st.c b/examples/unix/c99/z_sub_st.c index 6b3c8728f..ceda1495f 100644 --- a/examples/unix/c99/z_sub_st.c +++ b/examples/unix/c99/z_sub_st.c @@ -103,4 +103,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/windows/z_get.c b/examples/windows/z_get.c index e89c2f3f3..5d2676ffc 100644 --- a/examples/windows/z_get.c +++ b/examples/windows/z_get.c @@ -100,4 +100,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/windows/z_ping.c b/examples/windows/z_ping.c index 6a0a3cb82..f2334804f 100644 --- a/examples/windows/z_ping.c +++ b/examples/windows/z_ping.c @@ -176,4 +176,4 @@ int main(void) { "requires them.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/windows/z_pong.c b/examples/windows/z_pong.c index 6202b38b1..8991729e9 100644 --- a/examples/windows/z_pong.c +++ b/examples/windows/z_pong.c @@ -76,4 +76,4 @@ int main(void) { "requires them.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/windows/z_pub_st.c b/examples/windows/z_pub_st.c index caa342504..cc6f41361 100644 --- a/examples/windows/z_pub_st.c +++ b/examples/windows/z_pub_st.c @@ -76,4 +76,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/windows/z_pull.c b/examples/windows/z_pull.c index 3c31de4be..4480a43d0 100644 --- a/examples/windows/z_pull.c +++ b/examples/windows/z_pull.c @@ -84,4 +84,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/windows/z_put.c b/examples/windows/z_put.c index ca89e386c..29febb7a2 100644 --- a/examples/windows/z_put.c +++ b/examples/windows/z_put.c @@ -74,4 +74,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/windows/z_queryable.c b/examples/windows/z_queryable.c index ef166b73a..d010ce3fa 100644 --- a/examples/windows/z_queryable.c +++ b/examples/windows/z_queryable.c @@ -95,4 +95,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/windows/z_sub.c b/examples/windows/z_sub.c index afe3b4785..57cd8f13f 100644 --- a/examples/windows/z_sub.c +++ b/examples/windows/z_sub.c @@ -83,4 +83,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/windows/z_sub_st.c b/examples/windows/z_sub_st.c index fb808e1ea..9b41877fa 100644 --- a/examples/windows/z_sub_st.c +++ b/examples/windows/z_sub_st.c @@ -72,4 +72,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/zephyr/z_get.c b/examples/zephyr/z_get.c index 08a1ccb17..ffe90520a 100644 --- a/examples/zephyr/z_get.c +++ b/examples/zephyr/z_get.c @@ -94,4 +94,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/zephyr/z_pub.c b/examples/zephyr/z_pub.c index 4bfd33d88..1f47be9a0 100644 --- a/examples/zephyr/z_pub.c +++ b/examples/zephyr/z_pub.c @@ -88,4 +88,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/zephyr/z_pull.c b/examples/zephyr/z_pull.c index e2906063f..61bed75d0 100644 --- a/examples/zephyr/z_pull.c +++ b/examples/zephyr/z_pull.c @@ -91,4 +91,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/zephyr/z_queryable.c b/examples/zephyr/z_queryable.c index b92be70c1..044664bb2 100644 --- a/examples/zephyr/z_queryable.c +++ b/examples/zephyr/z_queryable.c @@ -95,4 +95,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/examples/zephyr/z_sub.c b/examples/zephyr/z_sub.c index 0293954ef..ac307a47a 100644 --- a/examples/zephyr/z_sub.c +++ b/examples/zephyr/z_sub.c @@ -89,4 +89,4 @@ int main(void) { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n"); return -2; } -#endif \ No newline at end of file +#endif diff --git a/tests/modularity.py b/tests/modularity.py index 44c66d8e5..662236a1d 100644 --- a/tests/modularity.py +++ b/tests/modularity.py @@ -27,7 +27,8 @@ def pub_and_sub(args): Putting Data ('demo/example/zenoh-pico-pub': 'Pub from Pico!')...''' else : z_pub_expected_status = 254 - z_pub_expected_output = "ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it." + z_pub_expected_output = ("ERROR: Zenoh pico was compiled without " + "Z_FEATURE_PUBLICATION but this example requires it.") # Expected z_sub output & status if args.sub == 1: @@ -52,12 +53,17 @@ def pub_and_sub(args): Enter 'q' to quit...''' else : z_sub_expected_status = 254 - z_sub_expected_output = "ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it." - + z_sub_expected_output = ("ERROR: Zenoh pico was compiled without " + "Z_FEATURE_SUBSCRIPTION but this example requires it.") + print("Start subscriber") # Start z_sub in the background z_sub_command = f"./{DIR_EXAMPLES}/z_sub" - z_sub_process = subprocess.Popen(z_sub_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + z_sub_process = subprocess.Popen(z_sub_command, + shell=True, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True) # Introduce a delay to ensure z_sub starts time.sleep(2) @@ -65,7 +71,12 @@ def pub_and_sub(args): print("Start publisher") # Start z_pub z_pub_command = f"./{DIR_EXAMPLES}/z_pub" - z_pub_process = subprocess.Popen(z_pub_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + z_pub_process = subprocess.Popen(z_pub_command, + shell=True, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True) # Wait for z_pub to finish z_pub_process.wait() @@ -90,7 +101,7 @@ def pub_and_sub(args): # Check output of z_pub z_pub_output = z_pub_process.stdout.read() - if z_pub_output.__contains__(z_pub_expected_output): + if z_pub_expected_output in z_pub_output: print("z_pub output valid") else: print("z_pub output invalid:") @@ -109,7 +120,7 @@ def pub_and_sub(args): # Check output of z_sub z_sub_output = z_sub_process.stdout.read() - if z_sub_output.__contains__(z_sub_expected_output): + if z_sub_expected_output in z_sub_output: print("z_sub output valid") else: print("z_sub output invalid:") @@ -149,7 +160,8 @@ def query_and_queryable(args): >> Received query final notification''' else : z_query_expected_status = 254 - z_query_expected_output = "ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it." + z_query_expected_output = ("ERROR: Zenoh pico was compiled without " + "Z_FEATURE_QUERY but this example requires it.") # Expected z_queryable output & status if args.queryable == 1: @@ -167,12 +179,18 @@ def query_and_queryable(args): Enter 'q' to quit...''' else : z_queryable_expected_status = 254 - z_queryable_expected_output = "ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it." - + z_queryable_expected_output = ("ERROR: Zenoh pico was compiled without " + "Z_FEATURE_QUERYABLE but this example requires it.") + print("Start queryable") # Start z_queryable in the background z_queryable_command = f"./{DIR_EXAMPLES}/z_queryable" - z_queryable_process = subprocess.Popen(z_queryable_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + z_queryable_process = subprocess.Popen(z_queryable_command, + shell=True, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True) # Introduce a delay to ensure z_queryable starts time.sleep(2) @@ -180,7 +198,12 @@ def query_and_queryable(args): print("Start query") # Start z_query z_query_command = f"./{DIR_EXAMPLES}/z_get" - z_query_process = subprocess.Popen(z_query_command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + z_query_process = subprocess.Popen(z_query_command, + shell=True, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True) # Introduce a delay to ensure z_query starts time.sleep(2) @@ -220,12 +243,13 @@ def query_and_queryable(args): if z_query_status == z_query_expected_status: print("z_query status valid") else: - print(f"z_query status invalid, expected: {z_query_expected_status}, received: {z_query_status}") + print(f"z_query status invalid, expected: {z_query_expected_status}," + f" received: {z_query_status}") test_status = 1 # Check output of z_query z_query_output = z_query_process.stdout.read() - if z_query_output.__contains__(z_query_expected_output): + if z_query_expected_output in z_query_output: print("z_query output valid") else: print("z_query output invalid:") @@ -239,12 +263,13 @@ def query_and_queryable(args): if z_queryable_status == z_queryable_expected_status: print("z_queryable status valid") else: - print(f"z_queryable status invalid, expected: {z_queryable_expected_status}, received: {z_queryable_status}") + print(f"z_queryable status invalid, expected: {z_queryable_expected_status}," + f" received: {z_queryable_status}") test_status = 1 # Check output of z_queryable z_queryable_output = z_queryable_process.stdout.read() - if z_queryable_output.__contains__(z_queryable_expected_output): + if z_queryable_expected_output in z_queryable_output: print("z_queryable output valid") else: print("z_queryable output invalid:") @@ -255,21 +280,24 @@ def query_and_queryable(args): return test_status if __name__ == "__main__": - parser = argparse.ArgumentParser(description="This script runs zenoh-pico examples and checks them according to the given configuration") + parser = argparse.ArgumentParser(description="This script runs zenoh-pico examples" + " and checks them according to the given configuration") parser.add_argument("--pub", type=int, choices=[0, 1], help="Z_FEATURE_PUBLICATION (0 or 1)") parser.add_argument("--sub", type=int, choices=[0, 1], help="Z_FEATURE_SUBSCRIPTION (0 or 1)") - parser.add_argument("--queryable", type=int, choices=[0, 1], help="Z_FEATURE_QUERYABLE (0 or 1)") + parser.add_argument("--queryable", type=int, choices=[0, 1], + help="Z_FEATURE_QUERYABLE (0 or 1)") parser.add_argument("--query", type=int, choices=[0, 1], help="Z_FEATURE_QUERY (0 or 1)") - exit_status = 0 - args = parser.parse_args() - print(f"Args value, pub:{args.pub}, sub:{args.sub}, queryable:{args.queryable}, query:{args.query}") + EXIT_STATUS = 0 + prog_args = parser.parse_args() + print(f"Args value, pub:{prog_args.pub}, sub:{prog_args.sub}, " + f"queryable:{prog_args.queryable}, query:{prog_args.query}") # Test pub and sub examples - if pub_and_sub(args) == 1: - exit_status = 1 + if pub_and_sub(prog_args) == 1: + EXIT_STATUS = 1 # Test query and queryable examples - if query_and_queryable(args) == 1: - exit_status = 1 + if query_and_queryable(prog_args) == 1: + EXIT_STATUS = 1 # Exit - sys.exit(exit_status) \ No newline at end of file + sys.exit(EXIT_STATUS) diff --git a/tests/z_msgcodec_test.c b/tests/z_msgcodec_test.c index 88433b878..5d20469df 100644 --- a/tests/z_msgcodec_test.c +++ b/tests/z_msgcodec_test.c @@ -187,7 +187,7 @@ _z_bytes_t gen_bytes(size_t len) { arr.start = (uint8_t *)z_malloc(sizeof(uint8_t) * len); for (_z_zint_t i = 0; i < len; i++) { - ((uint8_t *)arr.start)[i] = gen_uint8() & 0b01111111; + ((uint8_t *)arr.start)[i] = gen_uint8() & 0x7f; // 0b01111111 } return arr;