AU: Try to remove unit test flakiness on buildbots.
Retry to delete the loop device with some sleep. I haven't been able to
reproduce the issue on my desktop but loop device deletion fails pretty often on
buildbot.
BUG=9601
TEST=unit tests
Change-Id: I8dfde0527f8f67d3568970f7906b0cbffb3fd959
Review URL: http://codereview.chromium.org/5561003
diff --git a/test_utils.h b/test_utils.h
index 9f2fee2..4c82888 100644
--- a/test_utils.h
+++ b/test_utils.h
@@ -108,13 +108,19 @@
public:
explicit ScopedLoopbackDeviceReleaser(const std::string& dev) : dev_(dev) {}
~ScopedLoopbackDeviceReleaser() {
- std::vector<std::string> args;
- args.push_back("/sbin/losetup");
- args.push_back("-d");
- args.push_back(dev_);
- int return_code = 0;
- EXPECT_TRUE(Subprocess::SynchronousExec(args, &return_code));
- EXPECT_EQ(0, return_code);
+ for (int retry = 0; retry < 5; retry++) {
+ std::vector<std::string> args;
+ args.push_back("/sbin/losetup");
+ args.push_back("-d");
+ args.push_back(dev_);
+ int return_code = 0;
+ EXPECT_TRUE(Subprocess::SynchronousExec(args, &return_code));
+ if (return_code == 0) {
+ return;
+ }
+ sleep(1);
+ }
+ ADD_FAILURE();
}
private:
const std::string dev_;