tests: test for correct ellipsis with -s in xattr

* tests/xattr-strings.c: New file.
* tests/xattr-strings.test: New test.
* tests/.gitignore: Add xattr-string.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add xattr-string.test.

Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr>
This commit is contained in:
Gabriel Laskar 2016-12-22 16:10:52 +01:00 committed by Dmitry V. Levin
parent dd3548a691
commit 2aa03c2af6
4 changed files with 40 additions and 0 deletions

1
tests/.gitignore vendored
View File

@ -358,6 +358,7 @@ waitid
waitid-v
waitpid
xattr
xattr-strings
xet_robust_list
xetitimer
xetpgid

View File

@ -418,6 +418,7 @@ check_PROGRAMS = \
waitid-v \
waitpid \
xattr \
xattr-strings \
xet_robust_list \
xetitimer \
xetpgid \
@ -793,6 +794,7 @@ DECODER_TESTS = \
waitid-v.test \
waitpid.test \
xattr.test \
xattr-strings.test \
xet_robust_list.test \
xetitimer.test \
xetpgid.test \

30
tests/xattr-strings.c Normal file
View File

@ -0,0 +1,30 @@
#include "tests.h"
#ifdef HAVE_SYS_XATTR_H
# include <stdio.h>
# include <sys/xattr.h>
int
main(void)
{
static const char name[] = "strace.test";
static const char c_value[] = "foobar";
const char *const z_value = tail_memdup(c_value, sizeof(c_value));
long rc;
rc = fsetxattr(-1, name, z_value, sizeof(c_value), XATTR_REPLACE);
printf("fsetxattr(-1, \"%.*s\"..., \"%.*s\"..., %u, XATTR_REPLACE) = %s\n",
4, name, 4, c_value, (unsigned) sizeof(c_value), sprintrc(rc));
puts("+++ exited with 0 +++");
return 0;
}
#else
SKIP_MAIN_UNDEFINED("HAVE_SYS_XATTR_H")
#endif

7
tests/xattr-strings.test Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
# Check *xattr syscalls decoding when limiting string size.
. "${srcdir=.}/init.sh"
run_strace_match_diff -a22 -s 4 -e trace=fsetxattr