]> granicus.if.org Git - strace/commitdiff
tests: fix xattr.test for the case when listxattr returns a long list
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 22 Dec 2016 22:34:23 +0000 (22:34 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 22 Dec 2016 23:11:02 +0000 (23:11 +0000)
* tests/xattr.c (DEFAULT_STRLEN): New macro.
(main): Use it to limit the length passed to print_quoted_memory.
Print ellipsis when the list returned by listxattr is too long.

tests/xattr.c

index 877552fe11e94a534729d36c072916ddf3f47cdf..a772eced6681f1019b4a4996e0c0414633bc8256 100644 (file)
@@ -36,6 +36,8 @@
 #  define XATTR_SIZE_MAX 65536
 # endif
 
+#define DEFAULT_STRLEN 32
+
 int
 main(void)
 {
@@ -110,9 +112,13 @@ main(void)
        if (rc < 0)
                printf("%p", big);
        else {
+               const int ellipsis = rc > DEFAULT_STRLEN;
+
                putchar('"');
-               print_quoted_memory(big, rc);
+               print_quoted_memory(big, ellipsis ? DEFAULT_STRLEN : rc);
                putchar('"');
+               if (ellipsis)
+                       fputs("...", stdout);
        }
        printf(", %u) = %s\n", XATTR_SIZE_MAX + 1, errstr);