Package: sngrep Version: 1.2.0-1 Tags: patch sngrep fails to build because the testcases test-004, test-005 and test-005 fail, e.g.: https://buildd.debian.org/status/fetch.php?pkg=sngrep&arch=hppa&ver=1.2.0-1&stamp=1452639207
It turns out, that this is a bug in the C-code of the testcases of sngrep which affects only big-endian machines (e.g. s390x, ppc64 and hppa). Testcases 1,2,3 and 7 defines the keystroke table correctly like this: const char keys[] = {...}; while testcases 4,5 and 6 define the keystrokes like this (with "int" type): const int keys[] = {...}; In tests/test_input.c each various key is then written with: unused = write(ppipe[1], &keys[i], sizeof(char)); Please note the usage of "char" vs. "int" in the keys tables above. If "int" is used, then on big-endian machines the &keys[i] refers to the first byte of each 2-byte (int) value, which is on big-endian machines the higher-8-bit value which is "0", while on little-endian machines the lower 8-bit-value which is the key which was actually defined. So, the attached patch fixes this problem for all machines regardless of the endianess and adds a check to tests/test_input.c like this: const char keys[]; That way at least a compiler warning will be generated if new testcases with "int" usage would be added. Can you please apply this patch to the next upload of sngrep and/or report this upstream ? Thanks, Helge PS: I still wonder why the testcases 4-6 didn't broke on all other big-endian arches. I assume the compiler did some optimization of the "int"-based-keys table and as such just hided the coding problem...
diff -up ./tests/test_004.c.org ./tests/test_004.c --- ./tests/test_004.c.org 2016-01-13 17:12:19.119482967 +0100 +++ ./tests/test_004.c 2016-01-13 17:12:51.303469253 +0100 @@ -25,7 +25,7 @@ * * Basic Call Raw testing */ -const int keys[] = +const char keys[] = { /* Select some dialogs */ 32, 107, 107, 107, 32, 107, diff -up ./tests/test_005.c.org ./tests/test_005.c --- ./tests/test_005.c.org 2016-01-13 17:06:23.367642939 +0100 +++ ./tests/test_005.c 2016-01-13 17:13:01.559464906 +0100 @@ -26,7 +26,7 @@ * Basic Column selection testing */ -const int keys[] = +const char keys[] = { /* Show Raw panel */ 't', diff -up ./tests/test_006.c.org ./tests/test_006.c --- ./tests/test_006.c.org 2016-01-13 17:06:29.147640213 +0100 +++ ./tests/test_006.c 2016-01-13 17:13:12.079460465 +0100 @@ -25,7 +25,7 @@ * * Basic Message diff testing */ -const int keys[] = +const char keys[] = { /* Select some dialog */ 107, 107, 107, 32, 10, diff -up ./tests/test_input.c.org ./tests/test_input.c --- ./tests/test_input.c.org 2016-01-14 09:26:47.258821143 +0100 +++ ./tests/test_input.c 2016-01-14 09:25:08.806832567 +0100 @@ -47,6 +47,9 @@ #define TEST_PCAP_INPUT "aaa.pcap" #endif +/* keys array needs to be of type "char" */ +const char keys[]; + int main() {