]>
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 | |
efdec55a | 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
3b3a445c JH |
18 | */ |
19 | ||
83b1c8d2 UH |
20 | #if 0 |
21 | ||
3b3a445c | 22 | #include <libsigrokdecode/libsigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */ |
6ab78775 | 23 | #include <boost/test/unit_test.hpp> |
3b3a445c | 24 | |
fe3a1c21 | 25 | #include <libsigrokcxx/libsigrokcxx.hpp> |
3b3a445c | 26 | |
c17403e8 UH |
27 | #include "../../pv/data/decoderstack.hpp" |
28 | #include "../../pv/devicemanager.hpp" | |
f65cd27b | 29 | #include "../../pv/session.hpp" |
c17403e8 | 30 | #include "../../pv/view/decodetrace.hpp" |
3b3a445c | 31 | |
819f4c25 JH |
32 | using pv::data::DecoderStack; |
33 | using pv::data::decode::Decoder; | |
34 | using pv::view::DecodeTrace; | |
f9abf97e | 35 | using std::shared_ptr; |
819f4c25 | 36 | using std::vector; |
3b3a445c | 37 | |
6e89374a | 38 | BOOST_AUTO_TEST_SUITE(DecoderStackTest) |
3b3a445c | 39 | |
6e89374a | 40 | BOOST_AUTO_TEST_CASE(TwoDecoderStack) |
3b3a445c | 41 | { |
4c60462b | 42 | sr_context *ctx = nullptr; |
3b3a445c JH |
43 | |
44 | BOOST_REQUIRE(sr_init(&ctx) == SR_OK); | |
45 | BOOST_REQUIRE(ctx); | |
46 | ||
4c60462b | 47 | BOOST_REQUIRE(srd_init(nullptr) == SRD_OK); |
3b3a445c JH |
48 | |
49 | srd_decoder_load_all(); | |
50 | ||
51 | { | |
52 | pv::DeviceManager dm(ctx); | |
2b81ae46 | 53 | pv::Session ss(dm); |
3b3a445c JH |
54 | |
55 | const GSList *l = srd_decoder_list(); | |
56 | BOOST_REQUIRE(l); | |
57 | srd_decoder *const dec = (struct srd_decoder*)l->data; | |
58 | BOOST_REQUIRE(dec); | |
59 | ||
4e5a4405 JH |
60 | ss.add_decoder(dec); |
61 | ss.add_decoder(dec); | |
b6b267bb JH |
62 | |
63 | // Check the signals were created | |
819f4c25 | 64 | const vector< shared_ptr<DecodeTrace> > sigs = |
b6b267bb JH |
65 | ss.get_decode_signals(); |
66 | ||
819f4c25 | 67 | shared_ptr<DecoderStack> dec0 = sigs[0]->decoder(); |
b6b267bb JH |
68 | BOOST_REQUIRE(dec0); |
69 | ||
819f4c25 | 70 | shared_ptr<DecoderStack> dec1 = sigs[0]->decoder(); |
b6b267bb JH |
71 | BOOST_REQUIRE(dec1); |
72 | ||
73 | // Wait for the decode threads to complete | |
8dbbc7f0 JH |
74 | dec0->decode_thread_.join(); |
75 | dec1->decode_thread_.join(); | |
b6b267bb JH |
76 | |
77 | // Check there were no errors | |
78 | BOOST_CHECK_EQUAL(dec0->error_message().isEmpty(), true); | |
79 | BOOST_CHECK_EQUAL(dec1->error_message().isEmpty(), true); | |
3b3a445c JH |
80 | } |
81 | ||
82 | ||
83 | srd_exit(); | |
84 | sr_exit(ctx); | |
85 | } | |
86 | ||
87 | BOOST_AUTO_TEST_SUITE_END() | |
48ecc1fc | 88 | #endif |