From 3918c65f17445abb08546f28b859e3ca1b0fac8d Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Fri, 20 Oct 2023 10:48:06 +0200 Subject: [PATCH 01/21] feat: add modular test --- CMakeLists.txt | 2 + tests/z_modular_test.c | 285 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 287 insertions(+) create mode 100644 tests/z_modular_test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d562f411..8d97b4ddf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,6 +290,7 @@ if(UNIX OR MSVC) add_executable(z_keyexpr_test ${PROJECT_SOURCE_DIR}/tests/z_keyexpr_test.c) add_executable(z_api_null_drop_test ${PROJECT_SOURCE_DIR}/tests/z_api_null_drop_test.c) add_executable(z_api_double_drop_test ${PROJECT_SOURCE_DIR}/tests/z_api_double_drop_test.c) + add_executable(z_modular_test ${PROJECT_SOURCE_DIR}/tests/z_modular_test.c) target_link_libraries(z_data_struct_test ${Libname}) target_link_libraries(z_endpoint_test ${Libname}) @@ -298,6 +299,7 @@ if(UNIX OR MSVC) target_link_libraries(z_keyexpr_test ${Libname}) target_link_libraries(z_api_null_drop_test ${Libname}) target_link_libraries(z_api_double_drop_test ${Libname}) + target_link_libraries(z_modular_test ${Libname}) configure_file(${PROJECT_SOURCE_DIR}/tests/modularity.py ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/modularity.py COPYONLY) diff --git a/tests/z_modular_test.c b/tests/z_modular_test.c new file mode 100644 index 000000000..e5ea32b26 --- /dev/null +++ b/tests/z_modular_test.c @@ -0,0 +1,285 @@ +// +// Copyright (c) 2022 ZettaScale Technology +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// +// Contributors: +// ZettaScale Zenoh Team, + +#include +#include +#include +#include + +#include "zenoh-pico.h" + +#undef NDEBUG +#include + +static const char *ARG_LIST[] = {"Z_FEATURE_PUBLICATION", "Z_FEATURE_SUBSCRIPTION", "Z_FEATURE_QUERYABLE", + "Z_FEATURE_QUERY"}; +#define ARG_NB (sizeof(ARG_LIST) / sizeof(ARG_LIST[0])) + +int test_publication(void) { +#if Z_FEATURE_PUBLICATION == 1 + const char *keyexpr = "demo/example/zenoh-pico-pub"; + const char *value = "Pub from Pico!"; + const char *mode = "client"; + + // Set up config + z_owned_config_t config = z_config_default(); + zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); + // Open session + printf("Opening session...\n"); + z_owned_session_t s = z_open(z_move(config)); + if (!z_check(s)) { + printf("Unable to open session!\n"); + return -1; + } + // Start read and lease tasks for zenoh-pico + if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { + printf("Unable to start read and lease tasks"); + return -1; + } + // Declare publisher + printf("Declaring publisher for '%s'...\n", keyexpr); + z_owned_publisher_t pub = z_declare_publisher(z_loan(s), z_keyexpr(keyexpr), NULL); + if (!z_check(pub)) { + printf("Unable to declare publisher for key expression!\n"); + return -1; + } + // Put data + printf("Putting Data ('%s': '%s')...\n", keyexpr, value); + z_publisher_put_options_t options = z_publisher_put_options_default(); + options.encoding = z_encoding(Z_ENCODING_PREFIX_TEXT_PLAIN, NULL); + z_publisher_put(z_loan(pub), (const uint8_t *)value, strlen(value), &options); + + // Clean-up + z_undeclare_publisher(z_move(pub)); + zp_stop_read_task(z_loan(s)); + zp_stop_lease_task(z_loan(s)); + z_close(z_move(s)); + return 1; +#else + return 0; +#endif +} + +#if Z_FEATURE_SUBSCRIPTION == 1 +static void subscription_data_handler(const z_sample_t *sample, void *ctx) { + (void)(ctx); + z_owned_str_t keystr = z_keyexpr_to_string(sample->keyexpr); + printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_loan(keystr), (int)sample->payload.len, + sample->payload.start); + z_drop(z_move(keystr)); +} +#endif + +int test_subscription(void) { +#if Z_FEATURE_SUBSCRIPTION == 1 + const char *keyexpr = "demo/example/**"; + const char *mode = "client"; + + // Set up config + z_owned_config_t config = z_config_default(); + zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); + // Open session + printf("Opening session...\n"); + z_owned_session_t s = z_open(z_move(config)); + if (!z_check(s)) { + printf("Unable to open session!\n"); + return -1; + } + // Start read and lease tasks for zenoh-pico + if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { + printf("Unable to start read and lease tasks"); + return -1; + } + // Declare subscriber + z_owned_closure_sample_t callback = z_closure(subscription_data_handler); + printf("Declaring Subscriber on '%s'...\n", keyexpr); + z_owned_subscriber_t sub = z_declare_subscriber(z_loan(s), z_keyexpr(keyexpr), z_move(callback), NULL); + if (!z_check(sub)) { + printf("Unable to declare subscriber.\n"); + return -1; + } + // Clean-up + z_undeclare_subscriber(z_move(sub)); + zp_stop_read_task(z_loan(s)); + zp_stop_lease_task(z_loan(s)); + z_close(z_move(s)); + return 1; +#else + return 0; +#endif +} + +#if Z_FEATURE_QUERYABLE == 1 +static const char *queryable_keyexpr = "demo/example/zenoh-pico-queryable"; +static const char *queryable_value = "Queryable from Pico!"; + +void query_handler(const z_query_t *query, void *ctx) { + (void)(ctx); + z_owned_str_t keystr = z_keyexpr_to_string(z_query_keyexpr(query)); + z_bytes_t pred = z_query_parameters(query); + z_value_t payload_value = z_query_value(query); + printf(" >> [Queryable handler] Received Query '%s?%.*s'\n", z_loan(keystr), (int)pred.len, pred.start); + if (payload_value.payload.len > 0) { + printf(" with value '%.*s'\n", (int)payload_value.payload.len, payload_value.payload.start); + } + z_query_reply_options_t options = z_query_reply_options_default(); + options.encoding = z_encoding(Z_ENCODING_PREFIX_TEXT_PLAIN, NULL); + z_query_reply(query, z_keyexpr(queryable_keyexpr), (const unsigned char *)queryable_value, strlen(queryable_value), &options); + z_drop(z_move(keystr)); +} +#endif + +int test_queryable(void) { +#if Z_FEATURE_QUERYABLE == 1 + const char *mode = "client"; + + z_keyexpr_t ke = z_keyexpr(queryable_keyexpr); + if (!z_check(ke)) { + printf("%s is not a valid key expression", queryable_keyexpr); + return -1; + } + // Set up config + z_owned_config_t config = z_config_default(); + zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); + // Open session + printf("Opening session...\n"); + z_owned_session_t s = z_open(z_move(config)); + if (!z_check(s)) { + printf("Unable to open session!\n"); + return -1; + } + // Start read and lease tasks for zenoh-pico + if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { + printf("Unable to start read and lease tasks"); + return -1; + } + // Declare queryable + printf("Creating Queryable on '%s'...\n", queryable_keyexpr); + z_owned_closure_query_t callback = z_closure(query_handler); + z_owned_queryable_t qable = z_declare_queryable(z_loan(s), ke, z_move(callback), NULL); + if (!z_check(qable)) { + printf("Unable to create queryable.\n"); + return -1; + } + // Clean-up + z_undeclare_queryable(z_move(qable)); + zp_stop_read_task(z_loan(s)); + zp_stop_lease_task(z_loan(s)); + z_close(z_move(s)); + + return 1; +#else + return 0; +#endif +} + +#if Z_FEATURE_QUERY == 1 +void reply_dropper(void *ctx) { + (void)(ctx); + printf(">> Received query final notification\n"); +} + +void reply_handler(z_owned_reply_t *reply, void *ctx) { + (void)(ctx); + if (z_reply_is_ok(reply)) { + z_sample_t sample = z_reply_ok(reply); + z_owned_str_t keystr = z_keyexpr_to_string(sample.keyexpr); + printf(">> Received ('%s': '%.*s')\n", z_loan(keystr), (int)sample.payload.len, sample.payload.start); + z_drop(z_move(keystr)); + } else { + printf(">> Received an error\n"); + } +} +#endif + +int test_query(void) { +#if Z_FEATURE_QUERY == 1 + const char *keyexpr = "demo/example/**"; + const char *mode = "client"; + + z_keyexpr_t ke = z_keyexpr(keyexpr); + if (!z_check(ke)) { + printf("%s is not a valid key expression", keyexpr); + return -1; + } + // Set up config + z_owned_config_t config = z_config_default(); + zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); + // Open session + printf("Opening session...\n"); + z_owned_session_t s = z_open(z_move(config)); + if (!z_check(s)) { + printf("Unable to open session!\n"); + return -1; + } + // Start read and lease tasks for zenoh-pico + if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { + printf("Unable to start read and lease tasks"); + return -1; + } + // Send query + printf("Sending Query '%s'...\n", keyexpr); + z_get_options_t opts = z_get_options_default(); + z_owned_closure_reply_t callback = z_closure(reply_handler, reply_dropper); + if (z_get(z_loan(s), ke, "", z_move(callback), &opts) < 0) { + printf("Unable to send query.\n"); + return -1; + } + // Clean-up + zp_stop_read_task(z_loan(s)); + zp_stop_lease_task(z_loan(s)); + z_close(z_move(s)); + + return 1; +#else + return 0; +#endif +} + +// Send feature config as int list, and compare with compiled feature +int main(int argc, char **argv) { + if (argc < (int)(ARG_NB + 1)) { + printf("To start this test you must give the state of the feature config as argument\n"); + printf("Arg order: "); + for (size_t i = 0; i < ARG_NB; i++) { + printf("%s ", ARG_LIST[i]); + } + printf("\n"); + return -1; + } + if (test_publication() != atoi(argv[1])) { + printf("Problem during publication testing\n"); + return -1; + } else { + printf("Publication status ok\n"); + } + if (test_subscription() != atoi(argv[2])) { + printf("Problem during subscription testing\n"); + return -1; + } else { + printf("Subscription status ok\n"); + } + if (test_queryable() != atoi(argv[3])) { + printf("Problem during queryable testing\n"); + return -1; + } else { + printf("Queryable status ok\n"); + } + if (test_query() != atoi(argv[4])) { + printf("Problem during query testing\n"); + return -1; + } else { + printf("Query status ok\n"); + } + return 0; +} From b0c4599839a763be23fc13d233e9f937bbff0061 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 24 Oct 2023 10:16:16 +0200 Subject: [PATCH 02/21] build: add compile flags for crossbuild consistency --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d97b4ddf..178b5b1dd 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") From 8f9ab05a66bcd61868ef45f8c8438e7a3961d8f9 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 24 Oct 2023 10:23:57 +0200 Subject: [PATCH 03/21] fix: remove compile error on binary constant --- tests/z_msgcodec_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/z_msgcodec_test.c b/tests/z_msgcodec_test.c index 88433b878..98ae720b9 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; From d5f4863de5da91ba1dbeea2f65e15a586a2b095b Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 24 Oct 2023 10:26:43 +0200 Subject: [PATCH 04/21] build: add cmake generator option for build --- GNUmakefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 67932a3bc..ff4029495 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -52,6 +52,9 @@ Z_FEATURE_SUBSCRIPTION?=1 Z_FEATURE_QUERY?=1 Z_FEATURE_QUERYABLE?=1 +# Generator +CMAKE_GENERATOR?="Unix Makefiles" + # zenoh-pico/ directory ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) @@ -74,7 +77,7 @@ all: make $(BUILD_DIR)/Makefile: mkdir -p $(BUILD_DIR) echo $(CMAKE_OPT) - cmake $(CMAKE_OPT) -B $(BUILD_DIR) + cmake $(CMAKE_OPT) -B $(BUILD_DIR) -G $(CMAKE_GENERATOR) make: $(BUILD_DIR)/Makefile cmake --build $(BUILD_DIR) From 89aa07b63b444fc6a8402ef0ec1121df581d3b36 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 24 Oct 2023 11:04:01 +0200 Subject: [PATCH 05/21] fix: remove unused result compile warning --- examples/unix/c11/z_get.c | 3 ++- examples/unix/c11/z_pull.c | 3 ++- examples/unix/c11/z_queryable.c | 3 ++- examples/unix/c11/z_sub.c | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index b72ea0e9f..7fd88ee99 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; } diff --git a/examples/unix/c11/z_pull.c b/examples/unix/c11/z_pull.c index 4ed568f76..28230fafb 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; } diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index 92f13c652..55b25d188 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)); diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index 0f1d07c6f..aeee4e121 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)); From 8959e50f3280a297ecc8ae7affaa40adeeeec3e1 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 24 Oct 2023 11:15:11 +0200 Subject: [PATCH 06/21] style: run clang-format --- tests/z_modular_test.c | 3 ++- tests/z_msgcodec_test.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/z_modular_test.c b/tests/z_modular_test.c index e5ea32b26..87a7b005c 100644 --- a/tests/z_modular_test.c +++ b/tests/z_modular_test.c @@ -134,7 +134,8 @@ void query_handler(const z_query_t *query, void *ctx) { } z_query_reply_options_t options = z_query_reply_options_default(); options.encoding = z_encoding(Z_ENCODING_PREFIX_TEXT_PLAIN, NULL); - z_query_reply(query, z_keyexpr(queryable_keyexpr), (const unsigned char *)queryable_value, strlen(queryable_value), &options); + z_query_reply(query, z_keyexpr(queryable_keyexpr), (const unsigned char *)queryable_value, strlen(queryable_value), + &options); z_drop(z_move(keystr)); } #endif diff --git a/tests/z_msgcodec_test.c b/tests/z_msgcodec_test.c index 98ae720b9..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() & 0x7f; // 0b01111111 + ((uint8_t *)arr.start)[i] = gen_uint8() & 0x7f; // 0b01111111 } return arr; From 123b19c52c9b65769cac198c7853c13ef458598d Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 24 Oct 2023 11:20:07 +0200 Subject: [PATCH 07/21] build: add tests and format check in CI --- .github/workflows/build-check.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index b8a13d880..b1b80b927 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -20,6 +20,26 @@ 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: 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 . -iname "*.h" -o -iname "*.c" | xargs clang-format -n + modular_build: name: Modular build on ubuntu-latest runs-on: ubuntu-latest From 1d03f7aeb8549578dab275aa4ab3c2134698e0f5 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 24 Oct 2023 11:25:07 +0200 Subject: [PATCH 08/21] fix: repair mac-os build --- examples/unix/c11/z_put.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From f91ffc4c5ba3cdeba44a3e5355c543c49f336839 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 24 Oct 2023 14:45:46 +0200 Subject: [PATCH 09/21] fix: keep a command with default cmake generator --- .github/workflows/build-check.yaml | 7 ++++++- GNUmakefile | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index b1b80b927..4f19a012c 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -28,7 +28,10 @@ jobs: uses: actions/checkout@v4 - name: Build & run tests - run: make test + run: | + sudo apt install -y ninja-build + CMAKE_GENERATOR=Ninja make set_gen + make test check_format: name: Check codebase format with clang-format @@ -58,6 +61,8 @@ jobs: - name: Build project run: | + sudo apt install -y ninja-build + CMAKE_GENERATOR=Ninja make set_gen make all python3 ./build/tests/modularity.py --pub $Z_FEATURE_PUBLICATION --sub $Z_FEATURE_SUBSCRIPTION --queryable $Z_FEATURE_QUERYABLE --query $Z_FEATURE_QUERY timeout-minutes: 5 diff --git a/GNUmakefile b/GNUmakefile index ff4029495..e3f7e1000 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -77,7 +77,7 @@ all: make $(BUILD_DIR)/Makefile: mkdir -p $(BUILD_DIR) echo $(CMAKE_OPT) - cmake $(CMAKE_OPT) -B $(BUILD_DIR) -G $(CMAKE_GENERATOR) + cmake $(CMAKE_OPT) -B $(BUILD_DIR) make: $(BUILD_DIR)/Makefile cmake --build $(BUILD_DIR) @@ -88,6 +88,9 @@ install: $(BUILD_DIR)/Makefile test: make ctest --verbose --test-dir build +set_gen: + cmake $(CMAKE_OPT) -B $(BUILD_DIR) -G $(CMAKE_GENERATOR) + crossbuilds: $(CROSSBUILD_TARGETS) DOCKER_OK := $(shell docker version 2> /dev/null) From 86f9f188f067ec1943ec2da5c8cb7a379cd52d56 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 24 Oct 2023 15:00:48 +0200 Subject: [PATCH 10/21] fix: add line at end of file in examples --- examples/unix/c11/z_get.c | 2 +- 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 | 2 +- examples/unix/c11/z_queryable.c | 2 +- examples/unix/c11/z_sub.c | 2 +- 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 +- 27 files changed, 28 insertions(+), 35 deletions(-) diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index 7fd88ee99..e2aa07e9c 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -136,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 28230fafb..c39f19c52 100644 --- a/examples/unix/c11/z_pull.c +++ b/examples/unix/c11/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/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index 55b25d188..d9bb7c74a 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -131,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 aeee4e121..af42950c3 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/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/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 From b9ef31b49e1f0e6f26a23139d005b8d5dc0b132a Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 25 Oct 2023 15:05:36 +0200 Subject: [PATCH 11/21] build: remove unnecessary target --- .github/workflows/build-check.yaml | 3 +-- GNUmakefile | 6 ------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index 4f19a012c..998086bf8 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -30,8 +30,7 @@ jobs: - name: Build & run tests run: | sudo apt install -y ninja-build - CMAKE_GENERATOR=Ninja make set_gen - make test + CMAKE_GENERATOR=Ninja make test check_format: name: Check codebase format with clang-format diff --git a/GNUmakefile b/GNUmakefile index e3f7e1000..67932a3bc 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -52,9 +52,6 @@ Z_FEATURE_SUBSCRIPTION?=1 Z_FEATURE_QUERY?=1 Z_FEATURE_QUERYABLE?=1 -# Generator -CMAKE_GENERATOR?="Unix Makefiles" - # zenoh-pico/ directory ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) @@ -88,9 +85,6 @@ install: $(BUILD_DIR)/Makefile test: make ctest --verbose --test-dir build -set_gen: - cmake $(CMAKE_OPT) -B $(BUILD_DIR) -G $(CMAKE_GENERATOR) - crossbuilds: $(CROSSBUILD_TARGETS) DOCKER_OK := $(shell docker version 2> /dev/null) From e548eb6f1c13dc1a857d01da8da6733667351f8c Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 25 Oct 2023 16:00:23 +0200 Subject: [PATCH 12/21] fix: return error if clang-format dry run fails --- .github/workflows/build-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index 998086bf8..a565e51e1 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -40,7 +40,7 @@ jobs: uses: actions/checkout@v4 - name: Run clang-format dry-run - run: find . -iname "*.h" -o -iname "*.c" | xargs clang-format -n + run: find . -iname "*.h" -o -iname "*.c" | xargs clang-format -n -Werror modular_build: name: Modular build on ubuntu-latest From f5e858018438ea708c1434a2babaae5da24358d6 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 25 Oct 2023 16:10:01 +0200 Subject: [PATCH 13/21] fix: add arduino files to check format --- .github/workflows/build-check.yaml | 2 +- examples/arduino/z_get.ino | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index a565e51e1..756e89be3 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -40,7 +40,7 @@ jobs: uses: actions/checkout@v4 - name: Run clang-format dry-run - run: find . -iname "*.h" -o -iname "*.c" | xargs clang-format -n -Werror + run: find . -iname "*.ino" -o -iname "*.h" -o -iname "*.c" | xargs clang-format -n -Werror modular_build: name: Modular build on ubuntu-latest diff --git a/examples/arduino/z_get.ino b/examples/arduino/z_get.ino index 7ae75175f..cca330117 100644 --- a/examples/arduino/z_get.ino +++ b/examples/arduino/z_get.ino @@ -120,8 +120,6 @@ void loop() { } } #else -void setup() { - Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it."); -} +void setup() { Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it."); } void loop() {} #endif From feed6250df2d97fc08bf07a3591350ab1063ed33 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 6 Nov 2023 11:05:33 +0100 Subject: [PATCH 14/21] fix: missing end of file line ending --- .github/workflows/build-check.yaml | 5 ++--- .github/workflows/build-shared.yaml | 3 ++- .github/workflows/emscripten.yaml | 2 -- examples/arduino/z_sub.ino | 2 +- examples/espidf/z_get.c | 2 +- examples/espidf/z_pull.c | 2 +- examples/espidf/z_sub.c | 2 +- examples/freertos_plus_tcp/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/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 | 2 +- 21 files changed, 22 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index 756e89be3..103a79b7d 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -61,8 +61,7 @@ jobs: - name: Build project run: | sudo apt install -y ninja-build - CMAKE_GENERATOR=Ninja make set_gen - make all + 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: @@ -75,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..4538361fe 100644 --- a/.github/workflows/build-shared.yaml +++ b/.github/workflows/build-shared.yaml @@ -50,4 +50,5 @@ jobs: env: BUILD_TYPE: Debug BUILD_SHARED_LIBS: ON - ZENOH_DEBUG: 3 \ No newline at end of file + ZENOH_DEBUG: 3 + \ No newline at end of file diff --git a/.github/workflows/emscripten.yaml b/.github/workflows/emscripten.yaml index 7080b5579..efb196939 100644 --- a/.github/workflows/emscripten.yaml +++ b/.github/workflows/emscripten.yaml @@ -36,5 +36,3 @@ jobs: 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/examples/arduino/z_sub.ino b/examples/arduino/z_sub.ino index b07ca70c0..babb5d1f8 100644 --- a/examples/arduino/z_sub.ino +++ b/examples/arduino/z_sub.ino @@ -111,4 +111,4 @@ void setup() { Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it."); } 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/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..91b929837 100644 --- a/tests/modularity.py +++ b/tests/modularity.py @@ -272,4 +272,4 @@ def query_and_queryable(args): if query_and_queryable(args) == 1: exit_status = 1 # Exit - sys.exit(exit_status) \ No newline at end of file + sys.exit(exit_status) From 989f761cd18ea152e6af9bd74cac0dcec9265f9f Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 6 Nov 2023 11:29:27 +0100 Subject: [PATCH 15/21] chore: run pylint --- tests/modularity.py | 80 ++++++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 26 deletions(-) diff --git a/tests/modularity.py b/tests/modularity.py index 91b929837..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) + sys.exit(EXIT_STATUS) From 0c406a47933ec67236efcc4b1270bdf6440b7196 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 6 Nov 2023 11:50:39 +0100 Subject: [PATCH 16/21] fix: remove old modular test --- .github/workflows/build-shared.yaml | 1 - CMakeLists.txt | 2 - tests/z_modular_test.c | 286 ---------------------------- 3 files changed, 289 deletions(-) delete mode 100644 tests/z_modular_test.c diff --git a/.github/workflows/build-shared.yaml b/.github/workflows/build-shared.yaml index 4538361fe..055524f04 100644 --- a/.github/workflows/build-shared.yaml +++ b/.github/workflows/build-shared.yaml @@ -51,4 +51,3 @@ jobs: BUILD_TYPE: Debug BUILD_SHARED_LIBS: ON ZENOH_DEBUG: 3 - \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 178b5b1dd..90b98ea2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,7 +290,6 @@ if(UNIX OR MSVC) add_executable(z_keyexpr_test ${PROJECT_SOURCE_DIR}/tests/z_keyexpr_test.c) add_executable(z_api_null_drop_test ${PROJECT_SOURCE_DIR}/tests/z_api_null_drop_test.c) add_executable(z_api_double_drop_test ${PROJECT_SOURCE_DIR}/tests/z_api_double_drop_test.c) - add_executable(z_modular_test ${PROJECT_SOURCE_DIR}/tests/z_modular_test.c) target_link_libraries(z_data_struct_test ${Libname}) target_link_libraries(z_endpoint_test ${Libname}) @@ -299,7 +298,6 @@ if(UNIX OR MSVC) target_link_libraries(z_keyexpr_test ${Libname}) target_link_libraries(z_api_null_drop_test ${Libname}) target_link_libraries(z_api_double_drop_test ${Libname}) - target_link_libraries(z_modular_test ${Libname}) configure_file(${PROJECT_SOURCE_DIR}/tests/modularity.py ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/modularity.py COPYONLY) diff --git a/tests/z_modular_test.c b/tests/z_modular_test.c deleted file mode 100644 index 87a7b005c..000000000 --- a/tests/z_modular_test.c +++ /dev/null @@ -1,286 +0,0 @@ -// -// Copyright (c) 2022 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, - -#include -#include -#include -#include - -#include "zenoh-pico.h" - -#undef NDEBUG -#include - -static const char *ARG_LIST[] = {"Z_FEATURE_PUBLICATION", "Z_FEATURE_SUBSCRIPTION", "Z_FEATURE_QUERYABLE", - "Z_FEATURE_QUERY"}; -#define ARG_NB (sizeof(ARG_LIST) / sizeof(ARG_LIST[0])) - -int test_publication(void) { -#if Z_FEATURE_PUBLICATION == 1 - const char *keyexpr = "demo/example/zenoh-pico-pub"; - const char *value = "Pub from Pico!"; - const char *mode = "client"; - - // Set up config - z_owned_config_t config = z_config_default(); - zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - // Open session - printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); - if (!z_check(s)) { - printf("Unable to open session!\n"); - return -1; - } - // Start read and lease tasks for zenoh-pico - if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); - return -1; - } - // Declare publisher - printf("Declaring publisher for '%s'...\n", keyexpr); - z_owned_publisher_t pub = z_declare_publisher(z_loan(s), z_keyexpr(keyexpr), NULL); - if (!z_check(pub)) { - printf("Unable to declare publisher for key expression!\n"); - return -1; - } - // Put data - printf("Putting Data ('%s': '%s')...\n", keyexpr, value); - z_publisher_put_options_t options = z_publisher_put_options_default(); - options.encoding = z_encoding(Z_ENCODING_PREFIX_TEXT_PLAIN, NULL); - z_publisher_put(z_loan(pub), (const uint8_t *)value, strlen(value), &options); - - // Clean-up - z_undeclare_publisher(z_move(pub)); - zp_stop_read_task(z_loan(s)); - zp_stop_lease_task(z_loan(s)); - z_close(z_move(s)); - return 1; -#else - return 0; -#endif -} - -#if Z_FEATURE_SUBSCRIPTION == 1 -static void subscription_data_handler(const z_sample_t *sample, void *ctx) { - (void)(ctx); - z_owned_str_t keystr = z_keyexpr_to_string(sample->keyexpr); - printf(">> [Subscriber] Received ('%s': '%.*s')\n", z_loan(keystr), (int)sample->payload.len, - sample->payload.start); - z_drop(z_move(keystr)); -} -#endif - -int test_subscription(void) { -#if Z_FEATURE_SUBSCRIPTION == 1 - const char *keyexpr = "demo/example/**"; - const char *mode = "client"; - - // Set up config - z_owned_config_t config = z_config_default(); - zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - // Open session - printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); - if (!z_check(s)) { - printf("Unable to open session!\n"); - return -1; - } - // Start read and lease tasks for zenoh-pico - if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); - return -1; - } - // Declare subscriber - z_owned_closure_sample_t callback = z_closure(subscription_data_handler); - printf("Declaring Subscriber on '%s'...\n", keyexpr); - z_owned_subscriber_t sub = z_declare_subscriber(z_loan(s), z_keyexpr(keyexpr), z_move(callback), NULL); - if (!z_check(sub)) { - printf("Unable to declare subscriber.\n"); - return -1; - } - // Clean-up - z_undeclare_subscriber(z_move(sub)); - zp_stop_read_task(z_loan(s)); - zp_stop_lease_task(z_loan(s)); - z_close(z_move(s)); - return 1; -#else - return 0; -#endif -} - -#if Z_FEATURE_QUERYABLE == 1 -static const char *queryable_keyexpr = "demo/example/zenoh-pico-queryable"; -static const char *queryable_value = "Queryable from Pico!"; - -void query_handler(const z_query_t *query, void *ctx) { - (void)(ctx); - z_owned_str_t keystr = z_keyexpr_to_string(z_query_keyexpr(query)); - z_bytes_t pred = z_query_parameters(query); - z_value_t payload_value = z_query_value(query); - printf(" >> [Queryable handler] Received Query '%s?%.*s'\n", z_loan(keystr), (int)pred.len, pred.start); - if (payload_value.payload.len > 0) { - printf(" with value '%.*s'\n", (int)payload_value.payload.len, payload_value.payload.start); - } - z_query_reply_options_t options = z_query_reply_options_default(); - options.encoding = z_encoding(Z_ENCODING_PREFIX_TEXT_PLAIN, NULL); - z_query_reply(query, z_keyexpr(queryable_keyexpr), (const unsigned char *)queryable_value, strlen(queryable_value), - &options); - z_drop(z_move(keystr)); -} -#endif - -int test_queryable(void) { -#if Z_FEATURE_QUERYABLE == 1 - const char *mode = "client"; - - z_keyexpr_t ke = z_keyexpr(queryable_keyexpr); - if (!z_check(ke)) { - printf("%s is not a valid key expression", queryable_keyexpr); - return -1; - } - // Set up config - z_owned_config_t config = z_config_default(); - zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - // Open session - printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); - if (!z_check(s)) { - printf("Unable to open session!\n"); - return -1; - } - // Start read and lease tasks for zenoh-pico - if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); - return -1; - } - // Declare queryable - printf("Creating Queryable on '%s'...\n", queryable_keyexpr); - z_owned_closure_query_t callback = z_closure(query_handler); - z_owned_queryable_t qable = z_declare_queryable(z_loan(s), ke, z_move(callback), NULL); - if (!z_check(qable)) { - printf("Unable to create queryable.\n"); - return -1; - } - // Clean-up - z_undeclare_queryable(z_move(qable)); - zp_stop_read_task(z_loan(s)); - zp_stop_lease_task(z_loan(s)); - z_close(z_move(s)); - - return 1; -#else - return 0; -#endif -} - -#if Z_FEATURE_QUERY == 1 -void reply_dropper(void *ctx) { - (void)(ctx); - printf(">> Received query final notification\n"); -} - -void reply_handler(z_owned_reply_t *reply, void *ctx) { - (void)(ctx); - if (z_reply_is_ok(reply)) { - z_sample_t sample = z_reply_ok(reply); - z_owned_str_t keystr = z_keyexpr_to_string(sample.keyexpr); - printf(">> Received ('%s': '%.*s')\n", z_loan(keystr), (int)sample.payload.len, sample.payload.start); - z_drop(z_move(keystr)); - } else { - printf(">> Received an error\n"); - } -} -#endif - -int test_query(void) { -#if Z_FEATURE_QUERY == 1 - const char *keyexpr = "demo/example/**"; - const char *mode = "client"; - - z_keyexpr_t ke = z_keyexpr(keyexpr); - if (!z_check(ke)) { - printf("%s is not a valid key expression", keyexpr); - return -1; - } - // Set up config - z_owned_config_t config = z_config_default(); - zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(mode)); - // Open session - printf("Opening session...\n"); - z_owned_session_t s = z_open(z_move(config)); - if (!z_check(s)) { - printf("Unable to open session!\n"); - return -1; - } - // Start read and lease tasks for zenoh-pico - if (zp_start_read_task(z_loan(s), NULL) < 0 || zp_start_lease_task(z_loan(s), NULL) < 0) { - printf("Unable to start read and lease tasks"); - return -1; - } - // Send query - printf("Sending Query '%s'...\n", keyexpr); - z_get_options_t opts = z_get_options_default(); - z_owned_closure_reply_t callback = z_closure(reply_handler, reply_dropper); - if (z_get(z_loan(s), ke, "", z_move(callback), &opts) < 0) { - printf("Unable to send query.\n"); - return -1; - } - // Clean-up - zp_stop_read_task(z_loan(s)); - zp_stop_lease_task(z_loan(s)); - z_close(z_move(s)); - - return 1; -#else - return 0; -#endif -} - -// Send feature config as int list, and compare with compiled feature -int main(int argc, char **argv) { - if (argc < (int)(ARG_NB + 1)) { - printf("To start this test you must give the state of the feature config as argument\n"); - printf("Arg order: "); - for (size_t i = 0; i < ARG_NB; i++) { - printf("%s ", ARG_LIST[i]); - } - printf("\n"); - return -1; - } - if (test_publication() != atoi(argv[1])) { - printf("Problem during publication testing\n"); - return -1; - } else { - printf("Publication status ok\n"); - } - if (test_subscription() != atoi(argv[2])) { - printf("Problem during subscription testing\n"); - return -1; - } else { - printf("Subscription status ok\n"); - } - if (test_queryable() != atoi(argv[3])) { - printf("Problem during queryable testing\n"); - return -1; - } else { - printf("Queryable status ok\n"); - } - if (test_query() != atoi(argv[4])) { - printf("Problem during query testing\n"); - return -1; - } else { - printf("Query status ok\n"); - } - return 0; -} From ec4a7ba99b40ed773475f2191ce5162b69d64446 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 6 Nov 2023 12:06:56 +0100 Subject: [PATCH 17/21] build: update checkout directive --- .github/workflows/arduino_esp32.yaml | 2 +- .github/workflows/build-shared.yaml | 4 ++-- .github/workflows/build-static.yaml | 4 ++-- .github/workflows/codacy-analysis.yml | 2 +- .github/workflows/emscripten.yaml | 2 +- .github/workflows/espidf.yaml | 2 +- .github/workflows/freertos_plus_tcp.yaml | 2 +- .github/workflows/integration.yaml | 2 +- .github/workflows/mbed.yaml | 2 +- .github/workflows/multicast.yaml | 2 +- .github/workflows/release.yml | 6 +++--- .github/workflows/zephyr.yaml | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) 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-shared.yaml b/.github/workflows/build-shared.yaml index 055524f04..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,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/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 efb196939..fc9b864ff 100644 --- a/.github/workflows/emscripten.yaml +++ b/.github/workflows/emscripten.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 - uses: mymindstorm/setup-emsdk@v11 - name: Compile debug 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..71f93782a 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -32,7 +32,7 @@ jobs: os: [ ubuntu-latest, macOS-latest ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install latest stable uses: actions-rs/toolchain@v1 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: | From cbcafa5856ac333e8eac4aeb4813401e75ae6dd9 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 7 Nov 2023 10:10:52 +0100 Subject: [PATCH 18/21] fix: uniformize arduino examples --- .clang-format | 2 ++ examples/arduino/z_get.ino | 5 ++++- examples/arduino/z_pub.ino | 1 + examples/arduino/z_pull.ino | 1 + examples/arduino/z_queryable.ino | 1 + examples/arduino/z_sub.ino | 1 + 6 files changed, 10 insertions(+), 1 deletion(-) 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/examples/arduino/z_get.ino b/examples/arduino/z_get.ino index cca330117..ddd607641 100644 --- a/examples/arduino/z_get.ino +++ b/examples/arduino/z_get.ino @@ -120,6 +120,9 @@ void loop() { } } #else -void setup() { Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it."); } +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 babb5d1f8..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 From 64bc6982ab2aee0d2933725b487d9eae2ce10c6a Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Tue, 7 Nov 2023 10:11:50 +0100 Subject: [PATCH 19/21] build: check format only project files --- .github/workflows/build-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index 103a79b7d..8ea2af629 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -40,7 +40,7 @@ jobs: uses: actions/checkout@v4 - name: Run clang-format dry-run - run: find . -iname "*.ino" -o -iname "*.h" -o -iname "*.c" | xargs clang-format -n -Werror + 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 From 55713074f67dc4961fb0871bd36e815e6bc0e2a8 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 8 Nov 2023 17:13:51 +0100 Subject: [PATCH 20/21] build: update actions deps --- .github/workflows/codacy-analysis.yml | 5 +++-- .github/workflows/emscripten.yaml | 4 ++-- .github/workflows/integration.yaml | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml index 056e81353..29ffb6378 100644 --- a/.github/workflows/codacy-analysis.yml +++ b/.github/workflows/codacy-analysis.yml @@ -25,7 +25,8 @@ jobs: # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis - name: Run Codacy Analysis CLI - uses: codacy/codacy-analysis-cli-action@1.1.0 + uses: codacy/codacy-analysis-cli-action@v4.3.0 + with: # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository # You can also omit the token and run the tools that support default configurations @@ -41,6 +42,6 @@ jobs: # Upload the SARIF file generated in the previous step - name: Upload SARIF results file - uses: github/codeql-action/upload-sarif@v1 + uses: github/codeql-action/upload-sarif@v2.22.5 with: sarif_file: results.sarif diff --git a/.github/workflows/emscripten.yaml b/.github/workflows/emscripten.yaml index fc9b864ff..a240c7188 100644 --- a/.github/workflows/emscripten.yaml +++ b/.github/workflows/emscripten.yaml @@ -29,8 +29,8 @@ jobs: os: [ubuntu-latest] steps: - uses: actions/checkout@v4 - - uses: jwlawson/actions-setup-cmake@v1.13 - - uses: mymindstorm/setup-emsdk@v11 + - uses: jwlawson/actions-setup-cmake@v1.14 + - uses: mymindstorm/setup-emsdk@v12 - name: Compile debug run: | mkdir build diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 71f93782a..d6b3a0205 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -35,7 +35,7 @@ jobs: - 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 From e760ea3b7c062d8065953e85968461bf702bea89 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 8 Nov 2023 17:23:02 +0100 Subject: [PATCH 21/21] fix: revert codacy workflow changes --- .github/workflows/codacy-analysis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml index 29ffb6378..056e81353 100644 --- a/.github/workflows/codacy-analysis.yml +++ b/.github/workflows/codacy-analysis.yml @@ -25,8 +25,7 @@ jobs: # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis - name: Run Codacy Analysis CLI - uses: codacy/codacy-analysis-cli-action@v4.3.0 - + uses: codacy/codacy-analysis-cli-action@1.1.0 with: # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository # You can also omit the token and run the tools that support default configurations @@ -42,6 +41,6 @@ jobs: # Upload the SARIF file generated in the previous step - name: Upload SARIF results file - uses: github/codeql-action/upload-sarif@v2.22.5 + uses: github/codeql-action/upload-sarif@v1 with: sarif_file: results.sarif