summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2019-08-06 21:32:05 +0200
committerBryan Ferris <bferris@google.com>2020-01-21 22:48:13 +0100
commitba27adbbb6db81babc1ee3ac070ea6b6189dd2e1 (patch)
tree27706b56526ca10768c2bb21ff84f0bba1644020 /tests
parentImport translations. DO NOT MERGE (diff)
downloadandroid_bootable_recovery-ba27adbbb6db81babc1ee3ac070ea6b6189dd2e1.tar
android_bootable_recovery-ba27adbbb6db81babc1ee3ac070ea6b6189dd2e1.tar.gz
android_bootable_recovery-ba27adbbb6db81babc1ee3ac070ea6b6189dd2e1.tar.bz2
android_bootable_recovery-ba27adbbb6db81babc1ee3ac070ea6b6189dd2e1.tar.lz
android_bootable_recovery-ba27adbbb6db81babc1ee3ac070ea6b6189dd2e1.tar.xz
android_bootable_recovery-ba27adbbb6db81babc1ee3ac070ea6b6189dd2e1.tar.zst
android_bootable_recovery-ba27adbbb6db81babc1ee3ac070ea6b6189dd2e1.zip
Diffstat (limited to '')
-rw-r--r--tests/Android.bp1
-rw-r--r--tests/component/install_test.cpp28
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/Android.bp b/tests/Android.bp
index 09ef716d6..a0d82d5fd 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -99,6 +99,7 @@ librecovery_static_libs = [
"liblp",
"libvndksupport",
"libtinyxml2",
+ "libc++fs",
]
cc_test {
diff --git a/tests/component/install_test.cpp b/tests/component/install_test.cpp
index 385132939..c1f0ca812 100644
--- a/tests/component/install_test.cpp
+++ b/tests/component/install_test.cpp
@@ -34,6 +34,7 @@
#include "install/install.h"
#include "otautil/paths.h"
+#include "otautil/roots.h"
#include "private/setup_commands.h"
static void BuildZipArchive(const std::map<std::string, std::string>& file_map, int fd,
@@ -595,3 +596,30 @@ TEST(InstallTest, CheckPackageMetadata_ab_post_timestamp) {
"\n");
test_check_package_metadata(metadata, OtaType::AB, 0);
}
+
+TEST(InstallTest, SetupPackageMount_package_path) {
+ load_volume_table();
+ bool install_with_fuse;
+
+ // Setup should fail if the input path doesn't exist.
+ ASSERT_FALSE(SetupPackageMount("/does_not_exist", &install_with_fuse));
+
+ // Package should be installed with fuse if it's not in /cache.
+ TemporaryDir temp_dir;
+ TemporaryFile update_package(temp_dir.path);
+ ASSERT_TRUE(SetupPackageMount(update_package.path, &install_with_fuse));
+ ASSERT_TRUE(install_with_fuse);
+
+ // Setup should fail if the input path isn't canonicalized.
+ std::string uncanonical_package_path = android::base::Join(
+ std::vector<std::string>{
+ temp_dir.path,
+ "..",
+ android::base::Basename(temp_dir.path),
+ android::base::Basename(update_package.path),
+ },
+ '/');
+
+ ASSERT_EQ(0, access(uncanonical_package_path.c_str(), R_OK));
+ ASSERT_FALSE(SetupPackageMount(uncanonical_package_path, &install_with_fuse));
+}