From d446195e14bd3178bf8302dcb8987dc27a46b399 Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Tue, 17 Sep 2024 20:14:51 +0200 Subject: [PATCH] Fix DPS docker containers log configuration --- .github/workflows/docker-build-publish.yml | 2 +- .github/workflows/plgd-dps-tests.yml | 2 +- CMakeLists.txt | 10 +++++----- api/plgd/device-provisioning-client/plgd_dps_apis.c | 4 +++- api/plgd/device-provisioning-client/plgd_dps_pki.c | 6 +++--- .../device-provisioning-client/plgd_dps_security.c | 4 +++- docker/apps/Dockerfile.dps-cloud-server-debug | 3 +-- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/docker-build-publish.yml b/.github/workflows/docker-build-publish.yml index e8ed20a69..0b1b44b44 100644 --- a/.github/workflows/docker-build-publish.yml +++ b/.github/workflows/docker-build-publish.yml @@ -60,7 +60,7 @@ jobs: file: docker/apps/Dockerfile.dps-cloud-server - name: dps-cloud-server-debug build_type: Debug - build_args: -DOC_DEBUG_ENABLED=ON -DOC_LOG_MAXIMUM_LOG_LEVEL=DEBUG -DPLGD_DEV_DEVICE_PROVISIONING_TEST_PROPERTIES_ENABLED=ON + build_args: -DOC_DEBUG_ENABLED=ON -DOC_LOG_MAXIMUM_LOG_LEVEL=DEBUG -DPLGD_DEV_DEVICE_PROVISIONING_MAXIMUM_LOG_LEVEL=DEBUG -DPLGD_DPS_CLOUD_SERVER_DBG_ENABLED=ON -DPLGD_DEV_DEVICE_PROVISIONING_TEST_PROPERTIES_ENABLED=ON file: docker/apps/Dockerfile.dps-cloud-server uses: ./.github/workflows/docker-build-publish-with-cfg.yml with: diff --git a/.github/workflows/plgd-dps-tests.yml b/.github/workflows/plgd-dps-tests.yml index 0d15538e2..53f3c3d87 100644 --- a/.github/workflows/plgd-dps-tests.yml +++ b/.github/workflows/plgd-dps-tests.yml @@ -53,7 +53,7 @@ jobs: uses: ./.github/workflows/plgd-dps-test-with-cfg.yml with: args: ${{ matrix.args || '' }} - build_args: -DOC_DEBUG_ENABLED=ON -DPLGD_DPS_MAXIMUM_LOG_LEVEL=TRACE -DPLGD_DPS_CLOUD_SERVER_DBG_ENABLED=ON ${{ matrix.build_args }} + build_args: -DOC_DEBUG_ENABLED=ON -DPLGD_DEV_DEVICE_PROVISIONING_MAXIMUM_LOG_LEVEL=TRACE -DPLGD_DEV_DEVICE_PROVISIONING_TEST_PROPERTIES_ENABLED=ON -DPLGD_DPS_CLOUD_SERVER_DBG_ENABLED=ON ${{ matrix.build_args }} build_type: ${{ (github.event_name == 'workflow_dispatch' && inputs.build_type) || 'Debug' }} docker_file: ${{ matrix.docker_file || 'docker/apps/Dockerfile.dps-cloud-server-debug' }} skip: ${{ matrix.skip || false }} diff --git a/CMakeLists.txt b/CMakeLists.txt index cc74744d8..0456cdbc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -426,11 +426,11 @@ if(PLGD_DEV_DEVICE_PROVISIONING_ENABLED) endif() list(APPEND PUBLIC_COMPILE_DEFINITIONS "PLGD_DEV_DEVICE_PROVISIONING") - set(PLGD_DPS_MAXIMUM_LOG_LEVEL "DISABLED" CACHE STRING "Maximum supported Plgd DPS log level in compile time.") - set(PLGD_DPS_MAXIMUM_LOG_LEVEL_INT) - oc_set_maximum_log_level("${PLGD_DPS_MAXIMUM_LOG_LEVEL}" PLGD_DPS_MAXIMUM_LOG_LEVEL_INT) - list(APPEND PRIVATE_COMPILE_DEFINITIONS "PLGD_DPS_LOG_MAXIMUM_LEVEL=(${PLGD_DPS_MAXIMUM_LOG_LEVEL_INT})") - list(APPEND TEST_COMPILE_DEFINITIONS "PLGD_DPS_LOG_MAXIMUM_LEVEL=(${PLGD_DPS_MAXIMUM_LOG_LEVEL_INT})") + set(PLGD_DEV_DEVICE_PROVISIONING_MAXIMUM_LOG_LEVEL "DISABLED" CACHE STRING "Maximum supported Plgd DPS log level in compile time.") + set(PLGD_DEV_DEVICE_PROVISIONING_MAXIMUM_LOG_LEVEL_INT) + oc_set_maximum_log_level("${PLGD_DEV_DEVICE_PROVISIONING_MAXIMUM_LOG_LEVEL}" PLGD_DEV_DEVICE_PROVISIONING_MAXIMUM_LOG_LEVEL_INT) + list(APPEND PRIVATE_COMPILE_DEFINITIONS "PLGD_DPS_LOG_MAXIMUM_LEVEL=(${PLGD_DEV_DEVICE_PROVISIONING_MAXIMUM_LOG_LEVEL_INT})") + list(APPEND TEST_COMPILE_DEFINITIONS "PLGD_DPS_LOG_MAXIMUM_LEVEL=(${PLGD_DEV_DEVICE_PROVISIONING_MAXIMUM_LOG_LEVEL_INT})") endif() if(PLGD_DEV_DEVICE_PROVISIONING_TEST_PROPERTIES_ENABLED) diff --git a/api/plgd/device-provisioning-client/plgd_dps_apis.c b/api/plgd/device-provisioning-client/plgd_dps_apis.c index 343a1b8d2..5d367cfb4 100644 --- a/api/plgd/device-provisioning-client/plgd_dps_apis.c +++ b/api/plgd/device-provisioning-client/plgd_dps_apis.c @@ -30,6 +30,7 @@ #include "util/oc_macros_internal.h" #include +#include #include bool @@ -82,7 +83,8 @@ dps_reset_delayed_callback_ms(void *cb_data, oc_trigger_t callback, #define MILLISECONDS_IN_SECONDS 1000 #define OC_CLOCK_MILLISECOND (OC_CLOCK_SECOND / MILLISECONDS_IN_SECONDS) if (oc_clock_time_max / OC_CLOCK_MILLISECOND < milliseconds) { - DPS_DBG("delayed callback interval truncated to %lu", oc_clock_time_max); + DPS_DBG("delayed callback interval truncated to %" PRIu64, + oc_clock_time_max); milliseconds = oc_clock_time_max / OC_CLOCK_MILLISECOND; } oc_clock_time_t interval = milliseconds * OC_CLOCK_MILLISECOND; diff --git a/api/plgd/device-provisioning-client/plgd_dps_pki.c b/api/plgd/device-provisioning-client/plgd_dps_pki.c index c06b3bd6c..77f602942 100644 --- a/api/plgd/device-provisioning-client/plgd_dps_pki.c +++ b/api/plgd/device-provisioning-client/plgd_dps_pki.c @@ -135,9 +135,9 @@ dps_pki_validate_certificate(dps_pki_configuration_t cfg, uint64_t valid_from, } uint64_t now_s = now / OC_CLOCK_SECOND; - DPS_DBG( - "\tcheck certificate validity: now=%lu from=%lu to=%lu expiring_limit:%u", - now_s, valid_from, valid_to, (unsigned)cfg.expiring_limit); + DPS_DBG("\tcheck certificate validity: now=%" PRIu64 " from=%" PRIu64 + " to=%" PRIu64 " expiring_limit:%u", + now_s, valid_from, valid_to, (unsigned)cfg.expiring_limit); if (now_s < valid_from) { return DPS_CERTIFICATE_NOT_YET_VALID; } diff --git a/api/plgd/device-provisioning-client/plgd_dps_security.c b/api/plgd/device-provisioning-client/plgd_dps_security.c index f4d185a13..53b2c584d 100644 --- a/api/plgd/device-provisioning-client/plgd_dps_security.c +++ b/api/plgd/device-provisioning-client/plgd_dps_security.c @@ -33,6 +33,7 @@ #include "security/oc_tls_internal.h" #include +#include #include #include #include @@ -388,7 +389,8 @@ dps_check_credentials(const plgd_dps_context_t *ctx, if (!all_valid || !has_identity || !has_trust_anchor) { return false; } - DPS_DBG("earliest expiring certificate(valid-from: %lu, valid-to: %lu)", + DPS_DBG("earliest expiring certificate(valid-from: %" PRIu64 + ", valid-to: %" PRIu64 ")", valid_from, valid_to); if (min_validity != NULL) { min_validity->valid_from = valid_from; diff --git a/docker/apps/Dockerfile.dps-cloud-server-debug b/docker/apps/Dockerfile.dps-cloud-server-debug index 26aaef24b..f675c2f19 100644 --- a/docker/apps/Dockerfile.dps-cloud-server-debug +++ b/docker/apps/Dockerfile.dps-cloud-server-debug @@ -22,8 +22,7 @@ RUN mkdir build && \ cd build && \ cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DOC_CLOUD_ENABLED=ON \ -DOC_COLLECTIONS_IF_CREATE_ENABLED=ON -DOC_OSCORE_ENABLED=OFF -DOC_DISCOVERY_RESOURCE_OBSERVABLE_ENABLED=ON \ - -DOC_DEBUG_ENABLED=ON -DPLGD_DEV_TIME_ENABLED=ON -DPLGD_DEV_DEVICE_PROVISIONING_ENABLED=ON \ - -DPLGD_DEV_DEVICE_PROVISIONING_TEST_PROPERTIES_ENABLED=ON -DBUILD_TESTING=ON ${BUILD_ARGS} .. && \ + -DPLGD_DEV_TIME_ENABLED=ON -DPLGD_DEV_DEVICE_PROVISIONING_ENABLED=ON -DBUILD_TESTING=ON ${BUILD_ARGS} .. && \ cmake --build . --target mbedtls mbedx509 mbedcrypto && \ cmake --build . -j$(nproc) --target dps_cloud_server && \ cp /device-provisioning-client/build/apps/dps_cloud_server /dps/