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_unittest.cc b/p2p_manager_unittest.cc
index ce8d644..bee0248 100644
--- a/p2p_manager_unittest.cc
+++ b/p2p_manager_unittest.cc
@@ -287,6 +287,12 @@
// Check that sharing a *new* file works.
TEST_F(P2PManagerTest, ShareFile) {
+ if (!utils::IsXAttrSupported(FilePath("/tmp"))) {
+ LOG(WARNING) << "Skipping test because /tmp does not support xattr. "
+ << "Please update your system to support this feature.";
+ return;
+ }
+
scoped_ptr<P2PManager> manager(P2PManager::Construct(test_conf_,
NULL, "cros_au", 3));
EXPECT_TRUE(manager->FileShare("foo", 10 * 1000 * 1000));
@@ -304,6 +310,12 @@
// Check that making a shared file visible, does what is expected.
TEST_F(P2PManagerTest, MakeFileVisible) {
+ if (!utils::IsXAttrSupported(FilePath("/tmp"))) {
+ LOG(WARNING) << "Skipping test because /tmp does not support xattr. "
+ << "Please update your system to support this feature.";
+ return;
+ }
+
scoped_ptr<P2PManager> manager(P2PManager::Construct(test_conf_,
NULL, "cros_au", 3));
// First, check that it's not visible.
@@ -325,6 +337,12 @@
// Check that we return the right values for existing files in P2P_DIR.
TEST_F(P2PManagerTest, ExistingFiles) {
+ if (!utils::IsXAttrSupported(FilePath("/tmp"))) {
+ LOG(WARNING) << "Skipping test because /tmp does not support xattr. "
+ << "Please update your system to support this feature.";
+ return;
+ }
+
scoped_ptr<P2PManager> manager(P2PManager::Construct(test_conf_,
NULL, "cros_au", 3));
bool visible;