p2p: Skip some tests if xattr support is not available.
This is needed because some builders still lack xattr / fallocate
support despite being updated to Precise. Also gracefully handle lack
of fallocate(2) support since this feature is not always available
either.
BUG=chromium:298397
TEST=Remounted the filesystem holding my chroot with nouser_xattr
(e.g. 'mount -oremount,nouser_xattr /ssd') and unit tests pass with
the newly added warning.
Change-Id: I0fe53d762fad778a3d68162ddcd8bc74557fba6b
Reviewed-on: https://chromium-review.googlesource.com/170782
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
diff --git a/p2p_manager.cc b/p2p_manager.cc
index 7536fc6..596adf1 100644
--- a/p2p_manager.cc
+++ b/p2p_manager.cc
@@ -606,18 +606,21 @@
FALLOC_FL_KEEP_SIZE, // Keep file size as 0.
0,
expected_size) != 0) {
- // ENOSPC can happen (funky race though, cf. the statvfs() check
- // above), handle it gracefully, e.g. use logging level INFO.
- //
- // NOTE: we *could* handle ENOSYS gracefully (ie. we could
- // ignore it) but currently we don't because running out of
- // space later sounds absolutely horrible. Better to fail fast.
- PLOG(INFO) << "Error allocating " << expected_size
- << " bytes for file " << path.value();
- if (unlink(path.value().c_str()) != 0) {
- PLOG(ERROR) << "Error deleting file with path " << path.value();
+ if (errno == ENOSYS || errno == EOPNOTSUPP) {
+ // If the filesystem doesn't support the fallocate, keep
+ // going. This is helpful when running unit tests on build
+ // machines with ancient filesystems and/or OSes.
+ PLOG(WARNING) << "Ignoring fallocate(2) failure";
+ } else {
+ // ENOSPC can happen (funky race though, cf. the statvfs() check
+ // above), handle it gracefully, e.g. use logging level INFO.
+ PLOG(INFO) << "Error allocating " << expected_size
+ << " bytes for file " << path.value();
+ if (unlink(path.value().c_str()) != 0) {
+ PLOG(ERROR) << "Error deleting file with path " << path.value();
+ }
+ return false;
}
- return false;
}
string decimal_size = StringPrintf("%zu", expected_size);