From 3a94852d431029d4716a25f0c75fed3321d8fdb4 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Sun, 7 Oct 2018 05:34:36 +0200 Subject: [PATCH] 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. --- filter_qualify.c | 29 ++++++++++++++++ linux/alpha/alt_errnoent.h | 2 ++ linux/alpha/alt_signalent.h | 4 +++ linux/alt_errnoent.h | 3 ++ linux/alt_signalent.h | 4 +++ linux/hppa/alt_errnoent.h | 5 +++ linux/mips/alt_errnoent.h | 1 + linux/mips/alt_signalent.h | 4 +++ linux/powerpc/alt_errnoent.h | 2 ++ linux/powerpc64/alt_errnoent.h | 1 + linux/sparc/alt_errnoent.h | 1 + linux/sparc/alt_signalent.h | 4 +++ linux/sparc64/alt_signalent.h | 1 + tests/qual_signal.test | 60 ++++++++++++++++++++++++++++++++-- 14 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 linux/alpha/alt_errnoent.h create mode 100644 linux/alpha/alt_signalent.h create mode 100644 linux/alt_errnoent.h create mode 100644 linux/alt_signalent.h create mode 100644 linux/hppa/alt_errnoent.h create mode 100644 linux/mips/alt_errnoent.h create mode 100644 linux/mips/alt_signalent.h create mode 100644 linux/powerpc/alt_errnoent.h create mode 100644 linux/powerpc64/alt_errnoent.h create mode 100644 linux/sparc/alt_errnoent.h create mode 100644 linux/sparc/alt_signalent.h create mode 100644 linux/sparc64/alt_signalent.h diff --git a/filter_qualify.c b/filter_qualify.c index ee82402b..95936569 100644 --- a/filter_qualify.c +++ b/filter_qualify.c @@ -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; diff --git a/linux/alpha/alt_errnoent.h b/linux/alpha/alt_errnoent.h new file mode 100644 index 00000000..1436e95a --- /dev/null +++ b/linux/alpha/alt_errnoent.h @@ -0,0 +1,2 @@ +_("EWOULDBLOCK", "EAGAIN"), +_("EDEADLOCK", "EDEADLK" ), diff --git a/linux/alpha/alt_signalent.h b/linux/alpha/alt_signalent.h new file mode 100644 index 00000000..03ca0cdc --- /dev/null +++ b/linux/alpha/alt_signalent.h @@ -0,0 +1,4 @@ +_("SIGPOLL", "SIGIO"), +_("SIGUNUSED", "31"), +_("SIGPWR", "SIGINFO"), +_("SIGIOT", "SIGABRT"), diff --git a/linux/alt_errnoent.h b/linux/alt_errnoent.h new file mode 100644 index 00000000..ad4a2090 --- /dev/null +++ b/linux/alt_errnoent.h @@ -0,0 +1,3 @@ +_("EWOULDBLOCK", "EAGAIN" ), +_("ENOTSUP", "EOPNOTSUPP"), +_("EDEADLOCK", "EDEADLK"), diff --git a/linux/alt_signalent.h b/linux/alt_signalent.h new file mode 100644 index 00000000..45e25118 --- /dev/null +++ b/linux/alt_signalent.h @@ -0,0 +1,4 @@ +_("SIGPOLL", "SIGIO"), +_("SIGUNUSED", "31"), +_("SIGINFO", "SIGPWR"), +_("SIGIOT", "SIGABRT"), diff --git a/linux/hppa/alt_errnoent.h b/linux/hppa/alt_errnoent.h new file mode 100644 index 00000000..bf0cd16d --- /dev/null +++ b/linux/hppa/alt_errnoent.h @@ -0,0 +1,5 @@ +_("EWOULDBLOCK", "EAGAIN"), +_("EDEADLOCK", "EDEADLK"), +_("EREFUSED", "ECONNREFUSED"), +_("ECANCELED", "ECANCELLED"), + diff --git a/linux/mips/alt_errnoent.h b/linux/mips/alt_errnoent.h new file mode 100644 index 00000000..7f9188cc --- /dev/null +++ b/linux/mips/alt_errnoent.h @@ -0,0 +1 @@ +_("EWOULDBLOCK", "EAGAIN"), diff --git a/linux/mips/alt_signalent.h b/linux/mips/alt_signalent.h new file mode 100644 index 00000000..de1f0529 --- /dev/null +++ b/linux/mips/alt_signalent.h @@ -0,0 +1,4 @@ +_("SIGPOLL", "SIGIO"), +_("SIGUNUSED", "31"), +_("SIGINFO", "SIGPWR"), +_("SIGABRT, ""SIGIOT"), diff --git a/linux/powerpc/alt_errnoent.h b/linux/powerpc/alt_errnoent.h new file mode 100644 index 00000000..cc1994e2 --- /dev/null +++ b/linux/powerpc/alt_errnoent.h @@ -0,0 +1,2 @@ +_("EWOULDBLOCK", "EAGAIN"), +_("ENOTSUP", "EOPNOTSUPP"), diff --git a/linux/powerpc64/alt_errnoent.h b/linux/powerpc64/alt_errnoent.h new file mode 100644 index 00000000..09d0c519 --- /dev/null +++ b/linux/powerpc64/alt_errnoent.h @@ -0,0 +1 @@ +#include "powerpc/alt_errnoent.h" diff --git a/linux/sparc/alt_errnoent.h b/linux/sparc/alt_errnoent.h new file mode 100644 index 00000000..7f9188cc --- /dev/null +++ b/linux/sparc/alt_errnoent.h @@ -0,0 +1 @@ +_("EWOULDBLOCK", "EAGAIN"), diff --git a/linux/sparc/alt_signalent.h b/linux/sparc/alt_signalent.h new file mode 100644 index 00000000..d93a4537 --- /dev/null +++ b/linux/sparc/alt_signalent.h @@ -0,0 +1,4 @@ +_("SIGPOLL", "SIGIO"), +_("SIGUNUSED", "31"), +_("SIGPWR", "SIGLOST"), +_("SIGIOT", "SIGABRT"), diff --git a/linux/sparc64/alt_signalent.h b/linux/sparc64/alt_signalent.h new file mode 100644 index 00000000..6f0b1498 --- /dev/null +++ b/linux/sparc64/alt_signalent.h @@ -0,0 +1 @@ +#include "sparc/alt_signalent.h" diff --git a/tests/qual_signal.test b/tests/qual_signal.test index 52812b72..f1c13085 100755 --- a/tests/qual_signal.test +++ b/tests/qual_signal.test @@ -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 \