From a2554640fe618afa7125b64b532dd0ac39228a71 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 26 Jan 2022 21:26:33 -0500 Subject: [PATCH] Make the Darwin per-step YAML timeouts larger and configurable. (#14368) This makes the following changes: 1) Bumps kTimeoutInSeconds from 3 to 5. 2) For "WaitForMs" commands, sets the timeout to (waitTime/1000) + kTimeoutInSeconds, so longish waits work automatically. 3) Allows specifying a "stepTimeoutSecs" property in the YAML to override all of that and just set a value. Fixes https://github.com/project-chip/connectedhomeip/issues/14364 Fixes https://github.com/project-chip/connectedhomeip/issues/14260 --- .../CHIP/templates/clusters-tests.zapt | 2 +- .../CHIP/templates/partials/test_cluster.zapt | 10 +++- .../Framework/CHIPTests/CHIPClustersTests.m | 48 +++++++++---------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/darwin/Framework/CHIP/templates/clusters-tests.zapt b/src/darwin/Framework/CHIP/templates/clusters-tests.zapt index e998229c4e50c7..05873ac3dc9e19 100644 --- a/src/darwin/Framework/CHIP/templates/clusters-tests.zapt +++ b/src/darwin/Framework/CHIP/templates/clusters-tests.zapt @@ -19,7 +19,7 @@ const uint16_t kPairingTimeoutInSeconds = 10; const uint16_t kAddressResolveTimeoutInSeconds = 10; const uint16_t kCASESetupTimeoutInSeconds = 30; -const uint16_t kTimeoutInSeconds = 3; +const uint16_t kTimeoutInSeconds = 5; const uint64_t kDeviceId = 1; const uint16_t kDiscriminator = 3840; const uint32_t kSetupPINCode = 20202021; diff --git a/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt b/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt index ba7d54df9131d0..1fc95ee9918de2 100644 --- a/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt @@ -216,9 +216,17 @@ ResponseHandler {{> subscribeDataCallback}} = nil; {{/if}} {{#unless async}} - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + {{#*inline "minCommandTimeout"~}} + {{#if (isTestOnlyCluster cluster)~}} + {{#if (isStrEqual command "WaitForMs")~}} + {{#chip_tests_item_parameters}}{{#if (isStrEqual name "ms")}}({{definedValue}} / 1000) + {{/if}}{{/chip_tests_item_parameters}} + {{~/if}} + {{~/if}} + {{~/inline}} + [self waitForExpectationsWithTimeout:{{#if stepTimeoutSecs}}{{stepTimeoutSecs}}{{else}}{{> minCommandTimeout}}kTimeoutInSeconds{{/if}} handler:nil]; {{/unless}} } {{/chip_tests_items}} {{/chip_tests}} + diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 851db23b55f9bf..4f53e8353e6150 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -36,7 +36,7 @@ const uint16_t kPairingTimeoutInSeconds = 10; const uint16_t kAddressResolveTimeoutInSeconds = 10; const uint16_t kCASESetupTimeoutInSeconds = 30; -const uint16_t kTimeoutInSeconds = 3; +const uint16_t kTimeoutInSeconds = 5; const uint64_t kDeviceId = 1; const uint16_t kDiscriminator = 3840; const uint32_t kSetupPINCode = 20202021; @@ -8722,7 +8722,7 @@ - (void)testSendClusterTest_TC_CC_9_1_000022_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 2000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(2000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_CC_9_1_000023_ReadAttribute { @@ -11191,7 +11191,7 @@ - (void)testSendClusterTest_TC_LVL_2_1_000002_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 100); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_2_1_000003_ReadAttribute { @@ -11953,7 +11953,7 @@ - (void)testSendClusterTest_TC_LVL_3_1_000005_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 100); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_3_1_000006_ReadAttribute { @@ -12010,7 +12010,7 @@ - (void)testSendClusterTest_TC_LVL_3_1_000008_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 200); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(200 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_3_1_000009_ReadAttribute { @@ -12091,7 +12091,7 @@ - (void)testSendClusterTest_TC_LVL_3_1_000012_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 100); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_3_1_000013_ReadAttribute { @@ -12148,7 +12148,7 @@ - (void)testSendClusterTest_TC_LVL_3_1_000015_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 100); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_4_1_000000_WaitForCommissionee @@ -12238,7 +12238,7 @@ - (void)testSendClusterTest_TC_LVL_4_1_000004_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 3000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_4_1_000005_ReadAttribute { @@ -12319,7 +12319,7 @@ - (void)testSendClusterTest_TC_LVL_4_1_000008_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 3000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_4_1_000009_ReadAttribute { @@ -12431,7 +12431,7 @@ - (void)testSendClusterTest_TC_LVL_4_1_000013_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 100); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_4_1_000014_ReadAttribute { @@ -12490,7 +12490,7 @@ - (void)testSendClusterTest_TC_LVL_4_1_000016_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 100); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_5_1_000000_WaitForCommissionee @@ -12552,7 +12552,7 @@ - (void)testSendClusterTest_TC_LVL_5_1_000003_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 3000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_5_1_000004_ReadAttribute { @@ -12610,7 +12610,7 @@ - (void)testSendClusterTest_TC_LVL_5_1_000006_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 3000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_5_1_000007_ReadAttribute { @@ -12668,7 +12668,7 @@ - (void)testSendClusterTest_TC_LVL_5_1_000009_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 3000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_5_1_000010_ReadAttribute { @@ -12725,7 +12725,7 @@ - (void)testSendClusterTest_TC_LVL_5_1_000012_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 100); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_5_1_000013_Off { @@ -12805,7 +12805,7 @@ - (void)testSendClusterTest_TC_LVL_6_1_000003_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 100); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_6_1_000004_ReadAttribute { @@ -12870,7 +12870,7 @@ - (void)testSendClusterTest_TC_LVL_6_1_000006_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 2000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(2000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_6_1_000007_Stop { @@ -12958,7 +12958,7 @@ - (void)testSendClusterTest_TC_LVL_6_1_000010_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 100); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_LVL_6_1_000011_Off { @@ -15032,7 +15032,7 @@ - (void)testSendClusterTest_TC_OO_2_3_000002_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 1000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(1000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_OO_2_3_000003_ReadAttribute { @@ -15107,7 +15107,7 @@ - (void)testSendClusterTest_TC_OO_2_3_000006_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 1000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(1000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_OO_2_3_000007_ReadAttribute { @@ -15182,7 +15182,7 @@ - (void)testSendClusterTest_TC_OO_2_3_000010_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 1000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(1000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_OO_2_3_000011_ReadAttribute { @@ -18621,7 +18621,7 @@ - (void)testSendClusterTest_TC_SWTCH_2_2_000015_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 3000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_SWTCH_2_2_000016_UserPrompt { @@ -18677,7 +18677,7 @@ - (void)testSendClusterTest_TC_SWTCH_2_2_000022_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 3000); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(3000 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_SWTCH_2_2_000023_UserPrompt { @@ -40378,7 +40378,7 @@ - (void)testSendClusterTestDelayCommands_000001_WaitForMs dispatch_queue_t queue = dispatch_get_main_queue(); WaitForMs(expectation, queue, 100); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + [self waitForExpectationsWithTimeout:(100 / 1000) + kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTestDescriptorCluster_000000_WaitForCommissionee