Installation and usage of cpputest for embedded target

1,166 views
Skip to first unread message

Mikkel Jakobsen

unread,
Jun 12, 2014, 5:21:34 AM6/12/14
to cppu...@googlegroups.com
So, I feel like somewhat of a rookie for asking this question, but how exactly is cpputest installed and used? I find the documentation a bit confusing, but maybe I don't know how to read it properly....
I am working on a Windows 7 machine and planning to do off-target and if possible, on-target unittesting of C code for a PIC32 microcontroller with the XC32 compiler (which also compiles C++)
So far, I have performed these steps:
  • I have installed cygwin with the development package. 
  • I have downloaded cpputest and extracted to c:/cpputest-3.5
  • I have configured via cygwin bash -> ./configure
  • I have installed via cygwin bash -> ./Install
  • I have done the Make and Make check which seems to perform as expected
My question is now, how do I get started with using cpputest, more specifically:
  • Do I make my new project somewhere and leave the cpputest files in c:/ccputest-3.5 or do I need to copy something into my new project directory?
  • How do I set up a dual target environment (PIC32 and Windows / cygwin)?
I am used to working in Windows, and have always used IDE's, so the linux command line approach that seems to be dictated by cpputest is a bit foreign for me. I passionately hate Microchips IDE, so if commandline is the way to go, I'm all for it.

Thanks in advance,
Mikkel

Felipe de Andrade Neves Lavratti

unread,
Jun 12, 2014, 6:28:03 AM6/12/14
to cppu...@googlegroups.com
I
​'m not sure if it is possible to run CppUTest in a baremetal firmware. Doesn't it has OS dependencies, like threads etc.?​


--
You received this message because you are subscribed to the Google Groups "cpputest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cpputest+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Skype: felipeanl

Mikkel Jakobsen

unread,
Jun 12, 2014, 6:45:39 AM6/12/14
to cppu...@googlegroups.com
According to Grennnings book, it is not only possible, but encouraged. I don't know about the ccputest implementation, but I don't see why it should have any OS dependencies.

For now, I would be happy just to run my unit test suite on a PC, thats my main objective right now.


On Thursday, June 12, 2014 12:28:03 PM UTC+2, Felipe de Andrade Neves Lavratti wrote:
I
​'m not sure if it is possible to run CppUTest in a baremetal firmware. Doesn't it has OS dependencies, like threads etc.?

--
Skype: felipeanl

Ryan Hartlage

unread,
Jun 12, 2014, 7:14:14 AM6/12/14
to cppu...@googlegroups.com
The best place to start is to use the build system from the examples (cpputest/examples).  This uses a makefile that allows you to specify where to find CppUTest and the directories where your application code and tests live:

As far as running tests on your embedded target, I would wait until you have exhausted the benefits of running off target.  It brings some advantages, but running on target is not a good starting point.

Ryan


James Grenning

unread,
Jun 12, 2014, 9:14:32 AM6/12/14
to cppu...@googlegroups.com
Hi Mikkel

Thanks for reading my book. I agree with Ryan. The biggest value is to
get off target testing.

There are risks associated with off target (int size, endian, struct
alignment, portability issues) that on-target helps find. So on-target
can be helpful too, but often a challenge from a memory size and
embedded compiler quirks perspective. CppUTest dependencies on OS are
minimal, but embedded compilers tend to need some coaxing to compile it.

I have two starter projects that give step by step instructions for
getting you first file of existing code in the test harness.

https://github.com/jwgrenning/cpputest-starter-project
https://github.com/jwgrenning/cpputest-starter-project-vs - for visual
studio

James

--------------------------------------------------------------------------------------------
James Grenning Author of TDD for Embedded C
www.wingman-sw.com http://pragprog.com/titles/jgade/
www.wingman-sw.com/blog
www.twitter.com/jwgrenning

Mikkel Jakobsen

unread,
Jun 12, 2014, 10:31:05 AM6/12/14
to cppu...@googlegroups.com
Thank you James and Ryan for your replies. 

You make a good point of off-target testing being a good starting point. I feel a bit overwhelmed by TDD and cpputest as it is, so I should learn to crawl before I attempt to walk. I will take a look at the links you provided and see how far I get. 
Reply all
Reply to author
Forward
0 new messages