]> sigrok.org Git - libsigrok.git/blame - tests/output_all.c
Build: Include <config.h> first in all source files
[libsigrok.git] / tests / output_all.c
CommitLineData
71185b48
UH
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, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
6ec6c43b 21#include <config.h>
71185b48
UH
22#include <stdlib.h>
23#include <check.h>
4960aeb0 24#include <libsigrok/libsigrok.h>
71185b48
UH
25#include "lib.h"
26
27/* Check whether at least one output module is available. */
28START_TEST(test_output_available)
29{
a755b0e1 30 const struct sr_output_module **outputs;
71185b48
UH
31
32 outputs = sr_output_list();
33 fail_unless(outputs != NULL, "No output modules found.");
34}
35END_TEST
36
a755b0e1
BV
37/* Check whether sr_output_id_get() works. */
38START_TEST(test_output_id)
39{
40 const struct sr_output_module **outputs;
41 const char *id;
42
43 outputs = sr_output_list();
44
45 id = sr_output_id_get(outputs[0]);
46 fail_unless(id != NULL, "No id found in output module.");
47}
48END_TEST
49
50/* Check whether sr_output_name_get() works. */
51START_TEST(test_output_name)
52{
53 const struct sr_output_module **outputs;
54 const char *name;
55
56 outputs = sr_output_list();
57
58 name = sr_output_name_get(outputs[0]);
59 fail_unless(name != NULL, "No name found in output module.");
60}
61END_TEST
62
63/* Check whether sr_output_description_get() works. */
64START_TEST(test_output_desc)
65{
66 const struct sr_output_module **outputs;
67 const char *desc;
68
69 outputs = sr_output_list();
70
71 desc = sr_output_description_get(outputs[0]);
72 fail_unless(desc != NULL, "No description found in output module.");
73}
74END_TEST
75
76/* Check whether sr_output_find() works. */
77START_TEST(test_output_find)
78{
79 const struct sr_output_module *omod;
80 const char *id;
81
82 omod = sr_output_find("bits");
83 fail_unless(omod != NULL, "Couldn't find the 'bits' output module.");
84 id = sr_output_id_get(omod);
85 fail_unless(!strcmp(id, "bits"), "That is not the 'bits' module!");
86}
87END_TEST
88
89/* Check whether sr_output_options_get() works. */
90START_TEST(test_output_options)
91{
34f4e3b4 92 const struct sr_option **opt;
a755b0e1
BV
93
94 opt = sr_output_options_get(sr_output_find("bits"));
95 fail_unless(opt != NULL, "Couldn't find 'bits' options.");
34f4e3b4 96 fail_unless(!strcmp((*opt)->id, "width"), "Wrong 'bits' option found!");
a755b0e1
BV
97}
98END_TEST
99
71185b48
UH
100Suite *suite_output_all(void)
101{
102 Suite *s;
103 TCase *tc;
104
105 s = suite_create("output-all");
106
107 tc = tcase_create("basic");
108 tcase_add_test(tc, test_output_available);
a755b0e1
BV
109 tcase_add_test(tc, test_output_id);
110 tcase_add_test(tc, test_output_name);
111 tcase_add_test(tc, test_output_desc);
112 tcase_add_test(tc, test_output_find);
113 tcase_add_test(tc, test_output_options);
71185b48
UH
114 suite_add_tcase(s, tc);
115
116 return s;
117}