Add support for alternative error/signal names

There are some error and signal constants that are defined as a synonyms
for other errors/sugnals. Let's support their qualification.

* filter_qualify.c (struct alt_name): New type definition.
(alt_signames, alt_errnames): New variables.
(sigstr_to_uint): Check alt_signames for possible alternative signal
name usage.
(find_errno_by_name): Check alt_errnames for possible alternative error
name usage.
* linux/alpha/alt_errnoent.h: New file.
* linux/alpha/alt_signalent.h: Likewise.
* linux/alt_errnoent.h: Likewise.
* linux/alt_signalent.h: Likewise.
* linux/hppa/alt_errnoent.h: Likewise.
* linux/mips/alt_errnoent.h: Likewise.
* linux/mips/alt_signalent.h: Likewise.
* linux/powerpc/alt_errnoent.h: Likewise.
* linux/powerpc64/alt_errnoent.h: Likewise.
* linux/sparc/alt_errnoent.h: Likewise.
* linux/sparc/alt_signalent.h: Likewise.
* linux/sparc64/alt_signalent.h: Likewise.
* tests/qual_signal.test: Add some checks for alternative signal names.
This commit is contained in:
Eugene Syromyatnikov 2018-10-07 05:34:36 +02:00
parent 323c689701
commit 3a94852d43
14 changed files with 119 additions and 2 deletions

View File

@ -48,6 +48,21 @@ struct inject_personality_data {
uint16_t scno;
};
struct alt_name {
const char *syn;
const char *orig;
};
#define _(a_, b_) { (a_), (b_) }
static const struct alt_name alt_signames[] = {
#include "linux/alt_signalent.h"
};
static const struct alt_name alt_errnames[] = {
#include "linux/alt_signalent.h"
};
#undef _
static bool
signame_eq(const char *needle, const char *straw)
{
@ -65,6 +80,13 @@ signame_eq(const char *needle, const char *straw)
static int
sigstr_to_uint(const char *s)
{
for (size_t i = 0; i < ARRAY_SIZE(alt_signames); i++) {
if (!signame_eq(s, alt_signames[i].syn)) {
s = alt_signames[i].orig;
break;
}
}
if (*s >= '0' && *s <= '9')
return string_to_uint_upto(s, nsig);
@ -80,6 +102,13 @@ sigstr_to_uint(const char *s)
static int
find_errno_by_name(const char *name)
{
for (unsigned int i = 0; i < ARRAY_SIZE(alt_errnames); ++i) {
if (!strcasecmp(name, alt_errnames[i].syn)) {
name = alt_errnames[i].orig;
break;
}
}
for (unsigned int i = 1; i < nerrnos; ++i) {
if (errnoent[i] && (strcasecmp(name, errnoent[i]) == 0))
return i;

View File

@ -0,0 +1,2 @@
_("EWOULDBLOCK", "EAGAIN"),
_("EDEADLOCK", "EDEADLK" ),

View File

@ -0,0 +1,4 @@
_("SIGPOLL", "SIGIO"),
_("SIGUNUSED", "31"),
_("SIGPWR", "SIGINFO"),
_("SIGIOT", "SIGABRT"),

3
linux/alt_errnoent.h Normal file
View File

@ -0,0 +1,3 @@
_("EWOULDBLOCK", "EAGAIN" ),
_("ENOTSUP", "EOPNOTSUPP"),
_("EDEADLOCK", "EDEADLK"),

4
linux/alt_signalent.h Normal file
View File

@ -0,0 +1,4 @@
_("SIGPOLL", "SIGIO"),
_("SIGUNUSED", "31"),
_("SIGINFO", "SIGPWR"),
_("SIGIOT", "SIGABRT"),

View File

@ -0,0 +1,5 @@
_("EWOULDBLOCK", "EAGAIN"),
_("EDEADLOCK", "EDEADLK"),
_("EREFUSED", "ECONNREFUSED"),
_("ECANCELED", "ECANCELLED"),

View File

@ -0,0 +1 @@
_("EWOULDBLOCK", "EAGAIN"),

View File

@ -0,0 +1,4 @@
_("SIGPOLL", "SIGIO"),
_("SIGUNUSED", "31"),
_("SIGINFO", "SIGPWR"),
_("SIGABRT, ""SIGIOT"),

View File

@ -0,0 +1,2 @@
_("EWOULDBLOCK", "EAGAIN"),
_("ENOTSUP", "EOPNOTSUPP"),

View File

@ -0,0 +1 @@
#include "powerpc/alt_errnoent.h"

View File

@ -0,0 +1 @@
_("EWOULDBLOCK", "EAGAIN"),

View File

@ -0,0 +1,4 @@
_("SIGPOLL", "SIGIO"),
_("SIGUNUSED", "31"),
_("SIGPWR", "SIGLOST"),
_("SIGIOT", "SIGABRT"),

View File

@ -0,0 +1 @@
#include "sparc/alt_signalent.h"

View File

@ -40,17 +40,27 @@ test_one_sig()
match_diff "$LOG" "$EXP"
}
test_sigs()
test_sigs_ex()
{
local first second sigs
first_id="$1"; shift
first="$1"; shift
second_id="$1"; shift
second="$1"; shift
for sigs; do
test_one_sig "$sigs" 2 "$first" 15 "$second"
test_one_sig "$sigs" "$first_id" "$first" "$second_id" "$second"
done
}
test_sigs()
{
local first
first="$1"; shift
test_sigs_ex 2 "$first" 15 "$@"
}
test_sigs '' '' \
none '!all' \
CHLD SIGCHLD ALRM SIGALRM \
@ -94,6 +104,52 @@ test_sigs SIGINT SIGTERM \
'!CHLD,SIGALRM' '!ALRM,SIGCHLD' \
'!9' '!9,4' '!9,4,11' '!4,CHLD,11,ALRM,9'
case "$STRACE_ARCH" in
alpha)
test_sigs '' '' \
none '!all' \
POLL UNUSED SIGPOLL SIGUNUSED \
poll unused sigpoll sigunused \
POLL,UNUSED SIGPOLL,UNUSED POLL,SIGUNUSED \
unused,poll unused,sigpoll sigunused,poll
PWR IOT SIGPWR SIGIOT \
pwr iot sigpwr sigiot \
PWR,IOT PWR,SIGIOT SIGPWR,IOT \
iot,pwr sigiot,pwr iot,siginfo
;;
*)
test_sigs_ex 29 '' 31 SIGSYS \
UNUSED SIGUNUSED unused sigunused \
POLL,UNUSED SIGPOLL,UNUSED POLL,SIGUNUSED \
unused,poll unused,sigpoll sigunused,poll
test_sigs_ex 29 SIGIO 31 '' \
POLL SIGPOLL poll sigpoll \
POLL,UNUSED SIGPOLL,UNUSED POLL,SIGUNUSED \
unused,poll unused,sigpoll sigunused,poll
test_sigs_ex 29 SIGIO 31 SIGSYS \
POLL UNUSED SIGPOLL SIGUNUSED \
poll unused sigpoll sigunused \
POLL,UNUSED SIGPOLL,UNUSED POLL,SIGUNUSED \
unused,poll unused,sigpoll sigunused,poll
test_sigs_ex 30 '' 6 SIGABRT \
IOT SIGIOT iot sigiot \
INFO,IOT INFO,SIGIOT SIGINFO,IOT \
iot,info sigiot,info iot,siginfo
test_sigs_ex 30 SIGPWR 6 '' \
INFO SIGINFO info siginfo \
INFO,IOT INFO,SIGIOT SIGINFO,IOT \
iot,info sigiot,info iot,siginfo
test_sigs_ex 30 SIGPWR 6 SIGABRT \
INFO IOT SIGINFO SIGIOT \
info iot siginfo sigiot \
INFO,IOT INFO,SIGIOT SIGINFO,IOT \
iot,info sigiot,info iot,siginfo
;;
esac
fail_with()
{
dump_log_and_fail_with \