Automated Testing for Embedded Software in C or C++

12,347 views

Published on

When software developers write automated tests for their software, the quality increases, the design improves and the project becomes more manageable. The development also becomes more fun!

In this presentation you will learn how to write automated tests for embedded software. You will see a live demonstration of writing an automated test for a feedback control algorithm in C. I will also talk about the benefits of writing tests and why it can actually improve your design and save you time.

When having a large set of automated tests it becomes valuable to run all tests automatically every time the code is changed. I will touch upon what is the best continuous integration setup for embedded software projects.

Sample code can be downloaded from http://www.zealake.com/public/embedded-autotest.zip

Published in: Technology
2 Comments
7 Likes
Statistics
Notes
  • These are the Top 5 Best Java Training Institutes in Pune go to the link :lhttp://crbtech.in/Java-Training/
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • keylabs is providing best devops online training..please go to the link below http://www.keylabstraining.com/devops-online-training-tutorial
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
12,347
On SlideShare
0
From Embeds
0
Number of Embeds
248
Actions
Shares
0
Downloads
229
Comments
2
Likes
7
Embeds 0
No embeds

No notes for slide

Automated Testing for Embedded Software in C or C++

  1. 1. Who is Lars Thorup?● Software developer ● Web: C# and JavaScript ● Embedded C++ for several devices using agile and automated testing● Coach: Teaching agile and automated testing● Advisor: Assesses software projects and companies● Founder and CEO of BestBrains and ZeaLake
  2. 2. Agenda● What is automated testing?● Unity, test framework for embedded C● Code example● Why should we write automated tests?● Questions
  3. 3. What is automated testing?● Developers write test ● Automated execution of all programs test programs
  4. 4. The Unity testing framework● Small memory footprint ● Many test functions ● ASSERT_TRUE● Pure C ● FAIL ● ASSERT_EQUAL● Optional tools to generate ● ASSERT_WITHIN test runners automatically ● ASSERT_BITS ● ASSERT_NOT_NULL● Alternatives in C++ ● ASSERT_MEMORY ● CppUnit ● Google Test
  5. 5. How do we handle dependencies?● The flow example ● a flow sensor ● generates pulse counts proportional to actual flow ● calculate average flow rate with regular intervals● The dependencies in the flow example ● the sensor creating the pulse interrupt ● recurring timer event ● thread safe counting● Decouple the dependencies ● Pulse: provide a callback to the FlowSensor component ● Timer and Counting: inject components into the Flow component● flow.c
  6. 6. Dependencies, on device main.c Listen GetRate flowSensor.c flow.c Pulse GetTime timerImpl.c Increment counterImpl.c
  7. 7. Dependencies, in test flowTest.c Pulse GetRate flow.c SetTime GetTime timerStub.c Increment counterImpl.c
  8. 8. Strategy for testing embedded software● Continuous Integration ● Automate build and test execution ● On desktop, simulator and/or the device● Break dependencies ● Hardware Abstraction Layer ● Simulate time measurements and timer events ● Standardize on frequently used stubs ● Use mock objects for testing protocols● Dependency injection ● Link time, where possible ● Run time, using function pointers, where necessary
  9. 9. Why should we write unit tests?● Speed up development ● Because of all the things we no longer have to waste time on ● Test Driven Development vs Debug Later Programming ● Avoid piling up technical dept (manual testing, bug fixing) ● Typing code is not where the bottleneck is● Find bugs faster ● Trivial bugs found immediately ● QA can do exploratory testing earlier and more extensively● Prevent bugs from reappearing ● Never fix a bug until we have a failing test● Improve the software design ● Loose coupling is required to write tests
  10. 10. Links to further resources● List of testing tools for C and C++ ● http://www.opensourcetesting.org/unit_c.php● Book ● http://pragprog.com/titles/jgade/test-driven-development-for- embedded-c● Experiement on the benefits of TDD ● http://www.infoq.com/news/2009/03/TDD-Improves-Quality● Meetup groups ● http://www.meetup.com/Test-Driven-Developers-Bay-Area/
  11. 11. Questions

×