2012-01-23 00:52:05 +00:00
|
|
|
/*!
|
|
|
|
* \file gnss_sdr_valve_test.cc
|
|
|
|
* \brief This file implements unit tests for the valve custom block.
|
|
|
|
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
|
|
|
|
* Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es
|
|
|
|
*
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2012-01-23 00:52:05 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2012-01-23 00:52:05 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2012-01-23 00:52:05 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2011-10-01 18:45:20 +00:00
|
|
|
*/
|
|
|
|
|
2012-01-23 00:52:05 +00:00
|
|
|
|
2013-02-17 09:54:41 +00:00
|
|
|
#include <gnuradio/analog/sig_source_waveform.h>
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <gnuradio/top_block.h>
|
2018-08-31 11:52:35 +00:00
|
|
|
#ifdef GR_GREATER_38
|
|
|
|
#include <gnuradio/analog/sig_source.h>
|
|
|
|
#else
|
2013-02-17 09:54:41 +00:00
|
|
|
#include <gnuradio/analog/sig_source_f.h>
|
2018-08-31 11:52:35 +00:00
|
|
|
#endif
|
2019-07-17 13:56:30 +00:00
|
|
|
#include "concurrent_queue.h"
|
2018-12-09 21:00:09 +00:00
|
|
|
#include "gnss_sdr_valve.h"
|
2013-07-04 13:47:40 +00:00
|
|
|
#include <gnuradio/blocks/null_sink.h>
|
2019-07-17 13:56:30 +00:00
|
|
|
#include <pmt/pmt.h>
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2017-06-25 20:53:11 +00:00
|
|
|
TEST(ValveTest, CheckEventSentAfter100Samples)
|
2012-01-23 00:52:05 +00:00
|
|
|
{
|
2020-06-18 09:49:28 +00:00
|
|
|
auto queue = std::make_shared<Concurrent_Queue<pmt::pmt_t>>();
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2020-06-18 09:49:28 +00:00
|
|
|
auto top_block = gr::make_top_block("gnss_sdr_valve_test");
|
2013-02-17 09:54:41 +00:00
|
|
|
|
2020-06-18 09:49:28 +00:00
|
|
|
auto source = gr::analog::sig_source_f::make(100, gr::analog::GR_CONST_WAVE, 100, 1, 0);
|
|
|
|
auto valve = gnss_sdr_make_valve(sizeof(float), 100, queue.get());
|
|
|
|
auto sink = gr::blocks::null_sink::make(sizeof(float));
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2019-07-17 13:56:30 +00:00
|
|
|
bool expected0 = false;
|
|
|
|
pmt::pmt_t msg;
|
|
|
|
EXPECT_EQ(expected0, queue->timed_wait_and_pop(msg, 100));
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2012-01-23 00:52:05 +00:00
|
|
|
top_block->connect(source, 0, valve, 0);
|
|
|
|
top_block->connect(valve, 0, sink, 0);
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2012-01-23 00:52:05 +00:00
|
|
|
top_block->run();
|
|
|
|
top_block->stop();
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2019-07-17 13:56:30 +00:00
|
|
|
bool expected1 = true;
|
|
|
|
EXPECT_EQ(expected1, queue->timed_wait_and_pop(msg, 100));
|
2012-01-23 00:52:05 +00:00
|
|
|
}
|