CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Unit Test Framework

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
enovak



Joined: 24 Nov 2021
Posts: 5

View user's profile Send private message

Unit Test Framework
PostPosted: Thu Dec 09, 2021 9:25 am     Reply with quote

I've been researching implementing some automated unit test in my project. I know that there are a number of different frameworks which are available to use. I was curious if anyone has implemented anything using the CCS compiler. Any input on the best framework to use? Are you executing your tests on target or simulating them? Thanks for the input.
zaz



Joined: 18 Dec 2019
Posts: 2

View user's profile Send private message

PostPosted: Thu Mar 10, 2022 3:19 am     Reply with quote

I am also looking for unit test framework for CCS project.
temtronic



Joined: 01 Jul 2010
Posts: 8900
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 10, 2022 6:21 am     Reply with quote

I can't see any UTF or another 'simulator' actually being 100% accurate with using a simple PIC like the 16C84, let alone a modern version, say a 46K22.
The problem I see is that the UTF programmer has no hands on, real world experience with a PIC ? Just HOW does he emulate random cross talk that feeds into the 2nd UART and corrupts the data stream ? Or the effects of a nearby lightning bolt ?
Ttelmah



Joined: 11 Mar 2010
Posts: 18862

View user's profile Send private message

PostPosted: Thu Mar 10, 2022 6:40 am     Reply with quote

Dead right.
I have used Criterion to make test values to prove functionality of some
code in the past, but the problem is that instrumentation code is far more
likely to have problems from things like EMP, than from general 'code errors'.
I have yet to see any simulator that I would rate as being more than 99%
accurate, and all will miss 'oddities' with particular chips, that the real
instrument has to handle.
So use a tool like Criterion to generate your test sequence values, but do
test these in the real instrument, and these also need to be tested with the
same hardware electrical signals actually present.
jeremiah



Joined: 20 Jul 2010
Posts: 1301

View user's profile Send private message

PostPosted: Thu Mar 10, 2022 12:18 pm     Reply with quote

We tend to distinguish between UNIT test and DVT (Design Verification Test). UNIT test is purely for testing code "paths", so you setup multiple sets of inputs in an attempt to verify every path in the code. For DVT, we hook up to actual signals and such to verify that the code design works as intended, treating the system as a black box and stressing all the inputs physically.

In our world UNIT test doesn't require an emulator. You generally create functions that call other functions/blocks of code with various hard coded input sets (some are generated by tools if we need random input sets) and each output is compared to an expected output of the function / block of code.
Ttelmah



Joined: 11 Mar 2010
Posts: 18862

View user's profile Send private message

PostPosted: Thu Mar 10, 2022 1:07 pm     Reply with quote

Absolutely.
Test things like how the maths behaves with an overflow, and that the
case statements do go where they are meant to go.
zaz



Joined: 18 Dec 2019
Posts: 2

View user's profile Send private message

PostPosted: Sun Mar 13, 2022 3:21 am     Reply with quote

What about Unity framework (for embedded software) for testing FW code.
Ttelmah



Joined: 11 Mar 2010
Posts: 18862

View user's profile Send private message

PostPosted: Mon Mar 14, 2022 10:34 am     Reply with quote

Unity is designed very much for .net languages. I don't know how easy it is
to adapt for languages.
enovak



Joined: 24 Nov 2021
Posts: 5

View user's profile Send private message

PostPosted: Wed Mar 16, 2022 6:44 am     Reply with quote

@zaz I did end up using Unity and getting it to work with the Microchip simulator. I did have to mock out some of the HW interactions. Using mocks is going to be key to helping to ensure that all of the code paths are tested and confirmed to be operating correctly.

Here are a couple of links that I referenced in the work that I was doing:
* http://www.throwtheswitch.org/unity
* https://spin.atomicobject.com/2012/10/22/getting-started-with-tdd-for-microchips-pics/
Ttelmah



Joined: 11 Mar 2010
Posts: 18862

View user's profile Send private message

PostPosted: Wed Mar 16, 2022 7:55 am     Reply with quote

Well done.
As Jeremiah says, you then have to test the actual hardware operation.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group