<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Now I&#8217;ll really use test driven development to write device driver code</title>
	<atom:link href="http://www.renaissancesoftware.net/blog/archives/8/feed" rel="self" type="application/rss+xml" />
	<link>http://www.renaissancesoftware.net/blog/archives/8</link>
	<description>Blogging about Agile Development, especially embedded.  Follow me on twitter: jwgrenning</description>
	<lastBuildDate>Thu, 02 Feb 2012 07:09:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: James Grenning&#8217;s Blog &#187; Blog Archive &#187; Why Test Driven Development for Embedded?</title>
		<link>http://www.renaissancesoftware.net/blog/archives/8/comment-page-1#comment-718</link>
		<dc:creator>James Grenning&#8217;s Blog &#187; Blog Archive &#187; Why Test Driven Development for Embedded?</dc:creator>
		<pubDate>Sat, 24 Oct 2009 13:07:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.renaissancesoftware.net/blog/?p=8#comment-718</guid>
		<description>[...] can TDD to the hardware, see these two articles: Who says you can’t test drive a device driver? Now I’ll really use test driven development to write device driver code Progress Before [...]</description>
		<content:encoded><![CDATA[<p>[...] can TDD to the hardware, see these two articles: Who says you can’t test drive a device driver? Now I’ll really use test driven development to write device driver code Progress Before [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gernot Eggen</title>
		<link>http://www.renaissancesoftware.net/blog/archives/8/comment-page-1#comment-257</link>
		<dc:creator>Gernot Eggen</dc:creator>
		<pubDate>Thu, 23 Oct 2008 22:40:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.renaissancesoftware.net/blog/?p=8#comment-257</guid>
		<description>Hi James,

Sorry for the late response (holidays).
About the interfaces these are fairly wide like 200 plus functions or more.  Besides that, as you already hinted, is the behavior of the interface never fully known. We use often hardware where we get drivers built by the vendor. What indeed is the way to go (I guess) is the &quot; in between layer&quot;. I agree it should be small but it is the same approach I am hearing from collegeas in-product-software developers. 

Furthermore I indeed support your statement that the architecture should take care of modular designs. It offers indeeds the benefits for how you do your tests, the amount of modeling, reliability etc. As well it reduces complexity and that&#039;s also why I like TDD. My experience is that using TDD forces you to limit the number of dependencies in the code because you will have to provide a mock/stub for each dependency (thus extra work). However after applying TDD for some time (large scale development projects approx 1Mloc) we see that the TDD code (and xUnit code) grow to substantial amount (40 - 60 % of the total code produced). This automatically brings a maintenance burden. What is wise to do then? Should some of the TDDs be pruned? e.g. the ones that focus on classes in the &quot;middle (no interfaces with external code)? This is not dedicated to TDD development for tech apps of course but perhaps you have a hunch for me any way. Do you know of such large scale developments that use TDD for several years? 

I appreciate your answers.

Kind regards,
  Gernot Eggen</description>
		<content:encoded><![CDATA[<p>Hi James,</p>
<p>Sorry for the late response (holidays).<br />
About the interfaces these are fairly wide like 200 plus functions or more.  Besides that, as you already hinted, is the behavior of the interface never fully known. We use often hardware where we get drivers built by the vendor. What indeed is the way to go (I guess) is the &#8221; in between layer&#8221;. I agree it should be small but it is the same approach I am hearing from collegeas in-product-software developers. </p>
<p>Furthermore I indeed support your statement that the architecture should take care of modular designs. It offers indeeds the benefits for how you do your tests, the amount of modeling, reliability etc. As well it reduces complexity and that&#8217;s also why I like TDD. My experience is that using TDD forces you to limit the number of dependencies in the code because you will have to provide a mock/stub for each dependency (thus extra work). However after applying TDD for some time (large scale development projects approx 1Mloc) we see that the TDD code (and xUnit code) grow to substantial amount (40 &#8211; 60 % of the total code produced). This automatically brings a maintenance burden. What is wise to do then? Should some of the TDDs be pruned? e.g. the ones that focus on classes in the &#8220;middle (no interfaces with external code)? This is not dedicated to TDD development for tech apps of course but perhaps you have a hunch for me any way. Do you know of such large scale developments that use TDD for several years? </p>
<p>I appreciate your answers.</p>
<p>Kind regards,<br />
  Gernot Eggen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jwgrenning</title>
		<link>http://www.renaissancesoftware.net/blog/archives/8/comment-page-1#comment-235</link>
		<dc:creator>jwgrenning</dc:creator>
		<pubDate>Tue, 07 Oct 2008 14:37:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.renaissancesoftware.net/blog/?p=8#comment-235</guid>
		<description>&lt;b&gt;Regarding concurrency&lt;/b&gt;

I understand the desire to get threading built in from the start.  That said, the first concern should be to keep your design modular.  It is possible to keep separate the concerns of the application from the concerns of concurrency.  Modularity is the key.

If you keep things modular and then you find that some aspect of the threading model is not correct, it will be easier to change.  Mix application logic and threading too tightly together, and adjusting the concurrency model gets a lot harder.  

Look to designs that rely less on shared data and more on message passing, or queued access to shared resources.  This helps to isolate the parts of the code that care about the concurrency primitives, increasing the odds of getting it right.  Doug Schmidt did a lot of good work on this in C++ for the ACE framework.  I would use TDD to test my threading and synchronization constructs, but I would keep threading and synchronization  as separate as possible from application logic.   The app is complicated, concurrency is complicated, put them together and multiply the complexity, keep them separate and the overall complexity is additive.  

On development system unit tests you should probably mock out the concurrency calls.  Say your code wants to lock some resource using a mutex.   With a mock, you can test that the right number of locks and unlocks happen, you could test the order to guard against deadlock.  But for the most part the tests are single threaded.  There will be a chapter in my book on this.

&lt;b&gt;Regarding mocking wide interfaces&lt;/b&gt;

How wide is the interface? Can you provide an example?  Does the application need the whole interface?

My friends at Atomic Object have a tool called CMock for generating mocks.  You could go that way. 

I would look for design solutions as well.  A layered approach could be used to provide a higher level, easier to use, interface for the application to access the hardware services. It will be easier to mock a higher level interface. To connect the higher level interface to the driver you write an adapter that takes your higher level calls and translates them into what the driver wants.  This has all kinds of advantages.  Better modularity, protection in application investment from hardware changes, portability...

For example, a file system is a higher level interface than having applications directly accessing sectors on a hard drive.  If there were no file system, there would be a lot more complexity in code that needed to save and retrieve information on the hard drive.  If the apps used a lower level interface there would be increased complexity, leading to more difficulty in testing, leading to  tightly coupled designs.  Each new hard drive might require application changes.

The adapter might get you right back to the same problem of testing the code that uses the driver.  Maybe the code using the driver can be thin enough to only need manual tests.  More likely I would use an approach like the flash driver where you set the expectations on the IO read and write operations.  You might not know exactly how the driver works, but you can discover the workings.  Any unexpected read or write will cause a test failure.  Once you see what write the driver does, in response to some call to the driver interface, you can add an expectation.  This captures the de facto behavior in the test.</description>
		<content:encoded><![CDATA[<p><b>Regarding concurrency</b></p>
<p>I understand the desire to get threading built in from the start.  That said, the first concern should be to keep your design modular.  It is possible to keep separate the concerns of the application from the concerns of concurrency.  Modularity is the key.</p>
<p>If you keep things modular and then you find that some aspect of the threading model is not correct, it will be easier to change.  Mix application logic and threading too tightly together, and adjusting the concurrency model gets a lot harder.  </p>
<p>Look to designs that rely less on shared data and more on message passing, or queued access to shared resources.  This helps to isolate the parts of the code that care about the concurrency primitives, increasing the odds of getting it right.  Doug Schmidt did a lot of good work on this in C++ for the ACE framework.  I would use TDD to test my threading and synchronization constructs, but I would keep threading and synchronization  as separate as possible from application logic.   The app is complicated, concurrency is complicated, put them together and multiply the complexity, keep them separate and the overall complexity is additive.  </p>
<p>On development system unit tests you should probably mock out the concurrency calls.  Say your code wants to lock some resource using a mutex.   With a mock, you can test that the right number of locks and unlocks happen, you could test the order to guard against deadlock.  But for the most part the tests are single threaded.  There will be a chapter in my book on this.</p>
<p><b>Regarding mocking wide interfaces</b></p>
<p>How wide is the interface? Can you provide an example?  Does the application need the whole interface?</p>
<p>My friends at Atomic Object have a tool called CMock for generating mocks.  You could go that way. </p>
<p>I would look for design solutions as well.  A layered approach could be used to provide a higher level, easier to use, interface for the application to access the hardware services. It will be easier to mock a higher level interface. To connect the higher level interface to the driver you write an adapter that takes your higher level calls and translates them into what the driver wants.  This has all kinds of advantages.  Better modularity, protection in application investment from hardware changes, portability&#8230;</p>
<p>For example, a file system is a higher level interface than having applications directly accessing sectors on a hard drive.  If there were no file system, there would be a lot more complexity in code that needed to save and retrieve information on the hard drive.  If the apps used a lower level interface there would be increased complexity, leading to more difficulty in testing, leading to  tightly coupled designs.  Each new hard drive might require application changes.</p>
<p>The adapter might get you right back to the same problem of testing the code that uses the driver.  Maybe the code using the driver can be thin enough to only need manual tests.  More likely I would use an approach like the flash driver where you set the expectations on the IO read and write operations.  You might not know exactly how the driver works, but you can discover the workings.  Any unexpected read or write will cause a test failure.  Once you see what write the driver does, in response to some call to the driver interface, you can add an expectation.  This captures the de facto behavior in the test.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gernot Eggen</title>
		<link>http://www.renaissancesoftware.net/blog/archives/8/comment-page-1#comment-230</link>
		<dc:creator>Gernot Eggen</dc:creator>
		<pubDate>Mon, 06 Oct 2008 21:38:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.renaissancesoftware.net/blog/?p=8#comment-230</guid>
		<description>Hi James,

Thanks for the clarification. If I understand correctly the TDD test are defined for verification of requirements that can be tested in the scope of the development machine. It helps for early finding of bugs.  Looking at the way we use TDD in our in-product-software is that we use the test to think of how we will implement the production code. 
You also show this in your article. However what I think is that multi-threading, synchronization, timing and such have to be designed in/implemented right of the start. This would suggest I want to deal with these issues in TDD. 

A total different aspect I experience is that the software interacts with hardware via a driver that is delivered with the hardware. Typically these drivers have a very wide interface. Preferably you wouldn’t want to write mocks for such a wide interface. Can you give hints on ways to deal with this?

Gernot</description>
		<content:encoded><![CDATA[<p>Hi James,</p>
<p>Thanks for the clarification. If I understand correctly the TDD test are defined for verification of requirements that can be tested in the scope of the development machine. It helps for early finding of bugs.  Looking at the way we use TDD in our in-product-software is that we use the test to think of how we will implement the production code.<br />
You also show this in your article. However what I think is that multi-threading, synchronization, timing and such have to be designed in/implemented right of the start. This would suggest I want to deal with these issues in TDD. </p>
<p>A total different aspect I experience is that the software interacts with hardware via a driver that is delivered with the hardware. Typically these drivers have a very wide interface. Preferably you wouldn’t want to write mocks for such a wide interface. Can you give hints on ways to deal with this?</p>
<p>Gernot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jwgrenning</title>
		<link>http://www.renaissancesoftware.net/blog/archives/8/comment-page-1#comment-229</link>
		<dc:creator>jwgrenning</dc:creator>
		<pubDate>Mon, 06 Oct 2008 02:52:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.renaissancesoftware.net/blog/?p=8#comment-229</guid>
		<description>Hi Gernot,

I don&#039;t mean this to be the only testing done of the hardware interaction layer.  I would use this to test drive the code in the friendly confines of my development system.  In this example, I worked from the manufacture&#039;s specification.  You definitely want to run this code in the real hardware at the first chance.  No doubt there would be surprises. When I compared my implementation with the reference implementation from the manufacturer, I found reads and writes that were not in the spec.

Getting parts of the driver working to my understanding of the spec, narrows the problems that I might have when my code meets the hardware.  I probably won&#039;t have many silly coding mistakes.  The code will do what the tests confirm it does. But I do expect to find mistakes in my understanding of how the software interacts with the hardware.  I think its pretty cool, unit test (programmer tests) tell me that my code does what I think it does.  Testing in the hardware tells me that my code meets the requirements. 

When changes are made to make the code work in the hardware, the development system tests are changed to match the needs of the hardware, locking in the good behavior.  As maintenance continues, there is a good chance that problems will be introduced.  But the development system based tests, if they are any good, will catch those side effect defects.  Changing driver function A should not change driver function B.

I&#039;ll get something on concurrency in a later post.  But unit testing is not really geared to finding threading and synchronization problems.  You can&#039;t prove with unit tests that there are no concurrency problems.  The first part of the advice is to separate the threading and synchronization logic from the application logic.  Test the application logic for correct application behavior.  A higher level load test is the most helpful at detecting and finding threading and synchronization problems.

James</description>
		<content:encoded><![CDATA[<p>Hi Gernot,</p>
<p>I don&#8217;t mean this to be the only testing done of the hardware interaction layer.  I would use this to test drive the code in the friendly confines of my development system.  In this example, I worked from the manufacture&#8217;s specification.  You definitely want to run this code in the real hardware at the first chance.  No doubt there would be surprises. When I compared my implementation with the reference implementation from the manufacturer, I found reads and writes that were not in the spec.</p>
<p>Getting parts of the driver working to my understanding of the spec, narrows the problems that I might have when my code meets the hardware.  I probably won&#8217;t have many silly coding mistakes.  The code will do what the tests confirm it does. But I do expect to find mistakes in my understanding of how the software interacts with the hardware.  I think its pretty cool, unit test (programmer tests) tell me that my code does what I think it does.  Testing in the hardware tells me that my code meets the requirements. </p>
<p>When changes are made to make the code work in the hardware, the development system tests are changed to match the needs of the hardware, locking in the good behavior.  As maintenance continues, there is a good chance that problems will be introduced.  But the development system based tests, if they are any good, will catch those side effect defects.  Changing driver function A should not change driver function B.</p>
<p>I&#8217;ll get something on concurrency in a later post.  But unit testing is not really geared to finding threading and synchronization problems.  You can&#8217;t prove with unit tests that there are no concurrency problems.  The first part of the advice is to separate the threading and synchronization logic from the application logic.  Test the application logic for correct application behavior.  A higher level load test is the most helpful at detecting and finding threading and synchronization problems.</p>
<p>James</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gernot Eggen</title>
		<link>http://www.renaissancesoftware.net/blog/archives/8/comment-page-1#comment-228</link>
		<dc:creator>Gernot Eggen</dc:creator>
		<pubDate>Sun, 05 Oct 2008 20:18:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.renaissancesoftware.net/blog/?p=8#comment-228</guid>
		<description>I must admit, although being doubtful about software only testing of hardware interaction layers, that this post shows that it is possible to test a piece of hardware interacting software code . It shows testing program flow (functional) and even incorporating the state of the device (next blog called &quot;Who says you can’t test drive a device driver?&quot;). 

One of the things to keep in mind here is how wide a hardware-interface is and consequently the amount of work for simulating the interface. There is an economical break-even-point when to change from full software only testing to unit testing on hardware. 
Also, often I experience the fact that exact hardware behavior is not always known, due to lacking specifications or by &quot;obscure&quot; drivers in between. 

Other aspects I am curious to see in your next blogs is how you deal with multithreading and synchronization aspects. Another common problem is often related to timing and the fact that hardware tends to show variations whereas the software layer is quite &quot;rigid&quot;.

Please keep up the good work in finding answers to the questions common to TDD/Unit testing of embedded software.</description>
		<content:encoded><![CDATA[<p>I must admit, although being doubtful about software only testing of hardware interaction layers, that this post shows that it is possible to test a piece of hardware interacting software code . It shows testing program flow (functional) and even incorporating the state of the device (next blog called &#8220;Who says you can’t test drive a device driver?&#8221;). </p>
<p>One of the things to keep in mind here is how wide a hardware-interface is and consequently the amount of work for simulating the interface. There is an economical break-even-point when to change from full software only testing to unit testing on hardware.<br />
Also, often I experience the fact that exact hardware behavior is not always known, due to lacking specifications or by &#8220;obscure&#8221; drivers in between. </p>
<p>Other aspects I am curious to see in your next blogs is how you deal with multithreading and synchronization aspects. Another common problem is often related to timing and the fact that hardware tends to show variations whereas the software layer is quite &#8220;rigid&#8221;.</p>
<p>Please keep up the good work in finding answers to the questions common to TDD/Unit testing of embedded software.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Test-Driven Development for Embedded Software &#171; Gerard Meszaros&#8217; Weblog</title>
		<link>http://www.renaissancesoftware.net/blog/archives/8/comment-page-1#comment-218</link>
		<dc:creator>Test-Driven Development for Embedded Software &#171; Gerard Meszaros&#8217; Weblog</dc:creator>
		<pubDate>Fri, 19 Sep 2008 16:39:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.renaissancesoftware.net/blog/?p=8#comment-218</guid>
		<description>[...] (I would love to claim that I made up this great term but I first saw it on James Grenning&#8217;s blog  DOH stands for Debugging On the Hardware except on The Simpsons, where it is what Homer Simpson [...]</description>
		<content:encoded><![CDATA[<p>[...] (I would love to claim that I made up this great term but I first saw it on James Grenning&#8217;s blog  DOH stands for Debugging On the Hardware except on The Simpsons, where it is what Homer Simpson [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

