Writing cmocka Tests

From SambaWiki
Revision as of 21:12, 2 August 2017 by Abartlet (talk | contribs) (Abartlet moved page Writing cmocka tests to Writing cmocka Tests: follow pattern of other writing tests articles (capitalisation))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Unit Testing

Samba started to also implement unit tests. This gives an overview about cmocka the unit testing framework we use. As a start we suggest to read the following LWN article:

Unit testing with mock objects in C

cmocka its API is very well documented, you can find it here.

Best practice

Normally you can take it as a rule of thumb to write one text executable for one .c file! In the test you do #include "foo.c". This way you can also write tests for functions which are declared static.

If you have a huge file or complex functions, create one test binary for a bunch of similar functions or just one.

Writing a cmocka test for Samba

What a wurst!