Merge "snapuserd: Add test case"
This commit is contained in:
commit
18a307beb4
1 changed files with 36 additions and 0 deletions
|
|
@ -103,6 +103,7 @@ class CowSnapuserdTest final {
|
|||
void ReadSnapshotDeviceAndValidate();
|
||||
void Shutdown();
|
||||
void MergeInterrupt();
|
||||
void ReadDmUserBlockWithoutDaemon();
|
||||
|
||||
std::string snapshot_dev() const { return snapshot_dev_->path(); }
|
||||
|
||||
|
|
@ -481,6 +482,36 @@ void CowSnapuserdTest::CreateDmUserDevice() {
|
|||
ASSERT_TRUE(android::fs_mgr::WaitForFile(misc_device, 10s));
|
||||
}
|
||||
|
||||
void CowSnapuserdTest::ReadDmUserBlockWithoutDaemon() {
|
||||
DmTable dmuser_table;
|
||||
std::string dm_user_name = "dm-test-device";
|
||||
unique_fd fd;
|
||||
|
||||
// Create a dm-user block device
|
||||
ASSERT_TRUE(dmuser_table.AddTarget(std::make_unique<DmTargetUser>(0, 123456, dm_user_name)));
|
||||
ASSERT_TRUE(dmuser_table.valid());
|
||||
|
||||
dmuser_dev_ = std::make_unique<TempDevice>(dm_user_name, dmuser_table);
|
||||
ASSERT_TRUE(dmuser_dev_->valid());
|
||||
ASSERT_FALSE(dmuser_dev_->path().empty());
|
||||
|
||||
fd.reset(open(dmuser_dev_->path().c_str(), O_RDONLY));
|
||||
ASSERT_GE(fd, 0);
|
||||
|
||||
std::unique_ptr<uint8_t[]> buffer = std::make_unique<uint8_t[]>(1_MiB);
|
||||
|
||||
loff_t offset = 0;
|
||||
// Every IO should fail as there is no daemon to process the IO
|
||||
for (size_t j = 0; j < 10; j++) {
|
||||
ASSERT_EQ(ReadFullyAtOffset(fd, (char*)buffer.get() + offset, BLOCK_SZ, offset), false);
|
||||
|
||||
offset += BLOCK_SZ;
|
||||
}
|
||||
|
||||
fd = {};
|
||||
ASSERT_TRUE(dmuser_dev_->Destroy());
|
||||
}
|
||||
|
||||
void CowSnapuserdTest::InitDaemon() {
|
||||
bool ok = client_->AttachDmUser(system_device_ctrl_name_);
|
||||
ASSERT_TRUE(ok);
|
||||
|
|
@ -909,6 +940,11 @@ TEST(Snapuserd_Test, Snapshot_COPY_Overlap_Merge_Resume_TEST) {
|
|||
harness.Shutdown();
|
||||
}
|
||||
|
||||
TEST(Snapuserd_Test, ReadDmUserBlockWithoutDaemon) {
|
||||
CowSnapuserdTest harness;
|
||||
harness.ReadDmUserBlockWithoutDaemon();
|
||||
}
|
||||
|
||||
} // namespace snapshot
|
||||
} // namespace android
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue