From 892cf8b97954a9a0f9097faa37d4bb3c5fa16e78 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 13 Jan 2022 16:40:23 +0100 Subject: [PATCH] [Simulated Device] Print the list of available test commands if the command is unknown (#13529) * [Simulated Device] Print the list of available test commands if the command is unknown * Update generated simulated device code --- .../placeholder/linux/include/MatterCallbacks.h | 1 + examples/placeholder/templates/tests-commands.zapt | 14 ++++++++++++++ .../placeholder/app1/zap-generated/test/Commands.h | 6 ++++++ .../placeholder/app2/zap-generated/test/Commands.h | 6 ++++++ .../placeholder/zap-generated/af-gen-event.h | 0 5 files changed, 27 insertions(+) create mode 100644 zzz_generated/placeholder/zap-generated/af-gen-event.h diff --git a/examples/placeholder/linux/include/MatterCallbacks.h b/examples/placeholder/linux/include/MatterCallbacks.h index b7a9c45de6dd76..210dd2b267ee72 100644 --- a/examples/placeholder/linux/include/MatterCallbacks.h +++ b/examples/placeholder/linux/include/MatterCallbacks.h @@ -39,6 +39,7 @@ TestCommand * GetTargetTest() if (test.get() == nullptr) { ChipLogError(chipTool, "Specified test command does not exist: %s", command); + PrintTestCommands(); return nullptr; } diff --git a/examples/placeholder/templates/tests-commands.zapt b/examples/placeholder/templates/tests-commands.zapt index f23545eebd8ac5..d2f60abee86a39 100644 --- a/examples/placeholder/templates/tests-commands.zapt +++ b/examples/placeholder/templates/tests-commands.zapt @@ -21,3 +21,17 @@ std::unique_ptrGetTestCommand(std::string testName) return nullptr; } + +void PrintTestCommands() +{ + {{#if (getTests)}} + {{#chip_tests (getTests)}} + {{#first}} + ChipLogError(chipTool, "Supported commands:"); + {{/first}} + ChipLogError(chipTool, "\t* {{filename}}"); + {{else}} + ChipLogError("\t No available commands."); + {{/chip_tests}} + {{/if}} +} diff --git a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h index bab2de8270d0fa..a1b3008d43c825 100644 --- a/zzz_generated/placeholder/app1/zap-generated/test/Commands.h +++ b/zzz_generated/placeholder/app1/zap-generated/test/Commands.h @@ -395,3 +395,9 @@ std::unique_ptr GetTestCommand(std::string testName) return nullptr; } + +void PrintTestCommands() +{ + ChipLogError(chipTool, "Supported commands:"); + ChipLogError(chipTool, "\t* Test_TC_DM_1_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 bab2de8270d0fa..a1b3008d43c825 100644 --- a/zzz_generated/placeholder/app2/zap-generated/test/Commands.h +++ b/zzz_generated/placeholder/app2/zap-generated/test/Commands.h @@ -395,3 +395,9 @@ std::unique_ptr GetTestCommand(std::string testName) return nullptr; } + +void PrintTestCommands() +{ + ChipLogError(chipTool, "Supported commands:"); + ChipLogError(chipTool, "\t* Test_TC_DM_1_3_Simulated"); +} diff --git a/zzz_generated/placeholder/zap-generated/af-gen-event.h b/zzz_generated/placeholder/zap-generated/af-gen-event.h new file mode 100644 index 00000000000000..e69de29bb2d1d6