diff options
author | Tao Bao <tbao@google.com> | 2016-11-04 17:04:58 +0100 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-11-04 17:04:58 +0100 |
commit | 529032f4a0523dd0f78d6e3da982e8ee08c10c65 (patch) | |
tree | 1ebacbd3e78fe7981f4bbec73e59f0c0212ed33c /tests/component/updater_test.cpp | |
parent | Merge "Revert "Revert "Some cleanups to recovery.""" (diff) | |
parent | updater: Fix a bug in DeleteFn(). (diff) | |
download | android_bootable_recovery-529032f4a0523dd0f78d6e3da982e8ee08c10c65.tar android_bootable_recovery-529032f4a0523dd0f78d6e3da982e8ee08c10c65.tar.gz android_bootable_recovery-529032f4a0523dd0f78d6e3da982e8ee08c10c65.tar.bz2 android_bootable_recovery-529032f4a0523dd0f78d6e3da982e8ee08c10c65.tar.lz android_bootable_recovery-529032f4a0523dd0f78d6e3da982e8ee08c10c65.tar.xz android_bootable_recovery-529032f4a0523dd0f78d6e3da982e8ee08c10c65.tar.zst android_bootable_recovery-529032f4a0523dd0f78d6e3da982e8ee08c10c65.zip |
Diffstat (limited to 'tests/component/updater_test.cpp')
-rw-r--r-- | tests/component/updater_test.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/component/updater_test.cpp b/tests/component/updater_test.cpp index bd1df558e..337769e6b 100644 --- a/tests/component/updater_test.cpp +++ b/tests/component/updater_test.cpp @@ -147,3 +147,36 @@ TEST_F(UpdaterTest, file_getprop) { "\", \"ro.product.model\")"); expect("", script6.c_str(), kNoCause); } + +TEST_F(UpdaterTest, delete) { + // Delete none. + expect("0", "delete()", kNoCause); + expect("0", "delete(\"/doesntexist\")", kNoCause); + expect("0", "delete(\"/doesntexist1\", \"/doesntexist2\")", kNoCause); + expect("0", "delete(\"/doesntexist1\", \"/doesntexist2\", \"/doesntexist3\")", kNoCause); + + // Delete one file. + TemporaryFile temp_file1; + ASSERT_TRUE(android::base::WriteStringToFile("abc", temp_file1.path)); + std::string script1("delete(\"" + std::string(temp_file1.path) + "\")"); + expect("1", script1.c_str(), kNoCause); + + // Delete two files. + TemporaryFile temp_file2; + ASSERT_TRUE(android::base::WriteStringToFile("abc", temp_file2.path)); + TemporaryFile temp_file3; + ASSERT_TRUE(android::base::WriteStringToFile("abc", temp_file3.path)); + std::string script2("delete(\"" + std::string(temp_file2.path) + "\", \"" + + std::string(temp_file3.path) + "\")"); + expect("2", script2.c_str(), kNoCause); + + // Delete already deleted files. + expect("0", script2.c_str(), kNoCause); + + // Delete one out of three. + TemporaryFile temp_file4; + ASSERT_TRUE(android::base::WriteStringToFile("abc", temp_file4.path)); + std::string script3("delete(\"/doesntexist1\", \"" + std::string(temp_file4.path) + + "\", \"/doesntexist2\")"); + expect("1", script3.c_str(), kNoCause); +} |