1345 Commits

Author SHA1 Message Date
909ffde2d6 tests: guard against missing linux/netfilter/nfnetlink.h
nfnetlink was introduced in linux by commit v2.6.14-rc1~1035^2~217,
add a guard for the case when system headers are not fresh enough.

* configure.ac (AC_CHECK_HEADERS): Add linux/netfilter/nfnetlink.h.
* tests/netlink_netfilter.c: Check for HAVE_LINUX_NETFILTER_NFNETLINK_H.
2017-06-05 14:57:29 +00:00
JingPiao Chen
e2ba1126e7 tests: check decoding of NETLINK_XFRM message types
* tests/netlink_xfrm.c: New file.
* tests/gen_tests.in (netlink_xfrm): New entry.
* tests/pure_executables.list: Add netlink_xfrm.
* tests/.gitignore: Likewise.
2017-06-05 14:57:29 +00:00
JingPiao Chen
692a6219a4 tests: check decoding of NETLINK_SELINUX message types
* tests/netlink_selinux.c: New file.
* tests/gen_tests.in (netlink_selinux): New entry.
* tests/pure_executables.list: Add netlink_selinux.
* tests/.gitignore: Likewise.
2017-06-05 14:57:29 +00:00
JingPiao Chen
a5eb0a4311 tests: check decoding of NETLINK_NETFILTER message types
* tests/netlink_netfilter.c: New file.
* tests/gen_tests.in (netlink_netfilter): New entry.
* tests/pure_executables.list: Add netlink_netfilter.
* tests/.gitignore: Likewise.
2017-06-05 14:57:27 +00:00
JingPiao Chen
f549c8f9e7 tests: check decoding of NETLINK_AUDIT message types
* tests/netlink_audit.c: New file.
* tests/gen_tests.in (netlink_audit): New entry.
* tests/pure_executables.list: Add netlink_audit.
* tests/.gitignore: Likewise.
2017-06-05 14:56:57 +00:00
JingPiao Chen
f7ee6e17be tests: check decoding of NETLINK_ROUTE message types
* tests/netlink_route.c: New file.
* tests/gen_tests.in (netlink_route): New entry.
* tests/pure_executables.list: Add netlink_route.
* tests/.gitignore: Likewise.
2017-06-05 14:56:30 +00:00
JingPiao Chen
a73c47710a tests: check decoding of NETLINK_SOCK_DIAG message types
* tests/netlink_sock_diag.c: New file.
* tests/netlink_sock_diag.test: New test.
* tests/pure_executables.list: Add netlink_sock_diag.
* tests/.gitignore: Likewise.
* tests/Makefile.am (DECODER_TESTS): Add netlink_sock_diag.test.
2017-06-05 14:56:09 +00:00
0d6d520521 tests: use create_nl_socket in netlink_protocol.test
* tests/netlink_protocol.c (main): Use create_nl_socket.
2017-06-05 14:56:09 +00:00
1274e27487 tests: change netlink_protocol.test to trace sendto syscalls only
* tests/gen_tests.in (netlink_protocol): Replace %network with sendto.
* tests/netlink_protocol.c (main): Update expected output.
2017-06-05 14:56:08 +00:00
5c8d11b682 tests: enhance create_nl_socket diagnostics messages
* tests/tests.h (create_nl_socket): Rename to create_nl_socket_ext,
add a string argument.
(create_nl_socket): New macro wrapper around create_nl_socket_ext.
* tests/create_nl_socket.c (create_nl_socket): Rename
to create_nl_socket_ext, add a string argument, include it
in diagnostic messages.
2017-06-05 14:51:26 +00:00
3245b58351 tests: use const and designated initializers in create_nl_socket.c
* tests/create_nl_socket.c: Stop including <string.h>.
(create_nl_socket): Use const and designated initializers.
2017-06-05 14:51:26 +00:00
JingPiao Chen
7005bcd451 tests: add create_nl_socket function to libtests
* tests/create_nl_socket.c: New file.
* tests/tests.h (create_nl_socket): New prototype.
* tests/Makefile.am (libtests_a_SOURCES): Add create_nl_socket.c.
2017-06-05 14:39:02 +00:00
e6cdfb6e84 tests: avoid hitting SO_SNDBUF limit in sendfile/sendfile64 tests
Do not assume that an executable is small enough and SO_SNDBUF is large
enough so that the executable could be sendfile'ed into a socket pair.

* tests/sendfile.c (main): Create a regular file of the right size
to avoid hitting SO_SNDBUF limit.
* tests/sendfile64.c: Likewise.

Reported-by: Andreas Schwab <schwab@linux-m68k.org>
2017-06-04 21:17:15 +00:00
8a3551abc8 tests: extend checking of NLMSG_DONE decoding
* tests/netlink_protocol.c (test_nlmsg_done):  Use designated
initializers.  Check decoding of messages with non-integer payload.
2017-06-04 13:40:17 +00:00
JingPiao Chen
852046ce0e netlink: decode NLMSG_DONE messages
* netlink.c (decode_payload): Decode NLMSG_DONE messages.
* tests/netlink_protocol.c (test_nlmsg_done): New function
for checking decoding of NLMSG_DONE messages.
(main): Use it.
2017-06-04 13:17:06 +00:00
0bcfa7b5cb tests: check decoding of sigaction syscall
* tests/sigaction.c: New file.
* tests/gen_tests.in (sigaction): New entry.
* tests/pure_executables.list: Add sigaction.
* tests/.gitignore: Likewise.
2017-05-28 17:13:29 +00:00
7830648b9f tests: rename sigaction.test to rt_sigaction.test
* tests/sigaction.awk: Rename to rt_sigaction.awk.
* tests/sigaction.c: Rename to tests/rt_sigaction.c.
* tests/sigaction.test: Rename to tests/rt_sigaction.test.
* tests/.gitignore: Replace sigaction with rt_sigaction.
* tests/pure_executables.list: Likewise.
* tests/Makefile.am (DECODER_TESTS): Replace sigaction.test
with rt_sigaction.test.
(EXTRA_DIST): Replace sigaction.awk with rt_sigaction.awk.
2017-05-28 17:13:29 +00:00
221da524ad tests: check decoding of sigpending syscall
* tests/sigpending.c: New file.
* tests/gen_tests.in (sigpending): New entry.
* tests/pure_executables.list: Add sigpending.
* tests/.gitignore: Likewise.
2017-05-28 00:09:52 +00:00
6715387c5c tests: check decoding of sigprocmask syscall
* tests/sigprocmask.c: New file.
* tests/gen_tests.in (sigprocmask): New entry.
* tests/pure_executables.list: Add sigprocmask.
* tests/.gitignore: Likewise.
2017-05-28 00:09:45 +00:00
ae1b07bc2a tests: check termination signal forwarding
* tests/run_expect_termsig.c: New file.
* tests/unblock_reset_raise.c: Likewise.
* tests/termsig.test: New test.
* tests/.gitignore: Add run_expect_termsig and unblock_reset_raise.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add termsig.test.
2017-05-27 17:59:44 +00:00
2d2bc8fdc1 tests: check how signals are unblocked in interactive mode
* tests/block_reset_raise_run.c: New file.
* tests/interactive_block.test: New test.
* tests/.gitignore: Add block_reset_raise_run.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add interactive_block.test.
2017-05-27 10:00:43 +00:00
ea64209ef7 tests: check decoding of signal syscall
* tests/signal.c: New file.
* tests/gen_tests.in (signal): New entry.
* tests/pure_executables.list: Add signal.
* tests/.gitignore: Likewise.
2017-05-26 20:42:13 +00:00
Eugene Syromyatnikov
d86b6bc773 Unify capitalisation of (c) in copyright notices 2017-05-26 19:43:11 +00:00
3b97ee486b Fix compat personality support for sgetmask syscall
* signal.c (SYS_FUNC(sgetmask)): Replace sprintsigmask_val
with sprint_old_sigmask_val.
* tests/sxetmask.c (main): Check decoding of signal mask containing
RT signals.
2017-05-23 23:20:18 +00:00
ba0bd3f1ec Fix decoding of sgetmask and ssetmask syscalls
Old ssetmask syscall takes an argument and returns a value of type int.
Old sgetmask syscall may return an error.

* signal.c (SYS_FUNC(ssetmask)): Explicitly convert the argument
and return value to unsigned int, print it using sprint_old_sigmask_val.
(SYS_FUNC(sgetmask)): Do not print the mask in case of syserror.
* tests/sxetmask.c: New file.
* tests/gen_tests.in (sxetmask): New entry.
* tests/pure_executables.list: Add sxetmask.
* tests/.gitignore: Likewise.
* NEWS: Mention this fix.
2017-05-22 17:33:51 +00:00
Eugene Syromyatnikov
9d095c7860 Add copyright headers 2017-05-22 17:33:51 +00:00
Eugene Syromyatnikov
e83c44c28e Fix typos in copyright notices 2017-05-22 19:11:06 +02:00
95ccc828fe tests: enhance sigsuspend.test
* tests/sigsuspend.c (sigtxt): New variable.
(main): Change signal masks to contain all signals except USR1 and USR2.
2017-05-21 14:37:48 +00:00
d852b31a8b alpha, cris, mips, ppc, sh, sparc: fix decoding of sigsuspend syscall
On some architectures old sigsuspend syscall takes the signal mask from
the 3rd argument, on some from the 1st.  And, if it wasn't peculiar
enough, the signal mask is passed by value on all architectures except
mips where it's passed by reference.

* signal.c (SYS_FUNC(sigsuspend)): Take the signal mask from the last
argument.
* linux/alpha/syscallent.h (sigsuspend): Set nargs to 1.
* linux/crisv10/syscallent.h: Likewise.
* linux/mips/syscallent-o32.h: Likewise.
* linux/powerpc/syscallent.h: Likewise.
* linux/powerpc64/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sparc64/syscallent.h: Likewise.
* tests/sigsuspend.c: New file.
* tests/gen_tests.in (sigsuspend): New entry.
* tests/pure_executables.list: Add sigsuspend.
* tests/.gitignore: Likewise.
* NEWS: Mention this fix.
2017-05-01 14:49:26 +00:00
d5959c52ab tests: raise default timeout for individual tests
Recently added tests based on pure_executables.list are quite slow
by their nature, the one minute default timeout is no longer enough
for some of not so fast architectures.

* tests/init.sh (TIMEOUT_DURATION): Raise from 60 to 120.
2017-05-01 14:49:26 +00:00
ab25ab1f43 tests: enhance madvise decoder check
* tests/mmap.c (main): Remove madvise check.
* tests/madvise.c: New file.
* tests/gen_tests.in (madvise): New entry.
* tests/.gitignore: Add madvise.
* tests/pure_executables.list: Likewise.
2017-04-27 23:16:33 +00:00
Eugene Syromyatnikov
bfcf14b7d1 tests: add -etrace=?... test
Check for some architecture-specific syscalls which are not present
on most architectures.

* gen_tests.in: Add trace_question test.
* tests/trace_question.in: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
2017-04-25 14:35:47 +00:00
Eugene Syromyatnikov
df490b89d1 tests: add more information to generated header comments
* tests/gen_tests.sh: Update header comment with the source string
used for test generation.
2017-04-25 14:35:47 +00:00
Eugene Syromyatnikov
b97ac5df12 tests: move generated common header comment into a variable
* tests/gen_tests.sh: Move generated file header comment
into a variable, use it in all cases.
2017-04-25 14:35:47 +00:00
e399ea2f7d tests: use TAIL_ALLOC_OBJECT_CONST_PTR in v4l2 test
* tests/ioctl_v4l2.c (main): Use TAIL_ALLOC_OBJECT_CONST_PTR.
2017-04-25 14:35:47 +00:00
Edgar Kaziahmedov
bc8eab0142 tests: Check decoding of VIDIOC_G/S_TUNER's arg
* tests/ioctl_v4l2.c (main): Add checks for VIDIOC_G/S_TUNER's arg.

Signed-off-by: Edgar Kaziahmedov <edos@linux.com>
2017-04-25 14:35:47 +00:00
89390d356b tests: check decoding of invalid tv_sec and tv_usec values
* tests/futimesat.c (main): Check decoding of invalid tv_sec and tv_usec
values.
* tests/xetitimer.c (main): Likewise.
* tests/xettimeofday.c (main): Likewise.
* tests/xselect.c (main): Likewise.
* tests/xutimes.c (main): Likewise.
2017-04-24 23:14:57 +00:00
8b86137d56 tests: check decoding of invalid tv_sec and tv_nsec values
* tests/aio.c (main): Check decoding of invalid tv_sec and tv_nsec
values.
* tests/clock_nanosleep.c (main): Likewise.
* tests/clock_xettime.c (main): Likewise.
* tests/futex.c (main): Likewise.
* tests/nanosleep.c (main): Likewise.
* tests/ppoll.c (main): Likewise.
* tests/pselect6.c (main): Likewise.
* tests/recvmmsg-timeout.c (main): Likewise.
* tests/rt_sigtimedwait.c (main): Likewise.
* tests/semop.c (main): Likewise.
* tests/timer_xettime.c (main): Likewise.
* tests/timerfd_xettime.c (main): Likewise.
* tests/utimensat.c (main): Likewise.
2017-04-24 23:14:57 +00:00
Eugene Syromyatnikov
4b8def02be Print time in ISO 8601 format in time syscall decoder
* print_time.c (SYS_FUNC(time)): Print timestamp stringification
(via sprinttime) for the value stored in the argument and return value
(return RVAL_STR in the latter case).
* tests/time.c (main): Update expected output.
2017-04-24 23:14:57 +00:00
Eugene Syromyatnikov
fcd8b63210 Print string representation of timestamps in parsers of *utime* syscalls
* print_timespec.c (print_timespec_t_utime): Use sprinttime_nsec
to format a string representation of time, use tprints_comment
to print it as a comment.
* print_timeval.c (print_timeval_t_utime): New function.
(print_timeval_utimes): Use it instead of print_timeval_t.
[ALPHA] (print_timeval32_t_utime): New function.
[ALPHA] (print_timeval32_utimes): Use it instead of print_timeval32_t.
* tests/futimesat.c (print_tv): Update expected output.
* tests/utimensat.c (print_ts): Likewise.
* tests/xutimes.c (print_tv): Likewise.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-04-24 23:14:57 +00:00
Eugene Syromyatnikov
a791580857 tests: add support for printing timestamp with microsecond precision
It will be needed later.

* tests/tests.h (print_time_t_usec): New prototype.
* tests/print_time.c (print_time_t_usec): New function, a thin wrapper
around print_time_t_ex.
2017-04-24 23:14:57 +00:00
Eugene Syromyatnikov
9c8ec0a80f Print microseconds/nanoseconds as non-negative
Negative micro/nanoseconds values are treated as invalid by kernel
anyway, and in one case (timespec_valid in include/linux/time.h)
it is even checked by conversion to unsigned long.

* print_timespec.c (timespec_fmt): Change tv_sec format to %lld and
tv_nsec format to %llu.
(print_timespec_t): Cast tv_sec to long long and process tv_nsec with
zero_extend_signed_to_ull.
(sprint_timespec): Likewise.
* print_timeval.c (timeval_fmt): Change tv_sec format to %lld and
tv_usec format to %llu.
(print_timeval_t): Cast tv_sec to long long and process tv_nsec with
zero_extend_signed_to_ull.
(sprint_timeval, print_timeval32_t, sprint_timeval32): Likewise.
* defs.h (TIMESPEC_TEXT_BUFSIZE): Update.
* tests/adjtimex.c (main): Change tv_sec printing format to %lld, cast
it to long long; change tv_usec printing format to %llu, process it with
zero_extend_signed_to_ull.
* tests/clock_nanosleep.c (main): Change tv_sec printing format to %lld,
cast it to long long; change tv_nsec printing format to %llu, process it
with zero_extend_signed_to_ull.
* tests/clock_xettime.c (main): Likewise.
* tests/futex.c (main): Likewise.
* tests/futimesat.c (print_tv): Likewise.
* tests/getrusage.c (invoke_print): Likewise.
* tests/mq_sendrecv.c (do_send, do_recv, main): Likewise.
* tests/nanosleep.c (main): Likewise.
* tests/pselect6.c (main): Likewise.
* tests/restart_syscall.c (main): Likewise.
* tests/rt_sigtimedwait.c (iterate, main): Likewise.
* tests/sched_rr_get_interval.c (main): Likewise.
* tests/semop.c (main): Likewise.
* tests/timer_xettime.c (main): Likewise.
* tests/timerfd_xettime.c (main): Likewise.
* tests/waitid.c (main): Likewise.
* tests/xetitimer.c (main): Likewise.
* tests/xettimeofday.c (main): Likewise.
* tests/xselect.c (main): Likewise.
* tests/xutimes.c (print_tv): Likewise.
* tests/wait4.c (sprint_rusage): Likewise.
* tests/waitid.c (sprint_rusage): Likewise.
* tests/utimensat.c (print_ts): Likewise.
(main): Add check for higher bits of tv_sec/tv_nsec.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-04-24 23:14:57 +00:00
Eugene Syromyatnikov
3277a2370a Always print raw values of time data fields
Refactor sprinttime: implement sprinttime_nsec and sprinttime_usec
that handle nanoseconds and microseconds, respectively.
Always print raw values of time data fields, format string
representations of time as comments.

* defs.h (sprinttime): Change argument type from time_t to long long.
(sprinttime_nsec, sprinttime_usec): New prototypes.
* util.c (sprinttime_ex, sprinttime_nsec, sprinttime_usec): New
functions.
(sprinttime): Turn into a thin wrapper around sprinttime_ex.
* stat.h (struct strace_stat): Add has_nsec field.
* fetch_struct_stat.c (HAVE_NSEC): New macro.
(fetch_struct_stat): Initialize has_nsec field with HAVE_NSEC.
* fetch_struct_stat64.c (HAVE_NSEC): New macro.
(fetch_struct_stat64): Initialize has_nsec field with HAVE_NSEC.
* print_struct_stat.c (print_struct_stat) <PRINT_ST_TIME>:
Print raw values of time fields, use sprinttime_nsec to format a string
representation of time, use tprints_comment to print it as a comment.
* statx.c (SYS_FUNC(statx)) <PRINT_FIELD_TIME>: Likewise.
* utime.c (SYS_FUNC(utime)): Print raw values of struct utimbuf.actime
and struct utimbuf.modtime fields, use sprinttime to format a string
representation of time, use tprints_comment to print it as a comment.
* tests/tests.h (print_time_t_nsec): Add int argument.
* tests/print_time.c (print_time_t_ex): New function.
(print_time_t_nsec): Add int argument, turn into a thin wrapper around
print_time_t_ex.
* tests/utime.c (main): Update expected output.
* tests/xstatx.c [!IS_STATX] (HAVE_NSEC): New macro.
[!IS_STATX] (PRINT_ST_TIME), [IS_STATX] (PRINT_FIELD_TIME): Update
expected output.
* NEWS: Mention this timestamps representation improvement.

Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
2017-04-24 23:14:57 +00:00
c34952709d Introduce tprintf_comment and tprints_comment functions
* defs.h (tprintf_comment, tprints_comment): New prototypes.
* strace.c (tvprintf): New function.
(tprintf): Use it.
(tprintf_comment, tprints_comment): New functions.
* aio.c (tprint_lio_opcode): Use tprints_comment.
* dm.c (dm_decode_dm_target_spec, dm_decode_dm_target_deps,
dm_decode_dm_name_list, dm_decode_dm_target_versions,
dm_decode_dm_target_msg, dm_decode_string, dm_known_ioctl): Likewise.
* futex.c (SYS_FUNC(futex)): Likewise.
* perf.c (print_perf_event_attr): Likewise.
* seccomp.c (decode_bpf_code): Likewise.
* util.c (printxvals, printxval_searchn, printflags64): Likewise.
* btrfs.c (print_u64, btrfs_print_key_type, btrfs_print_objectid,
print_key_value_internal): Likewise.
(btrfs_ioctl): Use tprints_comment and tprintf_comment.
* dirent.c (SYS_FUNC(getdents)): Likewise.
* dirent64.c (SYS_FUNC(getdents64)): Likewise.
* execve.c (printargc): Use tprintf_comment.
* tests/btrfs.c (btrfs_test_get_dev_stats_ioctl,
btrfs_test_features_ioctls): Update expected output.
2017-04-24 19:31:54 +00:00
37fc8e673a Make output of execve/execveat syscall parsers more structured
* execve.c (printargc): Always print the address, format the number
of variables as a comment.
* tests/execve.c: Update expected output.
* tests/execveat.c: Likewise.
* tests/qual_syscall.test: Likewise.
* tests/strace-r.expected: Likewise.
* tests/strace-t.test: Likewise.
* tests/strace-tt.test: Likewise.
* tests/strace-ttt.test: Likewise.
* tests/threads-execve.c: Likewise.
* tests/threads-execve.test: Likewise.
2017-04-24 19:22:11 +00:00
b5304784b5 dm: fix diagnostics about misplaced parts of struct dm_ioctl
* dm.c (dm_decode_dm_target_spec, dm_decode_dm_target_deps,
dm_decode_dm_name_list, dm_decode_dm_target_versions,
dm_decode_dm_target_msg, dm_decode_string, dm_known_ioctl): Fix
diagnostics about various misplaced parts of struct dm_ioctl.
* tests/ioctl_dm.c: Update expected output.
2017-04-24 19:14:41 +00:00
Eugene Syromyatnikov
0399062e41 tests: add faulty pointer check to time test
* tests/time.c (main): Add check for an inaccessible pointer.
2017-04-23 23:48:22 +00:00
27a4fd6dbb tests: fix print_time_t_nsec usage in xstatx.c
* tests/xstatx.c (print_stat): Pass tv_nsec field through
zero_extend_signed_to_ull before feeding it to print_time_t_nsec.
2017-04-22 00:15:41 +00:00
d1cca88c80 tests: fix netlink_protocol on sparc
* tests/netlink_protocol.c (test_nlmsgerr): Do not access fields of an
unaligned structure, this makes architectures like sparc very unhappy.
2017-04-21 23:01:22 +00:00
39f5742468 tests: remove stat.sample creation from gen_tests.in
stat.sample is created by appropriate executables and never removed.

* tests/gen_tests.in (trace_fstat, trace_lstat, trace_stat,
trace_stat_like): Remove stat.sample creation.
2017-04-21 19:49:03 +00:00