1 // SPDX-License-Identifier: GPL-2.0+
3 * comedi/drivers/tests/comedi_example_test.c
4 * Example set of unit tests.
6 * COMEDI - Linux Control and Measurement Device Interface
7 * Copyright (C) 2016 Spencer E. Olson <olsonse@umich.edu>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 #include <linux/module.h>
24 /* *** BEGIN fake board data *** */
25 struct comedi_device {
26 const char *board_name;
30 static struct comedi_device dev = {
31 .board_name = "fake_device",
34 /* *** END fake board data *** */
36 /* *** BEGIN fake data init *** */
37 static void init_fake(void)
42 /* *** END fake data init *** */
44 static void test0(void)
47 unittest(dev.item != 11, "negative result\n");
48 unittest(dev.item == 10, "positive result\n");
51 /* **** BEGIN simple module entry/exit functions **** */
52 static int __init unittest_enter(void)
54 static const unittest_fptr unit_tests[] = {
59 exec_unittests("example", unit_tests);
63 static void __exit unittest_exit(void) { }
65 module_init(unittest_enter);
66 module_exit(unittest_exit);
68 MODULE_AUTHOR("Spencer Olson <olsonse@umich.edu>");
69 MODULE_DESCRIPTION("Comedi unit-tests example");
70 MODULE_LICENSE("GPL");
71 /* **** END simple module entry/exit functions **** */