From: Gabriel Laskar Date: Thu, 22 Dec 2016 15:10:52 +0000 (+0100) Subject: tests: test for correct ellipsis with -s in xattr X-Git-Tag: v4.16~293 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2aa03c2af62b54ca3c5ed458f215c06f3dac5275;p=strace 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 --- diff --git a/tests/.gitignore b/tests/.gitignore index 7dee9fd9..3b04590a 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -358,6 +358,7 @@ waitid waitid-v waitpid xattr +xattr-strings xet_robust_list xetitimer xetpgid diff --git a/tests/Makefile.am b/tests/Makefile.am index 1c32b1c6..7a8b411c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ diff --git a/tests/xattr-strings.c b/tests/xattr-strings.c new file mode 100644 index 00000000..310929a9 --- /dev/null +++ b/tests/xattr-strings.c @@ -0,0 +1,30 @@ +#include "tests.h" + +#ifdef HAVE_SYS_XATTR_H + +# include +# include + +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 diff --git a/tests/xattr-strings.test b/tests/xattr-strings.test new file mode 100755 index 00000000..25ef360b --- /dev/null +++ b/tests/xattr-strings.test @@ -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