]> granicus.if.org Git - strace/commitdiff
tests: test for correct ellipsis with -s in xattr
authorGabriel Laskar <gabriel@lse.epita.fr>
Thu, 22 Dec 2016 15:10:52 +0000 (16:10 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 22 Dec 2016 23:11:02 +0000 (23:11 +0000)
* 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>
tests/.gitignore
tests/Makefile.am
tests/xattr-strings.c [new file with mode: 0644]
tests/xattr-strings.test [new file with mode: 0755]

index 7dee9fd9f072a5a5d6ea7697cf639e2087fdced2..3b04590a617f33398bfbed718fb5d07e8bddf749 100644 (file)
@@ -358,6 +358,7 @@ waitid
 waitid-v
 waitpid
 xattr
+xattr-strings
 xet_robust_list
 xetitimer
 xetpgid
index 1c32b1c67fcc8c5418f461e3f0b650211e113140..7a8b411cfb28646f42308935fda092518c432163 100644 (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 \
diff --git a/tests/xattr-strings.c b/tests/xattr-strings.c
new file mode 100644 (file)
index 0000000..310929a
--- /dev/null
@@ -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
diff --git a/tests/xattr-strings.test b/tests/xattr-strings.test
new file mode 100755 (executable)
index 0000000..25ef360
--- /dev/null
@@ -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