[hamradio-commits] [gnss-sdr] 224/236: simplifiying unit test gnuradio message rx class

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Tue Apr 26 16:02:57 UTC 2016


This is an automated email from the git hooks/post-receive script.

carles_fernandez-guest pushed a commit to branch next
in repository gnss-sdr.

commit 273cc945c2be09c707539355b383fc58fc66a971
Author: Javier Arribas <javiarribas at gmail.com>
Date:   Mon Apr 25 20:20:41 2016 +0200

    simplifiying unit test gnuradio message rx class
---
 .../galileo_e1_pcps_ambiguous_acquisition_test.cc        | 15 ++++++---------
 src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc  | 15 ++++++---------
 src/tests/gnss_block/gps_l2_m_dll_pll_tracking_test.cc   | 10 ++++------
 src/tests/gnss_block/gps_l2_m_pcps_acquisition_test.cc   | 16 ++++++----------
 4 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc b/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc
index 2254482..63e6a33 100644
--- a/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc
+++ b/src/tests/gnss_block/galileo_e1_pcps_ambiguous_acquisition_test.cc
@@ -66,7 +66,7 @@ private:
     GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx();
 
 public:
-    int* rx_message;
+    int rx_message;
     ~GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx(); //!< Default destructor
 
 };
@@ -80,11 +80,11 @@ void GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t
 {
     try {
         long int message=pmt::to_long(msg);
-        *rx_message=message;
+        rx_message=message;
     }catch(boost::bad_any_cast& e)
     {
             LOG(WARNING) << "msg_handler_telemetry Bad any cast!\n";
-            *rx_message = 0;
+            rx_message = 0;
     }
 }
 
@@ -94,7 +94,7 @@ GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::GalileoE1PcpsAmbiguousAcquisitionT
 
     this->message_port_register_in(pmt::mp("events"));
     this->set_msg_handler(pmt::mp("events"), boost::bind(&GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::msg_handler_events, this, _1));
-
+    rx_message = 0;
 }
 
 GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx()
@@ -164,14 +164,12 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ConnectAndRun)
     struct timeval tv;
     long long int begin = 0;
     long long int end = 0;
-    int message=0;
     top_block = gr::make_top_block("Acquisition test");
     queue = gr::msg_queue::make(0);
     init();
     std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1, queue);
     std::shared_ptr<AcquisitionInterface> acquisition = std::dynamic_pointer_cast<AcquisitionInterface>(acq_);
     boost::shared_ptr<GpsL2MPcpsAcquisitionTest_msg_rx> msg_rx = GpsL2MPcpsAcquisitionTest_msg_rx_make();
-    msg_rx->rx_message=&message; // set message pointer to get last acquisition message
 
     ASSERT_NO_THROW( {
         acquisition->connect(top_block);
@@ -198,7 +196,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults)
     struct timeval tv;
     long long int begin = 0;
     long long int end = 0;
-    int message=0;
+
     double expected_delay_samples = 2920; //18250;
     double expected_doppler_hz = -632;
     init();
@@ -207,7 +205,6 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults)
     std::shared_ptr<GNSSBlockInterface> acq_ = factory->GetBlock(config, "Acquisition", "Galileo_E1_PCPS_Ambiguous_Acquisition", 1, 1, queue);
     std::shared_ptr<GalileoE1PcpsAmbiguousAcquisition> acquisition = std::dynamic_pointer_cast<GalileoE1PcpsAmbiguousAcquisition>(acq_);
     boost::shared_ptr<GpsL2MPcpsAcquisitionTest_msg_rx> msg_rx = GpsL2MPcpsAcquisitionTest_msg_rx_make();
-    msg_rx->rx_message=&message; // set message pointer to get last acquisition message
 
     ASSERT_NO_THROW( {
         acquisition->set_channel(gnss_synchro.Channel_ID);
@@ -256,7 +253,7 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults)
 
     unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples;
     std::cout <<  "Acquired " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
-    ASSERT_EQ(1, *(msg_rx->rx_message)) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
+    ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
 
     std::cout << "Delay: " << gnss_synchro.Acq_delay_samples << std::endl;
     std::cout << "Doppler: " << gnss_synchro.Acq_doppler_hz << std::endl;
diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc
index 3428b55..a060469 100644
--- a/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc
+++ b/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc
@@ -68,7 +68,7 @@ private:
     GpsL1CaPcpsAcquisitionTest_msg_rx();
 
 public:
-    int* rx_message;
+    int rx_message;
     ~GpsL1CaPcpsAcquisitionTest_msg_rx(); //!< Default destructor
 
 };
@@ -82,11 +82,11 @@ void GpsL1CaPcpsAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t msg)
 {
     try {
         long int message=pmt::to_long(msg);
-        *rx_message=message;
+        rx_message=message;
     }catch(boost::bad_any_cast& e)
     {
             LOG(WARNING) << "msg_handler_telemetry Bad any cast!\n";
-            *rx_message = 0;
+            rx_message = 0;
     }
 }
 
@@ -96,7 +96,7 @@ GpsL1CaPcpsAcquisitionTest_msg_rx::GpsL1CaPcpsAcquisitionTest_msg_rx() :
 
     this->message_port_register_in(pmt::mp("events"));
     this->set_msg_handler(pmt::mp("events"), boost::bind(&GpsL1CaPcpsAcquisitionTest_msg_rx::msg_handler_events, this, _1));
-
+    rx_message=0;
 }
 
 GpsL1CaPcpsAcquisitionTest_msg_rx::~GpsL1CaPcpsAcquisitionTest_msg_rx()
@@ -166,13 +166,11 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun)
     struct timeval tv;
     long long int begin = 0;
     long long int end = 0;
-    int message=0;
 
     top_block = gr::make_top_block("Acquisition test");
     init();
     boost::shared_ptr<GpsL1CaPcpsAcquisition> acquisition = boost::make_shared<GpsL1CaPcpsAcquisition>(config.get(), "Acquisition", 1, 1);
     boost::shared_ptr<GpsL1CaPcpsAcquisitionTest_msg_rx> msg_rx = GpsL1CaPcpsAcquisitionTest_msg_rx_make();
-    msg_rx->rx_message=&message; // set message pointer to get last acquisition message
 
     ASSERT_NO_THROW( {
         acquisition->connect(top_block);
@@ -206,9 +204,8 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults)
     double expected_doppler_hz = 1680;
     init();
     std::shared_ptr<GpsL1CaPcpsAcquisition> acquisition = std::make_shared<GpsL1CaPcpsAcquisition>(config.get(), "Acquisition", 1, 1);
-    int message=0;
+
     boost::shared_ptr<GpsL1CaPcpsAcquisitionTest_msg_rx> msg_rx = GpsL1CaPcpsAcquisitionTest_msg_rx_make();
-    msg_rx->rx_message=&message; // set message pointer to get last acquisition message
 
     ASSERT_NO_THROW( {
         acquisition->set_channel(1);
@@ -260,7 +257,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults)
     unsigned long int nsamples = gnss_synchro.Acq_samplestamp_samples;
     std::cout <<  "Acquired " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
 
-    ASSERT_EQ(1, *(msg_rx->rx_message)) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
+    ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
 
     double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples);
     float delay_error_chips = (float)(delay_error_samples * 1023 / 4000);
diff --git a/src/tests/gnss_block/gps_l2_m_dll_pll_tracking_test.cc b/src/tests/gnss_block/gps_l2_m_dll_pll_tracking_test.cc
index a289aef..7faa1a1 100644
--- a/src/tests/gnss_block/gps_l2_m_dll_pll_tracking_test.cc
+++ b/src/tests/gnss_block/gps_l2_m_dll_pll_tracking_test.cc
@@ -65,7 +65,7 @@ private:
     GpsL2MDllPllTrackingTest_msg_rx();
 
 public:
-    int* rx_message;
+    int rx_message;
     ~GpsL2MDllPllTrackingTest_msg_rx(); //!< Default destructor
 
 };
@@ -79,11 +79,11 @@ void GpsL2MDllPllTrackingTest_msg_rx::msg_handler_events(pmt::pmt_t msg)
 {
     try {
         long int message=pmt::to_long(msg);
-        *rx_message=message;
+        rx_message=message;
     }catch(boost::bad_any_cast& e)
     {
             LOG(WARNING) << "msg_handler_telemetry Bad any cast!\n";
-            *rx_message = 0;
+            rx_message = 0;
     }
 }
 
@@ -93,7 +93,7 @@ GpsL2MDllPllTrackingTest_msg_rx::GpsL2MDllPllTrackingTest_msg_rx() :
 
     this->message_port_register_in(pmt::mp("events"));
     this->set_msg_handler(pmt::mp("events"), boost::bind(&GpsL2MDllPllTrackingTest_msg_rx::msg_handler_events, this, _1));
-
+    rx_message = 0;
 }
 
 GpsL2MDllPllTrackingTest_msg_rx::~GpsL2MDllPllTrackingTest_msg_rx()
@@ -154,14 +154,12 @@ TEST_F(GpsL2MDllPllTrackingTest, ValidationOfResults)
     long long int end = 0;
     int fs_in = 5000000;
     int nsamples = fs_in*9;
-    int message=0;
 
     init();
     queue = gr::msg_queue::make(0);
     top_block = gr::make_top_block("Tracking test");
     std::shared_ptr<TrackingInterface> tracking = std::make_shared<GpsL2MDllPllTracking>(config.get(), "Tracking_2S", 1, 1, queue);
     boost::shared_ptr<GpsL2MDllPllTrackingTest_msg_rx> msg_rx = GpsL2MDllPllTrackingTest_msg_rx_make();
-    msg_rx->rx_message=&message; // set message pointer to get last message
 
     gnss_synchro.Acq_delay_samples = 1;
     gnss_synchro.Acq_doppler_hz = 1200;
diff --git a/src/tests/gnss_block/gps_l2_m_pcps_acquisition_test.cc b/src/tests/gnss_block/gps_l2_m_pcps_acquisition_test.cc
index eafaffa..4193a51 100644
--- a/src/tests/gnss_block/gps_l2_m_pcps_acquisition_test.cc
+++ b/src/tests/gnss_block/gps_l2_m_pcps_acquisition_test.cc
@@ -71,7 +71,7 @@ private:
     GpsL2MPcpsAcquisitionTest_msg_rx();
 
 public:
-    int* rx_message;
+    int rx_message;
     ~GpsL2MPcpsAcquisitionTest_msg_rx(); //!< Default destructor
 
 };
@@ -85,11 +85,11 @@ void GpsL2MPcpsAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t msg)
 {
     try {
         long int message=pmt::to_long(msg);
-        *rx_message=message;
+        rx_message=message;
     }catch(boost::bad_any_cast& e)
     {
             LOG(WARNING) << "msg_handler_telemetry Bad any cast!\n";
-            *rx_message = 0;
+            rx_message = 0;
     }
 }
 
@@ -99,7 +99,7 @@ GpsL2MPcpsAcquisitionTest_msg_rx::GpsL2MPcpsAcquisitionTest_msg_rx() :
 
     this->message_port_register_in(pmt::mp("events"));
     this->set_msg_handler(pmt::mp("events"), boost::bind(&GpsL2MPcpsAcquisitionTest_msg_rx::msg_handler_events, this, _1));
-
+    rx_message = 0;
 }
 
 GpsL2MPcpsAcquisitionTest_msg_rx::~GpsL2MPcpsAcquisitionTest_msg_rx()
@@ -158,7 +158,6 @@ void GpsL2MPcpsAcquisitionTest::init()
     config->set_property("Acquisition.doppler_max", "5000");
     config->set_property("Acquisition.doppler_step", "100");
     config->set_property("Acquisition.repeat_satellite", "false");
-    //config->set_property("Acquisition.pfa", "0.0");
 }
 
 
@@ -174,7 +173,6 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ConnectAndRun)
     struct timeval tv;
     long long int begin = 0;
     long long int end = 0;
-    int message=0;
     top_block = gr::make_top_block("Acquisition test");
     queue = gr::msg_queue::make(0);
 
@@ -188,7 +186,7 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ConnectAndRun)
         top_block->connect(source, 0, valve, 0);
         top_block->connect(valve, 0, acquisition->get_left_block(), 0);
         boost::shared_ptr<GpsL2MPcpsAcquisitionTest_msg_rx> msg_rx = GpsL2MPcpsAcquisitionTest_msg_rx_make();
-        msg_rx->rx_message=&message; // set message pointer to get last acquisition message
+
     }) << "Failure connecting the blocks of acquisition test." << std::endl;
 
     EXPECT_NO_THROW( {
@@ -207,7 +205,6 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ValidationOfResults)
     struct timeval tv;
     long long int begin = 0;
     long long int end = 0;
-    int message=0;
     top_block = gr::make_top_block("Acquisition test");
     queue = gr::msg_queue::make(0);
     double expected_delay_samples = 1;//2004;
@@ -215,7 +212,6 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ValidationOfResults)
     init();
     std::shared_ptr<GpsL2MPcpsAcquisition> acquisition = std::make_shared<GpsL2MPcpsAcquisition>(config.get(), "Acquisition", 1, 1);
     boost::shared_ptr<GpsL2MPcpsAcquisitionTest_msg_rx> msg_rx = GpsL2MPcpsAcquisitionTest_msg_rx_make();
-    msg_rx->rx_message=&message; // set message pointer to get last acquisition message
 
     ASSERT_NO_THROW( {
         acquisition->set_channel(1);
@@ -278,7 +274,7 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ValidationOfResults)
     std::cout <<  "gnss_synchro.Acq_doppler_hz = " << gnss_synchro.Acq_doppler_hz << " Hz" << std::endl;
     std::cout <<  "gnss_synchro.Acq_delay_samples = " << gnss_synchro.Acq_delay_samples << " Samples" << std::endl;
 
-    ASSERT_EQ(1, *(msg_rx->rx_message)) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
+    ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
 
     double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples);
     float delay_error_chips = (float)(delay_error_samples * 1023 / 4000);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git



More information about the pkg-hamradio-commits mailing list