CppUnit update/alteration suggestion

Stan Accy
  • Stan Accy

    Stan Accy - 2001-11-01

    One of the alterations we made to CppUnit 1.5 was to remove the need to have to #include your test case class header files in the test runner program (HostApp under MSVC6, or the text test runner) . Additionally, this also removed the need for the test program to be linked with each and every single production code DLL.

    How we did this was not clean, but it worked for us in the past:
    We hardcoded the mangled exported static function name into the test program, and had it dynamically load each and every DLL specified as command line parameters (or *.DLL in case no params were specified), and then look for this MSVC6 specific name mangled function.

    Nice or not, it works a treat for our MSVC6 / NT only development - this clearly wont work for other compilers/platforms because the name mangling by the compiler is most likely different for each combination.

    So....is it possible to remove the need to link our testing programs against each and every production DLL, and have to #include each and every testcase header file in the test runner programs?

    Anyone have any thoughts on this - by reducing the need to recompile and relink the test runner program, we get short code/test cycles - which reduces the barrier to testing. Its just not portable.

    Comments, suggestions, ideas?

    Is there a way to export a function that is not name mangled, and works across all compilers in a similar manner? In order to prevent C++ name mangling, we could use a static C style function that return a void* (yes, nasty I know) - and then we could reinterpret the void* in the host runner as a TestSuite* and then go from there.


    • Stan Accy

      Stan Accy - 2001-11-02

      PS. The void* option works ok. I added the following:

      extern "C" { __declspec(dllexport) void* GetCppUnitRegistry(void) }

      and the method is exported without mangling under MSVC6. The stuff also gets exported without mangling under Solaris 8.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks