Enhance error diagnostics about invalid syscalls in fault injection syntax
* basic_filters.c (qualify_syscall_tokens): Remove "name" argument, assume its value is "system call". * filter.h (qualify_syscall_tokens): Remove "name" argument. All callers updated. * tests/qual_fault-syntax.test: Update expected output.
This commit is contained in:
parent
7ef06058e2
commit
24d48dde06
@ -197,8 +197,7 @@ qualify_syscall(const char *token, struct number_set *set)
|
||||
* according to STR specification.
|
||||
*/
|
||||
void
|
||||
qualify_syscall_tokens(const char *const str, struct number_set *const set,
|
||||
const char *const name)
|
||||
qualify_syscall_tokens(const char *const str, struct number_set *const set)
|
||||
{
|
||||
/* Clear all sets. */
|
||||
clear_number_set_array(set, SUPPORTED_PERSONALITIES);
|
||||
@ -242,13 +241,13 @@ qualify_syscall_tokens(const char *const str, struct number_set *const set,
|
||||
token = strtok_r(NULL, ",", &saveptr)) {
|
||||
done = qualify_syscall(token, set);
|
||||
if (!done)
|
||||
error_msg_and_die("invalid %s '%s'", name, token);
|
||||
error_msg_and_die("invalid system call '%s'", token);
|
||||
}
|
||||
|
||||
free(copy);
|
||||
|
||||
if (!done)
|
||||
error_msg_and_die("invalid %s '%s'", name, str);
|
||||
error_msg_and_die("invalid system call '%s'", str);
|
||||
}
|
||||
|
||||
/*
|
||||
|
3
filter.h
3
filter.h
@ -34,7 +34,6 @@ typedef int (*string_to_uint_func)(const char *);
|
||||
|
||||
void qualify_tokens(const char *str, struct number_set *set,
|
||||
string_to_uint_func func, const char *name);
|
||||
void qualify_syscall_tokens(const char *str, struct number_set *set,
|
||||
const char *name);
|
||||
void qualify_syscall_tokens(const char *str, struct number_set *set);
|
||||
|
||||
#endif /* !STRACE_FILTER_H */
|
||||
|
@ -203,7 +203,7 @@ qualify_trace(const char *const str)
|
||||
{
|
||||
if (!trace_set)
|
||||
trace_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
|
||||
qualify_syscall_tokens(str, trace_set, "system call");
|
||||
qualify_syscall_tokens(str, trace_set);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -211,7 +211,7 @@ qualify_abbrev(const char *const str)
|
||||
{
|
||||
if (!abbrev_set)
|
||||
abbrev_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
|
||||
qualify_syscall_tokens(str, abbrev_set, "system call");
|
||||
qualify_syscall_tokens(str, abbrev_set);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -219,7 +219,7 @@ qualify_verbose(const char *const str)
|
||||
{
|
||||
if (!verbose_set)
|
||||
verbose_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
|
||||
qualify_syscall_tokens(str, verbose_set, "system call");
|
||||
qualify_syscall_tokens(str, verbose_set);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -227,7 +227,7 @@ qualify_raw(const char *const str)
|
||||
{
|
||||
if (!raw_set)
|
||||
raw_set = alloc_number_set_array(SUPPORTED_PERSONALITIES);
|
||||
qualify_syscall_tokens(str, raw_set, "system call");
|
||||
qualify_syscall_tokens(str, raw_set);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -258,7 +258,7 @@ qualify_inject_common(const char *const str,
|
||||
|
||||
struct number_set *tmp_set =
|
||||
alloc_number_set_array(SUPPORTED_PERSONALITIES);
|
||||
qualify_syscall_tokens(name, tmp_set, description);
|
||||
qualify_syscall_tokens(name, tmp_set);
|
||||
|
||||
free(copy);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Check -e fault= syntax.
|
||||
#
|
||||
# Copyright (c) 2016-2017 Dmitry V. Levin <ldv@altlinux.org>
|
||||
# Copyright (c) 2016-2018 Dmitry V. Levin <ldv@altlinux.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -40,7 +40,7 @@ fail_with()
|
||||
"strace -e fault=$* failed to handle an argument error properly"
|
||||
}
|
||||
|
||||
for arg in '' , ,, ,,, : :: ::: \! \!, \!: \
|
||||
for arg in , ,, ,,, \! \!, \!: \
|
||||
invalid_syscall_name \
|
||||
invalid_syscall_name:when=3 \
|
||||
-1 \!-1 \
|
||||
@ -49,7 +49,20 @@ for arg in '' , ,, ,,, : :: ::: \! \!, \!: \
|
||||
-2:when=5 \
|
||||
32767 \!32767 \
|
||||
32767:when=6 \
|
||||
chdir:42 \!chdir:42 \
|
||||
file,nonsense \
|
||||
\!desc,nonsense \
|
||||
chdir,nonsense \
|
||||
\!chdir,nonsense \
|
||||
1,nonsense \
|
||||
\!1,nonsense \
|
||||
; do
|
||||
$STRACE -e fault="$arg" true 2> "$LOG" &&
|
||||
fail_with "$arg"
|
||||
LC_ALL=C grep -F "invalid system call '" < "$LOG" > /dev/null ||
|
||||
fail_with "$arg"
|
||||
done
|
||||
|
||||
for arg in '' : :: ::: chdir:42 \!chdir:42 \
|
||||
chdir:42:when=7 \
|
||||
chdir:invalid \
|
||||
chdir:invalid:when=8 \
|
||||
@ -92,12 +105,6 @@ for arg in '' , ,, ,,, : :: ::: \! \!, \!: \
|
||||
chdir:when=65536:error=30 \
|
||||
chdir:when=1+65536 \
|
||||
chdir:when=1+65536:error=31 \
|
||||
file,nonsense \
|
||||
\!desc,nonsense \
|
||||
chdir,nonsense \
|
||||
\!chdir,nonsense \
|
||||
1,nonsense \
|
||||
\!1,nonsense \
|
||||
chdir:retval=0 \
|
||||
chdir:signal=1 \
|
||||
chdir:error=1:error=2 \
|
||||
|
Loading…
x
Reference in New Issue
Block a user