Unit testing the streaming

· by Steve · Read in about 2 min · (278 Words)

I’ve started unit testing the new base facilities I’ve added in resource-unstable since OgreMain is now building there. I’m using CppUnit to document the tests this time, since the tests I’m doing are internal in nature and don’t have the added complexity of having to check a visual result.

I’ve had a really annoying issue though - I’ve had to rebuild a lot of the dependencies (zlib, freetype, now zziplib) and I started to get really odd random crashes inside basic tools like _fstat and _lseek (which zziplib was using). Depending on the exact route that the code path took (either from my tests via OgreMain to zziplib to _lseek, or direct from my tests) I would get different results, and stepping through the _fstat implementation led me to believe that the code I was debugging wasn’t the code that was running (since the instruction pointer seemed inconsistent with ‘usual’ behaviour). In the end, I spent about 2 evenings trying various different approaches, and most of all making sure that all my runtime libraries were consistent. In the end, it appears to be that ‘_MT’ was not defined on all of my dependencies (zziplib and freetype, specifically), and that without them it was somewhat random which runtime library implementation I got - sometimes I would build and it would work, other times I’d change something small and it wouldn’t, I think because of the linker order subtly changing.

All in all it was a total pain in the arse and wasted tons of my time. So be warned, check all preprocessor defines on your dependencies as well as making sure the runtime library (LIBC, LIBCMT, MSVCRT) is consistent.