aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2020-01-23 11:34:11 +0100
committerAndreas Schneider <asn@cryptomilk.org>2020-01-23 11:34:11 +0100
commita9da0df8a616691afc5739e06698c17f5f1b6f4d (patch)
treeda62aa3a63663aec7bda9f48ba24f2fe59cd5c6c
parentd0593e3c2fb9c828e66b193056ca4be661e8abef (diff)
downloadcmocka-a9da0df8a616691afc5739e06698c17f5f1b6f4d.tar.gz
cmocka-a9da0df8a616691afc5739e06698c17f5f1b6f4d.tar.xz
cmocka-a9da0df8a616691afc5739e06698c17f5f1b6f4d.zip
More updates!
-rw-r--r--slides.md98
1 files changed, 66 insertions, 32 deletions
diff --git a/slides.md b/slides.md
index b7fccaa..5b57a3b 100644
--- a/slides.md
+++ b/slides.md
@@ -1,6 +1,6 @@
## About me
-Free and Open Source Software Developer:
+Source Code Artist working on:
- Samba - The domain controller and file server
- libssh - The SSH Library
- cmocka - a unit testing framework for C
@@ -10,7 +10,9 @@ Free and Open Source Software Developer:
note:
- Principal Software Engineer working for Red Hat
-- Samba, libssh, cmocka, cwrap, darktable and LineageOS
+- Samba maintainer at Red Hat
+- Work on other Free and Open Source Software
+- libssh, cmocka, cwrap, darktable and LineageOS
<!-- .slide: class="tetris-one center" -->
@@ -58,6 +60,7 @@ note:
- In your app it is e.g correctly processing a packet
- GOAL: Playing the perfect Tetris (no spaces)
+- In order to do that
- NEXT SLIDE: Test your code
<!-- .slide: class="tetris-game-6" -->
@@ -73,7 +76,7 @@ note:
---
note:
-## That happens if you don't!
+## If you don't, that will happen!
<!-- .slide: class="tetris-game-segfault" -->
@@ -92,23 +95,20 @@ note:
note:
## TETRIS
-- It is not only about about Tetris
-- It is about unit testing
+- Well yes, but we want to dive into unit testing
<!-- .slide: class="tetris-two center" -->
---
-## What is this talk about?
-
-The talk will cover:
+## The talk will cover:
- What is cmocka?
- What features does cmocka provide?
- What is mocking?
- How to write a mocking test?
note:
-The talk will cover:
+This talk will cover:
- What is cmocka?
- What features does cmocka provide?
- What is mocking?
@@ -134,9 +134,9 @@ note:
- **offers support for mock objects**.
note:
-* cmocka is an elegant unit testing framework for C
-* and it only requires the standard C library
-* it offers support for mock objects.
+1. cmocka is an elegant unit testing framework for C
+1. it only requires the standard C library
+1. it offers support for mock objects.
<!-- .slide: class="tetris-three center" -->
@@ -170,7 +170,8 @@ The goal of this project is to provide a powerful testing framework for C, on
different platforms and operating systems, which only requires the standard C
library.
-* We want a powerful framework but this defines the limitations how powerful it can be.
+* Conclusion: We want a powerful framework but this limits the scope. Keep it
+ simple.
<!-- .slide: class="tetris-three center" -->
@@ -178,10 +179,11 @@ library.
# It has a website
-https://cmocka.org/
+[cmocka.org](https://cmocka.org/)
note:
-# It has a website
+- In case you forget anything I'm telling you today.
+- Just don't forget the domain: cmocka.org
<!-- .slide: class="tetris-three center" -->
@@ -235,11 +237,11 @@ cmocka doesn't use `fork()` for exception handling in test cases!
* `fork()` is implemented diffrently on some OSes (Linux vs. MacOSX)
note:
-This might be interesting for some.
+Some interesting details about cmocka:
cmocka doesn't use `fork()` for exception handling in test cases!
* `fork()` is not available on all platforms!
-* `fork()` is implemented diffrently on some OSes (Linux vs. MacOSX)
-* We use setjmp and longjmp
+* `fork()` is implemented differently on some OSes (Linux vs. MacOSX)
+* We use setjmp and longjmp which is available on all operating systems
<!-- .slide: class="tetris-one" -->
@@ -272,6 +274,11 @@ formats like:
https://api.cmocka.org/
+note:
+- We have a complete API documentation!
+- If you start to use cmocka, please help to improve
+ the documentation!
+
<!-- .slide: class="tetris-one center" -->
---
@@ -285,7 +292,7 @@ https://api.cmocka.org/
#include <cmocka.h>
note:
-## A cmocka test
+## Lets take a look how a cmocka test looks like
First we need some includes.
@@ -325,6 +332,9 @@ note:
- Add the test to an array
- Run the group of test
+This is just the test harness
+- But we want to test somthing!
+
<!-- .slide: class="tetris-one" -->
---
@@ -336,7 +346,7 @@ We have a lot of assert functions for ...
note:
## Assert functions
-We have a lot of assert functions for ...
+For testing cmocka provides a lot of assert functions for ...
<!-- .slide: class="tetris-one center" -->
@@ -366,13 +376,37 @@ note:
---
-## Pointer
+## Integer ranges
+
+ assert_in_range(value, minimum, maximum)
+ assert_not_in_range(value, minimum, maximum)
+
+note:
+## Integer ranges
+
+<!-- .slide: class="tetris-one center" -->
+
+---
+
+## Floats
+
+ assert_float_equal(a, b)
+ assert_float_not_equal(a, b)
+
+note:
+## Floats
+
+<!-- .slide: class="tetris-one center" -->
+
+---
+
+## Pointers
assert_non_null(x)
assert_null(x)
note:
-## Pointer
+## Pointers
<!-- .slide: class="tetris-one center" -->
@@ -401,13 +435,13 @@ note:
---
-## Memory
+## Memory comparison
assert_memory_equal(a, b)
assert_memory_not_equal(a, b)
note:
-## Memory
+## Memory comarison
<!-- .slide: class="tetris-one center" -->
@@ -424,7 +458,7 @@ note:
## A cmocka test with assert function
- /* A test case that compare intetergers and fails. */
+ /* A test case that compare intetgers and will fail. */
static void integer_failure(void **state) {
int i = 4;
@@ -434,14 +468,14 @@ note:
note:
## A cmocka test with assert
- /* A test case that compare intetergers and fails. */
+ /* A test case that compare intetgers and will fail. */
static void integer_failure(void **state) {
int i = 4;
assert_int_equal(i, 5);
}
-This will fail.
+This test will obviously fail.
<!-- .slide: class="tetris-one center" -->
@@ -451,7 +485,7 @@ This will fail.
You can also easily extend cmocka by writing special assert functions for your project.
-Example: [socket_wrapper](https://cwrap.org/socket_wrapper.html) tests offer:
+Example: [socket_wrapper tests](https://gitlab.com/cwrap/socket_wrapper/blob/master/tests/test_echo_tcp_get_peer_sock_name.c#L33) offer:
assert_sockaddr_equal(ss, a)
assert_sockaddr_port_equal(ss, a, prt)
@@ -460,15 +494,15 @@ note:
## Extending assert functions
You can also easily extend cmocka by writing special assert functions for your project.
-Example: socket_wrapper tests has assert functions for sockaddr.
+Example: socket_wrapper project provides has assert functions for sockaddr.
<!-- .slide: class="tetris-one center" -->
---
-## Testing `assert()`
+## Testing `assert()` of libc
-If you test code which use `assert()`, you could redefine `assert()` and test
+If you use libc `assert()` in your code, you can redefine `assert()` and test
it!
#define assert mock_assert
@@ -483,7 +517,7 @@ it!
}
note:
-If you test code which use `assert()`, you can redefine `assert()` and test
+If you use libc `assert()` in your code, you can redefine `assert()` and test
if it gets called!
<!-- .slide: class="tetris-one" -->