Skip to content

Commit

Permalink
Merge branch 'project-chip:master' into issue_226_temp_2
Browse files Browse the repository at this point in the history
  • Loading branch information
austina-csa authored Jul 10, 2024
2 parents 79fe72a + 171843d commit 2a70fbb
Show file tree
Hide file tree
Showing 16 changed files with 248 additions and 73 deletions.
114 changes: 62 additions & 52 deletions docs/testing/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,58 +85,8 @@ The default_matter_test_main() function is used to run the test on the command
line. These two lines should appear verbatim at the bottom of every python test
file.

## Defining the test arguments

Below is the format:

```
# test-runner-runs: <run_identifier>
# test-runner-run/<run_identifier>/app: ${TYPE_OF_APP}
# test-runner-run/<run_identifier>/factoryreset: <True|False>
# test-runner-run/<run_identifier>/quiet: <True|False>
# test-runner-run/<run_identifier>/app-args: <app_arguments>
# test-runner-run/<run_identifier>/script-args: <script_arguments>
```

### Description of Parameters

- test-runner-runs: Specifies the identifier for the run. This can be any
unique identifier.

- Example: run1

- test-runner-run/<run_identifier>/app: Indicates the application to be used
in the test. Different app types as needed could be referenced from section
[name: Generate an argument environment file ] of the file
[.github/workflows/tests.yaml](https://github.com/project-chip/connectedhomeip/blob/master/.github/workflows/tests.yaml)

- Example: \${TYPE_OF_APP}

- test-runner-run/<run_identifier>/factoryreset: Determines whether a factory
reset should be performed before the test.

- Example: True

- test-runner-run/<run_identifier>/quiet: Sets the verbosity level of the test
run. When set to True, the test run will be quieter.

- Example: True

- test-runner-run/<run_identifier>/app-args: Specifies the arguments to be
passed to the application during the test.

- Example: --discriminator 1234 --KVS kvs1 --trace-to
json:\${TRACE_APP}.json

- test-runner-run/<run_identifier>/script-args: Specifies the arguments to be
passed to the test script.
- Example: --storage-path admin_storage.json --commissioning-method
on-network --discriminator 1234 --passcode 20202021 --trace-to
json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto

This structured format ensures that all necessary configurations are clearly
defined and easily understood, allowing for consistent and reliable test
execution.
The structured comments above the class definition are used to set up the CI for
the tests. Please see [Running tests in CI](#running-tests-in-ci).

## Cluster Codegen

Expand Down Expand Up @@ -610,3 +560,63 @@ example DUT on the host and includes factory reset support
- if there are things in your test that will fail on CI (ex. test vendor
checks), gate them on the PICS_SDK_CI_ONLY
- is_ci = self.check_pics('PICS_SDK_CI_ONLY')

The CI test runner uses a structured environment setup that can be declared
using structured comments at the top of the test file. To use this structured
format, use the --load-from-env flag with the run_python_tests.py runner.

Ex:
`scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --load-from-env /tmp/test_env.yaml --script src/python_testing/TC_ICDM_2_1.py'`

## Defining the CI test arguments

Below is the format:

```
# test-runner-runs: <run_identifier>
# test-runner-run/<run_identifier>/app: ${TYPE_OF_APP}
# test-runner-run/<run_identifier>/factoryreset: <True|False>
# test-runner-run/<run_identifier>/quiet: <True|False>
# test-runner-run/<run_identifier>/app-args: <app_arguments>
# test-runner-run/<run_identifier>/script-args: <script_arguments>
```

### Description of Parameters

- test-runner-runs: Specifies the identifier for the run. This can be any
unique identifier.

- Example: run1

- test-runner-run/<run_identifier>/app: Indicates the application to be used
in the test. Different app types as needed could be referenced from section
[name: Generate an argument environment file ] of the file
[.github/workflows/tests.yaml](https://github.com/project-chip/connectedhomeip/blob/master/.github/workflows/tests.yaml)

- Example: \${TYPE_OF_APP}

- test-runner-run/<run_identifier>/factoryreset: Determines whether a factory
reset should be performed before the test.

- Example: True

- test-runner-run/<run_identifier>/quiet: Sets the verbosity level of the test
run. When set to True, the test run will be quieter.

- Example: True

- test-runner-run/<run_identifier>/app-args: Specifies the arguments to be
passed to the application during the test.

- Example: --discriminator 1234 --KVS kvs1 --trace-to
json:\${TRACE_APP}.json

- test-runner-run/<run_identifier>/script-args: Specifies the arguments to be
passed to the test script.
- Example: --storage-path admin_storage.json --commissioning-method
on-network --discriminator 1234 --passcode 20202021 --trace-to
json:${TRACE_TEST_JSON}.json --trace-to perfetto:${TRACE_TEST_PERFETTO}.perfetto

This structured format ensures that all necessary configurations are clearly
defined and easily understood, allowing for consistent and reliable test
execution.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CHIPCommandBridge : public Command {
{
AddArgument("commissioner-name", &mCommissionerName);
AddArgument("commissioner-nodeId", 0, UINT64_MAX, &mCommissionerNodeId,
"Sets the commisser node ID of the given "
"Sets the commissioner node ID of the given "
"commissioner-name. Interactive mode will only set a single commissioner on the inital command. "
"The commissioner node ID will be persisted until a different one is specified.");
AddArgument("paa-trust-store-path", &mPaaTrustStorePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ - (void)controller:(MTRDeviceController *)controller statusUpdate:(MTRCommission
ChipLogError(chipTool, "MTRCommissioningStatusDiscoveringMoreDevices: This should not happen.");
break;
case MTRCommissioningStatusUnknown:
ChipLogError(chipTool, "Uknown Pairing Status");
ChipLogError(chipTool, "Unknown Pairing Status");
break;
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -844,11 +844,13 @@ - (void)_addDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)que
#endif

if (shouldSetUpSubscription) {
MTR_LOG("%@ - starting subscription setup", self);
// Record the time of first addDelegate call that triggers initial subscribe, and do not reset this value on subsequent addDelegate calls
if (!_initialSubscribeStart) {
_initialSubscribeStart = [NSDate now];
}
if ([self _deviceUsesThread]) {
MTR_LOG(" => %@ - device is a thread device, scheduling in pool", self);
[self _scheduleSubscriptionPoolWork:^{
std::lock_guard lock(self->_lock);
[self _setupSubscriptionWithReason:@"delegate is set and scheduled subscription is happening"];
Expand Down Expand Up @@ -1301,7 +1303,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:

// Sanity check we are not scheduling for this device multiple times in the pool
if (_subscriptionPoolWorkCompletionBlock) {
MTR_LOG_ERROR("%@ already scheduled in subscription pool for this device - ignoring: %@", self, description);
MTR_LOG("%@ already scheduled in subscription pool for this device - ignoring: %@", self, description);
return;
}

Expand All @@ -1310,6 +1312,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
// In the case where a resubscription triggering event happened and already established, running the work block should result in a no-op
MTRAsyncWorkItem * workItem = [[MTRAsyncWorkItem alloc] initWithQueue:self.queue];
[workItem setReadyHandler:^(id _Nonnull context, NSInteger retryCount, MTRAsyncWorkCompletionBlock _Nonnull completion) {
MTR_LOG("%@ - work item is ready to attempt pooled subscription", self);
os_unfair_lock_lock(&self->_lock);
#ifdef DEBUG
[self _callDelegatesWithBlock:^(id testDelegate) {
Expand All @@ -1335,6 +1338,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
workBlock();
}];
[self->_deviceController.concurrentSubscriptionPool enqueueWorkItem:workItem description:description];
MTR_LOG("%@ - enqueued in the subscription pool", self);
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/MTRError_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

NS_ASSUME_NONNULL_BEGIN

#ifndef YES_NO
#define YES_NO(x) ((x) ? @"YES" : @"NO")
#endif

MTR_DIRECT_MEMBERS
@interface MTRError : NSObject
+ (NSError *)errorWithCode:(MTRErrorCode)code;
Expand Down
12 changes: 12 additions & 0 deletions src/platform/nxp/common/CHIPDeviceNXPPlatformDefaultConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,15 @@
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DISCOVERY 1
#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1
#endif

#ifndef CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE
#define CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE 1
#endif // CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE

#ifndef CHIP_DEVICE_CONFIG_PROCESS_BLE_IN_THREAD
#define CHIP_DEVICE_CONFIG_PROCESS_BLE_IN_THREAD 0
#endif // CHIP_DEVICE_CONFIG_PROCESS_BLE_IN_THREAD

#ifndef CHIP_DEVICE_CONFIG_INIT_OT_PLAT_ALARM
#define CHIP_DEVICE_CONFIG_INIT_OT_PLAT_ALARM 1
#endif // CHIP_DEVICE_CONFIG_INIT_OT_PLAT_ALARM
6 changes: 3 additions & 3 deletions src/platform/nxp/common/CHIPDevicePlatformEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

#pragma once
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE
#include <sys/atomic.h>
#include <toolchain.h>
#include <zephyr/bluetooth/bluetooth.h>
Expand Down Expand Up @@ -74,7 +74,7 @@ enum InternalPlatformSpecificEventTypes

} // namespace DeviceEventType

#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE
struct BleConnEventType
{
bt_conn * BtConn;
Expand Down Expand Up @@ -108,7 +108,7 @@ struct ChipDevicePlatformEvent final
{
union
{
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CHIP_DEVICE_CONFIG_USE_ZEPHYR_BLE
BleConnEventType BleConnEvent;
BleCCCWriteEventType BleCCCWriteEvent;
BleC1WriteEventType BleC1WriteEvent;
Expand Down
28 changes: 28 additions & 0 deletions src/platform/nxp/common/CHIPNXPPlatformDefaultConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,34 @@
#define WDM_PUBLISHER_MAX_NOTIFIES_IN_FLIGHT 2
#endif // WDM_PUBLISHER_MAX_NOTIFIES_IN_FLIGHT

// ==================== ICD Configuration Overrides ====================

#ifndef NXP_ICD_ENABLED
#define NXP_ICD_ENABLED 0
#endif // NXP_ICD_ENABLED

#if NXP_ICD_ENABLED
#ifndef CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC
#define CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC NXP_IDLE_MODE_DURATION_SEC
#endif // CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC

#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS
#define CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS NXP_ACTIVE_MODE_DURATION_MS
#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS

#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS
#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS NXP_ACTIVE_MODE_THRESHOLD
#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS

#ifndef CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC
#define CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC NXP_ICD_SUPPORTED_CLIENTS_PER_FABRIC
#endif // CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC

#ifndef CHIP_CONFIG_SYNCHRONOUS_REPORTS_ENABLED
#define CHIP_CONFIG_SYNCHRONOUS_REPORTS_ENABLED 1
#endif
#endif // NXP_ICD_ENABLED

// ==================== Other Configuration Overrides ====================

#ifndef CHIP_CONFIG_RMP_DEFAULT_MAX_RETRANS
Expand Down
58 changes: 57 additions & 1 deletion src/platform/nxp/common/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

#include "fsl_device_registers.h"

#if CONFIG_BOOT_REASON_SDK_SUPPORT
#include "fsl_power.h"
#endif

#if CONFIG_CHIP_PLAT_LOAD_REAL_FACTORY_DATA
#include "FactoryDataProvider.h"
#endif
Expand All @@ -54,12 +58,61 @@ ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance()
return sInstance;
}

#if CONFIG_BOOT_REASON_SDK_SUPPORT
CHIP_ERROR ConfigurationManagerImpl::DetermineBootReason(uint8_t rebootCause)
{
/*
With current implementation kBrownOutReset couldn't be catched
*/
BootReasonType bootReason = BootReasonType::kUnspecified;

if (rebootCause == 0)
{
bootReason = BootReasonType::kPowerOnReboot;
}

else if (rebootCause == kPOWER_ResetCauseWdt)
{
/* Reboot can be due to hardware or software watchdog */
bootReason = BootReasonType::kHardwareWatchdogReset;
}
else if (rebootCause == kPOWER_ResetCauseSysResetReq)
{
/*
kConfigKey_SoftwareUpdateCompleted not supported for now
if (NXPConfig::ConfigValueExists(NXPConfig::kConfigKey_SoftwareUpdateCompleted))
{
bootReason = BootReasonType::kSoftwareUpdateCompleted;
}
else
{
bootReason = BootReasonType::kSoftwareReset;
}
*/
bootReason = BootReasonType::kSoftwareReset;
}

return StoreBootReason(to_underlying(bootReason));
}
#endif

CHIP_ERROR ConfigurationManagerImpl::StoreSoftwareUpdateCompleted()
{
/* Empty implementation*/
return CHIP_NO_ERROR;
}

CHIP_ERROR ConfigurationManagerImpl::Init()
{
CHIP_ERROR err;
uint32_t rebootCount = 0;
bool failSafeArmed;

#if CONFIG_BOOT_REASON_SDK_SUPPORT
uint8_t rebootCause = POWER_GetResetCause();
POWER_ClearResetCause(rebootCause);
#endif

// Initialize the generic implementation base class.
err = Internal::GenericConfigurationManagerImpl<NXPConfig>::Init();
SuccessOrExit(err);
Expand All @@ -84,12 +137,15 @@ CHIP_ERROR ConfigurationManagerImpl::Init()
err = StoreTotalOperationalHours(0);
SuccessOrExit(err);
}

#if CONFIG_BOOT_REASON_SDK_SUPPORT
SuccessOrExit(err = DetermineBootReason(rebootCause));
#else
if (!NXPConfig::ConfigValueExists(NXPConfig::kCounterKey_BootReason))
{
err = StoreBootReason(to_underlying(BootReasonType::kUnspecified));
SuccessOrExit(err);
}
#endif

// TODO: Initialize the global GroupKeyStore object here

Expand Down
4 changes: 4 additions & 0 deletions src/platform/nxp/common/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ConfigurationManagerImpl final : public Internal::GenericConfigurationMana
public:
// This returns an instance of this class.
static ConfigurationManagerImpl & GetDefaultInstance();
CHIP_ERROR StoreSoftwareUpdateCompleted();

private:
// ===== Members that implement the ConfigurationManager public interface.
Expand Down Expand Up @@ -78,6 +79,9 @@ class ConfigurationManagerImpl final : public Internal::GenericConfigurationMana
// ===== Private members reserved for use by this class only.

static void DoFactoryReset(intptr_t arg);
#if CONFIG_BOOT_REASON_SDK_SUPPORT
CHIP_ERROR DetermineBootReason(uint8_t rebootCause);
#endif
};

/**
Expand Down
2 changes: 2 additions & 0 deletions src/platform/nxp/common/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
#include <platform/internal/GenericConnectivityManagerImpl_TCP.ipp>
#endif

#if CHIP_SYSTEM_CONFIG_USE_LWIP
#include <lwip/dns.h>
#include <lwip/ip_addr.h>
#include <lwip/nd6.h>
#include <lwip/netif.h>
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
#include <platform/internal/GenericConnectivityManagerImpl_BLE.ipp>
Expand Down
Loading

0 comments on commit 2a70fbb

Please sign in to comment.