Merge changes from topic "fs_mgr_unit_test" am: 6d6ccdf7c6 am: b45e01bdd3

am: 9dc08bd409

Change-Id: Iae86306d7f8a174d86b94ff8a15eb16764ddc991
This commit is contained in:
Bowgo Tsai 2019-02-26 00:27:47 -08:00 committed by android-build-merger
commit 38eb0976d0
3 changed files with 47 additions and 41 deletions

View file

@ -14,6 +14,7 @@
cc_test {
name: "fs_mgr_unit_test",
test_suites: ["device-tests"],
shared_libs: [
"libbase",
@ -23,9 +24,6 @@ cc_test {
"libfs_mgr",
"libfstab",
],
data: [
"data/*",
],
srcs: [
"fs_mgr_test.cpp",
],

View file

@ -1,15 +0,0 @@
# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/dev/block/bootdevice/by-name/system / ext4 ro,barrier=1 wait,slotselect,avb
/dev/block/bootdevice/by-name/metadata /metadata ext4 noatime,nosuid,nodev,discard wait,formattable
/dev/block/bootdevice/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065,fsync_mode=nobarrier latemount,wait,check,fileencryption=ice,keydirectory=/metadata/vold/metadata_encryption,quota,formattable,sysfs_path=/sys/devices/platform/soc/1d84000.ufshc,reservedsize=128M
/dev/block/bootdevice/by-name/misc /misc emmc defaults defaults
/dev/block/bootdevice/by-name/modem /vendor/firmware_mnt vfat ro,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337,context=u:object_r:firmware_file:s0 wait,slotselect
/devices/platform/soc/a600000.ssusb/a600000.dwc3* auto vfat defaults voldmanaged=usb:auto
/dev/block/zram0 none swap defaults zramsize=1073741824,max_comp_streams=8
/dev/block/zram0 none2 swap nodiratime,remount,bind zramsize=1073741824,max_comp_streams=8
/dev/block/zram0 none3 swap unbindable,private,slave zramsize=1073741824,max_comp_streams=8
/dev/block/zram0 none4 swap noexec,shared,rec zramsize=1073741824,max_comp_streams=8
/dev/block/zram0 none5 swap rw zramsize=1073741824,max_comp_streams=8

View file

@ -203,10 +203,32 @@ TEST(fs_mgr, fs_mgr_read_fstab_file_proc_mounts) {
EXPECT_EQ(i, fstab.size());
}
TEST(fs_mgr, ReadFstabFromFile_MountOptions) {
// TODO(124837435): enable it later when it can pass TreeHugger.
TEST(fs_mgr, DISABLED_ReadFstabFromFile_MountOptions) {
TemporaryFile tf;
ASSERT_TRUE(tf.fd != -1);
std::string fstab_contents = R"fs(
source / ext4 ro,barrier=1 wait,slotselect,avb
source /metadata ext4 noatime,nosuid,nodev,discard wait,formattable
source /data f2fs noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065,fsync_mode=nobarrier latemount,wait,check,fileencryption=ice,keydirectory=/metadata/vold/metadata_encryption,quota,formattable,sysfs_path=/sys/devices/platform/soc/1d84000.ufshc,reservedsize=128M
source /misc emmc defaults defaults
source /vendor/firmware_mnt vfat ro,shortname=lower,uid=1000,gid=1000,dmask=227,fmask=337,context=u:object_r:firmware_file:s0 wait,slotselect
source auto vfat defaults voldmanaged=usb:auto
source none swap defaults zramsize=1073741824,max_comp_streams=8
source none2 swap nodiratime,remount,bind zramsize=1073741824,max_comp_streams=8
source none3 swap unbindable,private,slave zramsize=1073741824,max_comp_streams=8
source none4 swap noexec,shared,rec zramsize=1073741824,max_comp_streams=8
source none5 swap rw zramsize=1073741824,max_comp_streams=8
)fs";
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
std::string fstab_file = android::base::GetExecutableDirectory() + "/data/fstab.example";
EXPECT_TRUE(ReadFstabFromFile(fstab_file, &fstab));
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
ASSERT_EQ(11U, fstab.size());
EXPECT_EQ("/", fstab[0].mount_point);
EXPECT_EQ(static_cast<unsigned long>(MS_RDONLY), fstab[0].flags);
@ -286,7 +308,8 @@ static bool CompareFlags(FstabEntry::FsMgrFlags& lhs, FstabEntry::FsMgrFlags& rh
// clang-format on
}
TEST(fs_mgr, ReadFstabFromFile_FsMgrFlags) {
// TODO(124837435): enable it later when it can pass TreeHugger.
TEST(fs_mgr, DISABLED_ReadFstabFromFile_FsMgrFlags) {
TemporaryFile tf;
ASSERT_TRUE(tf.fd != -1);
std::string fstab_contents = R"fs(
@ -297,7 +320,7 @@ source none3 swap defaults checkpoint=block
source none4 swap defaults checkpoint=fs
source none5 swap defaults defaults
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -376,7 +399,7 @@ source none1 swap defaults encryptable=,forceencrypt=,fileencryptio
source none2 swap defaults forcefdeorfbe=
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -456,7 +479,7 @@ TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_Encryptable) {
std::string fstab_contents = R"fs(
source none0 swap defaults encryptable=/dir/key
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -480,7 +503,7 @@ source none1 swap defaults voldmanaged=sdcard
source none2 swap defaults voldmanaged=sdcard:3
source none3 swap defaults voldmanaged=sdcard:auto
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -521,7 +544,7 @@ TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_Length) {
source none0 swap defaults length=blah
source none1 swap defaults length=123456
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -547,7 +570,7 @@ TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_Swapprio) {
source none0 swap defaults swapprio=blah
source none1 swap defaults swapprio=123456
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -577,7 +600,7 @@ source none3 swap defaults zramsize=5%
source none4 swap defaults zramsize=105%
source none5 swap defaults zramsize=%
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -623,7 +646,7 @@ TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_Verify) {
source none0 swap defaults verify=/dir/key
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -646,7 +669,7 @@ TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_ForceEncrypt) {
source none0 swap defaults forceencrypt=/dir/key
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -669,7 +692,7 @@ TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_ForceFdeOrFbe) {
source none0 swap defaults forcefdeorfbe=/dir/key
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -704,7 +727,7 @@ source none9 swap defaults fileencryption=ice:adiantum
source none10 swap defaults fileencryption=ice:adiantum:
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -787,7 +810,7 @@ TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_MaxCompStreams) {
source none0 swap defaults max_comp_streams=blah
source none1 swap defaults max_comp_streams=123456
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -815,7 +838,7 @@ source none1 swap defaults reservedsize=2
source none2 swap defaults reservedsize=1K
source none3 swap defaults reservedsize=2m
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -853,7 +876,7 @@ source none1 swap defaults eraseblk=4000
source none2 swap defaults eraseblk=5000
source none3 swap defaults eraseblk=8192
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -891,7 +914,7 @@ source none1 swap defaults logicalblk=4000
source none2 swap defaults logicalblk=5000
source none3 swap defaults logicalblk=8192
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -927,7 +950,7 @@ TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_Avb) {
source none0 swap defaults avb=vbmeta_partition
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -950,7 +973,7 @@ TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_KeyDirectory) {
source none0 swap defaults keydirectory=/dir/key
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -972,7 +995,7 @@ TEST(fs_mgr, ReadFstabFromFile_FsMgrOptions_SysfsPath) {
source none0 swap defaults sysfs_path=/sys/device
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));
@ -1002,7 +1025,7 @@ source none5 swap defaults zram_backing_dev_path=/dev/path2
)fs";
ASSERT_TRUE(android::base::WriteStringToFd(fstab_contents, tf.fd));
ASSERT_TRUE(android::base::WriteStringToFile(fstab_contents, tf.path));
Fstab fstab;
EXPECT_TRUE(ReadFstabFromFile(tf.path, &fstab));