Skip to content

Commit

Permalink
Add Azure IoT test. (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenhui-xie authored Dec 13, 2023
1 parent e2f20d5 commit 947608f
Show file tree
Hide file tree
Showing 33 changed files with 15,752 additions and 4 deletions.
47 changes: 43 additions & 4 deletions .github/workflows/regression_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
cmake_path: ./test/cmake/netxduo64
result_affix: NetXDuo64
skip_deploy: true
NetXDuo_fast:
NetXDuo_Fast:
permissions:
contents: read
issues: read
Expand All @@ -86,9 +86,48 @@ jobs:
build_script: ./scripts/build_nxd_fast.sh
test_script: ./scripts/test_nxd_fast.sh
cmake_path: ./test/cmake/netxduo_fast
result_affix: NetXDuo_fast
result_affix: NetXDuo_Fast
skip_deploy: true
skip_coverage: true
Azure_IoT:
permissions:
contents: read
issues: read
checks: write
pull-requests: write
pages: write
id-token: write
uses: azure-rtos/threadx/.github/workflows/regression_template.yml@master
with:
build_script: ./scripts/build_azure_iot.sh
test_script: ./scripts/test_azure_iot.sh
cmake_path: ./test/cmake/azure_iot
result_affix: Azure_IoT
skip_deploy: true
Azure_IoT_Windows:
permissions:
contents: read
issues: read
checks: write
pull-requests: write
runs-on: windows-2019
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
submodules: true
- name: Checkout submodules
run: |
if (!(Test-Path ./test/cmake/threadx)) {git clone https://github.com/azure-rtos/threadx.git ./test/cmake/threadx --depth 1}
- name: CMake
run: |
mkdir build
cd build
cmake ../test/cmake/azure_iot -A Win32
- name: Build
run: |
cd build
cmake --build .
Deploy:
permissions:
contents: read
Expand All @@ -97,8 +136,8 @@ jobs:
pull-requests: write
pages: write
id-token: write
needs: [NetXDuo, Web, MQTT, NetXDuo64, NetXDuo_fast]
needs: [NetXDuo, Web, MQTT, NetXDuo64, NetXDuo_Fast, Azure_IoT]
uses: azure-rtos/threadx/.github/workflows/regression_template.yml@master
with:
skip_test: true
deploy_list: "NetXDuo Web MQTT NetXDuo64 NetXDuo_fast"
deploy_list: "NetXDuo Web MQTT NetXDuo64 NetXDuo_Fast Azure_IoT"
3 changes: 3 additions & 0 deletions scripts/build_azure_iot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

$(dirname `realpath $0`)/../test/cmake/azure_iot/run.sh build all
2 changes: 2 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ sudo apt-get install -y \
dos2unix \
gawk \
libssl-dev:i386 \
libcmocka-dev:i386 \
gcc-arm-none-eabi \
software-properties-common

wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
Expand Down
3 changes: 3 additions & 0 deletions scripts/test_azure_iot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

CTEST_PARALLEL_LEVEL=4 $(dirname `realpath $0`)/../test/cmake/azure_iot/run.sh test all
111 changes: 111 additions & 0 deletions test/cmake/azure_iot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)

if(NOT DEFINED THREADX_ARCH)
if(WIN32)
set(CMAKE_TOOLCHAIN_FILE
"configs/win32.cmake"
CACHE STRING "")
elseif(UNIX)
set(CMAKE_TOOLCHAIN_FILE
"configs/linux.cmake"
CACHE STRING "")
else()
message(FATAL_ERROR "Error: Architecture not supported")
endif()
endif()

# Project
project(AzureIoTMiddleware LANGUAGES C ASM)

# Set build configurations
if(NOT WIN32)
set(BUILD_CONFIGURATIONS
default_build_coverage disable_precondition_build disable_security_module_build)
set(CMAKE_CONFIGURATION_TYPES
${BUILD_CONFIGURATIONS}
CACHE STRING "list of supported configuration types" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
${CMAKE_CONFIGURATION_TYPES})
list(GET CMAKE_CONFIGURATION_TYPES 0 BUILD_TYPE)
if((NOT CMAKE_BUILD_TYPE) OR (NOT ("${CMAKE_BUILD_TYPE}" IN_LIST
CMAKE_CONFIGURATION_TYPES)))
set(CMAKE_BUILD_TYPE
"${BUILD_TYPE}"
CACHE STRING "Build Type of the project" FORCE)
endif()
endif()

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")

set(default_build_coverage)
set(disable_precondition_build -DAZ_NO_PRECONDITION_CHECKING -DAZ_NO_LOGGING -DNX_DISABLE_IPV6)
set(disable_security_module_build -DNX_AZURE_DISABLE_IOT_SECURITY_MODULE)

# Set property for folder
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(DISABLE_TEST
OFF
CACHE BOOL "Disable test projects (default is OFF)")
set(NX_AZURE_DISABLE_IOT_SECURITY_MODULE
OFF
CACHE BOOL "Disable Azure IoT Security Module (default is OFF)")

if(NOT WIN32)
if("-DNX_AZURE_DISABLE_IOT_SECURITY_MODULE" IN_LIST ${CMAKE_BUILD_TYPE})
set(NX_AZURE_DISABLE_IOT_SECURITY_MODULE ON)
endif()
endif()

# CFLAGS
if(WIN32)
set(ADDITIONAL_C_FLAGS $ENV{CFLAGS} "/MP -DWIN32 -D_CRT_SECURE_NO_WARNINGS")
else()
if(THREADX_ARCH STREQUAL "linux")
set(ADDITIONAL_C_FLAGS
"$ENV{CFLAGS} -O0 -g3 -ggdb -m32 -gdwarf-2 -fdiagnostics-color -fprofile-arcs -ftest-coverage -Wno-error=misleading-indentation")
endif()
set(ADDITIONAL_C_FLAGS_AZURE_SERVICES
"-std=c99 -Werror -Wall -Wextra -pedantic -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -Wunused -Wuninitialized -Wmissing-declarations -Wconversion -Wpointer-arith -Wshadow -Wlogical-op -Wfloat-equal -fprofile-arcs -ftest-coverage -Wjump-misses-init -Wno-error=misleading-indentation"
)
endif()

# Add definitions
add_definitions(
${ADDITIONAL_C_FLAGS}
${DRIVER_FLAG}
-DNX_PCAP_SOURCE_NAME=\"${PCAP_NAME}\"
-DNX_ENABLE_EXTENDED_NOTIFY_SUPPORT
-DNX_SECURE_ENABLE
-DNX_DNS_CLIENT_USER_CREATE_PACKET_POOL
-DNX_DNS_CLIENT_CLEAR_QUEUE
-DNXD_MQTT_CLOUD_ENABLE
-DNX_SNTP_CLIENT_MAX_ROOT_DISPERSION=0
-DNX_SNTP_CLIENT_MIN_SERVER_STRATUM=3
-DNX_ENABLE_IP_PACKET_FILTER
-DNX_SECURE_TLS_DISABLE_TLS_1_1
-DNXD_MQTT_PING_TIMEOUT_DELAY=500
-DNXD_MQTT_SOCKET_TIMEOUT=0
-DNXD_MQTT_OVER_WEBSOCKET
-DNX_AZURE_IOT_ADU_AGENT_PROXY_UPDATE_COUNT=1
${${CMAKE_BUILD_TYPE}})

# Include azure rtos cmake
include(configs/azure_rtos_src.cmake)

if(NX_AZURE_DISABLE_IOT_SECURITY_MODULE)
add_definitions(
-DNX_AZURE_DISABLE_IOT_SECURITY_MODULE
)
endif()

# Link libraries
if(THREADX_ARCH STREQUAL "linux")
add_link_options(-m32 -fprofile-arcs -ftest-coverage)
endif()

if((NOT DISABLE_TEST) AND UNIX)
# Include tests cmake
include(configs/azure_rtos_tests.cmake)
endif()
47 changes: 47 additions & 0 deletions test/cmake/azure_iot/configs/azure_rtos_src.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Set folder
set(TX_FOLDER "${PROJECT_SOURCE_DIR}/../threadx")
set(NXD_FOLDER "${PROJECT_SOURCE_DIR}/../../..")

# Add tx
add_subdirectory(${TX_FOLDER} threadx)

# Add nxd
set(NXD_ENABLE_FILE_SERVERS OFF CACHE BOOL "Disable fileX dependency by netxduo")
set(NXD_ENABLE_AZURE_IOT ON CACHE BOOL "Enable Azure IoT from netxduo")
add_subdirectory(${NXD_FOLDER} netxduo)

set_target_properties(threadx PROPERTIES FOLDER "azure_rtos")
set_target_properties(netxduo PROPERTIES FOLDER "azure_rtos")

set_target_properties(az_core PROPERTIES FOLDER "azure_iot_embedded_sdk")
set_target_properties(az_iot_common PROPERTIES FOLDER "azure_iot_embedded_sdk")
set_target_properties(az_iot_hub PROPERTIES FOLDER "azure_iot_embedded_sdk")
set_target_properties(az_iot_provisioning PROPERTIES FOLDER "azure_iot_embedded_sdk")
set_target_properties(az_nohttp PROPERTIES FOLDER "azure_iot_embedded_sdk")
set_target_properties(az_noplatform PROPERTIES FOLDER "azure_iot_embedded_sdk")

# Enable strict build flags for netxduo
if(THREADX_TOOLCHAIN STREQUAL "gnu")
target_compile_options(
netxduo
PRIVATE -std=c99
-Werror
-Wall
-Wextra
-pedantic
-fmessage-length=0
-fsigned-char
-ffunction-sections
-fdata-sections
-Wunused
-Wuninitialized
-Wmissing-declarations
-Wconversion
-Wpointer-arith
-Wshadow
-Wlogical-op
-Wfloat-equal
-fprofile-arcs
-Wjump-misses-init
-Wno-error=misleading-indentation)
endif()
Loading

0 comments on commit 947608f

Please sign in to comment.