summaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-07-09 19:53:56 +0200
committerandroid-build-merger <android-build-merger@google.com>2018-07-09 19:53:56 +0200
commit7c9549471b7a007fe1725d09655e57fd1636d5e7 (patch)
treed17cd00549fddc484bdb926f66287ee76cc692cf /tests/unit
parentMerge "tests: Split unit tests out of component/applypatch_test.cpp." am: cf1f9bdb12 (diff)
parentMerge "updater: Add ABORT command." (diff)
downloadandroid_bootable_recovery-7c9549471b7a007fe1725d09655e57fd1636d5e7.tar
android_bootable_recovery-7c9549471b7a007fe1725d09655e57fd1636d5e7.tar.gz
android_bootable_recovery-7c9549471b7a007fe1725d09655e57fd1636d5e7.tar.bz2
android_bootable_recovery-7c9549471b7a007fe1725d09655e57fd1636d5e7.tar.lz
android_bootable_recovery-7c9549471b7a007fe1725d09655e57fd1636d5e7.tar.xz
android_bootable_recovery-7c9549471b7a007fe1725d09655e57fd1636d5e7.tar.zst
android_bootable_recovery-7c9549471b7a007fe1725d09655e57fd1636d5e7.zip
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/commands_test.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/commands_test.cpp b/tests/unit/commands_test.cpp
index cb2be9176..3daa58f33 100644
--- a/tests/unit/commands_test.cpp
+++ b/tests/unit/commands_test.cpp
@@ -159,6 +159,27 @@ TEST(CommandsTest, Parse_EmptyInput) {
ASSERT_EQ("invalid type", err);
}
+TEST(CommandsTest, Parse_ABORT_Allowed) {
+ Command::abort_allowed_ = true;
+
+ const std::string input{ "abort" };
+ std::string err;
+ Command command = Command::Parse(input, 0, &err);
+ ASSERT_TRUE(command);
+
+ ASSERT_EQ(TargetInfo(), command.target());
+ ASSERT_EQ(SourceInfo(), command.source());
+ ASSERT_EQ(StashInfo(), command.stash());
+ ASSERT_EQ(PatchInfo(), command.patch());
+}
+
+TEST(CommandsTest, Parse_ABORT_NotAllowed) {
+ const std::string input{ "abort" };
+ std::string err;
+ Command command = Command::Parse(input, 0, &err);
+ ASSERT_FALSE(command);
+}
+
TEST(CommandsTest, Parse_BSDIFF) {
const std::string input{
"bsdiff 0 148 "
@@ -312,9 +333,12 @@ TEST(CommandsTest, Parse_ZERO) {
}
TEST(CommandsTest, Parse_InvalidNumberOfArgs) {
+ Command::abort_allowed_ = true;
+
// Note that the case of having excess args in BSDIFF, IMGDIFF and MOVE is covered by
// ParseTargetInfoAndSourceInfo_InvalidInput.
std::vector<std::string> inputs{
+ "abort foo",
"bsdiff",
"erase",
"erase 4,3,5,10,12 hash1",