summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-06-06 03:41:22 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-06-06 03:41:22 +0200
commit3e72aaf11c00060241f2a59bbd4523600bf29a86 (patch)
tree440384897fa5143e97d5b266b9b7172450ddf5ae /tests
parentMerge "Use ro.build.fingerprint instead of ro.bootimage.*" (diff)
parentMerge QQ3A.200605.002 into master (diff)
downloadandroid_bootable_recovery-3e72aaf11c00060241f2a59bbd4523600bf29a86.tar
android_bootable_recovery-3e72aaf11c00060241f2a59bbd4523600bf29a86.tar.gz
android_bootable_recovery-3e72aaf11c00060241f2a59bbd4523600bf29a86.tar.bz2
android_bootable_recovery-3e72aaf11c00060241f2a59bbd4523600bf29a86.tar.lz
android_bootable_recovery-3e72aaf11c00060241f2a59bbd4523600bf29a86.tar.xz
android_bootable_recovery-3e72aaf11c00060241f2a59bbd4523600bf29a86.tar.zst
android_bootable_recovery-3e72aaf11c00060241f2a59bbd4523600bf29a86.zip
Diffstat (limited to '')
-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 3d223907c..a9a088a32 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -92,6 +92,7 @@ librecovery_static_libs = [
"libhidlbase",
"liblp",
"libtinyxml2",
+ "libc++fs",
]
// recovery image for unittests.
diff --git a/tests/unit/install_test.cpp b/tests/unit/install_test.cpp
index 370fbdcc5..ee753494c 100644
--- a/tests/unit/install_test.cpp
+++ b/tests/unit/install_test.cpp
@@ -35,6 +35,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) {
@@ -513,3 +514,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));
+}