Skip navigation.

Archives

Heuristics Art Show, EuroSTAR 2008

Galvanized by Jerry Weinberg's workshop on experiential learning at AYE 2008, I led a tutorial at EuroSTAR 2008 that included an experiential exercise invented by my colleague James Bach. I call it The Heuristics Art Show.

TotT: Finding Data Races in C++

If you've got some multi-threaded code, you may have data races in it. Data races are hard to find and reproduce – usually they will not occur in testing but will fire once a month in production.

For example, you ask each of your two interns to bring you a bottle of beer. This will usually result in your getting two bottles (perhaps empty), but in a rare situation that the interns collide near the fridge, you may get fewer bottles.

 4 int bottles_of_beer = 0;
 5 void Intern1() { bottles_of_beer++; } // Intern1 forgot to use Mutex.
 6 void Intern2() { bottles_of_beer++; } // Intern2 copied from Intern1.
 7 int main() {
 8 // Folks, bring me one bottle of beer each, please.
 9 ClosureThread intern1(NewPermanentCallback(Intern1)),
10 intern2(NewPermanentCallback(Intern2));
11 intern1.SetJoinable(true); intern2.SetJoinable(true);
12 intern1.Start(); intern2.Start();
13 intern1.Join(); intern2.Join();
14 CHECK_EQ(2, bottles_of_beer) << "Who didn't bring me my beer!?";
15 }

New tool added - Moxy

Moxy generates mock objects on the fly from C++ header files. Mock objects allow interaction-based unit testing and can improve object decoupling.

New tool added - CMock

CMock is a module/object mocking framework for interaction-based unit testing in C projects. CMock itself is a set of Ruby scripts that generate mock module source code in C from C header files. CMock is most useful for testing when used in concert with a unit test framework such as Unity.

New tool added - Unity

Unity is a lightweight xUnit-style unit test framework for C. It was developed for resource constrained environments and includes a number of features helpful for embedded development. Unity has been used successfully in a range of projects from very small embedded systems to desktop software.

The WordCount Simulation

I’ve mentioned my WordCount simulation here before, and some folks have expressed curiosity about it. I started writing a blog post about it, and quickly realized that it would take a whole lot of blog posts to tell all the stories I want to tell. So I’ll start by explaining the simulation in more detail, [...]