summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Ebourne <martin@ebourne.me.uk>2006-01-06 16:23:32 +0000
committerMartin Ebourne <martin@ebourne.me.uk>2006-01-06 16:23:32 +0000
commit4236badf30da3ebff007ad72d91fd10e32f5c345 (patch)
treea0099674f09f3d396811d85deaa47592b4d25d3d /test
parent18d03eb51a36ad7d31edace38cff956e90f3fa19 (diff)
Fixes for xattr on Linux
- A very unlikely failure where getxattr returns an error code the first time but succeeds the second time could cause buffer overrun and corruption. Affecting the tests only: - On Linux (and presumably Irix) normal users can only modify attributes in the 'user.' namespace. - Some filesystems can have strict limits on value size (eg. 1024 bytes on ext3 depending on block size) - ENOATTR is defined in xattr/xattr.h. This file is an optional install and is not needed for the rest of box to use extended attributes. Provide it ourselves if not present.
Diffstat (limited to 'test')
-rw-r--r--test/bbackupd/testbbackupd.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/test/bbackupd/testbbackupd.cpp b/test/bbackupd/testbbackupd.cpp
index 72917978..0e01619a 100644
--- a/test/bbackupd/testbbackupd.cpp
+++ b/test/bbackupd/testbbackupd.cpp
@@ -44,6 +44,11 @@
#include "MemLeakFindOn.h"
+// ENOATTR may be defined in a separate header file which we may not have
+#ifndef ENOATTR
+#define ENOATTR ENODATA
+#endif
+
// two cycles and a bit
#define TIME_TO_WAIT_FOR_BACKUP_OPERATION 12
@@ -194,7 +199,7 @@ bool write_xattr_test(const char *filename, const char *attrName, unsigned int l
}
else
{
- char data[4096];
+ char data[1024];
if(length > sizeof(data)) length = sizeof(data);
if(::fread(data, length, 1, xattrTestDataHandle) != 1)
@@ -327,7 +332,7 @@ int test_basics()
#ifdef HAVE_SYS_XATTR_H
// Write some attributes to the file, checking for ENOTSUP
bool xattrNotSupported = false;
- if(!write_xattr_test("testfiles/test1", "attr_1", 1276, &xattrNotSupported) && xattrNotSupported)
+ if(!write_xattr_test("testfiles/test1", "user.attr_1", 1000, &xattrNotSupported) && xattrNotSupported)
{
::printf("***********\nYour platform supports xattr, but your filesystem does not.\nSkipping tests.\n***********\n");
}
@@ -336,8 +341,8 @@ int test_basics()
BackupClientFileAttributes x1, x2, x3, x4;
// Write more attributes
- TEST_THAT(write_xattr_test("testfiles/test1", "attr_2", 3427));
- TEST_THAT(write_xattr_test("testfiles/test1", "sadfohij39998.3hj", 123));
+ TEST_THAT(write_xattr_test("testfiles/test1", "user.attr_2", 947));
+ TEST_THAT(write_xattr_test("testfiles/test1", "user.sadfohij39998.3hj", 123));
// Read file attributes
x1.ReadAttributes("testfiles/test1");
@@ -352,7 +357,7 @@ int test_basics()
// Add more attributes to a file
x2.ReadAttributes("testfiles/test1");
- TEST_THAT(write_xattr_test("testfiles/test1", "328989sj..sdf", 23));
+ TEST_THAT(write_xattr_test("testfiles/test1", "user.328989sj..sdf", 23));
// Read them again, and check that the Compare() function detects that they're different
x3.ReadAttributes("testfiles/test1");
@@ -360,7 +365,7 @@ int test_basics()
TEST_THAT(!x1.Compare(x3, true, true));
// Change the value of one of them, leaving the size the same.
- TEST_THAT(write_xattr_test("testfiles/test1", "328989sj..sdf", 23));
+ TEST_THAT(write_xattr_test("testfiles/test1", "user.328989sj..sdf", 23));
x4.ReadAttributes("testfiles/test1");
TEST_THAT(!x1.Compare(x4, true, true));
}