Archive: getting cppunit tests to work and pass on linux


getting cppunit tests to work and pass on linux
I tried to enable the cppunit tests in the debian package, but it didn't work.

Some issues:

The attached patch contains the changes I made while trying to get "scons test" to pass on my install. It does this mainly by turning off tests that fail.

Tests that failed:

Turning off compilation of the scripts is fine because we know what's wrong there. But turning off assertions defeats the purpose of the tests. The failure should not be ignored, the cause should be investigated.

Can you get a stack dump for the Plugins.cpp assertion failure? I can't reproduce it.

I was able to reproduce a segfault in mmap.cpp, but not an assertion failure. I'll look into it.


Indeed. The patch was just to show which assertions failed.

With the mmap failure, p2[j] is always 0 at the assertion point. CppUnit doesn't seem to raise a signal when an assertion is triggered, so I don't have a backtrace for this one. Is there any way to change this?

The Plugins.cpp error was with LogicLib.nsi, which uses System.dll (via Str*). I got the following backtrace when running under gdb.

Processing script file: ".test/Examples/LogicLib.nsi"
makensis: Source/Plugins.cpp:118: Value<unnamed>::get_value(const std::map<Key, Value, std::less<_Key>, std::allocator<std::pair<const _Key, _Tp> > >&, const Key&) [with Key = std::string, Value = std::string]: Assertion `the_map.find(key) != the_map.end()' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread -1210747200 (LWP 13424)]
0xb7d829e7 in raise () from /lib/tls/libc.so.6
(gdb) bt
#0 0xb7d829e7 in raise () from /lib/tls/libc.so.6
#1 0xb7d8431b in abort () from /lib/tls/libc.so.6
#2 0xb7d7b885 in __assert_fail () from /lib/tls/libc.so.6
#3 0x0806aff5 in (anonymous namespace)::get_value<std::string, std::string> (the_map=Variable "the_map" is not available.) at Source/Plugins.cpp:118
#4 0x0806a2c5 in Plugins::NormalizedCommand (this=0xbf9e02dc, command=@0xbf9cf1d4) at Source/Plugins.cpp:134
#5 0x0806a4dd in Plugins::IsPluginCommand (this=0xbf9e02dc, token=@0xbf9cf1d4) at Source/Plugins.cpp:110
#6 0x0808fd87 in CEXEBuild::doParse (this=0xbf9e0260, str=0x827ec68 " System::Int64Op `0x100000000` `=` `4294967296`") at Source/script.cpp:313
#7 0x0809059b in CEXEBuild::process_oneline (this=0xbf9e0260, line=0x81b7c5f " System::Int64Op `${_a}` `${_o}` `${_b}`", filename=0xbf9cf3a0 "macro:_Int64Cmp", linenum=0) at Source/script.cpp:751
#8 0x0808d81f in CEXEBuild::doCommand (this=0xbf9e0260, which_token=78, line=@0xbf9d36d4) at Source/script.cpp:983
#9 0x0808ff11 in CEXEBuild::doParse (this=0xbf9e0260, str=0x820d870 " !insertmacro _Int64Cmp `0x100000000` = `4294967296` `` `_542.5`") at Source/script.cpp:440
#10 0x0809059b in CEXEBuild::process_oneline (this=0xbf9e0260, line=0x81b7ceb " !insertmacro _Int64Cmp `${_a}` = `${_b}` `${_t}` `${_f}`", filename=0xbf9d38d0 "macro:_L=", linenum=0) at Source/script.cpp:751
#11 0x0808d81f in CEXEBuild::doCommand (this=0xbf9e0260, which_token=78, line=@0xbf9d7c04) at Source/script.cpp:983
#12 0x0808ff11 in CEXEBuild::doParse (this=0xbf9e0260, str=0x81e5820 " !insertmacro _L= `0x100000000` `4294967296` \"\" _542.5") at Source/script.cpp:440
#13 0x0809059b in CEXEBuild::process_oneline (this=0xbf9e0260, line=0x81b83df " !insertmacro _${_o} `${_a}` `${_b}` \"\" ${${_Logic}Else}", filename=0xbf9d7e00 "macro:_If", linenum=0) at Source/script.cpp:751
#14 0x0808d81f in CEXEBuild::doCommand (this=0xbf9e0260, which_token=78, line=@0xbf9dc134) at Source/script.cpp:983
#15 0x0808ff11 in CEXEBuild::doParse (this=0xbf9e0260, str=0x815a900 " !insertmacro _If true 0x100000000 L= 4294967296") at Source/script.cpp:440
#16 0x0809075f in CEXEBuild::parseScript (this=0xbf9e0260) at Source/script.cpp:626
#17 0x08090a46 in CEXEBuild::process_script (this=0xbf9e0260, filepointer=0x0, filename=0xbf9e22fc ".test/Examples/LogicLib.nsi") at Source/script.cpp:199
#18 0x08066dd0 in main (argc=2, argv=0xbf9e2794) at Source/makenssi.cpp:456
Also, I noted during getting the backtrace that even when DEBUG is set to yes, makensis is built with -s, causing debugging symbols from the .o files to be stripped.

I'd like to enable the tests during building in the debian package, but I imagine they might fail on lots of the debian architectures, forcing me to find and fix those failures before nsis could get back into the next release.

Patches to fix the two assertions and remove optimizations and symbol stripping in debug mode are attached.

The mmap test patch changes the test to fit the current situation, even though the mmap classes need a bit of work.

Thanks.


Cool. Just need the following changes to allow cppunit to be detected and Source/Tests/mmap.cpp to be compiled.

1. Add dl to libs in Source/Tests/SConscript. CppUnit seems to use the functions dlclose, dlopen, dlsym for dynamically loading shared libraries.
2. Change "min" to "std::min" in Source/Tests/mmap.cpp, or similar.


You're right, those are simple enough and can be easily made to work on Windows as well. Done.