tests: fix xattr.test for the case when listxattr returns a long list

* 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.
This commit is contained in:
Дмитрий Левин 2016-12-22 22:34:23 +00:00
parent 2aa03c2af6
commit d9d92cf220

View 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);