From 91a649ab62c9cf60ae9d02dd38c23fc23f98a1f3 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 21 May 2018 16:05:56 -0700 Subject: updater: Add ABORT command. This will be used for testing purpose only, replacing the previously used "fail", to intentionally abort an update. As we're separating the logic between commands parsing and execution, "abort" needs to be considered as a valid command during the parsing. Test: recovery_unit_test and recovery_component_test on marlin. Change-Id: I47c41c423e62c41cc8515fd92f3c5959be08da02 --- updater/include/private/commands.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'updater/include/private') diff --git a/updater/include/private/commands.h b/updater/include/private/commands.h index 784892fb5..087d7cfbf 100644 --- a/updater/include/private/commands.h +++ b/updater/include/private/commands.h @@ -213,9 +213,13 @@ class PatchInfo { // - Free the given stash data. // - Meaningful args: StashInfo // +// abort +// - Abort the current update. Allowed for testing code only. +// class Command { public: enum class Type { + ABORT, BSDIFF, ERASE, FREE, @@ -280,6 +284,11 @@ class Command { } private: + friend class ResumableUpdaterTest; + friend class UpdaterTest; + + FRIEND_TEST(CommandsTest, Parse_ABORT_Allowed); + FRIEND_TEST(CommandsTest, Parse_InvalidNumberOfArgs); FRIEND_TEST(CommandsTest, ParseTargetInfoAndSourceInfo_InvalidInput); FRIEND_TEST(CommandsTest, ParseTargetInfoAndSourceInfo_StashesOnly); FRIEND_TEST(CommandsTest, ParseTargetInfoAndSourceInfo_SourceBlocksAndStashes); @@ -293,6 +302,9 @@ class Command { const std::string& src_hash, SourceInfo* source, std::string* err); + // Allows parsing ABORT command, which should be used for testing purpose only. + static bool abort_allowed_; + // The type of the command. Type type_{ Type::LAST }; // The index of the Command object, which is specified by the caller. -- cgit v1.2.3