tests: fix signo to signame lookup in opr/softsig tests 67/12367/3
authorMichael Meffie <mmeffie@sinenomine.net>
Tue, 16 Aug 2016 16:56:47 +0000 (12:56 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 16 Dec 2016 20:20:39 +0000 (15:20 -0500)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

tests/opr/softsig-helper.c

index 91fa351..416f07c 100644 (file)
@@ -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;
        }