Skip to content

Commit

Permalink
Merge pull request #209 from wenhui-xie/master
Browse files Browse the repository at this point in the history
Add NetXDuo regression test.
  • Loading branch information
bo-ms authored Nov 30, 2023
2 parents 531239b + a817c0b commit 06faa36
Show file tree
Hide file tree
Showing 1,828 changed files with 708,603 additions and 1,998 deletions.
13 changes: 13 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"image": "ghcr.io/tiejunms/azure_rtos_docker",

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools"
],

"remoteUser": "vscode",

"runArgs": [ "--cap-add=NET_ADMIN"]
}
43 changes: 43 additions & 0 deletions .github/workflows/regression_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This is a basic workflow that is manually triggered

name: regression_test

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_dispatch:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
NetXDuo:
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_nxd.sh
test_script: ./scripts/test_nxd.sh
cmake_path: ./test/cmake/netxduo
result_affix: NetXDuo
skip_deploy: true
Deploy:
permissions:
contents: read
issues: read
checks: write
pull-requests: write
pages: write
id-token: write
needs: [NetXDuo]
uses: azure-rtos/threadx/.github/workflows/regression_template.yml@master
with:
skip_test: true
deploy_list: "NetXDuo"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.vscode/
_deps/
build/
coverage_report/
CMakeFiles/
CMakeScripts/
CMakeLists.txt.user
Expand All @@ -11,4 +12,5 @@ cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
.run.sh

1 change: 1 addition & 0 deletions addons/azure_iot/nx_azure_iot.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ UINT status;
/* Do nothing if the client is not connected. */
if (client_ptr -> nxd_mqtt_client_state != NXD_MQTT_CLIENT_STATE_CONNECTED)
{
tx_mutex_put(client_ptr -> nxd_mqtt_client_mutex_ptr);
LogError(LogLiteralArgs("MQTT NOT CONNECTED"));
return(NX_AZURE_IOT_DISCONNECTED);
}
Expand Down
4 changes: 2 additions & 2 deletions addons/azure_iot/nx_azure_iot_adu_agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -1745,8 +1745,8 @@ static UINT nx_azure_iot_adu_agent_jws_split(UCHAR *jws, UINT jws_length,
UCHAR **signature, UINT *signature_length)
{

UCHAR *dot1_pointer;
UCHAR *dot2_pointer;
UCHAR *dot1_pointer = jws;
UCHAR *dot2_pointer = jws;
UINT dot_count = 0;
UINT i = 0;

Expand Down
11 changes: 11 additions & 0 deletions samples/demo_netxduo_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,17 @@ UINT status;
if (mib2_mib[i].object_set_callback)
{

/* If the object data type is string. */
if (object_data -> nx_snmp_object_data_type == NX_SNMP_ANS1_OCTET_STRING)
{

/* Check the string length of the object value. */
if (object_data -> nx_snmp_object_octet_string_size > mib2_mib[i].length)
{
return(NX_SNMP_ERROR_TOOBIG);
}
}

/* Yes, call the set function. */
status = (mib2_mib[i].object_set_callback)(mib2_mib[i].object_value_ptr, object_data);
}
Expand Down
38 changes: 19 additions & 19 deletions samples/demo_snmp_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ULONG ipDefaultTTL = NX_IP_TIME_TO_LIVE; /* ipDefault
underlying application driver, but for now simple defaults are used. */
ULONG ifLastChange = 2048; /* ifLastChange:TimeTicks RO */
ULONG ifInOctets = 155; /* ifInOctets:Counter RO */
ULONG ifInUcastPkts = 0; /* ifInUcastPkts:Counter RO */
ULONG64 ifInUcastPkts = 0; /* ifInUcastPkts:Counter RO */
UCHAR ifDescr[] = "NetX Physical Interface"; /* ifDescr:OctetString RO */

/* Define the MIB-2 "address translation" group, assuming one address translation. */
Expand All @@ -62,31 +62,31 @@ MIB_ENTRY mib2_mib[] = {

/* OBJECT ID OBJECT VARIABLE GET ROUTINE/ GET_OCTET_ROUTINE SET ROUTINE LENGTH */

{(UCHAR *) "1.3.6.1.2.1.1.1.0", sysDescr, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, 0},
{(UCHAR *) "1.3.6.1.2.1.1.2.0", sysObjectID, nx_snmp_object_id_get, NX_NULL, NX_NULL, 0},
{(UCHAR *) "1.3.6.1.2.1.1.3.0", &sysUpTime, nx_snmp_object_timetics_get, NX_NULL, NX_NULL, 0},
{(UCHAR *) "1.3.6.1.2.1.1.4.0", sysContact, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, 0},
{(UCHAR *) "1.3.6.1.2.1.1.5.0", sysName, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, 0},
{(UCHAR *) "1.3.6.1.2.1.1.6.0", sysLocation, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, 0},
{(UCHAR *) "1.3.6.1.2.1.1.7.0", &sysServices, nx_snmp_object_integer_get, NX_NULL, NX_NULL, 0},
{(UCHAR *) "1.3.6.1.2.1.1.1.0", sysDescr, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, sizeof(sysDescr)},
{(UCHAR *) "1.3.6.1.2.1.1.2.0", sysObjectID, nx_snmp_object_id_get, NX_NULL, NX_NULL, sizeof(sysObjectID)},
{(UCHAR *) "1.3.6.1.2.1.1.3.0", &sysUpTime, nx_snmp_object_timetics_get, NX_NULL, NX_NULL, sizeof(sysUpTime)},
{(UCHAR *) "1.3.6.1.2.1.1.4.0", sysContact, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, sizeof(sysContact)},
{(UCHAR *) "1.3.6.1.2.1.1.5.0", sysName, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, sizeof(sysName)},
{(UCHAR *) "1.3.6.1.2.1.1.6.0", sysLocation, nx_snmp_object_string_get, NX_NULL, nx_snmp_object_string_set, sizeof(sysLocation)},
{(UCHAR *) "1.3.6.1.2.1.1.7.0", &sysServices, nx_snmp_object_integer_get, NX_NULL, NX_NULL, sizeof(sysServices)},

{(UCHAR *) "1.3.6.1.2.1.3.1.1.3.0", &atNetworkAddress, nx_snmp_object_ip_address_get, NX_NULL, nx_snmp_object_ip_address_set, 0},
{(UCHAR *) "1.3.6.1.2.1.3.1.1.3.0", &atNetworkAddress, nx_snmp_object_ip_address_get, NX_NULL, nx_snmp_object_ip_address_set, sizeof(atNetworkAddress)},
#ifdef FEATURE_NX_IPV6
/* Either GET method should work. IPv6 addresses are handled as octet strings and accept any IPv6 address format e.g. addresses with '::'s are accepted as is. */
{(UCHAR *) "1.3.6.1.2.1.3.1.1.3.1", &atIPv6NetworkAddress, nx_snmp_object_ipv6_address_get, NX_NULL, nx_snmp_object_ipv6_address_set, 0},
{(UCHAR *) "1.3.6.1.2.1.3.1.1.3.2", &atIPv6NetworkAddress, NX_NULL, nx_snmp_object_octet_string_get, nx_snmp_object_octet_string_set, 0},
{(UCHAR *) "1.3.6.1.2.1.3.1.1.3.1", &atIPv6NetworkAddress, nx_snmp_object_ipv6_address_get, NX_NULL, nx_snmp_object_ipv6_address_set, sizeof(atIPv6NetworkAddress)},
{(UCHAR *) "1.3.6.1.2.1.3.1.1.3.2", &atIPv6NetworkAddress, NX_NULL, nx_snmp_object_octet_string_get, nx_snmp_object_octet_string_set, sizeof(atIPv6NetworkAddress)},
#endif

{(UCHAR *) "1.3.6.1.2.1.2.2.1.2.0", ifDescr, nx_snmp_object_string_get, NX_NULL, NX_NULL, 0},
{(UCHAR *) "1.3.6.1.2.1.3.1.1.2.0", &atPhysAddress, NX_NULL, nx_snmp_object_octet_string_get, nx_snmp_object_octet_string_set, 0},
{(UCHAR *) "1.3.6.1.2.1.2.2.1.9.0", &ifLastChange, nx_snmp_object_timetics_get, NX_NULL, nx_snmp_object_timetics_set, 0},
{(UCHAR *) "1.3.6.1.2.1.2.2.1.10.0", &ifInOctets, nx_snmp_object_counter_get, NX_NULL, nx_snmp_object_counter_set, 0},
{(UCHAR *) "1.3.6.1.2.1.2.2.1.11.0", &ifInUcastPkts, nx_snmp_object_counter64_get, NX_NULL, nx_snmp_object_counter64_set, 0},
{(UCHAR *) "1.3.6.1.2.1.2.2.1.2.0", ifDescr, nx_snmp_object_string_get, NX_NULL, NX_NULL, sizeof(ifDescr)},
{(UCHAR *) "1.3.6.1.2.1.3.1.1.2.0", &atPhysAddress, NX_NULL, nx_snmp_object_octet_string_get, nx_snmp_object_octet_string_set, sizeof(atPhysAddress)},
{(UCHAR *) "1.3.6.1.2.1.2.2.1.9.0", &ifLastChange, nx_snmp_object_timetics_get, NX_NULL, nx_snmp_object_timetics_set, sizeof(ifLastChange)},
{(UCHAR *) "1.3.6.1.2.1.2.2.1.10.0", &ifInOctets, nx_snmp_object_counter_get, NX_NULL, nx_snmp_object_counter_set, sizeof(ifInOctets)},
{(UCHAR *) "1.3.6.1.2.1.2.2.1.11.0", &ifInUcastPkts, nx_snmp_object_counter64_get, NX_NULL, nx_snmp_object_counter64_set, sizeof(ifInUcastPkts)},

{(UCHAR *) "1.3.6.1.2.1.4.1.0", &ipForwarding, nx_snmp_object_integer_get, NX_NULL, nx_snmp_object_integer_set, 0},
{(UCHAR *) "1.3.6.1.2.1.4.2.0", &ipDefaultTTL, nx_snmp_object_integer_get, NX_NULL, NX_NULL, 0},
{(UCHAR *) "1.3.6.1.2.1.4.1.0", &ipForwarding, nx_snmp_object_integer_get, NX_NULL, nx_snmp_object_integer_set, sizeof(ipForwarding)},
{(UCHAR *) "1.3.6.1.2.1.4.2.0", &ipDefaultTTL, nx_snmp_object_integer_get, NX_NULL, NX_NULL, sizeof(ipDefaultTTL)},

{(UCHAR *) "1.3.6.1.7", (UCHAR *) "1.3.6.1.7", nx_snmp_object_end_of_mib, NX_NULL, NX_NULL, 0},
{(UCHAR *) "1.3.6.1.7", (UCHAR *) "1.3.6.1.7", nx_snmp_object_end_of_mib, NX_NULL, NX_NULL, sizeof("1.3.6.1.7") - 1},
{NX_NULL, NX_NULL, NX_NULL, NX_NULL, NX_NULL, 0}

};
Expand Down
3 changes: 3 additions & 0 deletions scripts/build_nxd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash

$(dirname `realpath $0`)/../test/cmake/netxduo/run.sh build all
32 changes: 32 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
#

# Remove large folder
rm -rf /opt/hostedtoolcache

# Install necessary softwares for Ubuntu.

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y \
gcc-multilib \
git \
g++ \
python3-pip \
ninja-build \
unifdef \
p7zip-full \
tofrodos \
dos2unix \
gawk \
libssl-dev:i386 \
software-properties-common

wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
CODENAME=$(lsb_release -c | cut -f2 -d':' | sed 's/\t//')
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $CODENAME main"

python3 -m pip install --upgrade pip
pip3 install gcovr==4.1
pip install --upgrade cmake

3 changes: 3 additions & 0 deletions scripts/test_nxd.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/netxduo/run.sh test all
33 changes: 33 additions & 0 deletions test/cmake/libs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)

project(libs LANGUAGES C)

if($ENV{ENABLE_64})
message(STATUS "Building for 64bit")
else()
add_compile_options(-m32)
add_link_options(-m32)
message(STATUS "Building for 32bit")
endif()
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")

set(TX_USER_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tx_user.h)
get_filename_component(
externals ${CMAKE_CURRENT_SOURCE_DIR}/../.. ABSOLUTE)
add_subdirectory(${externals}/threadx threadx)
add_subdirectory(${externals}/filex filex)
target_compile_options(threadx PRIVATE -DTX_ENABLE_EVENT_TRACE)
if(NOT DEFINED ENV{ENABLE_IDLE})
target_compile_options(threadx PRIVATE -DTX_LINUX_NO_IDLE_ENABLE)
endif()

foreach(lib threadx filex)
get_target_property(dirs ${lib} INCLUDE_DIRECTORIES)
execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/inc)
foreach(dir ${dirs})
file(GLOB header_files ${dir}/*.h)
foreach(header_file ${header_files})
execute_process(COMMAND ln -sf ${header_file} ${CMAKE_BINARY_DIR}/inc)
endforeach()
endforeach()
endforeach()
56 changes: 56 additions & 0 deletions test/cmake/libs/tx_user.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/


/**************************************************************************/
/**************************************************************************/
/** */
/** ThreadX Component */
/** */
/** User Specific */
/** */
/**************************************************************************/
/**************************************************************************/


/**************************************************************************/
/* */
/* PORT SPECIFIC C INFORMATION RELEASE */
/* */
/* tx_user.h PORTABLE C */
/* 6.0 */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This file contains user defines for configuring ThreadX in specific */
/* ways. This file will have an effect only if the application and */
/* ThreadX library are built with TX_INCLUDE_USER_DEFINE_FILE defined. */
/* Note that all the defines in this file may also be made on the */
/* command line when building ThreadX library and application objects. */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* */
/**************************************************************************/

#ifndef TX_USER_H
#define TX_USER_H

#define TX_THREAD_USER_EXTENSION int bsd_errno;

#endif
Loading

0 comments on commit 06faa36

Please sign in to comment.