summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2019-10-17 00:20:27 +0200
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-10-17 00:20:27 +0200
commitb8ba2fa86ee0c64dfc5b216a9fdda9d774f87106 (patch)
treeb38f957ec98276d05d00a5fff67d5341c2edd3fe /tests
parentMerge "[bootable][recovery] fix -Wreorder-init-list" am: 0d76cad830 am: 843c0bbb01 am: bd99b40ae9 (diff)
parentForce package installation with FUSE unless the package stores on device (diff)
downloadandroid_bootable_recovery-b8ba2fa86ee0c64dfc5b216a9fdda9d774f87106.tar
android_bootable_recovery-b8ba2fa86ee0c64dfc5b216a9fdda9d774f87106.tar.gz
android_bootable_recovery-b8ba2fa86ee0c64dfc5b216a9fdda9d774f87106.tar.bz2
android_bootable_recovery-b8ba2fa86ee0c64dfc5b216a9fdda9d774f87106.tar.lz
android_bootable_recovery-b8ba2fa86ee0c64dfc5b216a9fdda9d774f87106.tar.xz
android_bootable_recovery-b8ba2fa86ee0c64dfc5b216a9fdda9d774f87106.tar.zst
android_bootable_recovery-b8ba2fa86ee0c64dfc5b216a9fdda9d774f87106.zip
Diffstat (limited to 'tests')
-rw-r--r--tests/Android.bp1
-rw-r--r--tests/unit/install_test.cpp28
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/Android.bp b/tests/Android.bp
index 5b881e367..ec49c07af 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -94,6 +94,7 @@ librecovery_static_libs = [
"liblp",
"libvndksupport",
"libtinyxml2",
+ "libc++fs",
]
cc_test {
diff --git a/tests/unit/install_test.cpp b/tests/unit/install_test.cpp
index 4ec409908..60cdc1105 100644
--- a/tests/unit/install_test.cpp
+++ b/tests/unit/install_test.cpp
@@ -36,6 +36,7 @@
#include "install/wipe_device.h"
#include "otautil/paths.h"
#include "private/setup_commands.h"
+#include "recovery_utils/roots.h"
static void BuildZipArchive(const std::map<std::string, std::string>& file_map, int fd,
int compression_type) {
@@ -595,3 +596,30 @@ TEST(InstallTest, CheckPackageMetadata_ab_post_timestamp) {
"\n");
TestCheckPackageMetadata(metadata, OtaType::AB, true);
}
+
+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));
+}