1879 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
941fe71851 btrfs: refactor timespec printing into print_btrfs_timespec
* btrfs.c (print_btrfs_timespec): New function.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_SET_RECEIVED_SUBVOL>:
Use print_btrfs_timespec for printing stime and rtime fields.
* tests/btrfs.c (btrfs_test_set_received_subvol_ioctl): Update expected
output.
2018-04-20 12:39:05 +00:00
Eugene Syromyatnikov
85e7619e5b btrfs: print abbreviations and field names more consistently
* btrfs.c (btrfs_print_data_container_header): Do not print ", val=".
(btrfs_print_ino_path_container): Print val field name only in case
of non-abbreviated output.
(btrfs_print_qgroup_inherit): Print qgroups field name only in case
of non-abbreviated output.
(btrfs_print_tree_search): Print buf field name only in case
of non-abbreviated output.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_SEND>: Print
clone_sources field name only in case of non-abbreviated output.
(MPERS_PRINTER_DECL(btrfs_ioctl)) <case BTRFS_IOC_SPACE_INFO>: Print
spaces field name only in case of non-abbreviated output.
* tests/btrfs.c: Update expected output.
2018-04-20 12:39:05 +00:00
Eugene Syromyatnikov
f4118d896c btrfs: convert btrfs_print_{objectid,key_type} to PRINT_FIELD_XVAL_U
* btrfs.c (btrfs_print_key_type, btrfs_print_objectid): Convert into
thin wrappers around PRINT_FIELD_XVAL_U.
(btrfs_print_data_container_header, btrfs_print_tree_search,
MPERS_PRINTER_DECL(btrfs_ioctl)): Update calls to btrfs_print_key_type
and btrfs_print_objectid in accordance with the new calling convention.
(print_objectid_callback): Use printxvals_ex directly instead of
btrfs_print_objectid call.
* tests/btrfs.c (btrfs_print_objectid, btrfs_print_key_type): Update
expected output.
2018-04-20 12:39:05 +00:00
Eugene Syromyatnikov
321f9be806 tests: add btrfs tests with verbose xlat decoding
* tests/btrfs-X.test: New test.
* tests/btrfs-vX.test: Likewise.
* tests/btrfs-vwX.test: Likewise.
* tests/btrfs-wX.test: Likewise.
* tests/Makefile.am (DECODER_TESTS): Add them.
* tests/btrfs.c (verbose_xlat): New static variable.
(prfl_btrfs, prxval_btrfs): New function.
(btrfs_print_qgroup_inherit, btrfs_print_vol_args_v2,
btrfs_print_balance_args, btrfs_test_balance_ioctls,
btrfs_test_clone_ioctls, btrfs_test_defrag_ioctls,
btrfs_test_space_info_ioctl, btrfs_print_defrag_range_args,
btrfs_test_scrub_ioctls, btrfs_test_ino_path_ioctls,
btrfs_test_send_ioctl, btrfs_test_send_ioctl,
btrfs_test_quota_ctl_ioctl, btrfs_test_get_dev_stats_ioctl,
btrfs_test_get_dev_stats_ioctl, btrfs_test_dev_replace_ioctl,
btrfs_test_dev_replace_ioctl, btrfs_print_features): Use prfl_btrfs and
prxval_btrfs instead of printflags and printxval, respectively.
(btrfs_test_balance_ioctls, btrfs_test_ino_path_ioctls,
btrfs_test_quota_ctl_ioctl, btrfs_test_dev_replace_ioctl,
btrfs_test_dev_replace_ioctl): Update expected output based on
verbose_xlat setting.
(btrfs_print_defrag_range_args): Add compress_type_known arg, pass it
to prxval_btrfs.
(main): Handle -X option.
2018-04-20 12:39:05 +00:00
Eugene Syromyatnikov
ad7a72cd06 tests: check -X option syntax
* tests/options-syntax.test: Add checks for -X option with invalid
arguments.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-04-20 12:39:05 +00:00
Eugene Syromyatnikov
aa01b5368d bpf: print fields that interpreted as pointers using printaddr64
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_LOOKUP_ELEM),
BEGIN_BPF_CMD_DECODER(BPF_MAP_UPDATE_ELEM)): Print key and value
fields using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_MAP_DELETE_ELEM)): Print key field using
PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_MAP_GET_NEXT_KEY)): Print key and next_key
field using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)): Print insns and log_buf fields
using PRINT_FIELD_ADDR64.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_TEST_RUN)): Print data_in and data_out
fields using PRINT_FIELD_ADDR64.
* tests/bpf.c: Update expected output.
2018-04-20 12:39:05 +00:00
Eugene Syromyatnikov
25a5961610 bpf: add support for map_name and map_ifindex fields in BPF_MAP_CREATE
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_CREATE)): Decode map_name
and map_ifindex fields that were added in Linux commits
v4.15-rc1~84^2~605^2~3 and v4.16-rc1~123^2~145^2~5^2~8, respectively.
* bpf_attr.h (struct BPF_MAP_CREATE_struct): Add map_name
and map_ifindex fields.
* tests/bpf.c (init_BPF_MAP_CREATE_attr7): New function.
(BPF_MAP_CREATE_checks): Remove const qualifier, add two more checks.
2018-04-12 23:00:29 +00:00
Eugene Syromyatnikov
b20f744662 bpf: improve handling of various sizes of BPF_MAP_CREATE attributes
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_CREATE)): Skip printing
the rest of the structure if len is less than the offset of the end
of max_entries, map_flags, or inner_map_fd field.
* tests/bpf.c (BPF_MAP_CREATE_checks): Add two more checks.
2018-04-12 23:00:29 +00:00
Eugene Syromyatnikov
b8ed708a54 tests: add checks for bpf BPF_MAP_CREATE arguments
* tests/bpf.c (BPF_MAP_CREATE_checks): Add two more checks.
2018-04-12 23:00:28 +00:00
34c7794cc1 tests: robustify signal delivery test against kernel bugs
Recent kernel siginfo changes, namely, v4.14-rc1~60^2^2~1,
v4.16-rc1~159^2~37, and v4.16-rc1~159^2~39, introduced ABI regressions
that render the whole siginfo interface unreliable.

Looks like the kernel side is not eager to fix the breakage,
so here is a workaround.

* tests/signal_receive.c (s_sig, s_code, s_pid, s_uid): New volatile
variables.
(handler): Add siginfo_t parameter, save siginfo_t fields.
(sig_print): Remove.
(main): Rewrite.  Use variables saved by handler to print expected
siginfo output. Print diagnostics in case of siginfo mismatch.
* strace.spec.in (%check): Extract the diagnostics.

Closes: https://github.com/strace/strace/issues/21
2018-04-11 22:01:37 +00:00
fd4a485828 tests: skip -k tests on unsupported architectures
* tests/strace-k.test: When actual strace -k output doesn't match the
expected output because of limited architecture support, skip the test
on architectures that are not currently supported by libdw.
2018-04-11 22:01:37 +00:00
c78af2c9cf tests: check corner cases of udev_monitor_netlink_header decoding
* tests/netlink_kobject_uevent.c (test_nlmsg_type_kernel): Create
a tail-allocated udev_monitor_netlink_header object and pass it
to sys_send.
(test_nlmsg_type_udev): Likewise.  Check decoding of
udev_monitor_netlink_header object that ends in unmapped memory region.
2018-04-11 22:01:37 +00:00
Harsha Sharma
968a545ab7 tests: check decoding of udev_monitor_netlink_header
* tests/netlink_kobject_uevent.c: Include <string.h>, <arpa/inet.h>,
and "netlink_kobject_uevent.h".
(test_nlmsg_type_udev, test_nlmsg_type_kernel): New functions.
(main): Use them.
2018-04-11 22:01:37 +00:00
Harsha Sharma
d94871775a tests: check basic decoding of PTP_* ioctl commands
* tests/ioctl_ptp.c: New file.
* tests/gen_tests.in (ioctl_ptp): New entry.
* tests/pure_executables.list: Add ioctl_ptp.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-04-11 15:41:40 +00:00
Eugene Syromyatnikov
39f61ef513 bpf: decode BPF_PROG_QUERY command
BPF_PROG_QUERY was introduced in Linux commit v4.15-rc1~84^2~558^2~6.

* xlat/bpf_commands.in (BPF_PROG_QUERY): New constant.
* xlat/bpf_query_flags.in: New file.
* bpf.c: Include it.
(DECL_BPF_CMD_DECODER): Add priv argument for passing tcb private data.
(BEGIN_BPF_CMD_DECODER(BPF_PROG_QUERY)): New function.
(SYS_FUNC(bpf)) <bpf_cmd_decoders>: Add BPF_PROG_QUERY entry.
(SYS_FUNC(bpf)): Fetch buf on entering and exiting, pass buf on exiting,
retrieve private data on exiting, pass it to decoder as well, explicitly
rework rc handling logic for size argument printing.
* bpf_attr.h (struct BPF_PROG_QUERY_struct): New structure declaration.
(BPF_PROG_QUERY_struct_size, expected_BPF_PROG_QUERY_struct_size): New
macro.
* tests/bpf.c: Add checks for BPF_PROG_QUERY command.
2018-04-10 03:38:10 +00:00
2713444cb7 unwind: prepare configure subsystem for alternative unwinders
Introduce --enable-stacktrace configure option to control whether
-k option support is compiled in, --with-libunwind option remains
available to control whether libunwind can be used as an unwinder.

* m4/st_demangle.m4: New file.
* m4/st_libunwind.m4: Likewise.
* m4/st_stacktrace.m4: Likewise.
* configure.ac: Replace all libunwind and libiberty checks
with a single st_STACKTRACE invocation.
* Makefile.am: Conditionalize checks for USE_LIBUNWIND and USE_DEMANGLE
on ENABLE_STACKTRACE.
[ENABLE_STACKTRACE] (strace_SOURCES): Append unwind.c and unwind.h.
* strace.1.in: Replace libunwind with an unwinder-agnostic wording.
* defs.h: Replace USE_LIBUNWIND with ENABLE_STACKTRACE.
* strace.c: Likewise.
(print_version): Print stack-trace instead of stack-unwind.
* syscall.c: Replace USE_LIBUNWIND with ENABLE_STACKTRACE.
* tests/Makefile.am: Likewise.  Replace LIBUNWIND_TESTS
with STACKTRACE_TESTS.
* tests/strace-V.test: Update expected output.
2018-04-08 22:01:12 +00:00
Eugene Syromyatnikov
cbaa5db24d bpf: implement decoding of prog_name and prog_ifindex fields
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_PROG_LOAD)): Add support for decoding
of prog_name (introduced in Linux commit v4.15-rc1~84^2~605^2~4) and
prog_ifindex (introduced as prog_target_ifindex in v4.15-rc1~84^2~127^2~13,
renamed in v4.15-rc1~15^2~5^2~3^2~7).
* bpf_attr.h [!BPF_OBJ_NAME_LEN] (BPF_OBJ_NAME_LEN): New macro constant.
[BPF_OBJ_NAME_LEN]: Check that BPF_OBJ_NAME_LEN is equal to 16.
(struct BPF_PROG_LOAD_struct): Add prog_name and prog_ifindex fields.
(BPF_PROG_LOAD_struct_size, expected_BPF_PROG_LOAD_struct_size): Update.
* tests/bpf.c (init_BPF_PROG_LOAD_attr): Rename
to init_BPF_PROG_LOAD_attr3.
(print_BPF_PROG_LOAD_attr): Rename to print_BPF_PROG_LOAD_attr3.
(init_BPF_PROG_LOAD_attr4, print_BPF_PROG_LOAD_attr4): New functions.
(BPF_PROG_LOAD_checks): Check new decoding features.
2018-04-08 22:01:12 +00:00
958cb40a6e tests: robustify strace -k tests
Allow __getpid as an alternative name for getpid,
allow __kernel_vsyscall after getpid.

* tests/strace-k.expected: New file.
* tests/strace-k-demangle.expected: Likewise.
* tests/Makefile.am (EXTRA_DIST): Add them.
* tests/strace-k-demangle.test (expected): Remove.
* tests/strace-k.test: Likewise.  Use grep to check the output.
2018-04-07 23:35:45 +00:00
6bc832e2bc Update copyright headers
Headers updated automatically using maint/update_copyright_years.sh
script.
2018-04-05 01:40:00 +00:00
4eeba4e60f tests: robustify options-syntax.test against ash
* tests/options-syntax.test: Do not assume that shell provides $UID,
use "id -u" if it doesn't.
2018-04-04 21:36:07 +00:00
Eugene Syromyatnikov
698e9c30d4 strace.c: support simultaneous usage of -r and -t options
* strace.c (init): Do not set tflag when rflag is set.
(printleader): Handle rflag and tflag separately.
* strace.1.in (.SH OPTIONS): Add a note about differences between
the monotonic clock time  and the wall clock time.
* tests/options-syntax.test: Remove the check for
"-tt has no effect with -r" warning.
* NEWS: Mention this.

Suggested-by: Josh Triplett <josh@freedesktop.org>
Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466195
2018-04-04 20:32:42 +00:00
Eugene Syromyatnikov
bed7622d49 syscall.c: dump write I/O even if error is returned
It makes sense to try to dump the argument of write syscalls as they can
be readily available despite the fact that error has been returned.

* syscall.c (dumpio): Move check for syserror and check for fd in
read_set to the end of the function.
* tests/read-write.c: Add a check for this behaviour.
* tests/pread64-pwrite64.c: Update expected output.
* NEWS: Mention this.

Suggested-by: J. Bruce Fields <bfields@fieldses.org>
Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=436284
2018-04-04 20:32:42 +00:00
Eugene Syromyatnikov
a02a583b3f strace: handle possible NULL from localtime() call
* strace.c (printleader): Print raw tv_sec value if localtime() returned
NULL.
* tests/localtime.c: New file.
* tests/localtime.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add localtime.
(MISC_TESTS): Add localtime.test.
(localtime_LDADD): New variable.
* tests/.gitignore: Add localtime.
* ci/install-dependencies.sh (common_packages): Add faketime.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Closes: https://github.com/strace/strace/issues/42
2018-04-04 20:32:42 +00:00
a2e4217c95 tests: check decoding of bpf_attr of size 1
* tests/bpf.c (BPF_PROG_GET_NEXT_ID_checks): New entry.
2018-04-04 16:33:19 +00:00
Eugene Syromyatnikov
c5efe0a896 bpf: use print_big_u64_addr
Since pointers stored in the bpf_attr union are 64-bit regardless
of architecture bitness.

* bpf.c (DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Call print_big_u64_addr
for attr.license.
(DEF_BPF_CMD_DECODER(BPF_OBJ_PIN)): Call print_big_u64_addr
for attr.pathname.
* tests/bpf.c (BPF_OBJ_PIN_checks): Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-04-04 16:33:19 +00:00
Eugene Syromyatnikov
8e439e10f0 bpf: add support for file mode flags
These were introduced by Linux commit v4.15-rc1~84^2~384^2~4.

* bpf_attr.h (struct BPF_OBJ_PIN_struct): Add file_flags field.
(struct BPF_PROG_GET_NEXT_ID_struct, struct BPF_PROG_GET_FD_BY_ID_struct,
struct BPF_MAP_GET_FD_BY_ID_struct): Add open_flags field.
(BPF_OBJ_PIN_struct_size, expected_BPF_OBJ_PIN_struct_size,
expected_BPF_PROG_GET_NEXT_ID_struct_size,
expected_BPF_PROG_GET_FD_BY_ID_struct_size,
expected_BPF_MAP_GET_FD_BY_ID_struct_size): Update.
* bpf.c (DEF_BPF_CMD_DECODER(BPF_OBJ_PIN)): Check the length, skip
printing the rest of attributes if it is less than offset of the
end of the bpf_fd field, print file_flags field otherwise.
(DEF_BPF_CMD_DECODER(BPF_PROG_GET_NEXT_ID),
DEF_BPF_CMD_DECODER(BPF_PROG_GET_FD_BY_ID),
DEF_BPF_CMD_DECODER(BPF_MAP_GET_FD_BY_ID)): Check the length, skip
printing the rest of attributes if it is less than offset of the
end of the next_id field, print open_flags field otherwise.
* xlat/bpf_file_mode_flags.in: New file.
* tests/bpf.c (BPF_OBJ_PIN_checks, BPF_PROG_GET_NEXT_ID_checks,
BPF_PROG_GET_FD_BY_ID_checks, BPF_MAP_GET_FD_BY_ID_checks): Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-04-04 16:33:19 +00:00
Eugene Syromyatnikov
737762cb85 tests: refactor bpf test
The aim of this change is to introduce an ability to perform multiple
checks for a specific bpf command.  In order to achieve so, all the
related data is stored in check descriptor, and test_bpf iterates over
it.  There are also some provisions made in regard to future changes
(specifically, the way bpf_attr_data union is defined).

* tests/bpf.c (print_bpf_attr): New function, a wrapper around
struct bpf_check.printer.
(test_bpf_): Rename to...
(test_bpf): ...this.  Replace arguments with struct bpf_check pointer.
Iterate over possible attribute variants. Account for changes in
attribute initialisation routine: provide a pointer to locally defined
union bpf_attr_data and perform memcpy afterwards. Initialise memory
from data each time before a bpf call.
(TEST_BPF, DEF_*, init_*, print_*): Remove.
(init_BPF_PROG_LOAD_attr, print_BPF_PROG_LOAD_attr,
init_BPF_OBJ_PIN_attr): New functions.
(license, pathname): New variables.
(BPF_MAP_CREATE_checks, BPF_MAP_LOOKUP_ELEM_checks,
BPF_MAP_UPDATE_ELEM_checks, BPF_MAP_DELETE_ELEM_checks,
BPF_MAP_GET_NEXT_KEY_checks, BPF_PROG_LOAD_checks, BPF_OBJ_PIN_checks,
BPF_PROG_ATTACH_checks, BPF_PROG_DETACH_checks,
BPF_PROG_TEST_RUN_checks, BPF_PROG_GET_NEXT_ID_checks,
BPF_PROG_GET_FD_BY_ID_checks, BPF_MAP_GET_FD_BY_ID_checks,
BPF_OBJ_GET_INFO_BY_FD_checks): New arrays.
(BPF_OBJ_GET_checks, BPF_MAP_GET_NEXT_ID_checks): New macros.
(CHK): New macro, a shorthand for initialising array of struct bpf_check.
(main): New static constant checks, iterate over checks and run test_bpf
with each element.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-04-04 16:33:19 +00:00
3428c8b164 tests: check bpf syscall decoder unconditionally
* configure.ac (AC_CHECK_HEADERS([linux/bpf.h])): Check for
struct bpf_insn.
* tests/bpf.c: Remove the test guard, include "scno.h", "bpf_attr.h",
"xlat.h", and "xlat/bpf_commands.h".  Conditionalize inclusion of
<linux/bpf.h> on HAVE_LINUX_BPF_H.  Remove all HAVE_UNION_* checks.
(BPF_ATTR_DATA_FIELD): New macro.
(bpf_attr_data): New union.  Note that it is larger than modern
union bpf_attr, this allows more checks to be implemented in the future.
(sizeof_attr, test_bpf_): Replace union bpf_attr with
union bpf_attr_data.
(DEF_BPF_INIT_FIRST): Replace union bpf_attr with the corresponding
structure.
(init_BPF_MAP_CREATE_attr): Replace union bpf_attr with
struct BPF_MAP_CREATE_struct.
(init_BPF_MAP_LOOKUP_ELEM_attr): Replace union bpf_attr with
struct BPF_MAP_LOOKUP_ELEM_struct.
(init_BPF_MAP_UPDATE_ELEM_attr): Replace union bpf_attr with
struct BPF_MAP_UPDATE_ELEM_struct.
(init_BPF_MAP_DELETE_ELEM_attr): Replace union bpf_attr with
struct BPF_MAP_DELETE_ELEM_struct.
(init_BPF_MAP_GET_NEXT_KEY_attr): Replace union bpf_attr with
struct BPF_MAP_GET_NEXT_KEY_struct.
(init_BPF_PROG_LOAD_attr): Replace union bpf_attr with
struct BPF_PROG_LOAD_struct.
(init_BPF_OBJ_PIN_attr): Replace union bpf_attr with
struct BPF_OBJ_PIN_struct.
(init_BPF_PROG_ATTACH_attr): Replace union bpf_attr with
struct BPF_PROG_ATTACH_struct.
(init_BPF_PROG_DETACH_attr): Replace union bpf_attr with
struct BPF_PROG_DETACH_struct.
(init_BPF_PROG_GET_NEXT_ID_attr): Replace union bpf_attr with
struct BPF_PROG_GET_NEXT_ID_struct.
(sample_BPF_PROG_TEST_RUN_attr): Change type from union bpf_attr to
struct BPF_PROG_TEST_RUN_struct, all users updated.
(sample_BPF_OBJ_GET_INFO_BY_FD_attr): Change type from union bpf_attr
to struct BPF_OBJ_GET_INFO_BY_FD_struct, all users updated.
2018-04-04 12:24:19 +00:00
074f49451c tests: forward SIZEOF_KERNEL_LONG_T and SIZEOF_LONG to C preprocessor
* tests/Makefile.am (AM_CPPFLAGS): Forward SIZEOF_KERNEL_LONG_T
and SIZEOF_LONG as TESTS_SIZEOF_KERNEL_LONG_T and TESTS_SIZEOF_LONG.
* tests/tests.h [TESTS_SIZEOF_KERNEL_LONG_T] (SIZEOF_KERNEL_LONG_T):
Redefine to TESTS_SIZEOF_KERNEL_LONG_T.
[TESTS_SIZEOF_LONG] (SIZEOF_LONG): Redefine to TESTS_SIZEOF_LONG.

Complements: v4.21~5 ("Export SIZEOF_LONG and SIZEOF_KERNEL_LONG_T to tests")
2018-04-04 12:24:19 +00:00
ef1013795c tests/tests.h: fix indentation 2018-04-04 12:24:19 +00:00
d453156784 tests: fix potential errno clobbering in netlink_kobject_uevent.test
* tests/netlink_kobject_uevent.c (errstr): New variable.
(sys_send): New function.
(main): Use them.
2018-04-04 12:24:19 +00:00
Eugene Syromyatnikov
6d0b564103 tests/bpf.c: add a check for NULL bpf_attr pointer
* tests/bpf.c (main): Add a check with 0 passed in the third argument.
2018-04-01 13:14:15 +00:00
Eugene Syromyatnikov
ca6e35dc6e bpf: print byte range for extra data
As it could be not entirely clear what bytes are printed.

* bpf.c (decode_attr_extra_data): Print a comment about the byte range
to be printed.
* tests/bpf.c: Update expected output.
2018-04-01 13:14:15 +00:00
53b0d9c438 Add i18n support
Let's make a step towards the growing strace userbase all around
the world and translate something to the language of their choice.

This change enables translation of error messages corresponding
to errno codes, making it consistent with error diagnostics of other
i18n-aware tools, e.g.

$ LANG=es_ES strace -qq -a38 -P /missing unlink /missing
unlink("/missing")                    = -1 ENOENT (No existe el fichero o el directorio)
unlink: no se puede deshacer el enlace '/missing': No existe el fichero o el directorio

* strace.c: Include <locale.h>.
(main): Invoke setlocale.
* tests/init.sh: Export LC_ALL=C.
* NEWS: Mention this enhancement.
2018-04-01 13:14:15 +00:00
92d7499fbf Treat RVAL_DECIMAL the same way as RVAL_UDECIMAL
Assuming that syscalls may return negative values only as error codes,
always print non-error syscall return codes as unsigned.

* defs.h (RVAL_UDECIMAL): Remove.
(RVAL_DECIMAL): Rename to RVAL_UDECIMAL.
* syscall.c (syscall_exiting_trace) <case RVAL_DECIMAL>: Remove.
* clone.c (SYS_FUNC(fork)): Remove RVAL_UDECIMAL.
* lseek.c (SYS_FUNC(lseek)): Likewise.
* prctl.c (SYS_FUNC(prctl)): Likewise.
* uid.c (SYS_FUNC(getuid), SYS_FUNC(setfsuid)): Likewise.
* times.c (SYS_FUNC(times)): Always return 0.
* tests/inject-nf.c (main): Update expected output.
2018-03-29 16:00:18 +00:00
fc56ecefd1 tests: check handling of some invalid delay injection parameters
* tests/qual_inject-syntax.test: Check for negative delay injection
parameters.  Check for overriding delay injection parameters.
2018-03-29 01:30:09 +00:00
Eugene Syromyatnikov
4c9ed3f146 Implement injection of negative return values
Extend the range of injected return value to the maximum, print warnings
if negative injection value can be clipped in compat personality or can
inadvertently turn into a fault injection.

* defs.h (INJECT_F_ERROR): New macro.
* filter_qualify.c (parse_inject_token): Revert type of intval local
variable back to int, check INJECT_F_ERROR along with INJECT_F_RETVAL,
use strtoull to parse retval argument, print warnings in case of retval
clipping and inadvertent fault injection.
(qualify_inject_common): Set INJECT_F_ERROR instead of INJECT_F_RETVAL.
* syscall.c (tamper_with_syscall_exiting): Check inject_data.flags
to determine whether a fault injection or retval injection has to be
performed.
(syscall_exiting_trace) <case RVAL_DECIMAL>: Explicitly print
tcp->u_rval as int if current_klongsize < sizeof(tcp->u_rval).
* tests/inject-nf.c (main): Update.
* tests/inject-nf.test: Test injection of negative return values.
* tests/qual_inject-syntax.test: Remove retval=-1 check as it is now
allowed, add checks for invalid retval parameters.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-29 01:30:09 +00:00
Eugene Syromyatnikov
6f8bbc6fef tests: check decoding of kern_features syscall
* tests/kern_features.c: New file.
* tests/kern_features-fault.test: New test.
* tests/gen_tests.in (kern_features): New entry.
* tests/Makefile.am (DECODER_TESTS): Add kern_features-fault.test.
* tests/pure_executables.list: Add kern_features.
* tests/.gitignore: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-27 22:22:23 +00:00
Eugene Syromyatnikov
58598cd7f6 tests: check injection of return values into a "never fails" syscall
* tests/inject-nf.c: New file.
* tests/inject-nf.test: New test.
* tests/.gitignore: Add inject-nf.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add inject-nf.test.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-23 13:43:13 +00:00
73edd445e2 tests: fix potentially unbound variable in kernel_version_code
Fix the following use case:

	$ sh -uc '. tests/init.sh; kernel_version_code 4.5'
	tests/init.sh: line 242: 3: unbound variable

* tests/init.sh (kernel_version_code): Fix potentially unbound variable.
2018-03-23 13:43:13 +00:00
Eugene Syromyatnikov
51f0ef5140 tests/bpf.c: convert TEST_BPF_ macro to a function
As it looks like there's no compelling reason to keep it as a macro and
leaving it so quite complicates modification of the routine and makes
them error-prone.

* tests/bpf.c (TEST_BPF_): Convert it to...
(test_bpf): ...this.  Rename cmd_ to cmd, cmd_str_ to cmd_str,
init_first_ to init_first, print_first_ to print_first, init_attr_
to init_attr, print_attr_ to print_attr.
(TEST_BPF): Call test_bpf_ instead of TEST_BPF_.
2018-03-22 21:35:12 +00:00
Eugene Syromyatnikov
afb25ea58d tests: btrfs.c whitespace cleanup
* tests/btrfs.c: Add spaces after PRI* format specifiers.
2018-03-22 21:35:12 +00:00
Elvira Khabirova
a3bef655cb tests: check delay injection
* tests/delay.c: New file.
* tests/delay.test: New test.
* tests/.gitignore: Add delay.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(delay_LDADD): New variable.
(MISC_TESTS): Add delay.test.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-22 06:23:25 +00:00
Eugene Syromyatnikov
2bcf86777b bpf: improve handling of various sizes of bpf_prog_attr structure
As program attributes have been added gradually over kernel versions,
attribute size less than expected should be printed accordingly.

* bpf.c (DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Do not print structure
fields if their size is less than the initially introduced (in Linux
commit v3.18-rc1~52^2~1^2~7) version.  Print fields of union bpf_attr
introduced in various kernel versions when the length is big enough
(new fields were introduced in Linux commits v3.18-rc1~52^2~1^2~4,
v4.1-rc1~84^2~50, and v4.12-rc2~34^2~29^2~2).
* tests/bpf.c (print_BPF_PROG_LOAD_first): Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-21 05:00:03 +03:00
Eugene Syromyatnikov
8fa209cf0a btrfs: print struct btrfs_ioctl_logical_ino_args.reserved if non-zero
* btrfs.c (btrfs_ioctl) <case BTRFS_IOC_LOGICAL_INO>: Print
struct btrfs_ioctl_logical_ino_args.reserved field if it is not zero.
* tests/btrfs.c (btrfs_test_ino_path_ioctls): Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
2018-03-20 20:44:34 +00:00
dfccb60a75 Fix -O option handling
Fast syscalls usually take less than a microsecond of system cpu time
nowadays, making -O option almost useless.

* count.c (call_summary_pers): Avoid negative time counts.
* tests/count.test: Check it.
* NEWS: Mention it.
2018-03-20 02:30:24 +00:00
85b35818db build: do not hardcode -lrt
Depending on libc implementation, various -lrt functions can be
implemented either in -lc or in -lrt.  For example, starting with
glibc-2.17 the clock_* suite of functions is available directly in -lc.

Check whether clock_* and mq_* suites of functions are provided
by -lrt or by the main C library, do not link with -lrt unnecessarily.

This change affects only tests yet, but this is going to be
more important as soon as strace starts using clock_gettime.

* configure.ac (AC_SEARCH_LIBS): Check for clock_gettime and mq_open
in -lrt.
(AC_SUBST): Add clock_LIBS and mq_LIBS.
* tests/Makefile.am (mq_LDADD): Replace -lrt with $(mq_LIBS).
(threads_execve_LDADD, times_LDADD): Replace -lrt with $(clock_LIBS).
2018-03-14 21:15:55 +00:00
a51d9f9647 tests: do not link with -lrt unnecessarily
* tests/Makefile.am (attach_f_p_LDADD): Remove -lrt.
(clock_xettime_LDADD, mq_sendrecv_LDADD, mq_sendrecv_read_LDADD,
mq_sendrecv_write_LDADD): Remove.
2018-03-14 21:15:55 +00:00
3de1462ed8 tests: extend ioctl.test libc protection to -y output
* tests/ioctl.test: Extend the filter of ioctl calls with standard
descriptor arguments to -y output.
2018-03-13 01:53:04 +00:00
Chen Jingpiao
8932ac050e tests: add check for decoding of netfilter subsystem
* tests/netlink_netfilter.c(test_nfgenmsg): Add check for decoding
of netfilter subsystem.
2018-03-11 15:35:19 +00:00