]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2013 Uwe Hermann <uwe@hermann-uwe.de> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
20 | #include <config.h> | |
21 | #include <stdlib.h> | |
22 | #include <check.h> | |
23 | #include <libsigrok/libsigrok.h> | |
24 | #include "lib.h" | |
25 | ||
26 | /* Check whether at least one output module is available. */ | |
27 | START_TEST(test_output_available) | |
28 | { | |
29 | const struct sr_output_module **outputs; | |
30 | ||
31 | outputs = sr_output_list(); | |
32 | fail_unless(outputs != NULL, "No output modules found."); | |
33 | } | |
34 | END_TEST | |
35 | ||
36 | /* Check whether sr_output_id_get() works. */ | |
37 | START_TEST(test_output_id) | |
38 | { | |
39 | const struct sr_output_module **outputs; | |
40 | const char *id; | |
41 | ||
42 | outputs = sr_output_list(); | |
43 | ||
44 | id = sr_output_id_get(outputs[0]); | |
45 | fail_unless(id != NULL, "No id found in output module."); | |
46 | } | |
47 | END_TEST | |
48 | ||
49 | /* Check whether sr_output_name_get() works. */ | |
50 | START_TEST(test_output_name) | |
51 | { | |
52 | const struct sr_output_module **outputs; | |
53 | const char *name; | |
54 | ||
55 | outputs = sr_output_list(); | |
56 | ||
57 | name = sr_output_name_get(outputs[0]); | |
58 | fail_unless(name != NULL, "No name found in output module."); | |
59 | } | |
60 | END_TEST | |
61 | ||
62 | /* Check whether sr_output_description_get() works. */ | |
63 | START_TEST(test_output_desc) | |
64 | { | |
65 | const struct sr_output_module **outputs; | |
66 | const char *desc; | |
67 | ||
68 | outputs = sr_output_list(); | |
69 | ||
70 | desc = sr_output_description_get(outputs[0]); | |
71 | fail_unless(desc != NULL, "No description found in output module."); | |
72 | } | |
73 | END_TEST | |
74 | ||
75 | /* Check whether sr_output_find() works. */ | |
76 | START_TEST(test_output_find) | |
77 | { | |
78 | const struct sr_output_module *omod; | |
79 | const char *id; | |
80 | ||
81 | omod = sr_output_find("bits"); | |
82 | fail_unless(omod != NULL, "Couldn't find the 'bits' output module."); | |
83 | id = sr_output_id_get(omod); | |
84 | fail_unless(!strcmp(id, "bits"), "That is not the 'bits' module!"); | |
85 | } | |
86 | END_TEST | |
87 | ||
88 | /* Check whether sr_output_options_get() works. */ | |
89 | START_TEST(test_output_options) | |
90 | { | |
91 | const struct sr_option **opt; | |
92 | ||
93 | opt = sr_output_options_get(sr_output_find("bits")); | |
94 | fail_unless(opt != NULL, "Couldn't find 'bits' options."); | |
95 | fail_unless(!strcmp((*opt)->id, "width"), "Wrong 'bits' option found!"); | |
96 | } | |
97 | END_TEST | |
98 | ||
99 | Suite *suite_output_all(void) | |
100 | { | |
101 | Suite *s; | |
102 | TCase *tc; | |
103 | ||
104 | s = suite_create("output-all"); | |
105 | ||
106 | tc = tcase_create("basic"); | |
107 | tcase_add_test(tc, test_output_available); | |
108 | tcase_add_test(tc, test_output_id); | |
109 | tcase_add_test(tc, test_output_name); | |
110 | tcase_add_test(tc, test_output_desc); | |
111 | tcase_add_test(tc, test_output_find); | |
112 | tcase_add_test(tc, test_output_options); | |
113 | suite_add_tcase(s, tc); | |
114 | ||
115 | return s; | |
116 | } |