Deflake libdm#CreateEmptyDevice test

Judging from local experiments, it looks like device-mapper doesn't
always generate a uevent after DM_DEV_CREATE ioctl.

Test: presubmit
Bug: 193462349
Change-Id: I8a74375631b20c14a32a41dbaf38380ebc0078e6
Merged-In: I8a74375631b20c14a32a41dbaf38380ebc0078e6
This commit is contained in:
Nikita Ioffe 2021-07-15 15:30:09 +01:00 committed by David Anderson
parent ea376a5c0f
commit 654bb5225b
1 changed files with 2 additions and 6 deletions

View File

@ -684,13 +684,9 @@ TEST(libdm, DeleteDeviceDeferredWaitsForLastReference) {
TEST(libdm, CreateEmptyDevice) {
DeviceMapper& dm = DeviceMapper::Instance();
ASSERT_TRUE(dm.CreateEmptyDevice("empty-device"));
auto guard = android::base::make_scope_guard([&]() { dm.DeleteDevice("empty-device", 5s); });
auto guard =
android::base::make_scope_guard([&]() { dm.DeleteDeviceIfExists("empty-device", 5s); });
// Empty device should be in suspended state.
ASSERT_EQ(DmDeviceState::SUSPENDED, dm.GetState("empty-device"));
std::string path;
ASSERT_TRUE(dm.WaitForDevice("empty-device", 5s, &path));
// Path should exist.
ASSERT_EQ(0, access(path.c_str(), F_OK));
}