diff --git a/examples/placeholder/linux/apps/app1/tests.js b/examples/placeholder/linux/apps/app1/tests.js index 0db800bdaa7fb5..82fabb0cb94e5f 100644 --- a/examples/placeholder/linux/apps/app1/tests.js +++ b/examples/placeholder/linux/apps/app1/tests.js @@ -19,6 +19,7 @@ function getTests() { const tests = [ "Test_TC_DM_1_3_Simulated", + "Test_TC_DM_3_3_Simulated", ]; return tests.join(', '); diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 628d4ac8775ed8..cb797a2052bf9d 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -21,6 +21,9 @@ PICS: - label: "Does the device support discovery over WiFi?" id: WIFI + - label: "Does the device support discover over THREAD" + id: THREAD + - label: "Does the device support manufacturing date" id: MANF_DATE diff --git a/src/app/tests/suites/certification/Test_TC_DM_3_3_Simulated.yaml b/src/app/tests/suites/certification/Test_TC_DM_3_3_Simulated.yaml new file mode 100644 index 00000000000000..6eb3d5e4f4b553 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_DM_3_3_Simulated.yaml @@ -0,0 +1,28 @@ +name: 10.3.3. [TC-DM-3.3] Network Commissioning Commands [DUT - Commissioner] + +config: + cluster: "Network Commissioning" + endpoint: 0 + +tests: + - label: "Wait for the device to be commissioned" + cluster: "DelayCommands" + command: "WaitForCommissioning" + + - label: "Wait for Scan Network Command" + wait: "ScanNetworks" + + - label: "Wait for Add Wifi Network Command" + wait: "AddOrUpdateWiFiNetwork" + PICS: WIFI + + - label: "Wait for Update Thread Network Command" + wait: "AddOrUpdateThreadNetwork" + PICS: THREAD + + - label: "Wait for Enable Network Command" + wait: "ConnectNetwork" + + - label: "Wait for Remove Network Command" + wait: "RemoveNetwork" + PICS: WIFI | THREAD diff --git a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h index 1d4a0cffd26c00..de11e79d64b2cb 100644 --- a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h +++ b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h @@ -388,12 +388,187 @@ class Test_TC_DM_1_3_Simulated : public TestCommand } }; +class Test_TC_DM_3_3_Simulated : public TestCommand +{ +public: + Test_TC_DM_3_3_Simulated() : TestCommand("Test_TC_DM_3_3_Simulated"), mTestIndex(0) + { + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + } + + ~Test_TC_DM_3_3_Simulated() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DM_3_3_Simulated\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DM_3_3_Simulated\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the device to be commissioned\n"); + err = TestWaitForTheDeviceToBeCommissioned_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Wait for Scan Network Command\n"); + err = TestWaitForScanNetworkCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Wait for Add Wifi Network Command\n"); + if (ShouldSkip("WIFI")) + { + NextTest(); + return; + } + err = TestWaitForAddWifiNetworkCommand_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for Update Thread Network Command\n"); + if (ShouldSkip("THREAD")) + { + NextTest(); + return; + } + err = TestWaitForUpdateThreadNetworkCommand_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for Enable Network Command\n"); + err = TestWaitForEnableNetworkCommand_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for Remove Network Command\n"); + if (ShouldSkip("WIFI | THREAD")) + { + NextTest(); + return; + } + err = TestWaitForRemoveNetworkCommand_5(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mCluster; + chip::Optional mEndpoint; + + // + // Tests methods + // + + CHIP_ERROR TestWaitForTheDeviceToBeCommissioned_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissioning(); + } + + CHIP_ERROR TestWaitForScanNetworkCommand_1() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: ScanNetworks] Wait for Scan Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworks::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForAddWifiNetworkCommand_2() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError( + chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: AddOrUpdateWiFiNetwork] Wait for Add Wifi Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = + chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateWiFiNetwork::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForUpdateThreadNetworkCommand_3() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: AddOrUpdateThreadNetwork] Wait for Update Thread " + "Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = + chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateThreadNetwork::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForEnableNetworkCommand_4() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: ConnectNetwork] Wait for Enable Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetwork::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForRemoveNetworkCommand_5() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: RemoveNetwork] Wait for Remove Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::RemoveNetwork::Id); + return CHIP_NO_ERROR; + } +}; + std::unique_ptr GetTestCommand(std::string testName) { if (testName == "Test_TC_DM_1_3_Simulated") { return std::unique_ptr(new Test_TC_DM_1_3_Simulated()); } + if (testName == "Test_TC_DM_3_3_Simulated") + { + return std::unique_ptr(new Test_TC_DM_3_3_Simulated()); + } return nullptr; } @@ -402,4 +577,5 @@ void PrintTestCommands() { ChipLogError(chipTool, "Supported commands:"); ChipLogError(chipTool, "\t* Test_TC_DM_1_3_Simulated"); + ChipLogError(chipTool, "\t* Test_TC_DM_3_3_Simulated"); } diff --git a/zzz_generated/placeholder/app2/zap-generated/test/Commands.h b/zzz_generated/placeholder/app2/zap-generated/test/Commands.h index 1d4a0cffd26c00..de11e79d64b2cb 100644 --- a/zzz_generated/placeholder/app2/zap-generated/test/Commands.h +++ b/zzz_generated/placeholder/app2/zap-generated/test/Commands.h @@ -388,12 +388,187 @@ class Test_TC_DM_1_3_Simulated : public TestCommand } }; +class Test_TC_DM_3_3_Simulated : public TestCommand +{ +public: + Test_TC_DM_3_3_Simulated() : TestCommand("Test_TC_DM_3_3_Simulated"), mTestIndex(0) + { + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + } + + ~Test_TC_DM_3_3_Simulated() {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DM_3_3_Simulated\n"); + } + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DM_3_3_Simulated\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the device to be commissioned\n"); + err = TestWaitForTheDeviceToBeCommissioned_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Wait for Scan Network Command\n"); + err = TestWaitForScanNetworkCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Wait for Add Wifi Network Command\n"); + if (ShouldSkip("WIFI")) + { + NextTest(); + return; + } + err = TestWaitForAddWifiNetworkCommand_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for Update Thread Network Command\n"); + if (ShouldSkip("THREAD")) + { + NextTest(); + return; + } + err = TestWaitForUpdateThreadNetworkCommand_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for Enable Network Command\n"); + err = TestWaitForEnableNetworkCommand_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for Remove Network Command\n"); + if (ShouldSkip("WIFI | THREAD")) + { + NextTest(); + return; + } + err = TestWaitForRemoveNetworkCommand_5(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mCluster; + chip::Optional mEndpoint; + + // + // Tests methods + // + + CHIP_ERROR TestWaitForTheDeviceToBeCommissioned_0() + { + SetIdentity(kIdentityAlpha); + return WaitForCommissioning(); + } + + CHIP_ERROR TestWaitForScanNetworkCommand_1() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: ScanNetworks] Wait for Scan Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::ScanNetworks::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForAddWifiNetworkCommand_2() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError( + chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: AddOrUpdateWiFiNetwork] Wait for Add Wifi Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = + chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateWiFiNetwork::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForUpdateThreadNetworkCommand_3() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: AddOrUpdateThreadNetwork] Wait for Update Thread " + "Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = + chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::AddOrUpdateThreadNetwork::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForEnableNetworkCommand_4() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: ConnectNetwork] Wait for Enable Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::ConnectNetwork::Id); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForRemoveNetworkCommand_5() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + ChipLogError(chipTool, + "[Endpoint: 0x%08x Cluster: Network Commissioning Command: RemoveNetwork] Wait for Remove Network Command", + endpoint); + + ClearAttributeAndCommandPaths(); + mCommandPath = chip::app::ConcreteCommandPath(endpoint, chip::app::Clusters::NetworkCommissioning::Id, + chip::app::Clusters::NetworkCommissioning::Commands::RemoveNetwork::Id); + return CHIP_NO_ERROR; + } +}; + std::unique_ptr GetTestCommand(std::string testName) { if (testName == "Test_TC_DM_1_3_Simulated") { return std::unique_ptr(new Test_TC_DM_1_3_Simulated()); } + if (testName == "Test_TC_DM_3_3_Simulated") + { + return std::unique_ptr(new Test_TC_DM_3_3_Simulated()); + } return nullptr; } @@ -402,4 +577,5 @@ void PrintTestCommands() { ChipLogError(chipTool, "Supported commands:"); ChipLogError(chipTool, "\t* Test_TC_DM_1_3_Simulated"); + ChipLogError(chipTool, "\t* Test_TC_DM_3_3_Simulated"); }