]>
Commit | Line | Data |
---|---|---|
3b3a445c JH |
1 | /* |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk> | |
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 | ||
3b3a445c | 21 | #include <libsigrokdecode/libsigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */ |
6ab78775 | 22 | #include <boost/test/unit_test.hpp> |
3b3a445c JH |
23 | |
24 | #include <libsigrok/libsigrok.h> | |
25 | ||
6e89374a | 26 | #include "../../pv/data/decoderstack.h" |
3b3a445c JH |
27 | #include "../../pv/devicemanager.h" |
28 | #include "../../pv/sigsession.h" | |
b9329558 | 29 | #include "../../pv/view/decodetrace.h" |
3b3a445c JH |
30 | |
31 | using namespace boost; | |
32 | using namespace std; | |
33 | ||
6e89374a | 34 | BOOST_AUTO_TEST_SUITE(DecoderStackTest) |
3b3a445c | 35 | |
6e89374a | 36 | BOOST_AUTO_TEST_CASE(TwoDecoderStack) |
3b3a445c | 37 | { |
b6b267bb JH |
38 | using namespace pv; |
39 | ||
3b3a445c JH |
40 | sr_context *ctx = NULL; |
41 | ||
42 | BOOST_REQUIRE(sr_init(&ctx) == SR_OK); | |
43 | BOOST_REQUIRE(ctx); | |
44 | ||
45 | BOOST_REQUIRE(srd_init(NULL) == SRD_OK); | |
46 | ||
47 | srd_decoder_load_all(); | |
48 | ||
49 | { | |
50 | pv::DeviceManager dm(ctx); | |
51 | pv::SigSession ss(dm); | |
52 | ||
53 | const GSList *l = srd_decoder_list(); | |
54 | BOOST_REQUIRE(l); | |
55 | srd_decoder *const dec = (struct srd_decoder*)l->data; | |
56 | BOOST_REQUIRE(dec); | |
57 | ||
4e5a4405 JH |
58 | ss.add_decoder(dec); |
59 | ss.add_decoder(dec); | |
b6b267bb JH |
60 | |
61 | // Check the signals were created | |
b9329558 | 62 | const vector< shared_ptr<view::DecodeTrace> > sigs = |
b6b267bb JH |
63 | ss.get_decode_signals(); |
64 | ||
6e89374a | 65 | shared_ptr<data::DecoderStack> dec0 = sigs[0]->decoder(); |
b6b267bb JH |
66 | BOOST_REQUIRE(dec0); |
67 | ||
6e89374a | 68 | shared_ptr<data::DecoderStack> dec1 = sigs[0]->decoder(); |
b6b267bb JH |
69 | BOOST_REQUIRE(dec1); |
70 | ||
71 | // Wait for the decode threads to complete | |
72 | dec0->_decode_thread.join(); | |
73 | dec1->_decode_thread.join(); | |
74 | ||
75 | // Check there were no errors | |
76 | BOOST_CHECK_EQUAL(dec0->error_message().isEmpty(), true); | |
77 | BOOST_CHECK_EQUAL(dec1->error_message().isEmpty(), true); | |
3b3a445c JH |
78 | } |
79 | ||
80 | ||
81 | srd_exit(); | |
82 | sr_exit(ctx); | |
83 | } | |
84 | ||
85 | BOOST_AUTO_TEST_SUITE_END() |