diff --git a/src/algorithms/acquisition/gnuradio_blocks/gps_l1_ca_pcps_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/gps_l1_ca_pcps_acquisition_cc.cc index c10567062..623a6b414 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/gps_l1_ca_pcps_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/gps_l1_ca_pcps_acquisition_cc.cc @@ -126,6 +126,10 @@ void gps_l1_ca_pcps_acquisition_cc::set_satellite(Gnss_Satellite satellite) // Now the GPS codes are generated on the fly using a custom version of the GPS code generator code_gen_complex_sampled(d_fft_if->get_inbuf(), satellite.get_PRN(), d_fs_in, 0); + + + + d_fft_if->execute(); // We need the FFT of GPS C/A code //Conjugate the local code //TODO Optimize it ! try conj() diff --git a/src/algorithms/libs/gps_sdr_signal_processing.cc b/src/algorithms/libs/gps_sdr_signal_processing.cc index d397b8db4..8f999e312 100644 --- a/src/algorithms/libs/gps_sdr_signal_processing.cc +++ b/src/algorithms/libs/gps_sdr_signal_processing.cc @@ -146,50 +146,50 @@ signed int code_gen(CPX *_dest, signed int _prn) */ void code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift) { - // This function is based on the GNU software GPS for MATLAB in the Kay Borre book - std::complex _code[1023]; - signed int _samplesPerCode,_codeValueIndex; - float _ts; - float _tc; - const signed int _codeFreqBasis=1023000; //Hz - const signed int _codeLength=1023; + // This function is based on the GNU software GPS for MATLAB in the Kay Borre book + std::complex _code[1023]; + signed int _samplesPerCode, _codeValueIndex; + float _ts; + float _tc; + const signed int _codeFreqBasis = 1023000; //Hz + const signed int _codeLength = 1023; - //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = round(_fs / (_codeFreqBasis / _codeLength)); + //--- Find number of samples per spreading code ---------------------------- + _samplesPerCode = round(_fs / (_codeFreqBasis / _codeLength)); - //--- Find time constants -------------------------------------------------- - _ts = 1/(float)_fs; // Sampling period in sec - _tc = 1/(float)_codeFreqBasis; // C/A chip period in sec - code_gen_conplex(_code,_prn,_chip_shift); //generate C/A code 1 sample per chip - //std::cout<<"ts="<<_ts< upsample - } - //std::cout<<_codeValueIndex; - - } + //--- Make the digitized version of the C/A code ----------------------- + // The "upsampled" code is made by selecting values form the CA code + // chip array (caCode) for the time instances of each sample. + if (i == _samplesPerCode - 1) + { + //--- Correct the last index (due to number rounding issues) ----------- + _dest[i] = _code[_codeLength - 1]; + } + else + { + _dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample + } + } } diff --git a/src/algorithms/libs/pass_through.cc b/src/algorithms/libs/pass_through.cc index ab5477c65..dd1e795f9 100644 --- a/src/algorithms/libs/pass_through.cc +++ b/src/algorithms/libs/pass_through.cc @@ -42,7 +42,7 @@ using google::LogMessage; -PassThrough::PassThrough(ConfigurationInterface* configuration, std::string role, +Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string role, unsigned int in_streams, unsigned int out_streams) : role_(role), @@ -77,25 +77,25 @@ PassThrough::PassThrough(ConfigurationInterface* configuration, std::string role DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")"; } -PassThrough::~PassThrough() +Pass_Through::~Pass_Through() {} -void PassThrough::connect(gr_top_block_sptr top_block) +void Pass_Through::connect(gr_top_block_sptr top_block) { DLOG(INFO) << "nothing to connect internally"; } -void PassThrough::disconnect(gr_top_block_sptr top_block) +void Pass_Through::disconnect(gr_top_block_sptr top_block) { // Nothing to disconnect } -gr_basic_block_sptr PassThrough::get_left_block() +gr_basic_block_sptr Pass_Through::get_left_block() { return kludge_copy_; } -gr_basic_block_sptr PassThrough::get_right_block() +gr_basic_block_sptr Pass_Through::get_right_block() { return kludge_copy_; } diff --git a/src/algorithms/libs/pass_through.h b/src/algorithms/libs/pass_through.h index 25f51e333..b747923b1 100644 --- a/src/algorithms/libs/pass_through.h +++ b/src/algorithms/libs/pass_through.h @@ -43,16 +43,16 @@ class ConfigurationInterface; -class PassThrough : public GNSSBlockInterface +class Pass_Through : public GNSSBlockInterface { public: - PassThrough(ConfigurationInterface* configuration, + Pass_Through(ConfigurationInterface* configuration, std::string role, unsigned int in_stream, unsigned int out_stream); - virtual ~PassThrough(); + virtual ~Pass_Through(); std::string role() { diff --git a/src/algorithms/output_filter/adapters/file_output_filter.cc b/src/algorithms/output_filter/adapters/file_output_filter.cc index 9e8a32732..865fe1840 100644 --- a/src/algorithms/output_filter/adapters/file_output_filter.cc +++ b/src/algorithms/output_filter/adapters/file_output_filter.cc @@ -46,7 +46,7 @@ FileOutputFilter::FileOutputFilter(ConfigurationInterface* configuration, out_streams_(out_streams) { - std::string default_filename = "./data/signal.dat"; + std::string default_filename = "./output.dat"; std::string default_item_type = "short"; filename_ = configuration->property(role + ".filename", default_filename); diff --git a/src/algorithms/signal_source/adapters/file_signal_source.cc b/src/algorithms/signal_source/adapters/file_signal_source.cc index 38d2b31e3..b2c7ba433 100644 --- a/src/algorithms/signal_source/adapters/file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/file_signal_source.cc @@ -51,98 +51,95 @@ DEFINE_string(signal_source, "-", FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, std::string role, unsigned int in_streams, unsigned int out_streams, gr_msg_queue_sptr queue) : - role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_( - queue) + role_(role), in_streams_(in_streams), out_streams_(out_streams), queue_(queue) { - std::string default_filename = "./signal_samples/signal.dat"; + std::string default_filename = "../data/sc2_d16.dat"; std::string default_item_type = "short"; - std::string default_dump_filename = "./data/signal_source.dat"; + std::string default_dump_filename = "../data/sc2_d16.dat"; samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role - + ".sampling_frequency", 0); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); filename_ = configuration->property(role + ".filename", default_filename); + // override value with commandline flag, if present if (FLAGS_signal_source.compare("-") != 0) filename_= FLAGS_signal_source; - item_type_ = configuration->property(role + ".item_type", - default_item_type); + item_type_ = configuration->property(role + ".item_type", default_item_type); repeat_ = configuration->property(role + ".repeat", false); dump_ = configuration->property(role + ".dump", false); - dump_filename_ = configuration->property(role + ".dump_filename", - default_dump_filename); - enable_throttle_control_ = configuration->property(role - + ".enable_throttle_control", false); + dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); + enable_throttle_control_ = configuration->property(role + ".enable_throttle_control", false); if (item_type_.compare("gr_complex") == 0) - { - item_size_ = sizeof(gr_complex); - } + { + item_size_ = sizeof(gr_complex); + } else if (item_type_.compare("float") == 0) - { - item_size_ = sizeof(float); - } + { + item_size_ = sizeof(float); + } else if (item_type_.compare("short") == 0) - { - item_size_ = sizeof(short); - } + { + item_size_ = sizeof(short); + } else - { - LOG_AT_LEVEL(WARNING) << item_type_ - << " unrecognized item type. Using short."; - item_size_ = sizeof(short); - } + { + LOG_AT_LEVEL(WARNING) << item_type_ + << " unrecognized item type. Using short."; + item_size_ = sizeof(short); + } - file_source_ - = gr_make_file_source(item_size_, filename_.c_str(), repeat_); + file_source_ = gr_make_file_source(item_size_, filename_.c_str(), repeat_); DLOG(INFO) << "file_source(" << file_source_->unique_id() << ")"; - if (samples_==0) - { - /*! - * BUG workaround: The GNURadio file source does not stop the receiver after reaching the End of File. - * A possible solution is to compute the file length in samples using file size, excluding the last 100 milliseconds, and enable always the - * valve block - */ - std::ifstream file (filename_.c_str(), std::ios::in|std::ios::binary|std::ios::ate); - std::ifstream::pos_type size; - if (file.is_open()) - { - size =file.tellg(); - }else{ - std::cout<<"file_signal_source: Unable to open the samples file "<0) - { - samples_=floor((double)size/(double)item_size())-ceil(0.1*(double)sampling_frequency_); //process all the samples available in the file excluding the last 100 ms + if (samples_ == 0) + { + /*! + * BUG workaround: The GNURadio file source does not stop the receiver after reaching the End of File. + * A possible solution is to compute the file length in samples using file size, excluding the last 100 milliseconds, and enable always the + * valve block + */ + std::ifstream file (filename_.c_str(), std::ios::in | std::ios::binary | std::ios::ate); + std::ifstream::pos_type size; + if (file.is_open()) + { + size = file.tellg(); + } + else + { + std::cout << "file_signal_source: Unable to open the samples file " << filename_.c_str() << std::endl; + LOG_AT_LEVEL(ERROR) << "file_signal_source: Unable to open the samples file " << filename_.c_str(); + } + std::cout << std::setprecision(16); + std::cout <<"Processing file " << filename_ << ", which contains " << (double)size << " [bytes]" << std::endl; + if (size > 0) + { + samples_ = floor((double)size / (double)item_size()) - ceil(0.1 * (double)sampling_frequency_); //process all the samples available in the file excluding the last 100 ms - } - } + } + } double signal_duration_s; - signal_duration_s=(double)samples_*(1/(double)sampling_frequency_); - DLOG(INFO)<<"Total samples to be processed="<unique_id() << ")"; - } + { + valve_ = gnss_sdr_make_valve(item_size_, samples_, queue_); + DLOG(INFO) << "valve(" << valve_->unique_id() << ")"; + } if (dump_) - { - sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str()); - DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")"; - } + { + sink_ = gr_make_file_sink(item_size_, dump_filename_.c_str()); + DLOG(INFO) << "file_sink(" << sink_->unique_id() << ")"; + } if (enable_throttle_control_) - { - throttle_ = gr_make_throttle(item_size_, sampling_frequency_); - } + { + throttle_ = gr_make_throttle(item_size_, sampling_frequency_); + } DLOG(INFO) << "File source filename " << filename_; DLOG(INFO) << "Samples " << samples_; DLOG(INFO) << "Sampling frequency " << sampling_frequency_; @@ -151,132 +148,152 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, DLOG(INFO) << "Repeat " << repeat_; DLOG(INFO) << "Dump " << dump_; DLOG(INFO) << "Dump filename " << dump_filename_; - } + + + FileSignalSource::~FileSignalSource() -{ -} +{} + + + void FileSignalSource::connect(gr_top_block_sptr top_block) { if (samples_ != 0) - { - if (enable_throttle_control_ == true) { - top_block->connect(file_source_, 0, throttle_, 0); - DLOG(INFO) << "connected file source to throttle"; - top_block->connect(throttle_, 0, valve_, 0); - DLOG(INFO) << "connected throttle to valve"; - if (dump_) - { - top_block->connect(valve_, 0, sink_, 0); - DLOG(INFO) << "connected valve to file sink"; - } + if (enable_throttle_control_ == true) + { + top_block->connect(file_source_, 0, throttle_, 0); + DLOG(INFO) << "connected file source to throttle"; + top_block->connect(throttle_, 0, valve_, 0); + DLOG(INFO) << "connected throttle to valve"; + if (dump_) + { + top_block->connect(valve_, 0, sink_, 0); + DLOG(INFO) << "connected valve to file sink"; + } + } + else + { + top_block->connect(file_source_, 0, valve_, 0); + DLOG(INFO) << "connected file source to valve"; + if (dump_) + { + top_block->connect(valve_, 0, sink_, 0); + DLOG(INFO) << "connected valve to file sink"; + } + } } - else - { - top_block->connect(file_source_, 0, valve_, 0); - DLOG(INFO) << "connected file source to valve"; - if (dump_) - { - top_block->connect(valve_, 0, sink_, 0); - DLOG(INFO) << "connected valve to file sink"; - } - } - } else - { - if (enable_throttle_control_ == true) { - top_block->connect(file_source_, 0, throttle_, 0); - DLOG(INFO) << "connected file source to throttle"; - if (dump_) - { - top_block->connect(file_source_, 0, sink_, 0); - DLOG(INFO) << "connected file source to sink"; - } + if (enable_throttle_control_ == true) + { + top_block->connect(file_source_, 0, throttle_, 0); + DLOG(INFO) << "connected file source to throttle"; + if (dump_) + { + top_block->connect(file_source_, 0, sink_, 0); + DLOG(INFO) << "connected file source to sink"; + } + } + else + { + if (dump_) + { + top_block->connect(file_source_, 0, sink_, 0); + DLOG(INFO) << "connected file source to sink"; + } + } } - else - { - if (dump_) - { - top_block->connect(file_source_, 0, sink_, 0); - DLOG(INFO) << "connected file source to sink"; - } - } - } } + + + + + void FileSignalSource::disconnect(gr_top_block_sptr top_block) { if (samples_ != 0) - { - if (enable_throttle_control_ == true) { - top_block->disconnect(file_source_, 0, throttle_, 0); - DLOG(INFO) << "disconnected file source to throttle"; - top_block->disconnect(throttle_, 0, valve_, 0); - DLOG(INFO) << "disconnected throttle to valve"; - if (dump_) - { - top_block->disconnect(valve_, 0, sink_, 0); - DLOG(INFO) << "disconnected valve to file sink"; - } + if (enable_throttle_control_ == true) + { + top_block->disconnect(file_source_, 0, throttle_, 0); + DLOG(INFO) << "disconnected file source to throttle"; + top_block->disconnect(throttle_, 0, valve_, 0); + DLOG(INFO) << "disconnected throttle to valve"; + if (dump_) + { + top_block->disconnect(valve_, 0, sink_, 0); + DLOG(INFO) << "disconnected valve to file sink"; + } + } + else + { + top_block->disconnect(file_source_, 0, valve_, 0); + DLOG(INFO) << "disconnected file source to valve"; + if (dump_) + { + top_block->disconnect(valve_, 0, sink_, 0); + DLOG(INFO) << "disconnected valve to file sink"; + } + } } - else - { - top_block->disconnect(file_source_, 0, valve_, 0); - DLOG(INFO) << "disconnected file source to valve"; - if (dump_) - { - top_block->disconnect(valve_, 0, sink_, 0); - DLOG(INFO) << "disconnected valve to file sink"; - } - } - } else - { - if (enable_throttle_control_ == true) { - top_block->disconnect(file_source_, 0, throttle_, 0); - DLOG(INFO) << "disconnected file source to throttle"; - if (dump_) - { - top_block->disconnect(file_source_, 0, sink_, 0); - DLOG(INFO) << "disconnected file source to sink"; - } + if (enable_throttle_control_ == true) + { + top_block->disconnect(file_source_, 0, throttle_, 0); + DLOG(INFO) << "disconnected file source to throttle"; + if (dump_) + { + top_block->disconnect(file_source_, 0, sink_, 0); + DLOG(INFO) << "disconnected file source to sink"; + } + } + else + { + if (dump_) + { + top_block->disconnect(file_source_, 0, sink_, 0); + DLOG(INFO) << "disconnected file source to sink"; + } + } } - else - { - if (dump_) - { - top_block->disconnect(file_source_, 0, sink_, 0); - DLOG(INFO) << "disconnected file source to sink"; - } - } - } } + + + + gr_basic_block_sptr FileSignalSource::get_left_block() { LOG_AT_LEVEL(WARNING) - << "Left block of a signal source should not be retrieved"; + << "Left block of a signal source should not be retrieved"; return gr_block_sptr(); } + + + + gr_basic_block_sptr FileSignalSource::get_right_block() { - if (samples_ != 0) - { - return valve_; - }else - { - if (enable_throttle_control_ == true) - { - return throttle_; - }else{ - return file_source_; - } - } + if (samples_ != 0) + { + return valve_; + } + else + { + if (enable_throttle_control_ == true) + { + return throttle_; + } + else + { + return file_source_; + } + } } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.cc index f1b350cd4..77a90959f 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_fll_pll_tracking_cc.cc @@ -107,7 +107,7 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc(Gnss_Satell d_carrier_loop_filter.set_params(fll_bw_hz,pll_bw_hz,order); // Get space for a vector with the C/A code replica sampled 1x/chip - d_ca_code = new gr_complex[(int)GPS_L1_CA_CODE_LENGTH_CHIPS+2]; + d_ca_code = new gr_complex[(int)GPS_L1_CA_CODE_LENGTH_CHIPS + 2]; // Get space for the resampled early / prompt / late local replicas //d_early_code = new gr_complex[d_vector_length*2]; @@ -116,10 +116,16 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc(Gnss_Satell // space for carrier wipeoff LO vector //d_carr_sign = new gr_complex[d_vector_length*2]; - posix_memalign((void**)&d_early_code, 16, d_vector_length*sizeof(gr_complex)*2); - posix_memalign((void**)&d_late_code, 16, d_vector_length*sizeof(gr_complex)*2); - posix_memalign((void**)&d_prompt_code, 16, d_vector_length*sizeof(gr_complex)*2); - posix_memalign((void**)&d_carr_sign,16, d_vector_length*sizeof(gr_complex)*2); + /* If an array is partitioned for more than one thread to operate on, + * having the sub-array boundaries unaligned to cache lines could lead + * to performance degradation. Here we allocate memory + * (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes + */ + // todo: do something if posix_memalign fails + if (posix_memalign((void**)&d_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; + if (posix_memalign((void**)&d_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; + if (posix_memalign((void**)&d_prompt_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; + if (posix_memalign((void**)&d_carr_sign, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; // sample synchronization d_sample_counter = 0; @@ -138,7 +144,6 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc(Gnss_Satell d_CN0_SNV_dB_Hz = 0; d_carrier_lock_fail_counter = 0; d_carrier_lock_threshold = 5; - } @@ -213,7 +218,9 @@ void Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::start_tracking() d_pull_in = true; d_enable_tracking = true; - std::cout << "PULL-IN Doppler [Hz]= " << d_carrier_doppler_hz << " Code Phase correction [samples]=" << delay_correction_samples << " PULL-IN Code Phase [samples]= " << d_acq_code_phase_samples << std::endl; + std::cout << "PULL-IN Doppler [Hz]= " << d_carrier_doppler_hz + << " Code Phase correction [samples]=" << delay_correction_samples + << " PULL-IN Code Phase [samples]= " << d_acq_code_phase_samples << std::endl; } @@ -271,10 +278,6 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc() d_dump_file.close(); delete[] d_ca_code; - //delete[] d_early_code; - //delete[] d_prompt_code; - //delete[] d_late_code; - //delete[] d_carr_sign; free(d_prompt_code); free(d_late_code); free(d_early_code); @@ -292,14 +295,6 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc() int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - // if ((unsigned int)ninput_items[0]<(d_vector_length*2)) - // { - // std::cout<<"End of signal detected\r\n"; - // const int samples_available = ninput_items[0]; - // consume_each(samples_available); - // return 0; - // } - // process vars float code_error_chips = 0; float correlation_time_s = 0; float PLL_discriminator_hz = 0; @@ -318,26 +313,21 @@ int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vecto if (d_pull_in == true) { int samples_offset; - - // 28/11/2011 ACQ to TRK transition BUG CORRECTION float acq_trk_shif_correction_samples; int acq_to_trk_delay_samples; acq_to_trk_delay_samples = d_sample_counter-d_acq_sample_stamp; acq_trk_shif_correction_samples = d_next_prn_length_samples - fmod((float)acq_to_trk_delay_samples, (float)d_next_prn_length_samples); - //std::cout<<"acq_trk_shif_correction="<3) + if ((((float)d_sample_counter - (float)d_acq_sample_stamp) / (float)d_fs_in) > 3) { d_FLL_discriminator_hz = 0; //disconnect the FLL after the initial lock } - /*! + /* * DLL and FLL+PLL filter and get current carrier Doppler and code frequency */ carr_nco_hz = d_carrier_loop_filter.get_carrier_error(d_FLL_discriminator_hz, PLL_discriminator_hz, correlation_time_s); @@ -466,9 +445,7 @@ int Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::general_work (int noutput_items, gr_vecto d_channel_internal_queue->push(tracking_message); d_carrier_lock_fail_counter = 0; d_enable_tracking = false; // TODO: check if disabling tracking is consistent with the channel state machine - } - //std::cout<<"d_carrier_lock_fail_counter"<property("Channels.count", 12); std::vector* channels = new std::vector< @@ -242,7 +242,7 @@ GNSSBlockInterface* GNSSBlockFactory::GetBlock( else if (implementation.compare("Pass_Through") == 0) { - block = new PassThrough(configuration, role, in_streams, out_streams); + block = new Pass_Through(configuration, role, in_streams, out_streams); } diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 5cd2e3d93..53902d7be 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -442,10 +442,10 @@ void GNSSFlowgraph::set_satellites_list() { /* - * Sets a sequential list of satellites (1...33) + * Sets a sequential list of satellites (1...32) */ - /*! + /* * \TODO Describe GNSS satellites more nicely, with RINEX notation * See http://igscb.jpl.nasa.gov/igscb/data/format/rinex301.pdf (page 5) */ diff --git a/src/jamfile.jam b/src/jamfile.jam index a52a5d511..6d82b715c 100644 --- a/src/jamfile.jam +++ b/src/jamfile.jam @@ -1,5 +1,5 @@ build-project algorithms ; build-project core ; build-project main ; -# build-project tests ; +build-project tests ; diff --git a/src/tests/arithmetic/complex_arithmetic_gsl.cc b/src/tests/arithmetic/complex_arithmetic_gsl.cc deleted file mode 100644 index d9929854c..000000000 --- a/src/tests/arithmetic/complex_arithmetic_gsl.cc +++ /dev/null @@ -1,50 +0,0 @@ - -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include - -using google::LogMessage; - -DEFINE_int32(N, 2046, "Size of the arrays used for calculations"); -DEFINE_int32(M, 1000, "Iterations"); - -int main(int argc, char** argv) { - - google::InitGoogleLogging(argv[0]); - google::ParseCommandLineFlags(&argc, &argv, true); - - LOG_AT_LEVEL(INFO) << "Using standard GNU GSL library to perform complex arithmetic"; - - std::srand((int)time(0)); - - gsl_vector_complex* input = gsl_vector_complex_alloc(FLAGS_N); - gsl_complex zero; - GSL_SET_COMPLEX(&zero, std::rand() % 10000, std::rand() % 10000); - - gsl_vector_complex_set_all(input, zero); - - LOG_AT_LEVEL(INFO) << "Begin calculations"; - - struct timeval tv; - gettimeofday(&tv, NULL); - long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; - - for(int i=0;i. + * + * ------------------------------------------------------------------------- + */ + + + +#include +#include #include #include - -#include - +#include #include #include -#include -#include -#include using google::LogMessage; -DEFINE_int32(size, 100000, "Size of the arrays used for calculations"); +DEFINE_int32(size_multiply_test, 100000, "Size of the arrays used for calculations"); -int main(int argc, char** argv) { +TEST(Multiply_Test, StandardCImplementation) +{ + //LOG_AT_LEVEL(INFO) << "Using standard C++ library implementation to perform complex arithmetic"; + std::complex* input = new std::complex[FLAGS_size_multiply_test]; + std::complex* output = new std::complex[FLAGS_size_multiply_test]; - google::InitGoogleLogging(argv[0]); - google::ParseCommandLineFlags(&argc, &argv, true); + memset(input, 0, sizeof(std::complex) * FLAGS_size_multiply_test); - LOG_AT_LEVEL(INFO) << "Using standard C++ library implementation to perform complex arithmetic"; + //LOG_AT_LEVEL(INFO) << "Allocated two vectors containing " << FLAGS_size << " complex numbers"; + //LOG_AT_LEVEL(INFO) << "Begin multiplications"; - std::complex* input = new std::complex[FLAGS_size]; - std::complex* output = new std::complex[FLAGS_size]; + struct timeval tv; + gettimeofday(&tv, NULL); + long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; - memset(input, 0, sizeof(std::complex)*FLAGS_size); + for(int i=0; i finished in " << (end - begin) << " microseconds" << std::endl; } diff --git a/src/tests/arithmetic/complex_arithmetic_simd.cc b/src/tests/arithmetic/complex_arithmetic_simd.cc deleted file mode 100644 index 623971bd9..000000000 --- a/src/tests/arithmetic/complex_arithmetic_simd.cc +++ /dev/null @@ -1,49 +0,0 @@ - -#include -#include - -#include "gps_sdr_simd.h" - -#include - -#include -#include -#include - -#include -#include - -using google::LogMessage; - -DEFINE_int32(N, 2046, "Size of the arrays used for calculations"); -DEFINE_int32(M, 1000, "Iterations"); - -int main(int argc, char** argv) { - - google::InitGoogleLogging(argv[0]); - google::ParseCommandLineFlags(&argc, &argv, true); - - LOG_AT_LEVEL(INFO) << "Using standard SIMD implementation (GPS-SDR) to perform complex arithmetic"; - - std::srand((int)time(0)); - CPX* input = new CPX[FLAGS_N]; - - for(int i=0;i -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -using google::LogMessage; - -DEFINE_int32(N, 2046, "Samples per milisecond of signal"); -DEFINE_int32(M, 6000, "Number of correlations per GNSS-SDR channel"); -DEFINE_int32(C, 12, "Number of channels to simulate"); -DEFINE_string(data_type, "complex", "Data type for samples"); - -int main(int argc, char** argv) { - - google::InitGoogleLogging(argv[0]); - google::ParseCommandLineFlags(&argc, &argv, true); - - int correlations = FLAGS_M * FLAGS_C; - - LOG_AT_LEVEL(INFO) << "Simulating " << FLAGS_C << " channels"; - LOG_AT_LEVEL(INFO) << FLAGS_M << " correlations per channel"; - LOG_AT_LEVEL(INFO) << "Performing " << correlations << " correlations"; - - LOG_AT_LEVEL(INFO) << "Testing GNU GSL library using float complex numbers"; - - std::srand((unsigned)time(0)); - - gsl_vector_complex* input = gsl_vector_complex_alloc(FLAGS_N); - gsl_vector_complex* ones = gsl_vector_complex_alloc(FLAGS_N); - gsl_complex random; - gsl_complex one; - gsl_complex sum; - GSL_SET_COMPLEX(&one, 1, 1); - GSL_SET_COMPLEX(&sum, 1, 1); - GSL_SET_COMPLEX(&random, std::rand() % 10000, std::rand() % 10000); - - gsl_vector_complex_set_all(input, random); - gsl_vector_complex_set_all(ones, one); - - LOG_AT_LEVEL(INFO) << "Begin Calculations"; - - struct timeval tv; - gettimeofday(&tv, NULL); - long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; - - for(int i=0;i. + * + * ------------------------------------------------------------------------- + */ + + +#include #include #include #include #include - -#include - +#include #include #include #include -#include -#include + using google::LogMessage; -DEFINE_int32(N, 2046, "Samples per milisecond of signal"); -DEFINE_int32(M, 6000, "Number of correlations per GNSS-SDR channel"); +DEFINE_int32(N, 2046, "Samples per millisecond of signal"); +DEFINE_int32(M, 3, "Number of correlations per GNSS-SDR channel"); DEFINE_int32(C, 12, "Number of channels to simulate"); DEFINE_string(data_type, "complex", "Data type for samples"); -int main(int argc, char** argv) { +TEST(Correlation_Test, StandardCImplementation) +{ + int correlations = FLAGS_M * FLAGS_C; - google::InitGoogleLogging(argv[0]); - google::ParseCommandLineFlags(&argc, &argv, true); + //LOG_AT_LEVEL(INFO) << "Simulating " << FLAGS_C << " channels"; + //LOG_AT_LEVEL(INFO) << FLAGS_M << " correlations per channel"; + //LOG_AT_LEVEL(INFO) << "Performing " << correlations << " correlations"; + //LOG_AT_LEVEL(INFO) << "Testing standard C++ library using complex numbers"; - int correlations = FLAGS_M * FLAGS_C; + std::complex* input = new std::complex[FLAGS_N]; + std::complex accum; - LOG_AT_LEVEL(INFO) << "Simulating " << FLAGS_C << " channels"; - LOG_AT_LEVEL(INFO) << FLAGS_M << " correlations per channel"; - LOG_AT_LEVEL(INFO) << "Performing " << correlations << " correlations"; + std::srand((unsigned)time(0)); - LOG_AT_LEVEL(INFO) << "Testing standard C++ library using complex numbers"; + for(int i=0; i < FLAGS_N; i++) + { + input[i] = std::complex(std::rand() % 10000, std::rand() % 10000); + } - std::complex* input = new std::complex[FLAGS_N]; - std::complex accum; + struct timeval tv; + gettimeofday(&tv, NULL); + long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; - std::srand((unsigned)time(0)); + for(int i=0; i(std::rand() % 10000, std::rand() % 10000); - } - - LOG_AT_LEVEL(INFO) << "Begin Calculations"; - - struct timeval tv; - gettimeofday(&tv, NULL); - long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; - - for(int i=0;i -#include -#include - -#include "gps_sdr_simd.h" - -#include - -#include -#include -#include - -#include -#include - -using google::LogMessage; - -DEFINE_int32(N, 2046, "Samples per milisecond of signal"); -DEFINE_int32(M, 6000, "Number of correlations per GNSS-SDR channel"); -DEFINE_int32(C, 12, "Number of channels to simulate"); -DEFINE_string(data_type, "complex", "Data type for samples"); - -int main(int argc, char** argv) { - - google::InitGoogleLogging(argv[0]); - google::ParseCommandLineFlags(&argc, &argv, true); - - int correlations = FLAGS_M * FLAGS_C; - - LOG_AT_LEVEL(INFO) << "Simulating " << FLAGS_C << " channels"; - LOG_AT_LEVEL(INFO) << FLAGS_M << " correlations per channel"; - LOG_AT_LEVEL(INFO) << "Performing " << correlations << " correlations"; - - LOG_AT_LEVEL(INFO) << "Testing GPS SDR SIMD library using CPX struct"; - - std::srand((unsigned)time(0)); - - CPX* input = new CPX[FLAGS_N]; - - for (int i=0;iHAVE_INLINE GSL_RANGE_CHECK_OFF ; - -exe complex_arithmetic_atlas : -.//complex_arithmetic_gsl -../../..//glog -../../..//gflags -../../..//gsl -../../..//gslcblas : -HAVE_INLINE GSL_RANGE_CHECK_OFF ; - -exe complex_arithmetic_gotoblas2 : -.//complex_arithmetic_gsl -../../..//glog -../../..//gflags -../../..//gsl -../../..//gslcblas : -HAVE_INLINE GSL_RANGE_CHECK_OFF ; - -exe complex_arithmetic_libc : complex_arithmetic_libc.cc -../../..//glog -../../..//gflags ; - -exe complex_arithmetic_simd : complex_arithmetic_simd.cc -../../..//glog -../../..//gflags -../../gps_sdr//gps_sdr_simd ; - - -install ../../../install/tests : -complex_arithmetic_gotoblas2 -complex_arithmetic_atlas -complex_arithmetic_gsl_blas -complex_arithmetic_libc -complex_arithmetic_simd ; \ No newline at end of file diff --git a/src/tests/configuration/file_configuration_test.cc b/src/tests/configuration/file_configuration_test.cc index 44b634fd2..15ccb7c6d 100644 --- a/src/tests/configuration/file_configuration_test.cc +++ b/src/tests/configuration/file_configuration_test.cc @@ -1,25 +1,46 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * This class implements a Unit Test for the class FileConfiguration. +/*! + * \file file_configuration_test.cc + * \brief This file implements tests for the ControlMessageFactory. + * \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- */ + #include #include - #include #include "file_configuration.h" -TEST(FileConfiguration, OverridedProperties) { - ConfigurationInterface *configuration = new FileConfiguration("./src/tests/data/config_file_sample.txt"); + + + +TEST(File_Configuration_Test, OverridedProperties) +{ + ConfigurationInterface *configuration = new FileConfiguration("./data/config_file_sample.txt"); std::string default_value = "default_value"; std::string value = configuration->property("NotThere", default_value); @@ -33,7 +54,10 @@ TEST(FileConfiguration, OverridedProperties) { delete configuration; } -TEST(FileConfiguration, LoadFromNonExistentFile) { + + +TEST(File_Configuration_Test, LoadFromNonExistentFile) +{ ConfigurationInterface *configuration = new FileConfiguration("./i_dont_exist.conf"); std::string default_value = "default_value"; @@ -44,8 +68,12 @@ TEST(FileConfiguration, LoadFromNonExistentFile) { delete configuration; } -TEST(FileConfiguration, PropertyDoesNotExist) { - ConfigurationInterface *configuration = new FileConfiguration("./src/tests/data/config_file_sample.txt"); + + + +TEST(File_Configuration_Test, PropertyDoesNotExist) +{ + ConfigurationInterface *configuration = new FileConfiguration("./data/config_file_sample.txt"); std::string default_value = "default_value"; std::string value = configuration->property("whatever.whatever", default_value); diff --git a/src/tests/control_thread/control_message_factory_test.cc b/src/tests/control_thread/control_message_factory_test.cc index cdec3c6d7..65883d8b8 100644 --- a/src/tests/control_thread/control_message_factory_test.cc +++ b/src/tests/control_thread/control_message_factory_test.cc @@ -1,75 +1,101 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * This class implements a Unit Tests for the class ControlMessageFactory. +/*! + * \file control message_factory_test.cc + * \brief This file implements tests for the ControlMessageFactory. + * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com + * Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- */ + #include - #include - #include "control_message_factory.h" -TEST(ControlMessageFactory, GetQueueMessage) { - ControlMessageFactory *factory = new ControlMessageFactory(); - gr_message_sptr queue_message = factory->GetQueueMessage(0, 0); - ControlMessage *control_message = (ControlMessage*)queue_message->msg(); - EXPECT_EQ(0, control_message->who); - EXPECT_EQ(0, control_message->what); - EXPECT_EQ(sizeof(ControlMessage), queue_message->length()); +TEST(Control_Message_Factory_Test, GetQueueMessage) +{ + ControlMessageFactory *factory = new ControlMessageFactory(); - delete factory; + gr_message_sptr queue_message = factory->GetQueueMessage(0, 0); + ControlMessage *control_message = (ControlMessage*)queue_message->msg(); + + EXPECT_EQ(0, control_message->who); + EXPECT_EQ(0, control_message->what); + EXPECT_EQ(sizeof(ControlMessage), queue_message->length()); + + delete factory; } -TEST(ControlMessageFactory, GetControlMessages) { - ControlMessageFactory *factory = new ControlMessageFactory(); - ControlMessage *control_message = new ControlMessage; - control_message->who = 1; - control_message->what = 4; - gr_message_sptr queue_message = gr_make_message(0, 0, 0, sizeof(ControlMessage)); - memcpy(queue_message->msg(), control_message, sizeof(ControlMessage)); - std::vector *control_messages = factory->GetControlMessages(queue_message); +TEST(Control_Message_Factory_Test, GetControlMessages) +{ + ControlMessageFactory *factory = new ControlMessageFactory(); + ControlMessage *control_message = new ControlMessage; - EXPECT_EQ(1, control_messages->size()); - EXPECT_EQ(1, control_messages->at(0)->who); - EXPECT_EQ(4, control_messages->at(0)->what); + control_message->who = 1; + control_message->what = 4; - delete control_message; - delete control_messages; - delete factory; + gr_message_sptr queue_message = gr_make_message(0, 0, 0, sizeof(ControlMessage)); + memcpy(queue_message->msg(), control_message, sizeof(ControlMessage)); + std::vector *control_messages = factory->GetControlMessages(queue_message); + + EXPECT_EQ(1, control_messages->size()); + EXPECT_EQ(1, control_messages->at(0)->who); + EXPECT_EQ(4, control_messages->at(0)->what); + + delete control_message; + delete control_messages; + delete factory; } -TEST(ControlMessageFactory, GetControlMessagesWrongSize) { - ControlMessageFactory *factory = new ControlMessageFactory(); - ControlMessage *control_message = new ControlMessage; - control_message->who = 1; - control_message->what = 4; - int another_int = 10; +TEST(Control_Message_Factory_Test, GetControlMessagesWrongSize) +{ - gr_message_sptr queue_message = gr_make_message(0, 0, 0, sizeof(ControlMessage) + sizeof(int)); - memcpy(queue_message->msg(), control_message, sizeof(ControlMessage)); - memcpy(queue_message->msg() + sizeof(ControlMessage), &another_int, sizeof(int)); - std::vector *control_messages = factory->GetControlMessages(queue_message); + ControlMessageFactory *factory = new ControlMessageFactory(); + ControlMessage *control_message = new ControlMessage; - EXPECT_EQ(0, control_messages->size()); + control_message->who = 1; + control_message->what = 4; + int another_int = 10; - delete control_message; - delete control_messages; - delete factory; + gr_message_sptr queue_message = gr_make_message(0, 0, 0, sizeof(ControlMessage) + sizeof(int)); + memcpy(queue_message->msg(), control_message, sizeof(ControlMessage)); + memcpy(queue_message->msg() + sizeof(ControlMessage), &another_int, sizeof(int)); + std::vector *control_messages = factory->GetControlMessages(queue_message); + + EXPECT_EQ(0, control_messages->size()); + + delete control_message; + delete control_messages; + delete factory; } diff --git a/src/tests/control_thread/control_thread_test.cc b/src/tests/control_thread/control_thread_test.cc index 0d48c1939..99c2960df 100644 --- a/src/tests/control_thread/control_thread_test.cc +++ b/src/tests/control_thread/control_thread_test.cc @@ -13,34 +13,32 @@ */ #include - #include - #include "control_thread.h" #include "in_memory_configuration.h" -TEST(ControlThread, InstantiateRunControlMessages) { +TEST(Control_Thread_Test, InstantiateRunControlMessages) { InMemoryConfiguration *config = new InMemoryConfiguration(); - config->set_property("SignalSource.implementation", "FileSignalSource"); - config->set_property("SignalSource.filename", "./signal_samples/signal.dat"); - config->set_property("SignalSource.item_type", "gr_complex"); - config->set_property("SignalConditioner.implementation", "PassThrough"); - config->set_property("SignalConditioner.item_type", "gr_complex"); - config->set_property("Channels.count", "12"); - config->set_property("Acquisition.implementation", "PassThrough"); - config->set_property("Acquisition.item_type", "gr_complex"); - config->set_property("Tracking.implementation", "PassThrough"); - config->set_property("Tracking.item_type", "gr_complex"); - config->set_property("Navigation.implementation", "PassThrough"); - config->set_property("Navigation.item_type", "gr_complex"); - config->set_property("Pseudorange.implementation", "PassThrough"); - config->set_property("Pseudorange.item_type", "gr_complex"); - config->set_property("PVT.implementation", "Adder"); - config->set_property("PVT.item_type", "gr_complex"); - config->set_property("OutputFilter.implementation", "NullSinkOutputFilter"); - config->set_property("OutputFilter.item_type", "gr_complex"); + config->set_property("SignalSource.implementation", "File_Signal_Source"); + config->set_property("SignalSource.filename", "/Users/carlesfernandez/Documents/workspace/gnss-sdr/trunk/data/sc2_d16.dat"); + config->set_property("SignalSource.item_type", "gr_complex"); + config->set_property("SignalConditioner.implementation", "Pass_Through"); + config->set_property("SignalConditioner.item_type", "gr_complex"); + config->set_property("Channels.count", "12"); + config->set_property("Acquisition.implementation", "GPS_L1_CA_PCPS_Acquisition"); + config->set_property("Acquisition.item_type", "gr_complex"); + config->set_property("Tracking.implementation", "GPS_L1_CA_DLL_FLL_PLL_Tracking"); + config->set_property("Tracking.item_type", "gr_complex"); + config->set_property("Navigation.implementation", "GPS_L1_CA_Telemetry_Decoder"); + config->set_property("Navigation.item_type", "gr_complex"); + config->set_property("Pseudorange.implementation", "GPS_L1_CA_Observables"); + config->set_property("Pseudorange.item_type", "gr_complex"); + config->set_property("PVT.implementation", "GPS_L1_CA_PVT"); + config->set_property("PVT.item_type", "gr_complex"); + config->set_property("OutputFilter.implementation", "Null_Sink_Output_Filter"); + config->set_property("OutputFilter.item_type", "gr_complex"); ControlThread *control_thread = new ControlThread(config); @@ -78,26 +76,30 @@ TEST(ControlThread, InstantiateRunControlMessages) { delete control_msg_factory; } -TEST(ControlThread, InstantiateRunControlMessages2) { + + + + +TEST(Control_Thread_Test, InstantiateRunControlMessages2) { InMemoryConfiguration *config = new InMemoryConfiguration(); - config->set_property("SignalSource.implementation", "FileSignalSource"); - config->set_property("SignalSource.filename", "./signal_samples/signal.dat"); + config->set_property("SignalSource.implementation", "File_Signal_Source"); + config->set_property("SignalSource.filename", "/Users/carlesfernandez/Documents/workspace/gnss-sdr/trunk/data/sc2_d16.dat"); config->set_property("SignalSource.item_type", "gr_complex"); - config->set_property("SignalConditioner.implementation", "PassThrough"); + config->set_property("SignalConditioner.implementation", "Pass_Through"); config->set_property("SignalConditioner.item_type", "gr_complex"); config->set_property("Channels.count", "12"); - config->set_property("Acquisition.implementation", "PassThrough"); + config->set_property("Acquisition.implementation", "GPS_L1_CA_PCPS_Acquisition"); config->set_property("Acquisition.item_type", "gr_complex"); - config->set_property("Tracking.implementation", "PassThrough"); + config->set_property("Tracking.implementation", "GPS_L1_CA_DLL_FLL_PLL_Tracking"); config->set_property("Tracking.item_type", "gr_complex"); - config->set_property("Navigation.implementation", "PassThrough"); + config->set_property("Navigation.implementation", "GPS_L1_CA_Telemetry_Decoder"); config->set_property("Navigation.item_type", "gr_complex"); - config->set_property("Pseudorange.implementation", "PassThrough"); + config->set_property("Pseudorange.implementation", "GPS_L1_CA_Observables"); config->set_property("Pseudorange.item_type", "gr_complex"); - config->set_property("PVT.implementation", "Adder"); + config->set_property("PVT.implementation", "GPS_L1_CA_PVT"); config->set_property("PVT.item_type", "gr_complex"); - config->set_property("OutputFilter.implementation", "NullSinkOutputFilter"); + config->set_property("OutputFilter.implementation", "Null_Sink_Output_Filter"); config->set_property("OutputFilter.item_type", "gr_complex"); ControlThread *control_thread = new ControlThread(config); diff --git a/src/tests/data/config_file_sample.txt b/src/tests/data/config_file_sample.txt index 4cb3a666c..9c49d8fc0 100644 --- a/src/tests/data/config_file_sample.txt +++ b/src/tests/data/config_file_sample.txt @@ -1,24 +1,24 @@ -; Sample for a configuration file for MERCURIO +; Sample for a configuration file for GNS-SDR -[mercurio] +[GNSS-SDR] Foo.param1=value SignalSource.implementation=FileSignalSource -SignalSource.filename=./data/signal.dat +SignalSource.filename=/Users/carlesfernandez/Documents/workspace/gnss-sdr/trunk/data/sc2_d16.dat SignalSource.item_size=4 SignalSource.repeat=false -SignalConditioner.implementation=PassThrough +SignalConditioner.implementation=Pass_Through SignalConditioner.item_type=float SignalConditioner.vector_size=1 Channels.count=1 -Channel1.implementation=PassThrough +Channel1.implementation=Pass_Through Channel1.item_type=float Channel1.vector_size=1 -PVT.implementation=PassThrough +PVT.implementation=Pass_Through PVT.item_type=float PVT.vector_size=1 diff --git a/src/tests/flowgraph/adder_test.cc b/src/tests/flowgraph/adder_test.cc deleted file mode 100644 index fda98dabf..000000000 --- a/src/tests/flowgraph/adder_test.cc +++ /dev/null @@ -1,29 +0,0 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * This class implements a Unit Test for the class Adder - * - */ - -#include - -#include "adder.h" -#include "in_memory_configuration.h" - -TEST(Adder, Instantiate) { - - InMemoryConfiguration* config = new InMemoryConfiguration(); - - config->set_property("Test.item_type", "gr_complex"); - - Adder *adder = new Adder(config, "PVT", 4, 1); - - delete adder; -} \ No newline at end of file diff --git a/src/tests/flowgraph/file_output_filter_test.cc b/src/tests/flowgraph/file_output_filter_test.cc index 52046efd9..64a63b0d7 100644 --- a/src/tests/flowgraph/file_output_filter_test.cc +++ b/src/tests/flowgraph/file_output_filter_test.cc @@ -1,30 +1,44 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * This class implements a Unit Test for the class FileOutputFilter +/*! + * \file file_output_filter_test.cc + * \brief This file implements tests for the FileSignalSourceClass + * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com + * Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- */ #include - #include "file_output_filter.h" #include "in_memory_configuration.h" -TEST(FileOutoutFilter, Instantiate) { - - InMemoryConfiguration* config = new InMemoryConfiguration(); - - config->set_property("Test.filename", "./data/output.dat"); - config->set_property("Test.item_type", "float"); - - FileOutputFilter *output_filter = new FileOutputFilter(config, "Test", 1, 0); - - delete output_filter; -} \ No newline at end of file +TEST(FileOutputFilterTest, Instantiate) +{ + InMemoryConfiguration* config = new InMemoryConfiguration(); + config->set_property("Test.filename", "../data/output.dat"); + config->set_property("Test.item_type", "float"); + FileOutputFilter *output_filter = new FileOutputFilter(config, "Test", 1, 0); + delete output_filter; +} diff --git a/src/tests/flowgraph/file_signal_source_test.cc b/src/tests/flowgraph/file_signal_source_test.cc index 6136d5ba2..dee6d8634 100644 --- a/src/tests/flowgraph/file_signal_source_test.cc +++ b/src/tests/flowgraph/file_signal_source_test.cc @@ -1,52 +1,77 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * This class implements a Unit Test for the class InMemoryConfiguration. +/*! + * \file file_signal_source_test.cc + * \brief This file implements tests for the FileSignalSourceClass + * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com + * Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- */ + #include - #include #include #include #include - #include - #include "file_signal_source.h" #include "in_memory_configuration.h" -TEST(FileSignalSource, Instantiate) { + +TEST(File_Signal_Source_Test, Instantiate) +{ gr_msg_queue_sptr queue = gr_make_msg_queue(0); InMemoryConfiguration* config = new InMemoryConfiguration(); config->set_property("Test.samples", "0"); config->set_property("Test.sampling_frequency", "0"); - config->set_property("Test.filename", "./signal_samples/signal.dat"); + + config->set_property("Test.filename", "/Users/carlesfernandez/Documents/workspace/gnss-sdr/trunk/data/sc2_d16.dat"); + config->set_property("Test.item_type", "gr_complex"); config->set_property("Test.repeat", "false"); - FileSignalSource *signal_source = new FileSignalSource(config, "Test", 1, 1, queue); - - EXPECT_STREQ("./signal_samples/signal.dat", signal_source->filename().c_str()); + try + { + FileSignalSource *signal_source = new FileSignalSource(config, "Test", 1, 1, queue); + } + catch(std::exception& e){} + EXPECT_STREQ("/Users/carlesfernandez/Documents/workspace/gnss-sdr/trunk/data/sc2_d16.dat", signal_source->filename().c_str()); EXPECT_STREQ("gr_complex", signal_source->item_type().c_str()); EXPECT_TRUE(signal_source->repeat() == false); delete signal_source; } -TEST(FileSignalSource, InstantiateFileNotExists) { + +TEST(File_Signal_Source_Test, InstantiateFileNotExists) +{ gr_msg_queue_sptr queue = gr_make_msg_queue(0); InMemoryConfiguration* config = new InMemoryConfiguration(); @@ -54,8 +79,9 @@ TEST(FileSignalSource, InstantiateFileNotExists) { config->set_property("Test.samples", "0"); config->set_property("Test.sampling_frequency", "0"); config->set_property("Test.filename", "./signal_samples/i_dont_exist.dat"); + config->set_property("Test.item_type", "gr_complex"); config->set_property("Test.repeat", "false"); - EXPECT_THROW(new FileSignalSource(config, "Test", 1, 1, queue), std::runtime_error); + EXPECT_THROW(new FileSignalSource(config, "Test", 1, 1, queue), std::exception); } diff --git a/src/tests/flowgraph/gnss_block_factory_test.cc b/src/tests/flowgraph/gnss_block_factory_test.cc index 0e61c9682..df9299184 100644 --- a/src/tests/flowgraph/gnss_block_factory_test.cc +++ b/src/tests/flowgraph/gnss_block_factory_test.cc @@ -26,10 +26,10 @@ TEST(GNSSBlockFactory, InstantiateChannels) { InMemoryConfiguration *configuration = new InMemoryConfiguration(); configuration->set_property("Channels.count", "2"); - configuration->set_property("Channel1.implementation", "PassThrough"); + configuration->set_property("Channel1.implementation", "Pass_Through"); configuration->set_property("Channel1.item_type", "float"); configuration->set_property("Channel1.vector_size", "1"); - configuration->set_property("Channel2.implementation", "PassThrough"); + configuration->set_property("Channel2.implementation", "Pass_Through"); configuration->set_property("Channel2.item_type", "float"); configuration->set_property("Channel2.vector_size", "1"); @@ -84,7 +84,7 @@ TEST(GNSSBlockFactory, InstantiateWrongSignalSource) { TEST(GNSSBlockFactory, InstantiateSignalConditioner) { InMemoryConfiguration *configuration = new InMemoryConfiguration(); - configuration->set_property("SignalConditioner.implementation", "PassThrough"); + configuration->set_property("SignalConditioner.implementation", "Pass_Through"); gr_msg_queue_sptr queue = gr_make_msg_queue(0); @@ -117,7 +117,7 @@ TEST(GNSSBlockFactory, InstantiateWrongSignalConditioner) { TEST(GNSSBlockFactory, InstantiatePVT) { InMemoryConfiguration *configuration = new InMemoryConfiguration(); - configuration->set_property("PVT.implementation", "PassThrough"); + configuration->set_property("PVT.implementation", "Pass_Through"); gr_msg_queue_sptr queue = gr_make_msg_queue(0); @@ -178,4 +178,4 @@ TEST(GNSSBlockFactory, InstantiateWrongOutputFilter) { delete configuration; delete factory; -} \ No newline at end of file +} diff --git a/src/tests/flowgraph/gnss_flowgraph_test.cc b/src/tests/flowgraph/gnss_flowgraph_test.cc index ea64eb522..8ea716819 100644 --- a/src/tests/flowgraph/gnss_flowgraph_test.cc +++ b/src/tests/flowgraph/gnss_flowgraph_test.cc @@ -13,54 +13,54 @@ */ #include - #include - #include "gnss_flowgraph.h" #include "gnss_block_interface.h" #include "in_memory_configuration.h" #include "file_configuration.h" #include "channel.h" #include "acquisition_interface.h" -#include "correlator_interface.h" +#include "tracking_interface.h" +#include "channel_interface.h" +#include "null_sink_output_filter.h" +#include "pass_through.h" +#include "file_signal_source.h" -TEST(GNSSFlowgraph, InstantiateConnectStartStop) { - InMemoryConfiguration* config = new InMemoryConfiguration(); +TEST(GNSSFlowgraph, InstantiateConnectStartStop) +{ + InMemoryConfiguration* config = new InMemoryConfiguration(); - config->set_property("SignalSource.implementation", "FileSignalSource"); - config->set_property("SignalConditioner.implementation", "PassThrough"); - config->set_property("Channels.count", "2"); - config->set_property("Channels.acquisition.implementation", "PassThrough"); - config->set_property("Channels.tracking.implementation", "PassThrough"); - config->set_property("Channels.navigation.implementation", "PassThrough"); - config->set_property("Channels.pseudorange.implementation", "PassThrough"); - config->set_property("PVT.implementation", "Adder"); - config->set_property("OutputFilter.implementation", "NullSinkOutputFilter"); + config->set_property("SignalSource.implementation", "File_Signal_Source"); + config->set_property("SignalConditioner.implementation", "Pass_Through"); + config->set_property("Channels.count", "2"); + config->set_property("Channels.acquisition.implementation", "Pass_Through"); + config->set_property("Channels.tracking.implementation", "Pass_Through"); + config->set_property("Channels.observables.implementation", "Pass_Through"); + config->set_property("Observables.implementation", "GpsL1CaObservables"); + config->set_property("PVT.implementation", "GPS_L1_CA_PVT"); + config->set_property("OutputFilter.implementation", "NullSinkOutputFilter"); - GNSSFlowgraph* flowgraph = new GNSSFlowgraph(config, gr_make_msg_queue(0)); + GNSSFlowgraph* flowgraph = new GNSSFlowgraph(config, gr_make_msg_queue(0)); - EXPECT_STREQ("FileSignalSource", flowgraph->signal_source()->implementation().c_str()); - EXPECT_STREQ("PassThrough", flowgraph->signal_conditioner()->implementation().c_str()); - EXPECT_STREQ("Channel", flowgraph->channel(0)->implementation().c_str()); - EXPECT_STREQ("PassThrough", ((GNSSChannel*)flowgraph->channel(0))->acquisition()->implementation().c_str()); - EXPECT_STREQ("PassThrough", ((GNSSChannel*)flowgraph->channel(0))->tracking()->implementation().c_str()); - EXPECT_STREQ("PassThrough", ((GNSSChannel*)flowgraph->channel(0))->navigation()->implementation().c_str()); - EXPECT_STREQ("PassThrough", ((GNSSChannel*)flowgraph->channel(0))->pseudorange()->implementation().c_str()); - EXPECT_STREQ("Channel", flowgraph->channel(1)->implementation().c_str()); - EXPECT_STREQ("PassThrough", ((GNSSChannel*)flowgraph->channel(1))->acquisition()->implementation().c_str()); - EXPECT_STREQ("PassThrough", ((GNSSChannel*)flowgraph->channel(1))->tracking()->implementation().c_str()); - EXPECT_STREQ("PassThrough", ((GNSSChannel*)flowgraph->channel(1))->navigation()->implementation().c_str()); - EXPECT_STREQ("PassThrough", ((GNSSChannel*)flowgraph->channel(1))->pseudorange()->implementation().c_str()); - EXPECT_STREQ("Adder", flowgraph->pvt()->implementation().c_str()); - EXPECT_STREQ("NullSinkOutputFilter", flowgraph->output_filter()->implementation().c_str()); + EXPECT_STREQ("FileSignalSource", flowgraph->signal_source()->implementation().c_str()); + EXPECT_STREQ("Pass_Through", flowgraph->signal_conditioner()->implementation().c_str()); + EXPECT_STREQ("Channel", flowgraph->channel(0)->implementation().c_str()); + EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(0))->acquisition()->implementation().c_str()); + EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(0))->tracking()->implementation().c_str()); + EXPECT_STREQ("Channel", flowgraph->channel(1)->implementation().c_str()); + EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(1))->acquisition()->implementation().c_str()); + EXPECT_STREQ("Pass_Through", ((Channel*)flowgraph->channel(1))->tracking()->implementation().c_str()); + EXPECT_STREQ("GpsL1CaObservables", flowgraph->observables()->implementation().c_str()); + EXPECT_STREQ("GPS_L1_CA_PVT", flowgraph->pvt()->implementation().c_str()); + EXPECT_STREQ("NullSinkOutputFilter", flowgraph->output_filter()->implementation().c_str()); - EXPECT_NO_THROW(flowgraph->connect()); - EXPECT_TRUE(flowgraph->connected()); - EXPECT_NO_THROW(flowgraph->start()); - EXPECT_TRUE(flowgraph->running()); - flowgraph->stop(); - EXPECT_FALSE(flowgraph->running()); + EXPECT_NO_THROW(flowgraph->connect()); + EXPECT_TRUE(flowgraph->connected()); + EXPECT_NO_THROW(flowgraph->start()); + EXPECT_TRUE(flowgraph->running()); + flowgraph->stop(); + EXPECT_FALSE(flowgraph->running()); - delete flowgraph; + delete flowgraph; } diff --git a/src/tests/flowgraph/pass_through_test.cc b/src/tests/flowgraph/pass_through_test.cc index 1df0e7f31..2d66e2b73 100644 --- a/src/tests/flowgraph/pass_through_test.cc +++ b/src/tests/flowgraph/pass_through_test.cc @@ -1,35 +1,55 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * This class implements a Unit Test for the class NoConditioningSignalConditioner. +/*! + * \file pass_through_test.cc + * \brief This file implements tests for the Pass_Through block + * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com + * Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- */ + #include #include #include - #include "pass_through.h" #include "in_memory_configuration.h" -TEST(PassThrough, Instantiate) { - InMemoryConfiguration* config = new InMemoryConfiguration(); - config->set_property("Test.item_type", "gr_complex"); - config->set_property("Test.vector_size", "2"); +TEST(Pass_Through_Test, Instantiate) +{ + InMemoryConfiguration* config = new InMemoryConfiguration(); - PassThrough *signal_conditioner = new PassThrough(config, "Test", 1, 1); + config->set_property("Test.item_type", "gr_complex"); + config->set_property("Test.vector_size", "2"); - EXPECT_STREQ("gr_complex", signal_conditioner->item_type().c_str()); - EXPECT_EQ(2, signal_conditioner->vector_size()); + Pass_Through *signal_conditioner = new Pass_Through(config, "Test", 1, 1); - delete signal_conditioner; -} \ No newline at end of file + EXPECT_STREQ("gr_complex", signal_conditioner->item_type().c_str()); + EXPECT_EQ(2, signal_conditioner->vector_size()); + + delete signal_conditioner; +} diff --git a/src/tests/gnss_block/gnss_block_factory_test.cc b/src/tests/gnss_block/gnss_block_factory_test.cc index 0e61c9682..a74f467af 100644 --- a/src/tests/gnss_block/gnss_block_factory_test.cc +++ b/src/tests/gnss_block/gnss_block_factory_test.cc @@ -26,10 +26,10 @@ TEST(GNSSBlockFactory, InstantiateChannels) { InMemoryConfiguration *configuration = new InMemoryConfiguration(); configuration->set_property("Channels.count", "2"); - configuration->set_property("Channel1.implementation", "PassThrough"); + configuration->set_property("Channel1.implementation", "Pass_Through"); configuration->set_property("Channel1.item_type", "float"); configuration->set_property("Channel1.vector_size", "1"); - configuration->set_property("Channel2.implementation", "PassThrough"); + configuration->set_property("Channel2.implementation", "Pass_Through"); configuration->set_property("Channel2.item_type", "float"); configuration->set_property("Channel2.vector_size", "1"); @@ -51,7 +51,7 @@ TEST(GNSSBlockFactory, InstantiateChannels) { TEST(GNSSBlockFactory, InstantiateSignalSource) { InMemoryConfiguration *configuration = new InMemoryConfiguration(); - configuration->set_property("SignalSource.implementation", "FileSignalSource"); + configuration->set_property("SignalSource.implementation", "File_Signal_Source"); gr_msg_queue_sptr queue = gr_make_msg_queue(0); @@ -84,7 +84,7 @@ TEST(GNSSBlockFactory, InstantiateWrongSignalSource) { TEST(GNSSBlockFactory, InstantiateSignalConditioner) { InMemoryConfiguration *configuration = new InMemoryConfiguration(); - configuration->set_property("SignalConditioner.implementation", "PassThrough"); + configuration->set_property("SignalConditioner.implementation", "Pass_Through"); gr_msg_queue_sptr queue = gr_make_msg_queue(0); @@ -178,4 +178,4 @@ TEST(GNSSBlockFactory, InstantiateWrongOutputFilter) { delete configuration; delete factory; -} \ No newline at end of file +} diff --git a/src/tests/gnuradio_block/gnss_sdr_valve_test.cc b/src/tests/gnuradio_block/gnss_sdr_valve_test.cc index 3ecaac195..6c4af953a 100644 --- a/src/tests/gnuradio_block/gnss_sdr_valve_test.cc +++ b/src/tests/gnuradio_block/gnss_sdr_valve_test.cc @@ -1,50 +1,65 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * This class implements unit tests for a the valve custom block. +/*! + * \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 * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- */ + +#include #include #include #include #include - -#include - #include "gnss_sdr_valve.h" +//#include +//#include -#include -#include +//using google::LogMessage; -using google::LogMessage; +TEST(Valve_Test, CheckEventSentAfter100Samples) +{ + gr_msg_queue_sptr queue = gr_make_msg_queue(0); -TEST(GNSS_SDR_VALVE, CheckEventSentAfter100Samples) { + gr_top_block_sptr top_block = gr_make_top_block("gnss_sdr_valve_test"); + gr_block_sptr valve = gnss_sdr_make_valve(sizeof(float), 100, queue); + gr_sig_source_f_sptr source = gr_make_sig_source_f(100, GR_CONST_WAVE, 100, 1, 0); + gr_block_sptr sink = gr_make_null_sink(sizeof(float)); - gr_msg_queue_sptr queue = gr_make_msg_queue(0); + //LOG_AT_LEVEL(INFO) << "Queue count is " << queue->count(); + EXPECT_EQ(0, queue->count()); - gr_top_block_sptr top_block = gr_make_top_block("gnss_sdr_valve_test"); - gr_block_sptr valve = gnss_sdr_make_valve(sizeof(float), 100, queue); - gr_sig_source_f_sptr source = gr_make_sig_source_f(100, GR_CONST_WAVE, 100, 1, 0); - gr_block_sptr sink = gr_make_null_sink(sizeof(float)); + top_block->connect(source, 0, valve, 0); + top_block->connect(valve, 0, sink, 0); - LOG_AT_LEVEL(INFO) << "Queue count is " << queue->count(); - EXPECT_EQ(0, queue->count()); + top_block->run(); + top_block->stop(); - top_block->connect(source, 0, valve, 0); - top_block->connect(valve, 0, sink, 0); - - top_block->run(); - top_block->stop(); - - LOG_AT_LEVEL(INFO) << "Queue count is " << queue->count(); - EXPECT_EQ(1, queue->count()); - -} \ No newline at end of file + //LOG_AT_LEVEL(INFO) << "Queue count is " << queue->count(); + EXPECT_EQ(1, queue->count()); +} diff --git a/src/tests/gnuradio_block/gps_sdr_tong_acquisition_test.cc b/src/tests/gnuradio_block/gps_sdr_tong_acquisition_test.cc index 3cfe67ad2..1af44fae0 100644 --- a/src/tests/gnuradio_block/gps_sdr_tong_acquisition_test.cc +++ b/src/tests/gnuradio_block/gps_sdr_tong_acquisition_test.cc @@ -49,21 +49,21 @@ DEFINE_int32(B_value, 2, "Value of the initial K variable in Tong algorithm"); int main(int argc, char** argv) { - google::InitGoogleLogging(argv[0]); - google::ParseCommandLineFlags(&argc, &argv, true); + google::InitGoogleLogging(argv[0]); + google::ParseCommandLineFlags(&argc, &argv, true); - gr_msg_queue_sptr queue = gr_msg_queue_sptr(); + gr_msg_queue_sptr queue = gr_msg_queue_sptr(); - int samples_per_ms = ceil(FLAGS_fs_in/1000); - gr_complex div = 0.001; + int samples_per_ms = ceil(FLAGS_fs_in/1000); + gr_complex div = 0.001; - LOG_AT_LEVEL(INFO) << "fs_in " << FLAGS_fs_in; - LOG_AT_LEVEL(INFO) << "if_freq " << FLAGS_if_freq; - LOG_AT_LEVEL(INFO) << "satellite " << FLAGS_satellite; -// LOG_AT_LEVEL(INFO) << "max_dwells " << FLAGS_max_dwells; - LOG_AT_LEVEL(INFO) << "threshold " << FLAGS_acquisition_threshold; - LOG_AT_LEVEL(INFO) << "A_value " << FLAGS_A_value; - LOG_AT_LEVEL(INFO) << "B_value " << FLAGS_B_value; + LOG_AT_LEVEL(INFO) << "fs_in " << FLAGS_fs_in; + LOG_AT_LEVEL(INFO) << "if_freq " << FLAGS_if_freq; + LOG_AT_LEVEL(INFO) << "satellite " << FLAGS_satellite; + // LOG_AT_LEVEL(INFO) << "max_dwells " << FLAGS_max_dwells; + LOG_AT_LEVEL(INFO) << "threshold " << FLAGS_acquisition_threshold; + LOG_AT_LEVEL(INFO) << "A_value " << FLAGS_A_value; + LOG_AT_LEVEL(INFO) << "B_value " << FLAGS_B_value; gr_top_block_sptr top_block = gr_make_top_block("gps_sdr_tong_acquisition_test"); @@ -81,14 +81,14 @@ int main(int argc, char** argv) { top_block->connect(stream_to_vector, 0 , acquisition, 0); top_block->connect(acquisition, 0, null_sink, 0); - LOG_AT_LEVEL(INFO) << "Run"; - struct timeval tv; - gettimeofday(&tv, NULL); - long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; - top_block->run(); // Start threads and wait - gettimeofday(&tv, NULL); - long long int end = tv.tv_sec *1000000 + tv.tv_usec; - LOG_AT_LEVEL(INFO) << "Finished in " << (end - begin) << " microseconds"; - std::cout << (end - begin) << std::endl; - top_block->stop(); + LOG_AT_LEVEL(INFO) << "Run"; + struct timeval tv; + gettimeofday(&tv, NULL); + long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; + top_block->run(); // Start threads and wait + gettimeofday(&tv, NULL); + long long int end = tv.tv_sec *1000000 + tv.tv_usec; + LOG_AT_LEVEL(INFO) << "Finished in " << (end - begin) << " microseconds"; + std::cout << (end - begin) << std::endl; + top_block->stop(); } diff --git a/src/tests/gps_sdr/simd_tests.cc b/src/tests/gps_sdr/simd_tests.cc deleted file mode 100644 index b2ae84db3..000000000 --- a/src/tests/gps_sdr/simd_tests.cc +++ /dev/null @@ -1,77 +0,0 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * Executes a gps sdr acquisition based on some input parameters. - * - */ - -#include -#include - -#include - -#include -#include - -using google::LogMessage; - -#include -#include -#include -#include -#include - -#include "gps_sdr_simd.h" - -int main(int argc, char** argv) { - - google::InitGoogleLogging(argv[0]); - - CPX* A = new CPX[100]; - CPX* B = new CPX[100]; - CPX* C = new CPX[100]; - - for(int i=0;i<100;i++) { - A[i].i = 1; - A[i].q = 1; - B[i].i = 0; - B[i].q = 0; - C[i].i = 2; - C[i].q = 2; - } - - LOG_AT_LEVEL(INFO) << "Run"; - struct timeval tv; - gettimeofday(&tv, NULL); - long long int begin = tv.tv_sec * 1000000 + tv.tv_usec; - sse_cmulsc(A, B, C, 10, 10); - gettimeofday(&tv, NULL); - long long int end = tv.tv_sec *1000000 + tv.tv_usec; - LOG_AT_LEVEL(INFO) << "Finished in " << (end - begin) << " microseconds"; - std::cout << (end - begin) << std::endl; - - std::cout << "A=["; - for(int i=0;i<100;i++) { - std::cout << A[i].i << "," << A[i].q << ":"; - } - std::cout << "]" << std::endl; - - std::cout << "B=["; - for(int i=0;i<100;i++) { - std::cout << B[i].i << "," << B[i].q << ":"; - } - std::cout << "]" << std::endl; - - std::cout << "C=["; - for(int i=0;i<100;i++) { - std::cout << C[i].i << "," << C[i].q << ":"; - } - std::cout << "]" << std::endl;; -} diff --git a/src/tests/integration/test_1.cc b/src/tests/integration/test_1.cc index 4e499198f..cf864cfaa 100644 --- a/src/tests/integration/test_1.cc +++ b/src/tests/integration/test_1.cc @@ -13,46 +13,41 @@ */ #include - #include #include - #include "in_memory_configuration.h" #include "control_thread.h" -TEST(SignalSource, CorrectFileSignalSource) { +TEST(SignalSource, CorrectFileSignalSource) +{ + InMemoryConfiguration* config = new InMemoryConfiguration(); - InMemoryConfiguration* config = new InMemoryConfiguration(); + config->set_property("ControlThread.wait_for_flowgraph", "true"); + config->set_property("SignalSource.implementation", "FileSignalSource"); + config->set_property("SignalSource.samples", "0"); + config->set_property("SignalSource.filename", "./signal_samples/signal_1ms.dat"); + config->set_property("SignalSource.dump", "true"); + config->set_property("SignalSource.dump_filename", "./data/test1_dump.dat"); + config->set_property("SignalConditioner.implementation", "PassThrough"); + config->set_property("Channels.count", "1"); - config->set_property("ControlThread.wait_for_flowgraph", "true"); + ControlThread* control_thread = new ControlThread(config); + control_thread->run(); - config->set_property("SignalSource.implementation", "FileSignalSource"); - config->set_property("SignalSource.samples", "0"); - config->set_property("SignalSource.filename", "./signal_samples/signal_1ms.dat"); - config->set_property("SignalSource.dump", "true"); - config->set_property("SignalSource.dump_filename", "./data/test1_dump.dat"); + delete control_thread; + delete config; - config->set_property("SignalConditioner.implementation", "PassThrough"); + std::ifstream signal_expected; + signal_expected.open("./signal_samples/signal_1ms.dat", std::ios::in | std::ios::binary | std::ios::ate); + EXPECT_FALSE(signal_expected.fail()); - config->set_property("Channels.count", "1"); + std::ifstream signal_result; + signal_result.open("./data/test_dump.dat", std::ios::in | std::ios::binary | std::ios::ate); + EXPECT_FALSE(signal_result.fail()); - ControlThread* control_thread = new ControlThread(config); - control_thread->run(); + EXPECT_EQ(signal_expected.tellg(), signal_result.tellg()); + std::cout << signal_expected.tellg() << ":" << signal_result.tellg() << std::endl; - delete control_thread; - delete config; - - std::ifstream signal_expected; - signal_expected.open("./signal_samples/signal_1ms.dat", std::ios::in|std::ios::binary|std::ios::ate); - EXPECT_FALSE(signal_expected.fail()); - - std::ifstream signal_result; - signal_result.open("./data/test_dump.dat", std::ios::in|std::ios::binary|std::ios::ate); - EXPECT_FALSE(signal_result.fail()); - - EXPECT_EQ(signal_expected.tellg(), signal_result.tellg()); - std::cout << signal_expected.tellg() << ":" << signal_result.tellg() << std::endl; - - signal_expected.close(); - signal_result.close(); + signal_expected.close(); + signal_result.close(); } diff --git a/src/tests/jamfile.jam b/src/tests/jamfile.jam index e2edcc722..d29afb94c 100644 --- a/src/tests/jamfile.jam +++ b/src/tests/jamfile.jam @@ -1,3 +1,65 @@ -build-project arithmetic ; +lib gtest ; -obj test_main : test_main.cc ; \ No newline at end of file +obj test_main : test_main.cc ; + +project : build-dir ../../build ; +exe run_tests : test_main.cc +../algorithms/acquisition/adapters//gps_l1_ca_gps_sdr_acquisition +../algorithms/acquisition/adapters//gps_l1_ca_pcps_acquisition +../algorithms/acquisition/adapters//gps_l1_ca_tong_pcps_acquisition +../algorithms/acquisition/gnuradio_blocks//gps_l1_ca_gps_sdr_acquisition_cc +../algorithms/acquisition/gnuradio_blocks//gps_l1_ca_gps_sdr_acquisition_ss +../algorithms/acquisition/gnuradio_blocks//gps_l1_ca_pcps_acquisition_cc +../algorithms/acquisition/gnuradio_blocks//gps_l1_ca_tong_pcps_acquisition_cc +../algorithms/channel/adapters//channel +../algorithms/channel/libs//gps_l1_ca_channel_fsm +../algorithms/conditioner/adapters//direct_resampler_conditioner +../algorithms/conditioner/gnuradio_blocks//direct_resampler_conditioner_cc +../algorithms/conditioner/gnuradio_blocks//direct_resampler_conditioner_ss +../algorithms/libs//gps_sdr_signal_processing +../algorithms/libs//gnss_sdr_valve +../algorithms/libs//pass_through +../algorithms/libs//gps_sdr_fft +../algorithms/libs//gps_sdr_simd +../algorithms/libs//gps_sdr_x86 +../algorithms/observables/adapters//gps_l1_ca_observables +../algorithms/observables/gnuradio_blocks//gps_l1_ca_observables_cc +../algorithms/PVT/libs//rinex_printer +../algorithms/PVT/libs//kml_printer +../algorithms/PVT/libs//gps_l1_ca_ls_pvt +../algorithms/output_filter/adapters//file_output_filter +../algorithms/output_filter/adapters//null_sink_output_filter +../algorithms/signal_source/adapters//file_signal_source +#../algorithms/signal_source/adapters//usrp1_signal_source +../algorithms/telemetry_decoder/adapters//gps_l1_ca_telemetry_decoder +../algorithms/telemetry_decoder/gnuradio_blocks//gps_l1_ca_telemetry_decoder_cc +../algorithms/telemetry_decoder/libs//gps_l1_ca_subframe_fsm +../algorithms/PVT/adapters//gps_l1_ca_pvt +../algorithms/PVT/gnuradio_blocks//gps_l1_ca_pvt_cc +../algorithms/tracking/adapters//gps_l1_ca_dll_pll_tracking +../algorithms/tracking/adapters//gps_l1_ca_dll_fll_pll_tracking +../algorithms/tracking/gnuradio_blocks//gps_l1_ca_dll_pll_tracking_cc +../algorithms/tracking/gnuradio_blocks//gps_l1_ca_dll_fll_pll_tracking_cc +../algorithms/tracking/libs//tracking_discriminators +../algorithms/tracking/libs//CN_estimators +../algorithms/tracking/libs//tracking_FLL_PLL_filter +../algorithms/tracking/libs//tracking_2nd_PLL_filter +../algorithms/tracking/libs//tracking_2nd_DLL_filter +../algorithms/tracking/libs//correlator +../core/libs//INIReader +../core/libs//ini +../core/libs//string_converter +../core/receiver//control_message_factory +../core/receiver//control_thread +../core/receiver//file_configuration +../core/receiver//in_memory_configuration +../core/receiver//gnss_block_factory +../core/receiver//gnss_flowgraph +../core/system_parameters//gps_navigation_message +../core/system_parameters//gnss_satellite +../..//gflags +../..//glog +../..//gnuradio-core +../..//gtest ; + +install ../../install : run_tests ; \ No newline at end of file diff --git a/src/tests/string_converter/INIReader/INIReader.cpp b/src/tests/string_converter/INIReader/INIReader.cpp deleted file mode 100644 index d4dd66fb6..000000000 --- a/src/tests/string_converter/INIReader/INIReader.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Read an INI file into easy-to-access name/value pairs. - -#include -#include -#include "ini.h" -#include "INIReader.h" - -using std::string; - -INIReader::INIReader(string filename) -{ - _error = ini_parse(filename.c_str(), ValueHandler, this); -} - -int INIReader::ParseError() -{ - return _error; -} - -string INIReader::Get(string section, string name, string default_value) -{ - string key = MakeKey(section, name); - return _values.count(key) ? _values[key] : default_value; -} - -long INIReader::GetInteger(string section, string name, long default_value) -{ - string valstr = Get(section, name, ""); - const char* value = valstr.c_str(); - char* end; - // This parses "1234" (decimal) and also "0x4D2" (hex) - long n = strtol(value, &end, 0); - return end > value ? n : default_value; -} - -string INIReader::MakeKey(string section, string name) -{ - string key = section + "." + name; - // Convert to lower case to make lookups case-insensitive - for (unsigned int i = 0; i < key.length(); i++) - key[i] = tolower(key[i]); - return key; -} - -int INIReader::ValueHandler(void* user, const char* section, const char* name, - const char* value) -{ - INIReader* reader = (INIReader*)user; - reader->_values[MakeKey(section, name)] = value; - return 1; -} diff --git a/src/tests/string_converter/INIReader/INIReader.h b/src/tests/string_converter/INIReader/INIReader.h deleted file mode 100644 index e0882941d..000000000 --- a/src/tests/string_converter/INIReader/INIReader.h +++ /dev/null @@ -1,43 +0,0 @@ -// Read an INI file into easy-to-access name/value pairs. - -// inih and INIReader are released under the New BSD license (see LICENSE.txt). -// Go to the project home page for more info: -// -// http://code.google.com/p/inih/ - -#ifndef __INIREADER_H__ -#define __INIREADER_H__ - -#include -#include - -// Read an INI file into easy-to-access name/value pairs. (Note that I've gone -// for simplicity here rather than speed, but it should be pretty decent.) -class INIReader -{ -public: - // Construct INIReader and parse given filename. See ini.h for more info - // about the parsing. - INIReader(std::string filename); - - // Return the result of ini_parse(), i.e., 0 on success, line number of - // first error on parse error, or -1 on file open error. - int ParseError(); - - // Get a string value from INI file, returning default_value if not found. - std::string Get(std::string section, std::string name, - std::string default_value); - - // Get an integer (long) value from INI file, returning default_value if - // not found. - long GetInteger(std::string section, std::string name, long default_value); - -private: - int _error; - std::map _values; - static std::string MakeKey(std::string section, std::string name); - static int ValueHandler(void* user, const char* section, const char* name, - const char* value); -}; - -#endif // __INIREADER_H__ diff --git a/src/tests/string_converter/INIReader/ini.c b/src/tests/string_converter/INIReader/ini.c deleted file mode 100644 index c4eb2b5bc..000000000 --- a/src/tests/string_converter/INIReader/ini.c +++ /dev/null @@ -1,130 +0,0 @@ -/* inih -- simple .INI file parser - -inih is released under the New BSD license (see LICENSE.txt). Go to the project -home page for more info: - -http://code.google.com/p/inih/ - -*/ - -#include -#include -#include - -#include "ini.h" - -#define MAX_LINE 200 -#define MAX_SECTION 50 -#define MAX_NAME 50 - -/* Strip whitespace chars off end of given string, in place. Return s. */ -static char* rstrip(char* s) -{ - char* p = s + strlen(s); - while (p > s && isspace(*--p)) - *p = '\0'; - return s; -} - -/* Return pointer to first non-whitespace char in given string. */ -static char* lskip(const char* s) -{ - while (*s && isspace(*s)) - s++; - return (char*)s; -} - -/* Return pointer to first char c or ';' in given string, or pointer to - null at end of string if neither found. */ -static char* find_char_or_comment(const char* s, char c) -{ - while (*s && *s != c && *s != ';') - s++; - return (char*)s; -} - -/* Version of strncpy that ensures dest (size bytes) is null-terminated. */ -static char* strncpy0(char* dest, const char* src, size_t size) -{ - strncpy(dest, src, size); - dest[size - 1] = '\0'; - return dest; -} - -/* See documentation in header file. */ -int ini_parse(const char* filename, - int (*handler)(void*, const char*, const char*, const char*), - void* user) -{ - /* Uses a fair bit of stack (use heap instead if you need to) */ - char line[MAX_LINE]; - char section[MAX_SECTION] = ""; - char prev_name[MAX_NAME] = ""; - - FILE* file; - char* start; - char* end; - char* name; - char* value; - int lineno = 0; - int error = 0; - - file = fopen(filename, "r"); - if (!file) - return -1; - - /* Scan through file line by line */ - while (fgets(line, sizeof(line), file) != NULL) { - lineno++; - start = lskip(rstrip(line)); - -#if INI_ALLOW_MULTILINE - if (*prev_name && *start && start > line) { - /* Non-black line with leading whitespace, treat as continuation - of previous name's value (as per Python ConfigParser). */ - if (!handler(user, section, prev_name, start) && !error) - error = lineno; - } - else -#endif - if (*start == '[') { - /* A "[section]" line */ - end = find_char_or_comment(start + 1, ']'); - if (*end == ']') { - *end = '\0'; - strncpy0(section, start + 1, sizeof(section)); - *prev_name = '\0'; - } - else if (!error) { - /* No ']' found on section line */ - error = lineno; - } - } - else if (*start && *start != ';') { - /* Not a comment, must be a name=value pair */ - end = find_char_or_comment(start, '='); - if (*end == '=') { - *end = '\0'; - name = rstrip(start); - value = lskip(end + 1); - end = find_char_or_comment(value, ';'); - if (*end == ';') - *end = '\0'; - rstrip(value); - - /* Valid name=value pair found, call handler */ - strncpy0(prev_name, name, sizeof(prev_name)); - if (!handler(user, section, name, value) && !error) - error = lineno; - } - else if (!error) { - /* No '=' found on name=value line */ - error = lineno; - } - } - } - - fclose(file); - - return error; -} diff --git a/src/tests/string_converter/INIReader/ini.h b/src/tests/string_converter/INIReader/ini.h deleted file mode 100644 index e4d0daf2f..000000000 --- a/src/tests/string_converter/INIReader/ini.h +++ /dev/null @@ -1,45 +0,0 @@ -/* inih -- simple .INI file parser - -inih is released under the New BSD license (see LICENSE.txt). Go to the project -home page for more info: - -http://code.google.com/p/inih/ - -*/ - -#ifndef __INI_H__ -#define __INI_H__ - -/* Make this header file easier to include in C++ code */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Parse given INI-style file. May have [section]s, name=value pairs - (whitespace stripped), and comments starting with ';' (semicolon). Section - is "" if name=value pair parsed before any section heading. - - For each name=value pair parsed, call handler function with given user - pointer as well as section, name, and value (data only valid for duration - of handler call). Handler should return nonzero on success, zero on error. - - Returns 0 on success, line number of first error on parse error, or -1 on - file open error. -*/ -int ini_parse(const char* filename, - int (*handler)(void* user, const char* section, - const char* name, const char* value), - void* user); - -/* Nonzero to allow multi-line value parsing, in the style of Python's - ConfigParser. If allowed, ini_parse() will call the handler with the same - name for each subsequent line parsed. */ -#ifndef INI_ALLOW_MULTILINE -#define INI_ALLOW_MULTILINE 1 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __INI_H__ */ diff --git a/src/tests/string_converter/INIReader/jamfile.jam b/src/tests/string_converter/INIReader/jamfile.jam deleted file mode 100644 index b2fd75e59..000000000 --- a/src/tests/string_converter/INIReader/jamfile.jam +++ /dev/null @@ -1,2 +0,0 @@ -obj INIParser : ini.c ; -obj INIReader : INIReader.cpp ; \ No newline at end of file diff --git a/src/tests/string_converter/string_converter.cc b/src/tests/string_converter/string_converter.cc deleted file mode 100644 index 1d20c9241..000000000 --- a/src/tests/string_converter/string_converter.cc +++ /dev/null @@ -1,101 +0,0 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -#include "string_converter.h" - -#include -#include - -StringConverter::StringConverter() { -} - -StringConverter::~StringConverter() { -} - -bool StringConverter::convert(std::string value, bool default_value) { - - if(value.compare("true") == 0) { - return true; - } else if(value.compare("false") == 0) { - return false; - } else { - return default_value; - } -} - - -long StringConverter::convert(std::string value, long default_value) { - - std::stringstream stream(value); - - long result; - stream >> result; - - if(stream.fail()) { - return default_value; - } else { - return result; - } -} - -int StringConverter::convert(std::string value, int default_value) { - - std::stringstream stream(value); - - int result; - stream >> result; - - if(stream.fail()) { - return default_value; - } else { - return result; - } -} - -unsigned int StringConverter::convert(std::string value, unsigned int default_value) { - - std::stringstream stream(value); - - unsigned int result; - stream >> result; - - if(stream.fail()) { - return default_value; - } else { - return result; - } -} - -float StringConverter::convert(std::string value, float default_value) { - - std::stringstream stream(value); - - float result; - stream >> result; - - if(stream.fail()) { - return default_value; - } else { - return result; - } -} - -double StringConverter::convert(std::string value, double default_value) { - - std::stringstream stream(value); - - double result; - stream >> result; - - if(stream.fail()) { - return default_value; - } else { - return result; - } -} diff --git a/src/tests/string_converter/string_converter.h b/src/tests/string_converter/string_converter.h deleted file mode 100644 index 1cbc05169..000000000 --- a/src/tests/string_converter/string_converter.h +++ /dev/null @@ -1,34 +0,0 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * This class interprets the contents of a string and converts it into - * different types. - */ - -#ifndef STRING_CONVERTER_H_ -#define STRING_CONVERTER_H_ - -#include - -class StringConverter { - -public: - StringConverter(); - virtual ~StringConverter(); - - bool convert(std::string value, bool default_value); - long convert(std::string value, long default_value); - int convert(std::string value, int default_value); - unsigned int convert(std::string value, unsigned int default_value); - float convert(std::string value, float default_value); - double convert(std::string value, double default_value); -}; - -#endif /*STRING_CONVERTER_H_*/ diff --git a/src/tests/string_converter/string_converter_test.cc b/src/tests/string_converter/string_converter_test.cc index 36e1dcb7b..969793195 100644 --- a/src/tests/string_converter/string_converter_test.cc +++ b/src/tests/string_converter/string_converter_test.cc @@ -1,61 +1,77 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * This class implements a Unit Tests for the class StringConverter. +/*! + * \file string_converter_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 * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- */ #include - #include "string_converter.h" -TEST(StringConverter, StringToBool) { - StringConverter *converter = new StringConverter(); - bool conversion_result = converter->convert("false", true); - - EXPECT_EQ(false, conversion_result); - - delete converter; +TEST(String_Converter_Test, StringToBool) +{ + StringConverter *converter = new StringConverter(); + bool conversion_result = converter->convert("false", true); + EXPECT_EQ(false, conversion_result); + delete converter; } -TEST(StringConverter, StringToSizeT) { - StringConverter *converter = new StringConverter(); - size_t conversion_result = converter->convert("8", 1); - EXPECT_EQ(8, conversion_result); - - delete converter; +TEST(String_Converter_Test, StringToSizeT) +{ + StringConverter *converter = new StringConverter(); + size_t conversion_result = converter->convert("8", 1); + EXPECT_EQ(8, conversion_result); + delete converter; } -TEST(StringConverter, StringToBoolFail) { - StringConverter *converter = new StringConverter(); - bool conversion_result = converter->convert("lse", true); - EXPECT_EQ(true, conversion_result); - - delete converter; +TEST(String_Converter_Test, StringToBoolFail) +{ + StringConverter *converter = new StringConverter(); + bool conversion_result = converter->convert("lse", true); + EXPECT_EQ(true, conversion_result); + delete converter; } -TEST(StringConverter, StringToSizeTFail) { - StringConverter *converter = new StringConverter(); - size_t conversion_result = converter->convert("false", 1); - EXPECT_EQ(1, conversion_result); - - delete converter; -} \ No newline at end of file +TEST(String_Converter_Test, StringToSizeTFail) +{ + StringConverter *converter = new StringConverter(); + size_t conversion_result = converter->convert("false", 1); + EXPECT_EQ(1, conversion_result); + delete converter; +} diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index 2a1b6b99e..61eddfe0d 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -1,13 +1,99 @@ +/*! + * \file test_main.cc + * \brief This file implements tests for the ControlMessageFactory. + * \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + + + #include +#include #include #include #include +#include +#include +#include +#include +#include "concurrent_queue.h" +#include "gps_navigation_message.h" +#include "control_thread.h" -int main(int argc, char **argv) { - std::cout << "Running main() from test_main.cc\n"; - testing::InitGoogleTest(&argc, argv); - google::InitGoogleLogging(argv[0]); +#include "control_thread/control_message_factory_test.cc" +//#include "control_thread/control_thread_test.cc" +#include "configuration/file_configuration_test.cc" +//#include "flowgraph/file_output_filter_test.cc" +//#include "flowgraph/file_signal_source_test.cc" +#include "flowgraph/pass_through_test.cc" +//#include "flowgraph/gnss_flowgraph_test.cc" +//#include "gnss_block/file_output_filter_test.cc" +#include "gnuradio_block/gnss_sdr_valve_test.cc" +#include "string_converter/string_converter_test.cc" +#include "arithmetic/complex_arithmetic_libc.cc" +#include "arithmetic/correlations_libc.cc" - return RUN_ALL_TESTS(); -} \ No newline at end of file + + +concurrent_queue global_gps_nav_msg_queue; + +/* +class Control_Message_Factory_Test : public ::testing:: Test +{ +protected: + Control_Message_Factory_Test(){} +}; + + + +class File_Configuration_Test : public ::testing:: Test +{ +protected: + File_Configuration_Test(){} +}; + + +class Control_Thread_Test : public ::testing:: Test +{ +protected: + Control_Thread_Test(){} +}; +*/ + + + + + +int main(int argc, char **argv) +{ + std::cout << "Running main() from test_main.cc" << std::endl; + testing::InitGoogleTest(&argc, argv); + google::InitGoogleLogging(argv[0]); + return RUN_ALL_TESTS(); +} diff --git a/src/tests/utils/gr_complex_to_short.cc b/src/tests/utils/gr_complex_to_short.cc index d127fafa2..091b274aa 100644 --- a/src/tests/utils/gr_complex_to_short.cc +++ b/src/tests/utils/gr_complex_to_short.cc @@ -3,11 +3,14 @@ #include #include - +#include "control_message_factory.h" #include -#include -#include +#include +#include #include +#include +#include + using google::LogMessage; diff --git a/src/tests/utils/test_1.cc b/src/tests/utils/test_1.cc deleted file mode 100644 index 4e499198f..000000000 --- a/src/tests/utils/test_1.cc +++ /dev/null @@ -1,58 +0,0 @@ - -/** - * Copyright notice - */ - -/** - * Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com - */ - -/** - * Integration test for file signal source. - * - */ - -#include - -#include -#include - -#include "in_memory_configuration.h" -#include "control_thread.h" - -TEST(SignalSource, CorrectFileSignalSource) { - - InMemoryConfiguration* config = new InMemoryConfiguration(); - - config->set_property("ControlThread.wait_for_flowgraph", "true"); - - config->set_property("SignalSource.implementation", "FileSignalSource"); - config->set_property("SignalSource.samples", "0"); - config->set_property("SignalSource.filename", "./signal_samples/signal_1ms.dat"); - config->set_property("SignalSource.dump", "true"); - config->set_property("SignalSource.dump_filename", "./data/test1_dump.dat"); - - config->set_property("SignalConditioner.implementation", "PassThrough"); - - config->set_property("Channels.count", "1"); - - ControlThread* control_thread = new ControlThread(config); - control_thread->run(); - - delete control_thread; - delete config; - - std::ifstream signal_expected; - signal_expected.open("./signal_samples/signal_1ms.dat", std::ios::in|std::ios::binary|std::ios::ate); - EXPECT_FALSE(signal_expected.fail()); - - std::ifstream signal_result; - signal_result.open("./data/test_dump.dat", std::ios::in|std::ios::binary|std::ios::ate); - EXPECT_FALSE(signal_result.fail()); - - EXPECT_EQ(signal_expected.tellg(), signal_result.tellg()); - std::cout << signal_expected.tellg() << ":" << signal_result.tellg() << std::endl; - - signal_expected.close(); - signal_result.close(); -}