From 4e5ae02f59d213809637c06991e4edeee5d1b4c7 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 3 May 2022 18:16:39 +0200 Subject: [PATCH] Update Update src/app/tests/suites/commands/log/LogCommands.* --- .../tests/suites/commands/log/LogCommands.cpp | 28 +++++++++---------- .../tests/suites/commands/log/LogCommands.h | 6 ++-- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/app/tests/suites/commands/log/LogCommands.cpp b/src/app/tests/suites/commands/log/LogCommands.cpp index b19bf857bc9d5e..866315cdc1573c 100644 --- a/src/app/tests/suites/commands/log/LogCommands.cpp +++ b/src/app/tests/suites/commands/log/LogCommands.cpp @@ -19,26 +19,26 @@ #include "LogCommands.h" #include -CHIP_ERROR LogCommands::Log(const char * message) +CHIP_ERROR LogCommands::Log(const char * identity, const chip::app::Clusters::LogCommands::Commands::Log::Type & value) { - ChipLogDetail(chipTool, "%s", message); + ChipLogDetail(chipTool, "%.*s", static_cast(value.message.size()), value.message.data()); return ContinueOnChipMainThread(CHIP_NO_ERROR); } -CHIP_ERROR LogCommands::UserPrompt(const char * message, const char * expectedValue) +CHIP_ERROR LogCommands::UserPrompt(const char * identity, + const chip::app::Clusters::LogCommands::Commands::UserPrompt::Type & value) { - CHIP_ERROR err = CHIP_NO_ERROR; - std::string line; - ChipLogDetail(chipTool, "USER_PROMPT: %s", message); - if (expectedValue == nullptr) - { - return ContinueOnChipMainThread(err); - } + ChipLogDetail(chipTool, "USER_PROMPT: %.*s", static_cast(value.message.size()), value.message.data()); - std::getline(std::cin, line); - if (line != expectedValue) + if (value.expectedValue.HasValue()) { - err = CHIP_ERROR_INVALID_ARGUMENT; + std::string line; + std::getline(std::cin, line); + if (line != value.expectedValue.Value().data()) + { + return ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT); + } } - return ContinueOnChipMainThread(err); + + return ContinueOnChipMainThread(CHIP_NO_ERROR); } diff --git a/src/app/tests/suites/commands/log/LogCommands.h b/src/app/tests/suites/commands/log/LogCommands.h index 7eed6a09b3dbd5..43585dff8acf2e 100644 --- a/src/app/tests/suites/commands/log/LogCommands.h +++ b/src/app/tests/suites/commands/log/LogCommands.h @@ -20,6 +20,8 @@ #include +#include + class LogCommands { public: @@ -28,6 +30,6 @@ class LogCommands virtual CHIP_ERROR ContinueOnChipMainThread(CHIP_ERROR err) = 0; - CHIP_ERROR Log(const char * message); - CHIP_ERROR UserPrompt(const char * message, const char * expectedValue = nullptr); + CHIP_ERROR Log(const char * identity, const chip::app::Clusters::LogCommands::Commands::Log::Type & value); + CHIP_ERROR UserPrompt(const char * identity, const chip::app::Clusters::LogCommands::Commands::UserPrompt::Type & value); };