summaryrefslogtreecommitdiffstats
path: root/tests/component
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-11-04 07:25:04 +0100
committerTao Bao <tbao@google.com>2016-11-04 07:28:36 +0100
commit0831d0b592b2b4abb317a785d0b27e443b8a83db (patch)
tree118e09d338dd3b14a6f2b3b2fa226882dad17d2c /tests/component
parentMerge "updater: Fix an off-by-1 bug in file_getprop()." (diff)
downloadandroid_bootable_recovery-0831d0b592b2b4abb317a785d0b27e443b8a83db.tar
android_bootable_recovery-0831d0b592b2b4abb317a785d0b27e443b8a83db.tar.gz
android_bootable_recovery-0831d0b592b2b4abb317a785d0b27e443b8a83db.tar.bz2
android_bootable_recovery-0831d0b592b2b4abb317a785d0b27e443b8a83db.tar.lz
android_bootable_recovery-0831d0b592b2b4abb317a785d0b27e443b8a83db.tar.xz
android_bootable_recovery-0831d0b592b2b4abb317a785d0b27e443b8a83db.tar.zst
android_bootable_recovery-0831d0b592b2b4abb317a785d0b27e443b8a83db.zip
Diffstat (limited to 'tests/component')
-rw-r--r--tests/component/updater_test.cpp33
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);
+}