From 6d3c1ddec2cc09e8e27fca5539acf9be275dbbe3 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Mon, 13 Dec 2021 11:04:24 +0100 Subject: [PATCH] samples: net: google_iot_mqtt: Fix CI for the sample The sample did not specify any tests in its sample.yaml file, causing CI failures. Additionally, the sample requires to generate secure key before building the sample, otherwise the build fails. For the CI needs, specify a dummy test key, which is only included if the build was triggered by Twister. For this, specify a USE_DUMMY_KEY variable in the sample.yaml file. Finally, fix some minor build issues in the sample itself - remove unused variable, and remove deleted (and also unneeded) mbed TLS header inclusion. Signed-off-by: Robert Lubos --- .../net/cloud/google_iot_mqtt/CMakeLists.txt | 15 ++- samples/net/cloud/google_iot_mqtt/sample.yaml | 5 + samples/net/cloud/google_iot_mqtt/src/main.c | 2 - .../src/private_info/test_key.c | 112 ++++++++++++++++++ .../net/cloud/google_iot_mqtt/src/protocol.c | 1 - 5 files changed, 127 insertions(+), 8 deletions(-) create mode 100644 samples/net/cloud/google_iot_mqtt/src/private_info/test_key.c diff --git a/samples/net/cloud/google_iot_mqtt/CMakeLists.txt b/samples/net/cloud/google_iot_mqtt/CMakeLists.txt index 5b965ea14db..6fd930b57ec 100644 --- a/samples/net/cloud/google_iot_mqtt/CMakeLists.txt +++ b/samples/net/cloud/google_iot_mqtt/CMakeLists.txt @@ -5,11 +5,16 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(google_iot_mqtt) -if(NOT EXISTS ${APPLICATION_SOURCE_DIR}/src/private_info/key.c) - message(FATAL_ERROR "!!!!!! Generate key file before continuing. See README !!!!!") -endif() - FILE(GLOB app_sources src/*.c) target_sources(app PRIVATE ${app_sources}) -target_sources(app PRIVATE ${APPLICATION_SOURCE_DIR}/src/private_info/key.c) zephyr_include_directories(${APPLICATION_SOURCE_DIR}/src/tls_config) + +if(USE_DUMMY_KEY) + target_sources(app PRIVATE ${APPLICATION_SOURCE_DIR}/src/private_info/test_key.c) +else() + if(NOT EXISTS ${APPLICATION_SOURCE_DIR}/src/private_info/key.c) + message(FATAL_ERROR "!!!!!! Generate key file before continuing. See README !!!!!") + endif() + + target_sources(app PRIVATE ${APPLICATION_SOURCE_DIR}/src/private_info/key.c) +endif() diff --git a/samples/net/cloud/google_iot_mqtt/sample.yaml b/samples/net/cloud/google_iot_mqtt/sample.yaml index cb648fd5c51..6b0a25348b6 100644 --- a/samples/net/cloud/google_iot_mqtt/sample.yaml +++ b/samples/net/cloud/google_iot_mqtt/sample.yaml @@ -5,3 +5,8 @@ common: tags: net mqtt cloud harness: net filter: TOOLCHAIN_HAS_NEWLIB == 1 + extra_args: USE_DUMMY_KEY=1 +tests: + sample.net.cloud.google_iot_mqtt: + depends_on: netif + platform_allow: frdm_k64f qemu_x86 diff --git a/samples/net/cloud/google_iot_mqtt/src/main.c b/samples/net/cloud/google_iot_mqtt/src/main.c index 82ede944910..31dbb5bad08 100644 --- a/samples/net/cloud/google_iot_mqtt/src/main.c +++ b/samples/net/cloud/google_iot_mqtt/src/main.c @@ -62,8 +62,6 @@ int do_sntp(void) */ void main(void) { - int res; - LOG_INF("Main entered"); app_dhcpv4_startup(); diff --git a/samples/net/cloud/google_iot_mqtt/src/private_info/test_key.c b/samples/net/cloud/google_iot_mqtt/src/private_info/test_key.c new file mode 100644 index 00000000000..14baccb56d2 --- /dev/null +++ b/samples/net/cloud/google_iot_mqtt/src/private_info/test_key.c @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +unsigned char zepfull_private_der[] = { + 0x30, 0x82, 0x04, 0xbe, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a, + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82, + 0x04, 0xa8, 0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, + 0x01, 0x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0x53, 0x00, 0xb0, 0x75, 0xac, 0xdb, 0xb2, 0xa4, 0x5d, + 0x18, 0x7d, 0x76, 0xf6, 0xc5, 0x69, 0x37, 0x6b, 0xfd, 0xc4, 0x56, 0x01, + 0x13, 0xf7, 0x7d, 0xcd, 0xf7, 0x3b, 0xa8, 0xec, 0x11, 0x95, 0x53, 0x25, + 0x5e, 0x99, 0xb9, 0x13, 0xf9, 0xa8, 0x68, 0x25, 0x23, 0x2c, 0x36, 0xc7, + 0xb6, 0x39, 0x7f, 0xe9, 0xf9, 0x70, 0x2b, 0x29, 0xbc, 0x70, 0xe9, 0x7a, + 0x00, 0xd2, 0x76, 0xa1, 0xef, 0x3c, 0x98, 0x71, 0x77, 0xbb, 0xcd, 0x83, + 0xf2, 0x3a, 0x7a, 0x5e, 0xc0, 0x27, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, + 0x82, 0x01, 0x01, 0x00, 0xb8, 0xf8, 0x67, 0x99, 0x16, 0xf8, 0xf0, 0xde, + 0xdc, 0x28, 0x71, 0xe0, 0x96, 0xd6, 0x59, 0xba, 0xd0, 0x9b, 0xf3, 0x75, + 0x13, 0xb0, 0xef, 0xdd, 0x1d, 0xf9, 0x29, 0xd4, 0xe4, 0xd5, 0x95, 0x68, + 0xe8, 0x78, 0x6c, 0x16, 0x9b, 0xe6, 0x34, 0x93, 0x6f, 0xdb, 0x3c, 0x6b, + 0x99, 0x59, 0x4a, 0x1d, 0x91, 0x04, 0x44, 0x4f, 0x71, 0xa3, 0xc8, 0x67, + 0x54, 0xa6, 0xca, 0xcd, 0x5c, 0x98, 0x26, 0x3e, 0x1c, 0xbc, 0x09, 0x35, + 0xf0, 0x08, 0x51, 0x7b, 0xdc, 0x6f, 0xa8, 0xc2, 0x37, 0x8e, 0x97, 0xc0, + 0x45, 0x7e, 0xc0, 0x3e, 0x81, 0xa5, 0x68, 0x06, 0x63, 0x39, 0x0b, 0x99, + 0x67, 0xfe, 0xe0, 0x0d, 0x48, 0x44, 0x42, 0x56, 0x54, 0xd4, 0x17, 0x9f, + 0xd3, 0x9f, 0xef, 0x18, 0xcc, 0x6a, 0x08, 0xd6, 0x9a, 0x91, 0x04, 0x8a, + 0xfd, 0xe3, 0x4f, 0x51, 0x62, 0xac, 0x60, 0xfc, 0xd2, 0x15, 0xb8, 0xff, + 0x53, 0x3e, 0xc0, 0x07, 0xe3, 0x75, 0x42, 0xbe, 0x35, 0x1b, 0x7e, 0xf5, + 0x00, 0x1a, 0x26, 0x10, 0x89, 0xb4, 0x8c, 0x21, 0x54, 0xb5, 0x1e, 0x1a, + 0x23, 0x32, 0xaf, 0x80, 0x38, 0x0a, 0xfa, 0xc0, 0x17, 0xb1, 0x49, 0x92, + 0xfa, 0x08, 0x15, 0x02, 0xa6, 0xe3, 0x36, 0x57, 0x03, 0xbd, 0x56, 0xd2, + 0x24, 0xaf, 0xb9, 0x45, 0xd0, 0x43, 0x16, 0xd1, 0x78, 0x86, 0x2e, 0xae, + 0xf6, 0xac, 0x1d, 0x0b, 0x03, 0xac, 0x90, 0x0d, 0x5d, 0xbe, 0xc0, 0xc0, + 0x9e, 0x30, 0x38, 0x9b, 0x61, 0x7b, 0x51, 0x39, 0xc2, 0x3d, 0x30, 0x85, + 0xf2, 0x33, 0x94, 0x53, 0xb0, 0x5a, 0x12, 0x72, 0xeb, 0x30, 0xb2, 0x8c, + 0x66, 0xec, 0xc2, 0x1f, 0x4d, 0xa5, 0x67, 0x20, 0xde, 0x3b, 0x05, 0x72, + 0xe9, 0x0e, 0x77, 0x1f, 0x3f, 0xd8, 0x8a, 0x77, 0x5c, 0x4c, 0xc0, 0x81, + 0xf2, 0xe3, 0x41, 0x96, 0x94, 0xa6, 0xe5, 0xc1, 0x02, 0x81, 0x81, 0x00, + 0xe3, 0xd3, 0x76, 0x49, 0x5f, 0x18, 0x58, 0x74, 0x31, 0x37, 0xca, 0xfa, + 0x42, 0x39, 0x74, 0x61, 0x4b, 0xec, 0x0c, 0x14, 0xc7, 0xfa, 0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, + 0x60, 0xc9, 0x39, 0x15, 0xaa, 0x6c, 0x56, 0x0a, 0x08, 0x24, 0x3f, 0xda, + 0xd4, 0x62, 0xed, 0xf2, 0x59, 0x10, 0x34, 0x14, 0xfa, 0x91, 0x08, 0x80, + 0xb2, 0x90, 0xba, 0x0f, 0x39, 0x45, 0x84, 0x69, 0x4a, 0xce, 0xbc, 0x71, + 0x24, 0x49, 0x4e, 0x53, 0x26, 0xd7, 0x38, 0x79, 0x05, 0xf7, 0x57, 0x7a, + 0x43, 0xd0, 0x55, 0xb6, 0xc1, 0x0b, 0xca, 0x4f, 0x02, 0x81, 0x80, 0x77, + 0x43, 0xc7, 0xf4, 0x78, 0xf7, 0xc1, 0xb6, 0x71, 0xdd, 0x87, 0x40, 0xa3, + 0x52, 0x78, 0x7e, 0x46, 0xc4, 0x77, 0x3e, 0x99, 0xc1, 0xe8, 0x1c, 0x4b, + 0xae, 0x82, 0x25, 0xe9, 0x2b, 0x40, 0x88, 0x87, 0x2b, 0xaa, 0x26, 0x0d, + 0x81, 0xe0, 0x96, 0x7c, 0x47, 0x51, 0x59, 0x1c, 0x12, 0x21, 0x43, 0xb2, + 0x52, 0x2d, 0x40, 0xf4, 0x32, 0x47, 0x74, 0x5c, 0x1c, 0x84, 0x2f, 0x71, + 0x24, 0xe4, 0x5c, 0x1d, 0xf7, 0xe1, 0xcf, 0xf0, 0xa0, 0x9e, 0x3d, 0xc6, + 0x85, 0xca, 0x77, 0x5a, 0x60, 0x8b, 0x1d, 0x15, 0x9c, 0xa0, 0xbe, 0x5f, + 0xbb, 0x32, 0x7a, 0xe3, 0x30, 0x91, 0xd7, 0xcb, 0x00, 0xd4, 0xea, 0xf7, + 0x82, 0xfe, 0xe5, 0xb3, 0x3d, 0x26, 0x92, 0xe3, 0xe6, 0xe6, 0xd9, 0xac, + 0xd8, 0x5b, 0xb0, 0x0e, 0xa8, 0xa9, 0x97, 0x8a, 0xfb, 0x8e, 0x6e, 0x62, + 0xbe, 0x78, 0x38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 0xb1, 0xe7, 0xb6, 0xab, 0x0c, 0x95, 0x17, + 0xe3, 0x7c, 0x86, 0x64, 0x0c, 0x06, 0x00, 0x10, 0x8a, 0x23, 0x14, 0x1b, + 0xa6, 0xdb, 0xc9, 0xcc, 0xcb, 0x96, 0xcd, 0x38, 0x77, 0xa5, 0xb1, 0x02, + 0xf7, 0x49, 0x87, 0x1d, 0x6a, 0x2b, 0xfb, 0x40, 0x6b, 0x03, 0x4d, 0x04, + 0xdf, 0xed, 0x16, 0x1b, 0xbe, 0x3c, 0x03, 0xca, 0x68, 0x3f, 0x4c, 0x28, + 0xfc, 0x99, 0xf0, 0xdd, 0x23, 0x51, 0xc0, 0x87, 0x85, 0x17, 0xa9, 0x1f, + 0x18, 0xe0, 0x10, 0xd6, 0xca, 0xbf, 0xb6, 0x5c, 0x0c, 0xce, 0x4d, 0x2e, + 0x9e, 0x75, 0xf0, 0x71, 0xe0, 0x01 +}; + +unsigned int zepfull_private_der_len = 1218; diff --git a/samples/net/cloud/google_iot_mqtt/src/protocol.c b/samples/net/cloud/google_iot_mqtt/src/protocol.c index cb32b5c5610..639b04a38bc 100644 --- a/samples/net/cloud/google_iot_mqtt/src/protocol.c +++ b/samples/net/cloud/google_iot_mqtt/src/protocol.c @@ -19,7 +19,6 @@ LOG_MODULE_DECLARE(net_google_iot_mqtt, LOG_LEVEL_DBG); #include #include -#include #include #include #include