13
Testing in a microcontroller world Angelo Compagnucci - IDEA SOC COOP – 04/12/2013

Testing in a microcontroller world

Embed Size (px)

DESCRIPTION

Il testing è un aspetto fondamentale nello sviluppo software particolarmente in ambienti critici quali quelli a micrcontrollore. Generalmente il solo testing che viene eseguito è quello di tipo funzionale, ma a volte può non bastare. Abbiamo messo a punto un sistema di unit test su microcontrollore che può essere usato per validare il codice dall'interno e simulare percorsi di esecuzione di difficile esplorazione. Nel tempo a disposizione cercheremo di analizzare le problematiche maggiori e di mostrare con un caso pratico, come si possa scrivere ed automatizzare l'esecuzione del testing. Per farlo mostreremo l'uso di uno strumento da noi ideato su architettura PIC, l'intergazione con l'IDE MPLABX, la simulazione del testing con il simulatore Microchip ed infine l'integrazione del testing con lo strumento di continuous integration Jenkins.

Citation preview

Page 1: Testing in a microcontroller world

Testing in a microcontroller world

Angelo Compagnucci - IDEA SOC COOP – 04/12/2013

Page 2: Testing in a microcontroller world
Page 3: Testing in a microcontroller world

Misunderstanding?

Page 4: Testing in a microcontroller world

What's going on here?

Page 5: Testing in a microcontroller world

Are we building the right product?

Page 6: Testing in a microcontroller world

Testing

Are we building the product right?

Testing never proves Testing never proves the absence of faults, the absence of faults, it only shows their it only shows their presence.presence.

Edsger W. DijkstraEdsger W. Dijkstra

Page 7: Testing in a microcontroller world

Black box testing

● Functional Testing● Fuzzy testing

Page 8: Testing in a microcontroller world

White-box Testing

● Test Case: esecuzione volta ad evidenziare la presenza di un guasto● Test suite: insieme di casi di test● Driver: strumento utilizzato per eseguire i test sul sistema● Sistem Under Test (SUT): il sistema che in un certo momento è sottoposto al test● Stubs: oggetti necessari a riprodurre componenti mancanti al fine del test di integrazione● Oracolo del Test: entità capace di valutare i risultati del test● Workload: carico di lavoro a cui un SUT viene sottopostotipicamente per evidenziare guasti dovuti a errori nel progettodella concorrenza o per evidenziare degradi di QoS

Page 9: Testing in a microcontroller world

Testing example in python

1 import random 2 import unittest 3 4 class TestSequenceFunctions(unittest.TestCase): 5 6 def setUp(self): 7 self.seq = list(range(10)) 8 9 def test_shuffle(self): 10 # make sure the shuffled sequence does not lose any elements 11 random.shuffle(self.seq) 12 self.seq.sort() 13 self.assertEqual(self.seq, list(range(10))) 14 15 # should raise an exception for an immutable sequence 16 self.assertRaises(TypeError, random.shuffle, (1,2,3)) 17 18 def test_choice(self): 19 element = random.choice(self.seq) 20 self.assertTrue(element in self.seq) 21 22 def test_sample(self): 23 with self.assertRaises(ValueError): 24 random.sample(self.seq, 20) 25 for element in random.sample(self.seq, 5): 26 self.assertTrue(element in self.seq) 27 28 if __name__ == '__main__': 29 unittest.main()

Page 10: Testing in a microcontroller world

PICUNIT

Free Software under the MIT license, designed by us!

http://github.com/idea-on-line/picunit

Page 11: Testing in a microcontroller world

PICUNIT

1. Start a new project2. Import .h files3. Make a new PICUNIT configuration4. Select simulator5. Write your testing functions!

Page 12: Testing in a microcontroller world

Continuous Integration

http://jenkins-ci.org/

Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early.

By integrating regularly, you can detect errors quickly, and locate them more easily.

Page 13: Testing in a microcontroller world

Continuous Integration

PICUNIT is Jenkins enabled!

CI folder in repo

Modify build_conf.sh and check_tests.sh to suite your needs