From 8b2c4665aabece187759157bda0e26c4b566dd2f Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Tue, 16 Aug 2016 12:56:47 -0400 Subject: [PATCH] tests: fix signo to signame lookup in opr/softsig tests Fix the loop condition when scanning the signal number to name table to convert a signal number to a name. Instead of looping sizeof(size_t) times, loop for the number of elements in the table. This bug was masked on 64 bit-platforms, since the signal number to name table table currently has 8 elements, which is coincidently the same as sizeof(size_t) on 64-bit platforms. The bug becomes apparent on 32-bit systems; only the first 4 elements of the table are checked. Example error output before this fix: $ cd tests $ ./libwrap ../lib ./runtests -o opr/softsig 1..11 ok 1 ok 2 ok 3 ok 4 ok 5 not ok 6 # Failed test in ./opr/softsig-t at line 57. # got: 'Received UNK # ' # expected: 'Received TERM # ' not ok 7 # Failed test in ./opr/softsig-t at line 60. # got: 'Received UNK # ' # expected: 'Received USR1 # ' not ok 8 # Failed test in ./opr/softsig-t at line 63. # got: 'Received UNK # ' # expected: 'Received USR2 # ' ok 9 - Helper exited on KILL signal. ok 10 - Helper exited on SEGV signal. ok 11 # skip Skipping buserror test; SIGBUS constant is not defined. # Looks like you failed 3 tests of 11. Change-Id: I863cc9f3650c4a5e9ac9159d90e063b986a8460a Reviewed-on: https://gerrit.openafs.org/12367 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- tests/opr/softsig-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/opr/softsig-helper.c b/tests/opr/softsig-helper.c index 91fa351073..416f07ca1f 100644 --- a/tests/opr/softsig-helper.c +++ b/tests/opr/softsig-helper.c @@ -55,7 +55,7 @@ static struct sigtable { static char *signame(int signo) { int i; - for (i = 0; i < sizeof(sizeof(sigtable) / sizeof(sigtable[0])); ++i) { + for (i = 0; i < sizeof(sigtable) / sizeof(sigtable[0]); ++i) { if (sigtable[i].signo == signo) { return sigtable[i].name; }