Skip to contentSkip to conversation

generic/337: add checks for listxattr call fails.

PATCH In review Artem Savkov 3 participants 9 messages Aug 24, 2016 – Aug 30, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/337: add checks for listxattr call fails.

Add simple checks for failed calls to listxattr syscall. So far ERANGE, ENOENT and EFAULT are checked.

Test is based on llistxattr02 test from LTP.

---
 .gitignore            |  1 +
 src/Makefile          |  2 +-
 src/listxattr_fails.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/337     |  4 ++++
 tests/generic/337.out |  3 +++
 5 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 src/listxattr_fails.c
.gitignore +1 -0
index d84f385..613d245 100644
@@ -66,6 +66,7 @@
 /src/holes
 /src/holetest
 /src/itrash
+/src/listxattr_fails
 /src/locktest
 /src/loggen
 /src/looptest
src/Makefile +1 -1
index 57b0df1..0fee55f 100644
@@ -21,7 +21,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
 	renameat2 t_getcwd e4compact test-nextquota punch-alternating \
-	attr-list-by-handle-cursor-test
+	attr-list-by-handle-cursor-test listxattr_fails
 
 SUBDIRS =
 
src/listxattr_fails.c new file +51 -0

51 lines not on this page · raw message

tests/generic/337 +4 -0
index 1758871..88b1e33 100755
@@ -68,5 +68,9 @@ $SETFATTR_PROG -n user.ping -v pong $SCRATCH_MNT/testfile
 # It should list all the xattrs we have set before.
 $GETFATTR_PROG --absolute-names --dump $SCRATCH_MNT/testfile | _filter_scratch
 
+# Call listattr_fails to check if we get expected errors on errorneus listxattr
+# calls.
+$here/src/listxattr_fails $SCRATCH_MNT/testfile
+
 status=0
 exit
tests/generic/337.out +3 -0
index 1cd92ff..8ff8374 100644
@@ -6,3 +6,6 @@ user.foobar="123"
 user.ping="pong"
 user.something="pizza"
 
+expected error: ERANGE
+expected error: ENOENT
+expected error: EFAULT
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 4 lines · Artem Savkov

Add simple checks for failed calls to listxattr syscall. So far ERANGE, ENOENT and EFAULT are checked.

Test is based on llistxattr02 test from LTP.

Any reason porting this from LTP? I think LTP is the right place for such syscall level tests, this test should stay there, or extend llistxattr02 test if you want to test new errnos.

Quoted 35 lines
---
 .gitignore            |  1 +
 src/Makefile          |  2 +-
 src/listxattr_fails.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/337     |  4 ++++
 tests/generic/337.out |  3 +++
 5 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 src/listxattr_fails.c
.gitignore +1 -0
index d84f385..613d245 100644
@@ -66,6 +66,7 @@
 /src/holes
 /src/holetest
 /src/itrash
+/src/listxattr_fails
 /src/locktest
 /src/loggen
 /src/looptest
src/Makefile +1 -1
index 57b0df1..0fee55f 100644
@@ -21,7 +21,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
 	renameat2 t_getcwd e4compact test-nextquota punch-alternating \
-	attr-list-by-handle-cursor-test
+	attr-list-by-handle-cursor-test listxattr_fails
 
 SUBDIRS =

[snip]

tests/generic/337 $SETFATTR_PROG -n user.ping -v pong $SCRATCH_MNT/testfile · line 74

Quoted 12 lines
tests/generic/337 +4 -0
index 1758871..88b1e33 100755
@@ -68,5 +68,9 @@ $SETFATTR_PROG -n user.ping -v pong $SCRATCH_MNT/testfile
 # It should list all the xattrs we have set before.
 $GETFATTR_PROG --absolute-names --dump $SCRATCH_MNT/testfile | _filter_scratch
 
+# Call listattr_fails to check if we get expected errors on errorneus listxattr
+# calls.
+$here/src/listxattr_fails $SCRATCH_MNT/testfile
+

And usually we don't add new test to existing cases, so if the new test fails we know it's not a regression.

Thanks,
Eryu

Quoted 20 lines
tests/generic/337 +0 -0
 status=0
 exit
tests/generic/337.out +3 -0
index 1cd92ff..8ff8374 100644
@@ -6,3 +6,6 @@ user.foobar="123"
 user.ping="pong"
 user.something="pizza"
 
+expected error: ERANGE
+expected error: ENOENT
+expected error: EFAULT
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 9 lines · Eryu Guan
Quoted 4 lines · Artem Savkov

Add simple checks for failed calls to listxattr syscall. So far ERANGE, ENOENT and EFAULT are checked.

Test is based on llistxattr02 test from LTP.

Any reason porting this from LTP? I think LTP is the right place for such syscall level tests, this test should stay there, or extend llistxattr02 test if you want to test new errnos.

It's pretty clear that nobody is actually using LTP in their day-to-day development work-flow. It's a pain to build and configure and it wants to write to places it shouldn't.

I asked that this test be added to xfstests, and that's especially important because I can't reproduce the reported problem with LTP. Hence we need to work out a reliable reproducer, and really that belongs in xfstests along with all the other xattr tests we run.

Quoted 10 lines
Quoted 10 lines
---
 .gitignore            |  1 +
 src/Makefile          |  2 +-
 src/listxattr_fails.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/337     |  4 ++++
 tests/generic/337.out |  3 +++
 5 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 src/listxattr_fails.c
Quoted 9 lines

.gitignore line 69

Quoted 9 lines
.gitignore +1 -0
index d84f385..613d245 100644
@@ -66,6 +66,7 @@
 /src/holes
 /src/holetest
 /src/itrash
+/src/listxattr_fails

Not the best name for a test program. Better is to write a simple tool that runs listxattr with a buffer size specified on the command line. That way it canbe used for more than just the specific test case. e.g. we can test corner cases rather than jsut "is the buffer too small?" by creating specific combinations of extended attributes and then calling the listxattr tool with different buffer sizes...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#3 lore raw

PATCH v2 1/1 Add a test for listxattr syscall with different buffer sizes.

Add generic/375 test that calls listxattr syscall with different buffer size arguments checking if it fails properly.

---
 .gitignore            |  1 +
 src/Makefile          |  2 +-
 src/listxattr.c       | 55 +++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375     | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375.out | 10 +++++++++
 tests/generic/group   |  1 +
 6 files changed, 130 insertions(+), 1 deletion(-)
 create mode 100644 src/listxattr.c
 create mode 100755 tests/generic/375
 create mode 100644 tests/generic/375.out
.gitignore +1 -0
index d84f385..915d2d8 100644
@@ -66,6 +66,7 @@
 /src/holes
 /src/holetest
 /src/itrash
+/src/listxattr
 /src/locktest
 /src/loggen
 /src/looptest
src/Makefile +1 -1
index 57b0df1..dd51216 100644
@@ -21,7 +21,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
 	renameat2 t_getcwd e4compact test-nextquota punch-alternating \
-	attr-list-by-handle-cursor-test
+	attr-list-by-handle-cursor-test listxattr
 
 SUBDIRS =
 
src/listxattr.c new file +55 -0

55 lines not on this page · raw message

tests/generic/375 new file +62 -0

62 lines not on this page · raw message

tests/generic/375.out new file +10 -0
new file mode 100644
index 0000000..0c02a83
@@ -0,0 +1,10 @@
+QA output created by 375
+xattr: user.foo
+xattr: user.ping
+xattr: user.xxxx
+listxattr failed with -2
+listxattr failed with -34
+listxattr failed with -34
+xattr: user.foo
+xattr: user.ping
+xattr: user.xxxx
tests/generic/group +1 -0
index ef38c35..3068510 100644
@@ -377,3 +377,4 @@
 372 auto quick clone
 373 auto quick clone
 374 auto quick clone dedupe
+375 auto quick metadata
Signature · 1 line
1.8.3.1
#4 lore raw

Re: [PATCH v2] Add a test for listxattr syscall with different buffer sizes.

src/listxattr.c

Quoted 47 lines · Artem Savkov

Add generic/375 test that calls listxattr syscall with different buffer size arguments checking if it fails properly.

---
 .gitignore            |  1 +
 src/Makefile          |  2 +-
 src/listxattr.c       | 55 +++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375     | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375.out | 10 +++++++++
 tests/generic/group   |  1 +
 6 files changed, 130 insertions(+), 1 deletion(-)
 create mode 100644 src/listxattr.c
 create mode 100755 tests/generic/375
 create mode 100644 tests/generic/375.out
.gitignore +1 -0
index d84f385..915d2d8 100644
@@ -66,6 +66,7 @@
 /src/holes
 /src/holetest
 /src/itrash
+/src/listxattr
 /src/locktest
 /src/loggen
 /src/looptest
src/Makefile +1 -1
index 57b0df1..dd51216 100644
@@ -21,7 +21,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
 	renameat2 t_getcwd e4compact test-nextquota punch-alternating \
-	attr-list-by-handle-cursor-test
+	attr-list-by-handle-cursor-test listxattr
 
 SUBDIRS =
 
src/listxattr.c new file +0 -0
new file mode 100644
index 0000000..7fdccb5
@@ -0,0 +1,55 @@

License, copyright.

Quoted 8 lines
src/listxattr.c new file +8 -0
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/xattr.h>
+

src/listxattr.c line 18

Quoted 10 lines
src/listxattr.c new file +10 -0
+int main(int argc, char **argv)
+{
+  int ret;
+  size_t bufsize = 0;
+  char *buf = NULL;
+
+  if (argc < 2) {
+    fprintf(stderr, "usage: %s <testfile> [bufsize]\n", argv[0]);
+    return 1;
+  };

Please use 8 space tabs for all new code in xfstests.

src/listxattr.c line 31

Quoted 13 lines
src/listxattr.c new file +13 -0
+
+  if (argc == 3) {
+    bufsize = strtoul(argv[2], NULL, 10);
+    if (bufsize == -1) {
+      perror("buffsize");
+      return 1;
+    }
+  }
+
+  if (bufsize == 0) {
+    bufsize = listxattr(argv[1], buf, 0);
+    if (bufsize == -1) {
+      fprintf(stderr, "listxattr failed with %d\n", -errno);
	perror("listxattr:");

src/listxattr.c line 44

Quoted 13 lines
src/listxattr.c new file +13 -0
+      return 1;
+    }
+  }
+
+  buf = malloc(bufsize + 1);
+  if (buf == NULL) {
+    perror("buf alloc");
+    return 1;
+  }
+
+  ret = listxattr(argv[1], buf, bufsize);
+  if (ret < 0) {
+    fprintf(stderr, "listxattr failed with %d\n", -errno);
	perror("listxattr:");
Quoted 17 lines
src/listxattr.c new file +11 -0
+  } else {
+    char *l;
+    for (l = buf; l != (buf + bufsize) && *l != '\0'; l = strchr(l, '\0') + 1) {
+      printf("xattr: %s\n", l);
+    }
+  }
+
+  free(buf);
+
+  return 0;
+}
tests/generic/375 new file +0 -0
new file mode 100755
index 0000000..ad7b168

tests/generic/375 line 5

Quoted 5 lines
tests/generic/375 new file +5 -0
@@ -0,0 +1,62 @@
+#! /bin/bash
+# FSQA Test No. 375
+#
+# Test listxattr syscall behaviour with different buffer sizes.
+#

Why did you remove the license and copyright statement from the template? Please add them back in when you resend.

Quoted 14 lines
tests/generic/375 new file +14 -0
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+

tests/generic/375 line 29

Quoted 10 lines
tests/generic/375 new file +10 -0
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_attrs

_require_test_program "listxattr"

listxattr="$here/src/listxattr"

tests/generic/375 line 38

Quoted 9 lines
tests/generic/375 new file +9 -0
+
+rm -f $seqres.full
+
+_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mount
+
+# Create a testfile with multiple xattrs.
+TESTFILE=${SCRATCH_MNT}/testfile
+touch $TESTFILE

testfile, not TESTFILE.

i.e. local variables use lower case, harness provided/global variables use upper case.

tests/generic/375 line 41

Quoted 3 lines
tests/generic/375 new file +3 -0
+$SETFATTR_PROG -n user.foo -v bar $TESTFILE
+$SETFATTR_PROG -n user.ping -v pong $TESTFILE
+$SETFATTR_PROG -n user.xxxx -v yyyy $TESTFILE

Why only 3 attributes? A small comment explaining the reason for the initial conditions helps a lot here.

tests/generic/375 line 44

Quoted 3 lines
tests/generic/375 new file +3 -0
+
+# Call listxattr without buffer length argument. This should succeed.
+$here/src/listxattr $TESTFILE

$listxattr $testfile

Quoted 5 lines
tests/generic/375 new file +5 -0
+
+# Calling listxattr on nonexistant file should fail with -ENOENT.
+$here/src/listxattr ""
+
+# Calling listxattr with buffersize not suffecient for even one xattr should

tests/generic/375 line 59

Quoted 10 lines
tests/generic/375 new file +10 -0
+# fail with -ERANGE.
+$here/src/listxattr $TESTFILE 1
+
+# Calling listxattr with buffersize sufficient for one xattr, but not
+# sufficient for the whole list should still fail with -ERANGE.
+$here/src/listxattr $TESTFILE 9
+
+# Calling listxattr with buffersize not suffecient for even one xattr should
+# fail with -ERANGE.
+$here/src/listxattr $TESTFILE 500

Comment above this case is wrong.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#5 lore raw

PATCH v3 1/1 Add a test for listxattr syscall with different buffer sizes.

Add generic/375 test that calls listxattr syscall with different buffer size arguments checking if it fails properly.

---
 .gitignore            |  1 +
 src/Makefile          |  2 +-
 src/listxattr.c       | 73 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375.out | 11 +++++++
 tests/generic/group   |  1 +
 6 files changed, 174 insertions(+), 1 deletion(-)
 create mode 100644 src/listxattr.c
 create mode 100755 tests/generic/375
 create mode 100644 tests/generic/375.out
.gitignore +1 -0
index d84f385..915d2d8 100644
@@ -66,6 +66,7 @@
 /src/holes
 /src/holetest
 /src/itrash
+/src/listxattr
 /src/locktest
 /src/loggen
 /src/looptest
src/Makefile +1 -1
index 57b0df1..dd51216 100644
@@ -21,7 +21,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
 	renameat2 t_getcwd e4compact test-nextquota punch-alternating \
-	attr-list-by-handle-cursor-test
+	attr-list-by-handle-cursor-test listxattr
 
 SUBDIRS =
 
src/listxattr.c new file +73 -0

73 lines not on this page · raw message

tests/generic/375 new file +87 -0

87 lines not on this page · raw message

tests/generic/375.out new file +11 -0
new file mode 100644
index 0000000..0d45622
@@ -0,0 +1,11 @@
+QA output created by 375
+xattr: user.foo
+xattr: user.ping
+xattr: user.hello
+listxattr: No such file or directory
+listxattr: Numerical result out of range
+listxattr: Numerical result out of range
+listxattr: Numerical result out of range
+xattr: user.foo
+xattr: user.ping
+xattr: user.hello
tests/generic/group +1 -0
index ef38c35..3068510 100644
@@ -377,3 +377,4 @@
 372 auto quick clone
 373 auto quick clone
 374 auto quick clone dedupe
+375 auto quick metadata
Signature · 1 line
1.8.3.1
#6 lore raw

Re: [PATCH v3] Add a test for listxattr syscall with different buffer sizes.

Quoted 182 lines · Artem Savkov

Add generic/375 test that calls listxattr syscall with different buffer size arguments checking if it fails properly.

---
 .gitignore            |  1 +
 src/Makefile          |  2 +-
 src/listxattr.c       | 73 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375.out | 11 +++++++
 tests/generic/group   |  1 +
 6 files changed, 174 insertions(+), 1 deletion(-)
 create mode 100644 src/listxattr.c
 create mode 100755 tests/generic/375
 create mode 100644 tests/generic/375.out
.gitignore +1 -0
index d84f385..915d2d8 100644
@@ -66,6 +66,7 @@
 /src/holes
 /src/holetest
 /src/itrash
+/src/listxattr
 /src/locktest
 /src/loggen
 /src/looptest
src/Makefile +1 -1
index 57b0df1..dd51216 100644
@@ -21,7 +21,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
 	renameat2 t_getcwd e4compact test-nextquota punch-alternating \
-	attr-list-by-handle-cursor-test
+	attr-list-by-handle-cursor-test listxattr
 
 SUBDIRS =
 
src/listxattr.c new file +73 -0
new file mode 100644
index 0000000..da9d163
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016 Artem Savkov <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/xattr.h>
+
+int main(int argc, char **argv)
+{
+        int ret;
+        size_t bufsize = 0;
+        char *buf = NULL;
+
+        if (argc < 2) {
+                fprintf(stderr, "usage: %s <testfile> [bufsize]\n", argv[0]);
+                return 1;
+        };
+
+        if (argc > 2) {
+                bufsize = strtoul(argv[2], NULL, 10);
+                if (bufsize == -1) {
+                        perror("buffsize");
+                        return 1;
+                }
+        }
+
+        if (bufsize == 0) {
+                bufsize = listxattr(argv[1], NULL, 0);
+                if (bufsize == -1) {
+                        perror("listxattr");
+                        return 1;
+                }
+        }
+
+        buf = malloc(bufsize);
+        if (buf == NULL) {
+                perror("buf alloc");
+                return 1;
+        }
+
+        ret = listxattr(argv[1], buf, bufsize);
+        if (ret < 0) {
+                perror("listxattr");
+        } else {
+                char *l;
+                for (l = buf; l != (buf + bufsize) && *l != '\0';
+                                l = strchr(l, '\0') + 1) {
+                        printf("xattr: %s\n", l);
+                }
+        }
+
+        free(buf);
+
+        return 0;
+}
tests/generic/375 new file +56 -0
new file mode 100755
index 0000000..8651c7d
@@ -0,0 +1,87 @@
+#! /bin/bash
+# FSQA Test No. 375
+#
+# Test listxattr syscall behaviour with different buffer sizes.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Artem Savkov <[email protected]>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_attrs
+_require_test_program "listxattr"
+
+listxattr="$here/src/listxattr"
+
+rm -f $seqres.full
+
+_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mount
+
+# Create a testfile with three xattrs such that the sum of namelengths of the

tests/generic/375 line 66

Quoted 10 lines
tests/generic/375 new file +10 -0
+# first two is bigger than the namelength of the third. This is needed for
+# the 5th testcase that tests one of the cornercases.
+testfile=${SCRATCH_MNT}/testfile
+touch $testfile
+$SETFATTR_PROG -n user.foo -v bar $testfile
+$SETFATTR_PROG -n user.ping -v pong $testfile
+$SETFATTR_PROG -n user.hello -v there $testfile
+
+# 1. Call listxattr without buffer length argument. This should succeed.
+$listxattr $testfile

This fails for me on btrfs as:
[root@dhcp-66-86-11 xfstests]# diff -u tests/generic/375.out /root/workspace/xfstests/results//btrfs/generic/375.out.bad

root/workspace/xfstests/results//btrfs/generic/375.out.bad 2016-08-30 12:28:48.392000000 +0800 renamed from generic/375.out 2016-08-30 12:23:06.827000000 +0800 +2 -2
@@ -1,11 +1,11 @@
 QA output created by 375
-xattr: user.foo
 xattr: user.ping
 xattr: user.hello
+xattr: user.foo
 listxattr: No such file or directory
 listxattr: Numerical result out of range
 listxattr: Numerical result out of range
 listxattr: Numerical result out of range
-xattr: user.foo
 xattr: user.ping
 xattr: user.hello
+xattr: user.foo

Seems btrfs returns xattrs in a different order, perhaps you need to sort the results in the test?

Quoted 43 lines
tests/generic/375 new file +21 -0
+
+# 2. Calling listxattr on nonexistant file should fail with -ENOENT.
+$listxattr ""
+
+# 3. Calling listxattr with buffersize not suffecient for even one xattr
+# should fail with -ERANGE.
+$listxattr $testfile 1
+
+# 4. Calling listxattr with buffersize suffecient for one xattr, but not
+# sufficient for the whole list should still fail with -ERANGE.
+$listxattr $testfile 9
+
+# 5. Calling listxattr with buffersize suffecient for the last xattr, but not
+# sufficient for the sum of first two. Should fail with -ERANGE.
+$listxattr $testfile 11
+
+# 6. Calling listxattr with buffersize bigger than needed should succeed.
+$listxattr $testfile 500
+
+status=0
+exit
tests/generic/375.out new file +11 -0
new file mode 100644
index 0000000..0d45622
@@ -0,0 +1,11 @@
+QA output created by 375
+xattr: user.foo
+xattr: user.ping
+xattr: user.hello
+listxattr: No such file or directory
+listxattr: Numerical result out of range
+listxattr: Numerical result out of range
+listxattr: Numerical result out of range
+xattr: user.foo
+xattr: user.ping
+xattr: user.hello
tests/generic/group +0 -0
index ef38c35..3068510 100644

tests/generic/group line 380

Quoted 4 lines
tests/generic/group +1 -0
@@ -377,3 +377,4 @@
 372 auto quick clone
 373 auto quick clone
 374 auto quick clone dedupe
+375 auto quick metadata

Add 'attr' group too?

Thanks,
Eryu

#7 lore raw

PATCH v4 1/1 Add a test for listxattr syscall with different buffer sizes.

Add generic/375 test that calls listxattr syscall with different buffer size arguments checking if it fails properly.

---
 .gitignore            |  1 +
 src/Makefile          |  2 +-
 src/listxattr.c       | 73 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375.out | 11 +++++++
 tests/generic/group   |  1 +
 6 files changed, 174 insertions(+), 1 deletion(-)
 create mode 100644 src/listxattr.c
 create mode 100755 tests/generic/375
 create mode 100644 tests/generic/375.out
.gitignore +1 -0
index d84f385..915d2d8 100644
@@ -66,6 +66,7 @@
 /src/holes
 /src/holetest
 /src/itrash
+/src/listxattr
 /src/locktest
 /src/loggen
 /src/looptest
src/Makefile +1 -1
index 57b0df1..dd51216 100644
@@ -21,7 +21,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
 	renameat2 t_getcwd e4compact test-nextquota punch-alternating \
-	attr-list-by-handle-cursor-test
+	attr-list-by-handle-cursor-test listxattr
 
 SUBDIRS =
 
src/listxattr.c new file +73 -0

73 lines not on this page · raw message

tests/generic/375 new file +87 -0

87 lines not on this page · raw message

tests/generic/375.out new file +11 -0
new file mode 100644
index 0000000..820f40c
@@ -0,0 +1,11 @@
+QA output created by 375
+xattr: user.foo
+xattr: user.hello
+xattr: user.ping
+listxattr: No such file or directory
+listxattr: Numerical result out of range
+listxattr: Numerical result out of range
+listxattr: Numerical result out of range
+xattr: user.foo
+xattr: user.hello
+xattr: user.ping
tests/generic/group +1 -0
index ef38c35..f5aea8d 100644
@@ -377,3 +377,4 @@
 372 auto quick clone
 373 auto quick clone
 374 auto quick clone dedupe
+375 attr auto quick metadata
Signature · 1 line
1.8.3.1
#8 lore raw

Re: [PATCH v3] Add a test for listxattr syscall with different buffer sizes.

In reply to Artem Savkov
Quoted 47 lines · Artem Savkov

Add generic/375 test that calls listxattr syscall with different buffer size arguments checking if it fails properly.

---
 .gitignore            |  1 +
 src/Makefile          |  2 +-
 src/listxattr.c       | 73 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/375.out | 11 +++++++
 tests/generic/group   |  1 +
 6 files changed, 174 insertions(+), 1 deletion(-)
 create mode 100644 src/listxattr.c
 create mode 100755 tests/generic/375
 create mode 100644 tests/generic/375.out
.gitignore +1 -0
index d84f385..915d2d8 100644
@@ -66,6 +66,7 @@
 /src/holes
 /src/holetest
 /src/itrash
+/src/listxattr
 /src/locktest
 /src/loggen
 /src/looptest
src/Makefile +1 -1
index 57b0df1..dd51216 100644
@@ -21,7 +21,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \
 	seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner \
 	renameat2 t_getcwd e4compact test-nextquota punch-alternating \
-	attr-list-by-handle-cursor-test
+	attr-list-by-handle-cursor-test listxattr
 
 SUBDIRS =
 
src/listxattr.c new file +0 -0
new file mode 100644
index 0000000..da9d163

src/listxattr.c line 2

Quoted 2 lines
src/listxattr.c new file +2 -0
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016 Artem Savkov <[email protected]>

This is somewhat contradictory and quite ambiguous - a personal copyright assertion from with your employer's email contact and a s-o-b from the same address. If it's your own personal copyright, then please use a private email address. i.e

Copyright (c) 2016 Artem Savkov <personal email address>

And the patch needs to have a S-o-B that matches the copyright statement.

However, you're doing all this work under a @redhat.com email address, it tends to mean the work is not owned directly by you but your employer, and hence the copywrite statement needs to be:

Copyright (c) 2016 Red Hat, Inc. All rights reserved.

I know, I'm being a pendant, but copyright is a legal construct and we need to be certain that it is correct and unambigious. If you have any doubt about whether you or your company owns the copyright for work you do on their behalf, please refer to your company legal counsel for advice...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]