[exim-dev] C question for test suite.

Pàgina inicial
Delete this message
Reply to this message
Autor: John Jetmore
Data:  
A: exim-dev
Assumpte: [exim-dev] C question for test suite.
I think I may have figured out why so many people are having a hard
time with the test suite - Phil's "cf" tool, which is used in just
about every test, doesn't seem to compile cleanly on 64bit OSs.
Specifically it segfaults. I think I tracked down why but I need some
help addressing in a portable manner.

The program in question can be reviewed here:

http://git.exim.org/users/jetmore/exim.git/blob_plain/HEAD:/test/src/cf.c

Here's the compilation output (From Mac OS X):

> gcc -g -O2 -o bin/cf src/cf.c

src/cf.c: In function 'readline_one':
src/cf.c:357: warning: cast from pointer to integer of different size
src/cf.c:357: warning: cast to pointer from integer of different size
src/cf.c: In function 'readline_two':
src/cf.c:406: warning: cast from pointer to integer of different size
src/cf.c:406: warning: cast to pointer from integer of different size

Here's what you get when you run it:

> bin/cf -exact test-mainlog-munged log/0383

Segmentation fault

Here are the specific lines that the compiler complained about:

357: bufnext_one = (char *) (((int)bufnext_one+3) & (-4));
406: bufnext_two = (char *) (((int)bufnext_two+3) & (-4));

I can only kind of keep up with what's going on there, but it appears
the source of the problem is a size difference between int and char*.
I went back and checked and on every platform I've had the test suite
working on sizeof(int) was 4 and sizeof(char*) was also 4. On both my
MacBook and tahini sizeof(int) is 4 and sizeof(char*) is 8.

So I really have two problems - can anyone unroll the lines in
question such that they don't rely on the types being the same size,
and, depending on the trick, any ideas how to make it portable? (the
test suite is under autoconf so that can be leveraged if needed).

In the mean time there's an option to run the testsuite with diff
instead of cf to compare files, but it would be nice to get cf
working, both tools have their places.

Thanks
--John