Commit Graph

3644 Commits

Author SHA1 Message Date
6124cd9932 tests: replace unix-yy.test with net-yy-unix.test
Unlike the former test that was based on match_awk,
the new one uses match_diff and does more rigorous testing.

* tests/net-yy-unix.c: New file.
* tests/net-yy-unix.test: New test.
* tests/unix-yy.test: Remove.
* tests/unix-yy-accept.awk: Remove.
* tests/unix-yy-connect.awk: Remove.
* tests/.gitignore: Add net-yy-unix.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Replace unix-yy.test with net-yy-unix.test.
(EXTRA_DIST): Remove unix-yy-accept.awk and unix-yy-connect.awk.
2016-02-03 12:39:06 +00:00
e364920b67 tests: add inode_of_sockfd function to libtests
* tests/tests.h (inode_of_sockfd): New prototype.
* tests/inode_of_sockfd.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
2016-02-02 00:24:48 +00:00
3d0f55e419 unix_parse_response: add a safety check
* socketutils.c (unix_parse_response): Check that netlink message
is large enough to contain a unix_diag_msg structure.
2016-02-02 00:24:46 +00:00
dfea1da0e6 Fixed decoding of mincore syscall's last argument
* mem.c (SYS_FUNC(mincore)): Print only those bytes of the vector
that were written by the kernel.
* NEWS: Mention this fix.
* tests/mincore.c: New file.
* tests/mincore.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add mincore.
(TESTS): Add mincore.test.
* tests/.gitignore: Add mincore.
2016-01-29 02:39:40 +00:00
ea8b8e3152 Move fallback -yy socket print from printfd to print_sockaddr_by_inode
* util.c (printfd): In -yy mode, move fallback print of proto:[inode] ...
* socketutils.c (to print_sockaddr_by_inode): ... here.
2016-01-23 16:35:02 +00:00
fa8c286d50 Implement simultaneous use of -p option and tracing of a command
* strace.c (init): Allow -p option along with a command.
(startup_child): In -D mode, record the parent of the tracer process
as strace_child.
(startup_attach): Save trace_tracer_pid before -D mode fork.
When tracing a command in -f mode, do not check for the command's
threads as it has no threads at this moment.
Never attach to the tracer process.
In -D mode, never attach to the parent of the tracer process,
terminate that process only once at the end of startup_attach,
and reset strace_child.
* strace.1: Document that -p option can be used along with tracing
of a command.
* NEWS: Mention it.
* tests/attach-p-cmd-cmd.c: New file.
* tests/attach-p-cmd-p.c: Likewise.
* tests/attach-p-cmd.test: New test.
* tests/.gitignore: Add attach-p-cmd-cmd and attach-p-cmd-p.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add attach-p-cmd.test.

This fixes Debian bug #549942.
2016-01-22 19:37:11 +00:00
38721432de strace.1: fix format of -P description
* strace.1 (-P): Write trailing using regular font.
2016-01-22 14:55:56 +00:00
a8eb52f952 tests: use local nanosleep based sleep utility replacement
* tests/sleep.c: New file.
* tests/.gitignore: Add sleep.
* tests/Makefile.am (check_PROGRAMS): Likewise.
* tests/count.test: Use it instead of system sleep utility.
2016-01-21 23:52:39 +00:00
3d54c92691 tests: add error_msg_and_fail function to libtests
* tests/tests.h (error_msg_and_fail): New prototype.
* tests/error_msg.c (error_msg_and_fail): New function.
2016-01-21 23:46:43 +00:00
d44707d889 Fix dumping of recvmmsg syscall in case of short read
* net.c (dumpiov_in_mmsghdr): Call dumpiov_upto instead of dumpiov,
pass data size limit to dumpiov_upto.
* NEWS: Mention this fix.
* tests/mmsg.c (main): Update.
2016-01-20 17:36:41 +00:00
93c9d1cdbd Fix dumping of recvmsg syscall in case of short read
* defs.h (dumpiov_in_msghdr): Add unsigned long argument.
* net.c (dumpiov_in_msghdr): Add data_size argument.  Call dumpiov_upto
instead of dumpiov, pass data_size to dumpiov_upto.
* syscall.c (dumpio): Pass data size limit to dumpiov_in_msghdr.
* NEWS: Mention this fix.
* tests/recvmsg.c: New file.
* tests/recvmsg.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add recvmsg.
(TESTS): Add recvmsg.test.
* tests/.gitignore: Add recvmsg.
2016-01-20 17:35:27 +00:00
05a0af6d60 Fix decoding and dumping of readv syscall in case of short read
* defs.h (dumpiov_upto): New prototype.
(dumpiov): Change to a wrapper around dumpiov_upto.
* util.c (dumpiov): Rename to dumpiov_upto, add and check data_size
argument.
* io.c (SYS_FUNC(readv)): Call tprint_iov_upto instead
of tprint_iov and specify syscall return value as a data size limit.
* syscall.c (dumpio): In case of SEN_readv, call dumpiov_upto instead
of dumpiov and specify syscall return value as a data size limit.
* NEWS: Mention this fix.
* tests/readv.c: New file.
* tests/readv.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add readv.
(TESTS): Add readv.test.
* tests/.gitignore: Add readv.
2016-01-20 15:31:26 +00:00
a5417308e4 tests/tests.h: add ARRAY_SIZE and LENGTH_OF macros
* tests/tests.h (ARRAY_SIZE, LENGTH_OF): New macros.
* tests/aio.c (ARRAY_SIZE): Remove.
* tests/mmsg.c (LENGTH_OF): Remove.
2016-01-20 15:24:45 +00:00
590b240444 tests: add hexdump_strdup function to libtests
* tests/tests.h (hexdump_strdup): New prototype.
* tests/hexdump_strdup.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
2016-01-20 15:24:41 +00:00
536a0353dd tests: add tprintf function to libtests
* tests/tests.h (tprintf): New prototype.
* tests/tprintf.c: New file.
* tests/Makefile.am (libtests_a_SOURCES): Add it.
* tests/mmsg.c: Use tprintf.
2016-01-20 15:17:28 +00:00
ed227111a4 quotactl: add Q_XGETQSTATV command decoding
* quota.c (fs_qfilestatv, fs_quota_statv): New structures.
(decode_cmd_data): Handle Q_XGETQSTATV case.
2016-01-19 23:48:36 +00:00
60d4892866 quotactl: add decoding of if_dqinfo.dqi_flags constants
* xlat/if_dqinfo_flags.in: New file.
* quota.c: Include "xlat/if_dqinfo_flags.h".
(decode_cmd_data): Print struct if_dqinfo.dqi_flags using printflags.
2016-01-19 02:10:23 +00:00
c02fd6109a quotactl: consistenly decode all write and unknown commands on entering
* quota.c (decode_cmd_data): Change return type to int.
Return 0 on entering Q_GETQUOTA, Q_V1_GETQUOTA, Q_V2_GETQUOTA,
Q_XGETQUOTA, Q_GETFMT, Q_GETINFO, Q_V2_GETINFO, Q_V1_GETSTATS,
Q_V2_GETSTATS, and Q_XGETQSTAT commands, return RVAL_DECODED
for any other command.
(SYS_FUNC(quotactl)): On entering, print third argument of any command.
For any command except Q_QUOTAON and Q_V1_QUOTAON, call decode_cmd_data
and forward its return value.
2016-01-19 02:00:20 +00:00
b176920bb7 quotactl: fix Q_QUOTAON command decoding
* quota.c (SYS_FUNC(quotactl)): Print Q_QUOTAON 4th argument as a path.
2016-01-19 01:43:24 +00:00
7258d27e9c quotactl: print third argument as unsigned int
* quota.c (SYS_FUNC(quotactl)): Consistently print the third
argument using "%u" format.
2016-01-19 01:43:24 +00:00
7ea48d6ff8 quotactl: fix Q_XQUOTAOFF command decoding
* quota.c (decode_cmd_data): Print xfs quota flags argument.
2016-01-19 01:43:17 +00:00
6a9ac9636a quotactl: fix Q_GETFMT and Q_XQUOTAON commands decoding
* quota.c (decode_cmd_data): As quota format value and xfs quota flags
are in-memory constants, print it like an array of one element instead
of a structure.
2016-01-19 01:42:08 +00:00
2d544968fe Update quotactl constants
* xlat/quota_formats.in: Add QFMT_OCFS2 and QFMT_VFS_V1.
* xlat/quotacmds.in: Add Q_XGETQSTATV.
* xlat/quotatypes.in: Add PRJQUOTA.
* xlat/xfs_quota_flags.in: Add FS_QUOTA_PDQ_ACCT and FS_QUOTA_PDQ_ENFD.
2016-01-17 22:30:54 +00:00
0894194648 Replace u_int{8,16,32,64} with uint{8,16,32,64}
* util.c: Replace u_int{32,64} with uint{32,64}.
* quota.c: Replace u_int{8,16,32,64} with uint{8,16,32,64}.
2016-01-19 00:28:38 +00:00
2105a9737c Move definitions of quotactl constants to xlat files
* quota.c (Q_*): Move to xlat/quotacmds.in.
(USRQUOTA, GRPQUOTA): Move to xlat/quotatypes.in.
(QFMT_VFS_OLD, QFMT_VFS_V0): Move to xlat/quota_formats.in.
(XFS_QUOTA_*): Move to xlat/xfs_quota_flags.in.
(XFS_*_QUOTA): Move to xlat/xfs_dqblk_flags.in.
(QIF_*): Move to xlat/if_dqblk_valid.in.
(IIF_*): Move to xlat/if_dqinfo_valid.in.
2016-01-19 00:06:09 +00:00
972018f2ea llseek.test: robustify against libcs invoking _llseek syscall on their own
* tests/llseek.test: Filter out _llseek calls made with non-negative
descriptor arguments.
2016-01-15 00:10:00 +00:00
8e37cffaa8 lseek.test: robustify against libcs invoking lseek syscall on their own
* tests/lseek.test: Filter out lseek calls made with non-negative
descriptor arguments.
2016-01-15 00:09:48 +00:00
19d10f8965 mmsg.test: fix regression introduced by commit v4.11-138-g6e815ce
This fixes the test on platforms where both __NR_sendmmsg and
HAVE_SENDMMSG are defined but the former is not implemented by the
kernel and the second is implemented as an indirect syscall.

* tests/mmsg.c (LENGTH_OF): New macro.
(send_mmsg, recv_mmsg): Print expected output in case of ENOSYS.
(main): Redirect stdout to a new descriptor.  Use LENGTH_OF.
Print expected output.
* tests/mmsg.test: Update.
* tests/mmsg.expected: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove mmsg.expected.
2016-01-14 00:06:20 +00:00
68f7a66dc9 aio.test: check memory access by aio decoders
* tests/aio.c (main): Place all objects passed to io_* syscalls
at the end of memory pages followed by inaccessible pages.
2016-01-13 22:06:18 +00:00
1763fa5f62 s390, s390x: fix printing of syscalls unknown to the kernel
On s390/s390x, syscalls with NR up to 255 can be implemented
directly using "svc NR", for NR >= 256 "svc 0" with %r1=NR is used.
The latter method is allowed for NR < 256, too.

When the syscall number specified directly or indirectly is recognized
by the kernel, i.e. it is less than its NR_syscalls value, it is stored
in %r2 and is available to arch_get_scno via s390_regset.gprs[2].
For syscall numbers >= NR_syscalls this register is set to 0,
but %r1 remains unchanged and could be used by arch_get_scno
via s390_regset.gprs[1] to decide what the syscall number is.

* linux/s390/get_scno.c (arch_get_scno): If s390_regset.gprs[2] is zero,
take syscall number from s390_regset.gprs[1].
* NEWS: Mention this fix.

This fixes Debian bug #485979 and Fedora bug #1298294.
2016-01-13 21:27:48 +00:00
e2136d4b89 s390, s390x: print all syscall arguments for syscall number 0
* linux/s390/syscallent.h [0]: Set nargs to MA.
* linux/s390x/syscallent.h: Likewise.
2016-01-13 21:26:26 +00:00
606fcd0878 mips o32: alias sys_syscall to printargs
* linux/dummy.h (sys_syscall): Alias to printargs.
* syscall.c [LINUX_MIPSO32] (SYS_FUNC(syscall)): Remove.
2016-01-13 21:26:26 +00:00
b227293f1c travis-ci: update build matrix
Add clang-3.6/x86_64, clang-3.6/x86, and musl-gcc/x86_64 to the matrix.

* .travis.yml (compiler): Add gcc, clang-3.6, and musl-gcc.
(env): Add matrix, remove global ENABLE_GCC_WERROR.
(matrix): Add exclude, remove include.
* travis-ci.sh: Add support for clang and musl-gcc.
Use --enable-gcc-Werror for gcc build unconditionally.
2016-01-13 12:12:33 +00:00
cc902e3272 mpers.awk: add support for DWARF files generated by clang
* mpers.awk: Define default_pointer_size.  Initialize byte_size
for DW_TAG_pointer_type to default_pointer_size.  Set parent
for DW_TAG_member only.  Handle DW_AT_count as an alternative
to DW_AT_upper_bound.
2016-01-13 02:38:59 +00:00
1ef7aa65ab configure.ac: reorder some statements for better readability
* configure.ac: Sort and group together AC_PROG_*, AC_C_*, AC_TYPE_*,
AC_HEADER_*, AC_CHECK_FUNCS, AC_CHECK_TYPES, AC_CHECK_MEMBERS,
and AC_CHECK_HEADERS.
2016-01-12 21:48:04 +00:00
3fdcdd47c6 scm_rights-fd.test: rewrite without fork
* tests/scm_rights.c (main): Rewrite without fork.
Place all objects passed to sendmsg and recvmsg at the end
of memory pages followed by inaccessible pages.
* tests/scm_rights-fd.test: Update.
2016-01-12 16:06:58 +00:00
55f3c8901d tests: fix clang "duplicate 'const' declaration specifier" warnings
* tests/ksysent.c (pstr_t): Remove second const specifier.
* tests/mmsg.c (main): Remove second const specifier from one[], two[],
and three[].
2016-01-12 05:06:10 +00:00
b6edea5ce7 tests/times.c: fix clang compilation warning
* tests/times.c (main): Initialize dummy variable.
2016-01-12 05:06:10 +00:00
eb4649a0dc tests/mmsg.c: fix build on rhel6/ppc
There are weird platforms that define __NR_sendmmsg but at the same time
do not define __NR_recvmmsg.  Add a workaround for them.

* configure.ac (AC_CHECK_FUNCS): Add recvmmsg.
* tests/mmsg.c: Check for __NR_recvmmsg || HAVE_RECVMMSG.
2016-01-12 05:06:10 +00:00
8493dcf6f7 s390: fix sigreturn decoding on recent kernels
Linux kernel commit v4.3-rc1-50-g8d4bd0e corrected uc_sigmask
of the compat signal frame, so remove the old workaround.

* linux/s390/arch_sigreturn.c (arch_sigreturn) [S390]: Remove.
2016-01-12 03:07:39 +00:00
65f8d39278 Update PTRACE_* constants
* ptrace.h (PTRACE_SECCOMP_GET_FILTER): Define.
* xlat/ptrace_cmds.in: Add PTRACE_SECCOMP_GET_FILTER.
2016-01-12 03:07:39 +00:00
e714b87064 Fix struct sigevent decoding for musl
Do not rely on "struct sigevent.__pad" being located at the same address
as "struct sigevent.sigev_notify_thread_id", it's not the case with musl
libc.  Do not rely on struct sigevent definition at all to access
sigev_notify_thread_id.

* configure.ac (AC_CHECK_MEMBERS): Remove struct sigevent._sigev_un._pad
and struct sigevent.__pad.
* sigevent.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* print_sigevent.c: Include it.
* print_sigevent.c (struct_sigevent): Remove.
(print_sigevent): Update all struct_sigevent users.
* tests/timer_create.c: Include "sigevent.h".
(main): Use struct_sigevent instead of struct sigevent,
all struct sigevent clients changed.
2016-01-12 03:07:39 +00:00
2a6ac9473c syscall.c: include <signal.h>
All users of NSIG macro must include <signal.h>.
This complements commit v4.10-184-g0e946ab.

* syscall.c: Include <signal.h>.
2016-01-12 03:07:39 +00:00
07572c68dd signal.c: fix musl libc compilation warning
musl libc defines SIGRTMAX to a function that returns signed int,
which obviously makes gcc -Wsign-compare unhappy.

* signal.c (signame): Cast ASM_SIGRTMAX to unsigned int.
2016-01-12 03:07:39 +00:00
7bbf8b54cd tests: fix TEST_SYSCALL_{NR,STR} and STRUCT_STAT_STR macros for musl
The contents of TEST_SYSCALL_NAME and STRUCT_STAT macros was subject
to macro expansion when used in definitions of TEST_SYSCALL_NR,
TEST_SYSCALL_STR, and STRUCT_STAT_STR macros.

As some libcs, e.g. musl libc, define lfs64 names as macros
(stat64 as stat, lstat64 as lstat, etc.), this might result to incorrect
expansion of TEST_SYSCALL_NR, TEST_SYSCALL_STR, and STRUCT_STAT_STR
macros.  To avoid this problem, define these macros directly and remove
TEST_SYSCALL_NAME macro.

* tests/_newselect.c (TEST_SYSCALL_NAME): Remove.
(TEST_SYSCALL_NR, TEST_SYSCALL_STR): New macros.
* tests/fcntl.c: Likewise.
* tests/fcntl64.c: Likewise.
* tests/fstat.c: Likewise.
* tests/fstatat64.c: Likewise.
* tests/lstat.c: Likewise.
* tests/newfstatat.c: Likewise.
* tests/select.c: Likewise.
* tests/stat.c: Likewise.
* tests/fstat64.c (TEST_SYSCALL_NAME): Remove.
(TEST_SYSCALL_NR, TEST_SYSCALL_STR, STRUCT_STAT_STR): New macros.
* tests/lstat64.c: Likewise.
* tests/stat64.c: Likewise.
* tests/fstatx.c (TEST_SYSCALL_NR, nrify, nrify_): Remove.
* tests/lstatx.c: Likewise.
* tests/struct_flock.c (TEST_SYSCALL_NR, TEST_SYSCALL_STR, nrify,
nrify_, stringify, stringify_): Remove.
* tests/xselect.c: Likewise.
* tests/xstatx.c: Check TEST_SYSCALL_STR instead of TEST_SYSCALL_NAME.
(STRUCT_STAT_STR, TEST_SYSCALL_STR, stringify, stringify_): Remove.
[!STRUCT_STAT] (STRUCT_STAT_STR): New macro.
2016-01-12 03:07:39 +00:00
2165a359fd tests/struct_flock.c: fix musl libc compilation warnings
The size of off_t is not something one can rely upon.  For example,
musl libc unconditionally defines it as an int64_t type on x86.
A cast to the target type helps to avoid these libc differences.

* configure.ac: Call AC_C_TYPEOF.
* tests/struct_flock.c (TYPEOF_FLOCK_OFF_T): New macro.
(test_flock_einval): Use it instead of off_t.
2016-01-12 03:07:38 +00:00
4776e3366f tests/inet-cmsg.c: fix musl libc compilation warnings
The types that are used to define msg_namelen member of struct msghdr
and cmsg_len member of struct cmsghdr differ between libcs.
For example, glibc defines them as size_t, while musl libc - as type
socklen_t.  Print these fields using %lu format to avoid issues caused
by libc differences.

* tests/inet-cmsg.c (main): Cast mh.msg_controllen and c->cmsg_len
to unsigned long and print them using %lu format.
2016-01-12 00:00:47 +00:00
c36270a28e aio.test: include <fcntl.h> instead of <sys/fcntl.h>
* tests/aio.c: Include <fcntl.h> instead of <sys/fcntl.h>.
2016-01-11 02:20:04 +00:00
35eb03fdf7 mmsg.test: check memory access by sendmmsg and recvmmsg decoders
* tests/tests.h (tail_memdup): New prototype.
* tests/tail_alloc.c (tail_memdup): New function.
* tests/mmsg.c (main): Place all objects passed to sendmmsg and recvmmsg
at the end of memory pages followed by inaccessible pages.
2016-01-11 01:05:34 +00:00
3a184fe9cc mmsg.test: check decoding of flags passed to sendmmsg and recvmmsg
* tests/mmsg.c (main): Pass MSG_DONTROUTE|MSG_NOSIGNAL to sendmmsg.
Pass MSG_DONTWAIT to recvmmsg.
* tests/mmsg.expected: Update.
2016-01-11 01:05:34 +00:00