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

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

Expand Messages
  • Micron Engineering
    Jun 1, 2006
    • 0 Attachment
      Ian Collins ha scritto:
      > Micron Engineering wrote:
      >
      >
      >> I would like to know some opinions about unit test implementations in
      >> embedded applications (mainly in C and C++).
      >>
      >>
      >>
      > Yes, lots.
      >
      > All the recent embedded products at my last company where developed
      > using XP. My preferred unit test framework is one of the CppUnit variants.
      >
      > All of the products were developed using TDD in a host environment, with
      > acceptance tests that cold be run against a simulation on the host, or a
      > real target. We tried various levels of hardware simulations, including
      > a very detailed model of the embedded microcontroller which enabled us
      > to TDD device drivers.
      >
      > We used the same tools for both C and C++ targets, the detailed
      > simulations required the C code to be built as C++ which has its pros
      > and cons.
      >
      > If you want any specific detail, please ask.
      >

      I read some papers about unit tests and would like to compare my actual
      approach with the list to see if my be improved or if it has a bad
      implementation.
      Mainly I develop embedded sw for custom boards based around a
      microcontroller (from 8 to 32 bits) and some sw on normal PCs (mainly
      for Windows o.s. and sometimes for Linux o.s.). So for little
      microcontrollers I use C compilers for all the other applications C++
      compilers (for Windows Borland C++ Buolder, for Linux Kylix3 and gcc C++
      compilers and WxWidgets).

      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:
      //------------------------------------------------------------------------------
      // MODULE CODE STARTS HERE
      //------------------------------------------------------------------------------
      ....

      //------------------------------------------------------------------------------
      //------------------------------------------------------------------------------
      //------------------------------------------------------------------------------
      // UNIT TEST FILE
      //------------------------------------------------------------------------------
      //------------------------------------------------------------------------------
      //------------------------------------------------------------------------------
      #if REGRESSION_NET == 1
      #include ".\UnitTests\NetRegressionTest.c"
      #endif

      so simply using a define inside the module or at compile time I may
      enable or not unit test code and confine it in a different file (also in
      a different directory for CVS purpose, in this way I may have also a
      unit test project thinking in terms of cvs).
      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.

      For example:

      long IntSum(int a, int b)
      {
      return(a + b);
      }

      int Series(int *iSum, int *iData, int len)
      {
      int i, j;
      for(i=0, j=0; i<len; i+=2, j++)
      iSum[j] = IntSum(iData[i], iData[i+1]);
      return(j);
      }

      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.

      C++ projects
      In this case test module = class so test functions are inside the class
      in public section (inside a #if ... #endif block).
      I read some papers about unit tests and would like to compare my actual
      approach with the list to see if my be improved or if it has a bad
      implementation.
      Mainly I develop embedded sw for custom boards based around a
      microcontroller (from 8 to 32 bits) and some sw on normal PCs (mainly
      for Windows o.s. and sometimes for Linux o.s.). So for little
      microcontrollers I use C compilers for all the other applications C++
      compilers (for Windows Borland C++ Buolder, for Linux Kylix3 and gcc C++
      compilers and WxWidgets).

      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:
      //------------------------------------------------------------------------------
      // MODULE CODE STARTS HERE
      //------------------------------------------------------------------------------
      ....

      //------------------------------------------------------------------------------
      //------------------------------------------------------------------------------
      //------------------------------------------------------------------------------
      // UNIT TEST FILE
      //------------------------------------------------------------------------------
      //------------------------------------------------------------------------------
      //------------------------------------------------------------------------------
      #if REGRESSION_NET == 1
      #include ".\UnitTests\NetRegressionTest.c"
      #endif

      so simply using a define inside the module or at compile time I may
      enable or not unit test code and confine it in a different file (also in
      a different directory for CVS purpose, in this way I may have also a
      unit test project thinking in terms of cvs).
      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.

      For example:

      long IntSum(int a, int b)
      {
      return(a + b);
      }

      int Series(int *iSum, int *iData, int len)
      {
      int i, j;
      for(i=0, j=0; i<len; i+=2, j++)
      iSum[j] = IntSum(iData[i], iData[i+1]);
      return(j);
      }

      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.

      C++ projects
      In this case test module = class so test functions are inside the class
      in public section (inside a #if ... #endif block).

      Are there better ways to realize unit tests?

      > Ian
      >
      >
      > To Post a message, send it to: extremeprogramming@...
      >
      > To Unsubscribe, send a blank message to: extremeprogramming-unsubscribe@...
      >
      > ad-free courtesy of objectmentor.com
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >


      ----------

      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