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