This source file includes following definitions.
- init_fake
- test0
- unittest_enter
- unittest_exit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include <linux/module.h>
22
23 #include "unittest.h"
24
25
26 struct comedi_device {
27 const char *board_name;
28 int item;
29 };
30
31 static struct comedi_device dev = {
32 .board_name = "fake_device",
33 };
34
35
36
37
38 void init_fake(void)
39 {
40 dev.item = 10;
41 }
42
43
44
45 void test0(void)
46 {
47 init_fake();
48 unittest(dev.item != 11, "negative result\n");
49 unittest(dev.item == 10, "positive result\n");
50 }
51
52
53 static int __init unittest_enter(void)
54 {
55 const unittest_fptr unit_tests[] = {
56 (unittest_fptr)test0,
57 NULL,
58 };
59
60 exec_unittests("example", unit_tests);
61 return 0;
62 }
63
64 static void __exit unittest_exit(void) { }
65
66 module_init(unittest_enter);
67 module_exit(unittest_exit);
68
69 MODULE_AUTHOR("Spencer Olson <olsonse@umich.edu>");
70 MODULE_DESCRIPTION("Comedi unit-tests example");
71 MODULE_LICENSE("GPL");
72