summaryrefslogtreecommitdiffstats
path: root/tests/component
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-11-04 17:19:24 +0100
committerandroid-build-merger <android-build-merger@google.com>2016-11-04 17:19:24 +0100
commitaf03617d814a6a12da46313346b75bba7ab35cf7 (patch)
tree63d24e6f552536578d72323afee67c3771302d23 /tests/component
parentMerge "Revert "Revert "Some cleanups to recovery.""" am: a7a8262944 am: cb3cbaffac am: b9c3411de7 (diff)
parentMerge "updater: Fix a bug in DeleteFn()." am: 529032f4a0 am: 4f91ca78b9 (diff)
downloadandroid_bootable_recovery-af03617d814a6a12da46313346b75bba7ab35cf7.tar
android_bootable_recovery-af03617d814a6a12da46313346b75bba7ab35cf7.tar.gz
android_bootable_recovery-af03617d814a6a12da46313346b75bba7ab35cf7.tar.bz2
android_bootable_recovery-af03617d814a6a12da46313346b75bba7ab35cf7.tar.lz
android_bootable_recovery-af03617d814a6a12da46313346b75bba7ab35cf7.tar.xz
android_bootable_recovery-af03617d814a6a12da46313346b75bba7ab35cf7.tar.zst
android_bootable_recovery-af03617d814a6a12da46313346b75bba7ab35cf7.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);
+}