CppUTest Release 3.7.1 :)

246 views
Skip to first unread message

Bas Vodde

unread,
May 4, 2015, 1:48:07 AM5/4/15
to cppu...@googlegroups.com

Hiya,

Oki, quickly packaged a new release.

The changelog of 3.7:

* -v and -ojunit together
* Better memory leak printing
* MEMCMP_EQUAL
* STRNCMP_EQUAL
* Memory Leak Detector multi-threading support
* Mock Output parameters
* Many Mock improvements
* Many small fixes and improvements
* Less platform specific dependencies
* More platforms supported

Let me know if there are problems with it, if not, I’ll update some of the package managers.

Thanks!

Bas

Ivan Zrno

unread,
Jul 6, 2015, 7:28:23 AM7/6/15
to cppu...@googlegroups.com
Thanks for the new version!

I am havin a few problems using this version with Keil uVision.

The file tests/UtestPlatformTest cannot be built because the identifier "EINTR" is undefined and unistd.h cannot be found.

After excluding that file from the build i got an linking error. "Undefined symbol atexit (referred from utestplatform.o)" Kinda strange because the stdlib is included in the utestplatform.cpp.

Any ideas?

A. Robert S.

unread,
Jul 6, 2015, 8:43:49 AM7/6/15
to cppu...@googlegroups.com
Hello Ivan,
 
The tests have been fixed for IAR in commit 0dec40e49cf4b41b092c8d61aee692ed8172ec19 (or the current head, of course).
 
There may also be changes needed to UtestPlatform.cpp, depending on which one you are using. The one for Iar has been fixed and could serve as an example. If you fix UtestPlatform.cpp it would be nice if you could create a pull request for it.
 
It is possible that we need to make further changes, so it will work on your system, too. We should probably turn the #ifdef round so only Gcc tries to run tests in a separate process...
 
Hope this helps
Robert

A. Robert S.

unread,
Jul 6, 2015, 8:55:43 AM7/6/15
to cppu...@googlegroups.com
Hi again,
 
Which version of UtestPlatform.cpp are you using (there isn't one for Keil in CppUTest)? E.g. VisualCpp, Gcc, Iar, or one of your own specifically for Keil?

On Monday, July 6, 2015 at 1:28:23 PM UTC+2, Ivan Zrno wrote:

Ivan Zrno

unread,
Jul 6, 2015, 9:14:28 AM7/6/15
to cppu...@googlegroups.com
I am using the ARMCC one.

With the 3.6 version i used the IAR one, like it was described in the platform succes story. But now if i use the IAR one i got 22 errors saying that the declarations in UtestPlatform.cpp and PlatformSpecificFunctions.c are incompatible.

A. Robert S.

unread,
Jul 6, 2015, 10:57:35 AM7/6/15
to cppu...@googlegroups.com
The ArmCC one needs to be brought up to date to use the new function-pointer based interfaces, basically, very similar to the IAR one. Since I don't have access to your processor, it would be best if you gave it a shot.
 
I could try to do a "rough draft" from my end, but it would probably not compile straight away.
 
How familiar are you with Github, forks, and pull requests?
 
Robert

A. Robert S.

unread,
Jul 6, 2015, 10:59:12 AM7/6/15
to cppu...@googlegroups.com
oh, by the way, the reason ArmCC hasn't been updated already is simply that I had no compiler to try it on...

On Monday, July 6, 2015 at 3:14:28 PM UTC+2, Ivan Zrno wrote:

A. Robert S.

unread,
Jul 6, 2015, 12:19:47 PM7/6/15
to cppu...@googlegroups.com
Hi, you'll find a first attempt on my fork, https://github.com/arstrube/cpputest/tree/armcc . Maybe you can pull it from there and then we can improve on it.
 
Robert

On Monday, July 6, 2015 at 3:14:28 PM UTC+2, Ivan Zrno wrote:

A. Robert S.

unread,
Jul 8, 2015, 3:47:42 AM7/8/15
to cppu...@googlegroups.com
Did you manage to solve your problem?
Robert

On Monday, July 6, 2015 at 3:14:28 PM UTC+2, Ivan Zrno wrote:

Ivan Zrno

unread,
Jul 8, 2015, 5:33:26 AM7/8/15
to cppu...@googlegroups.com
Hi Robert,

i didnt had the time to solve it and no time to respond to you. So yesterday i learned everyhting needed to start working with github. And i downloaded your new version. With that version i get the following errors:

UtestPlatform_keil.cpp(103): error:  #247: function "DummyPlatformSpecificRunTestInASeperateProcess" has already been defined
  static void DummyPlatformSpecificRunTestInASeperateProcess(UtestShell* shell, TestPlugin*, TestResult* result)

UtestPlatform_keil.cpp(108): error:  #247: function "DummyPlatformSpecificFork" has already been defined
  static int DummyPlatformSpecificFork(void)

...... and so on because they were defined 2 times. After i deleted the double definitions another problem was this part:

//void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell* shell, TestPlugin* plugin, TestResult* result) =
//        DummyPlatformSpecificRunTestInASeperateProcess;
//extern "C" int (*PlatformSpecificFork)(void) = DummyPlatformSpecificFork;
//extern "C" int (*PlatformSpecificWaitPid)(int, int*, int) = DummyPlatformSpecificWaitPid;

so i comented it out and left he ones without the extern c part. The errors were:

UtestPlatform_keil.cpp(106): error:  #147: declaration is incompatible with "int (*PlatformSpecificFork)()" (declared at line 36 of "C:\Git\fw_1023-1123_tdd\CppUTest\include\CppUTest/PlatformSpecificFunctions.h")
  extern "C" int (*PlatformSpecificFork)(void) = DummyPlatformSpecificFork;

.... for all 3 functions. Keil also reported the error that " PlatformSpecificFork has a different language linkage " and the other 2 functions also. So without the extern "C" part it compiled without errors.

After that i tried to use the new library in the tests but the  old error is coming, atexit and time are undefined in the library. Any ideas? Can i upload the new version to your fork?


Ivan Zrno

unread,
Jul 8, 2015, 5:46:10 AM7/8/15
to cppu...@googlegroups.com
And the Time problem is solved with this change:

static const char* TimeStringImplementation()
{
    time_t tm = 0; //time(NULL);
    return ctime(&tm);
}

But i dont have a solution for the the undefined atexit problem.

A. Robert S.

unread,
Jul 8, 2015, 6:29:51 AM7/8/15
to cppu...@googlegroups.com
Hi Ivan,
 
Most of this looks like some kind of merge errors, either at my end or at yours. There shouldn't have been "extern "C" declarations like the ones below... strange. I'll just make sure it's clean at my end.

A. Robert S.

unread,
Jul 8, 2015, 6:30:53 AM7/8/15
to cppu...@googlegroups.com
Okay.

A. Robert S.

unread,
Jul 8, 2015, 6:34:15 AM7/8/15
to cppu...@googlegroups.com
Of course you can create a pull request against that branch on my fork.
I will also go through those points in detail.
Your system doesn't seem to have the atexit function -- we need to provide a dummy for that.

A. Robert S.

unread,
Jul 8, 2015, 6:35:23 AM7/8/15
to cppu...@googlegroups.com
You don't have to create a pull request, since you are new to Github. Just let me know the name of your fork and I'll take a look at it.
 
Regards,
Robert

On Wednesday, July 8, 2015 at 11:33:26 AM UTC+2, Ivan Zrno wrote:

A. Robert S.

unread,
Jul 8, 2015, 8:19:21 AM7/8/15
to cppu...@googlegroups.com
Hi Ivan,
 
I pushed a new version. Hopefully I didn't miss any of the necessary changes. Once UtestPlatform.cpp is okay at your end, we can merge it into cpputest.
 
We need to make changes to the tests still. This will be a bit more involved, because we need to handle switching platforms a little better. For now, I am going to push a simple change which should get you going.
 
Robert
 

Ivan Zrno

unread,
Jul 8, 2015, 8:50:43 AM7/8/15
to cppu...@googlegroups.com
Hi Robert,
thanks for all the help so far! So i added all your changes. And everything is compiling now, just one test is failing:

Failure in TEST(UtestShell, TestDefaultCrashMethodInSeparateProcessTest)
.../TestTestingFixture.h:112: error:
        actual <
Generic:1: error: Failure in TEST(Generic, Generic)
        -p doesn't work on this platform, as it is lacking fork.

>   did not contain  <Failed in separate process - killed by signal 11>

Errors (1 failures, 429 tests, 415 ran, 735 checks, 14 ignored, 0 filtered out, 0 ms)

And about the atexit error, the strange part is that atexit is defined in keil inside the stdlib.h like this:

extern _ARMABI int atexit(void (* /*func*/)(void)) __attribute__((__nonnull__(1)));
   /*
    * registers the function pointed to by func, to be called without its
    * arguments at normal program termination. It is possible to register at
    * least 32 functions.
    * Returns: zero if the registration succeeds, nonzero if it fails.
    */
#if defined(__EDG__) && !defined(__GNUC__)
#define __LANGUAGE_LINKAGE_CHANGES_FUNCTION_TYPE
#endif
#if defined(__cplusplus) && defined(__LANGUAGE_LINKAGE_CHANGES_FUNCTION_TYPE)
    /* atexit that takes a ptr to a function with C++ linkage
     * but not in GNU mode 
     */
    typedef void (* __C_exitfuncptr)();
    extern "C++"
    inline int atexit(void (* __func)()) {
      return atexit((__C_exitfuncptr)__func);
    }
#endif

A. Robert S.

unread,
Jul 8, 2015, 10:08:06 AM7/8/15
to cppu...@googlegroups.com
Hi again,
 
Ah, I must have missed one test.
 
Can you supply me with a #define that will identify your compiler?
 
As for atexit, it is defined inline. That being so, it wants to be called rather than be pointed to ;-)
 
I pushed the change for UtestPlatform.cpp
 
Awaiting your answer for the TEST.
 
Robert

Ivan Zrno

unread,
Jul 10, 2015, 2:17:17 AM7/10/15
to cppu...@googlegroups.com
So the official sites say http://www.keil.com/support/man/docs/armccref/armccref_babjfefg.htm that the define is __arm__ .

Although inside the c/c++ compiler configuration tab i can see only one define: -D__UVISION_VERSION="515"

Thanks for all your help so far. SO i dont want only to take your changes and use them i would love to understand them. How can we just coment out half of the platform sepcific functions without breaking anything?

A. Robert S.

unread,
Jul 10, 2015, 3:50:50 AM7/10/15
to cppu...@googlegroups.com
Hmm. __arm__ seems a bit generic. But it's a start. The version is not really helpful here... I'll work with that, then.

Well let's talk about the other half of the platform-specific functions first. Let's say all platforms have them, but they employ different idioms to call them up.

Now for the ones we replaced by dummies. 

  • Some will result in loss of functionality. For example, the ability to run tests in a separate process (this is why some tests need to be #ifdef'd away). 
  • Others do are not needed for cppytest, but you might want to use them in your tests. So, if your system didn't have atexit(), you couldn't use it, but it wouldn't make any difference to cpputest.
  • Yet others will affect cpputest, but it doesn't matter. For example, if you are running on a system without operating system or threads, then it doesn't matter if SimpleMutex doesn't do anything. There are no tests for that either, since cpputest isn't really meant to run multithreaded tests (but you could do it on a PC)
  • In summary: That's the art of writing platform-independent code :-)
Regards,
Robert

A. Robert S.

unread,
Jul 10, 2015, 5:12:23 AM7/10/15
to cppu...@googlegroups.com
Pushed the changes and made a pull request. If you encounter problems, could you maybe continue this discussion here:
Thanks,
Robert

On Friday, July 10, 2015 at 8:17:17 AM UTC+2, Ivan Zrno wrote:
Reply all
Reply to author
Forward
0 new messages