From b0c7b38805be81912a2f52ae4a9756f44a0d832e Mon Sep 17 00:00:00 2001 From: Song Guo Date: Tue, 14 Sep 2021 10:25:00 +0800 Subject: [PATCH] Revert "[testsuite] Refactor test suite simulated cluster command" This reverts commit 8390956ecbd8ce456539bed856fa9e8d12bb6fa0. --- .../templates/partials/test_cluster.zapt | 7 ++++- .../partials/testsuite/WaitForMs.zapt | 6 ----- examples/chip-tool/templates/templates.json | 8 ------ src/app/tests/suites/TestDelayCommands.yaml | 2 +- .../common/ClusterTestGeneration.js | 13 +++++----- .../TestDelayCommands.js} | 19 ++++---------- src/app/zap-templates/templates/app/helper.js | 26 +++++++------------ .../CHIP/templates/partials/test_cluster.zapt | 3 ++- .../partials/testsuite/WaitForMs.zapt | 2 -- .../Framework/CHIP/templates/templates.json | 3 +++ 10 files changed, 33 insertions(+), 56 deletions(-) delete mode 100644 examples/chip-tool/templates/partials/testsuite/WaitForMs.zapt rename src/app/zap-templates/common/{TestSuiteHelperCluster.js => simulated-clusters/TestDelayCommands.js} (67%) delete mode 100644 src/darwin/Framework/CHIP/templates/partials/testsuite/WaitForMs.zapt diff --git a/examples/chip-tool/templates/partials/test_cluster.zapt b/examples/chip-tool/templates/partials/test_cluster.zapt index 6d7a4e3c352843..e9778de4277379 100644 --- a/examples/chip-tool/templates/partials/test_cluster.zapt +++ b/examples/chip-tool/templates/partials/test_cluster.zapt @@ -46,7 +46,12 @@ class {{filename}}: public TestCommand {{#chip_tests_items}} {{#if (isTestOnlyCluster cluster)}} - {{> (asTestSuiteSimulatedClusterCommandPartial command) }} + CHIP_ERROR TestSendCluster{{asUpperCamelCase cluster}}Command{{asUpperCamelCase command}}_{{index}}() + { + ChipLogProgress(chipTool, "{{cluster}} - {{label}}"); + + return {{command}}({{#chip_tests_item_parameters}}{{#not_first}}, {{/not_first}}{{definedValue}}{{/chip_tests_item_parameters}}); + } {{else}} // Test {{label}} using SuccessCallback_{{index}} = void (*)(void * context{{#chip_tests_item_response_parameters}}, {{#if isList}}uint16_t count, {{/if}}{{chipType}} {{#if isList}}* {{/if}}{{asLowerCamelCase name}}{{/chip_tests_item_response_parameters}}); diff --git a/examples/chip-tool/templates/partials/testsuite/WaitForMs.zapt b/examples/chip-tool/templates/partials/testsuite/WaitForMs.zapt deleted file mode 100644 index 771ae4227fe91b..00000000000000 --- a/examples/chip-tool/templates/partials/testsuite/WaitForMs.zapt +++ /dev/null @@ -1,6 +0,0 @@ -CHIP_ERROR TestSendCluster{{asUpperCamelCase cluster}}Command{{asUpperCamelCase command}}_{{index}}() -{ - ChipLogProgress(chipTool, "{{cluster}} - {{asUpperCamelCase command}} - {{label}}"); - - return {{command}}({{#chip_tests_item_parameters}}{{#not_first}}, {{/not_first}}{{definedValue}}{{/chip_tests_item_parameters}}); -} diff --git a/examples/chip-tool/templates/templates.json b/examples/chip-tool/templates/templates.json index e378232b78a82f..02d6cf552ce243 100644 --- a/examples/chip-tool/templates/templates.json +++ b/examples/chip-tool/templates/templates.json @@ -30,14 +30,6 @@ { "name": "test_cluster", "path": "partials/test_cluster.zapt" - }, - { - "name": "TestSuiteHelper_WaitForMs", - "path": "partials/testsuite/WaitForMs.zapt" - }, - { - "name": "TestSuiteHelper_WaitForAttributeReport", - "path": "partials/testsuite/WaitForAttributeReport.zapt" } ], "templates": [ diff --git a/src/app/tests/suites/TestDelayCommands.yaml b/src/app/tests/suites/TestDelayCommands.yaml index 6a32a4c7eaf972..b3f7839bdc93f3 100644 --- a/src/app/tests/suites/TestDelayCommands.yaml +++ b/src/app/tests/suites/TestDelayCommands.yaml @@ -20,7 +20,7 @@ config: tests: - label: "Wait 100ms" - cluster: "TestSuite" + cluster: "DelayCommands" command: "WaitForMs" arguments: values: diff --git a/src/app/zap-templates/common/ClusterTestGeneration.js b/src/app/zap-templates/common/ClusterTestGeneration.js index 58f9a37b66e926..4b0c741199bc9c 100644 --- a/src/app/zap-templates/common/ClusterTestGeneration.js +++ b/src/app/zap-templates/common/ClusterTestGeneration.js @@ -26,7 +26,7 @@ const path = require('path'); // Import helpers from zap core const templateUtil = require(zapPath + 'dist/src-electron/generator/template-util.js') -const { TestSuiteHelperCluster } = require('./TestSuiteHelperCluster.js'); +const { DelayCommands } = require('./simulated-clusters/TestDelayCommands.js'); const { Clusters, asBlocks, asPromise } = require('./ClustersHelper.js'); const kClusterName = 'cluster'; @@ -221,19 +221,18 @@ function getClusters() { // Create a new array to merge the configured clusters list and test // simulated clusters. - return Clusters.getClusters().then(clusters => clusters.concat(TestSuiteHelperCluster)); + return Clusters.getClusters().then(clusters => clusters.concat(DelayCommands)); } function getCommands(clusterName) { - return (clusterName == TestSuiteHelperCluster.name) ? Promise.resolve(TestSuiteHelperCluster.commands) - : Clusters.getClientCommands(clusterName); + return (clusterName == DelayCommands.name) ? Promise.resolve(DelayCommands.commands) : Clusters.getClientCommands(clusterName); } function getAttributes(clusterName) { - return (clusterName == TestSuiteHelperCluster.name) ? Promise.resolve(TestSuiteHelperCluster.attributes) - : Clusters.getServerAttributes(clusterName); + return (clusterName == DelayCommands.name) ? Promise.resolve(DelayCommands.attributes) + : Clusters.getServerAttributes(clusterName); } function assertCommandOrAttribute(context) @@ -299,7 +298,7 @@ function chip_tests_items(options) function isTestOnlyCluster(name) { - return name == TestSuiteHelperCluster.name; + return name == DelayCommands.name; } function chip_tests_with_command_attribute_info(options) diff --git a/src/app/zap-templates/common/TestSuiteHelperCluster.js b/src/app/zap-templates/common/simulated-clusters/TestDelayCommands.js similarity index 67% rename from src/app/zap-templates/common/TestSuiteHelperCluster.js rename to src/app/zap-templates/common/simulated-clusters/TestDelayCommands.js index 73fd1f3ef21b9d..7c4736dc533e1b 100644 --- a/src/app/zap-templates/common/TestSuiteHelperCluster.js +++ b/src/app/zap-templates/common/simulated-clusters/TestDelayCommands.js @@ -16,7 +16,7 @@ */ /* - * This file declare test suites utilities methods for test suite. + * This file declare test suites utilities methods for delayed commands. * * Each method declared in this file needs to be implemented on a per-language * basis and permits to exposes methods to the test suites that are not part @@ -30,21 +30,12 @@ const WaitForMs = { response : { arguments : [] } }; -const WaitForAttributeRepor = { - name : 'WaitForAttributeReport', - arguments : [], - response : { arguments : [ { name : 'value' } ] } - /* - * 'WaitForAttributeResponse' will take "attribute" parameter for detailed attribute path. - */ -}; - -const TestSuiteHelperCluster = { - name : 'TestSuite', - commands : [ WaitForMs, WaitForAttributeRepor ], +const DelayCommands = { + name : 'DelayCommands', + commands : [ WaitForMs ], }; // // Module exports // -exports.TestSuiteHelperCluster = TestSuiteHelperCluster; +exports.DelayCommands = DelayCommands; diff --git a/src/app/zap-templates/templates/app/helper.js b/src/app/zap-templates/templates/app/helper.js index cf5d8588127270..22e39b6a8d395d 100644 --- a/src/app/zap-templates/templates/app/helper.js +++ b/src/app/zap-templates/templates/app/helper.js @@ -335,22 +335,16 @@ function asMEI(prefix, suffix) return cHelper.asHex((prefix << 16) + suffix, 8); } -function asTestSuiteSimulatedClusterCommandPartial(label) -{ - return "TestSuiteHelper_" + asUpperCamelCase(label) -} - // // Module exports // -exports.asPrintFormat = asPrintFormat; -exports.asReadType = asReadType; -exports.asReadTypeLength = asReadTypeLength; -exports.chip_endpoint_generated_functions = chip_endpoint_generated_functions -exports.chip_endpoint_cluster_list = chip_endpoint_cluster_list -exports.asTypeLiteralSuffix = asTypeLiteralSuffix; -exports.asLowerCamelCase = asLowerCamelCase; -exports.asUpperCamelCase = asUpperCamelCase; -exports.hasSpecificAttributes = hasSpecificAttributes; -exports.asMEI = asMEI; -exports.asTestSuiteSimulatedClusterCommandPartial = asTestSuiteSimulatedClusterCommandPartial; +exports.asPrintFormat = asPrintFormat; +exports.asReadType = asReadType; +exports.asReadTypeLength = asReadTypeLength; +exports.chip_endpoint_generated_functions = chip_endpoint_generated_functions +exports.chip_endpoint_cluster_list = chip_endpoint_cluster_list +exports.asTypeLiteralSuffix = asTypeLiteralSuffix; +exports.asLowerCamelCase = asLowerCamelCase; +exports.asUpperCamelCase = asUpperCamelCase; +exports.hasSpecificAttributes = hasSpecificAttributes; +exports.asMEI = asMEI; diff --git a/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt b/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt index 85c2ab459b505f..ad989f3171b060 100644 --- a/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/test_cluster.zapt @@ -4,7 +4,8 @@ { XCTestExpectation * expectation = [self expectationWithDescription:@"{{label}}"]; {{#if (isTestOnlyCluster cluster)}} -{{> (asTestSuiteSimulatedClusterCommandPartial command)}} + dispatch_queue_t queue = dispatch_get_main_queue(); + {{command}}(expectation, queue{{#chip_tests_item_parameters}}, {{definedValue}}{{/chip_tests_item_parameters}}); {{else}} CHIPDevice * device = GetPairedDevice(kDeviceId); dispatch_queue_t queue = dispatch_get_main_queue(); diff --git a/src/darwin/Framework/CHIP/templates/partials/testsuite/WaitForMs.zapt b/src/darwin/Framework/CHIP/templates/partials/testsuite/WaitForMs.zapt deleted file mode 100644 index 57326c64d83df6..00000000000000 --- a/src/darwin/Framework/CHIP/templates/partials/testsuite/WaitForMs.zapt +++ /dev/null @@ -1,2 +0,0 @@ -dispatch_queue_t queue = dispatch_get_main_queue(); -{{command}}(expectation, queue{{#chip_tests_item_parameters}}, {{definedValue}}{{/chip_tests_item_parameters}}); diff --git a/src/darwin/Framework/CHIP/templates/templates.json b/src/darwin/Framework/CHIP/templates/templates.json index 72b96a1fabb180..34c4f155e569dc 100644 --- a/src/darwin/Framework/CHIP/templates/templates.json +++ b/src/darwin/Framework/CHIP/templates/templates.json @@ -26,6 +26,7 @@ { "name": "CHIPCallbackBridge", "path": "partials/CHIPCallbackBridge.zapt" +<<<<<<< HEAD }, { "name": "TestSuiteHelper_WaitForMs", @@ -34,6 +35,8 @@ { "name": "TestSuiteHelper_WaitForAttributeReport", "path": "partials/testsuite/WaitForAttributeReport.zapt" +======= +>>>>>>> parent of 8390956ec ([testsuite] Refactor test suite simulated cluster command) } ], "templates": [