Loading ...
Sorry, an error occurred while loading the content.

120203Re: [XP] Is there anyone who uses xp methods in embedded applications?

Expand Messages
  • Micron Engineering
    Jun 1, 2006
    • 0 Attachment
      Russel Hill ha scritto:
      > On 6/1/06, Micron Engineering <micronpn@...> wrote:
      >
      >> C projects
      >> I divide the sw in modules where module = file and every module has its
      >> test functions and its main() (for embedded applications the startup
      >> function is common to every module). This means that I write one or more
      >> test functions for every function contained in the file. Now, to manage
      >> better the test functions I decide to use this approach:
      >>
      >
      > I like to split my tests into a separate compilation unit. This has a
      > couple of distinct advantages:
      >
      I have a separate c file but I have to include it on original file to
      test (using #if...#endif to compile or not) and this to test also static
      functions and variables.
      > 1) I have the liberty of writing C++ test against C code (I like this one)
      >
      This means that you have a C++ compiler for the embedded cpu, I haven't
      for all cpu I used (example Z8Encore, eZ80Acclaim)
      > 2) I can compile application code _once_ and then use the linker to
      > control whether the test harness or main is in control.
      >
      How do you test static functions? And how can you use static variables?
      > 3) I like it better that way.
      >
      >
      Th
      >> I read about stub functions to substitute functions called inside a
      >> function to test. Actually I am not using them also if I understand that
      >> may be better isolate any single test but I really don't understand the
      >> way to do that.
      >>
      >
      > Stub functions are particularly troublesome in 'C' (and some C++). It
      > is possible to stub functions (or entire libraries) at link time. This
      > is not a trick that I keep close to the top of my bag but it is
      > occassionally useful. This would be another reason to keep test/stub
      > code in separate compilation units.
      >
      >
      >> to test IntSum() I need to test the returned value to see if it is
      >> correct. To test Series() I may understand what to test but I don't
      >> understand what may be the stub function and if it is a very advantage
      >> to write the stub function.
      >>
      >
      > In your example, there isn't much reason for a stub. Consider:
      >
      Yes, my example was a "difficult" example, I choose it because I read
      articles about a stub for every dependant function so I choose one
      difficult to implement to understand better; the most difficult are
      functions where the returned type depends from one or more input parameters.
      >


      ----------

      No virus found in this outgoing message.
      Checked by AVG Free Edition.
      Version: 7.1.394 / Virus Database: 268.7.4/351 - Release Date: 29/05/2006


      [Non-text portions of this message have been removed]
    • Show all 14 messages in this topic