Using CTest for testing

master
ismagom 11 years ago
parent 034b003a85
commit c4e0e403ce

@ -40,6 +40,9 @@ LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
INCLUDE(libLTEPackage) #setup cpack INCLUDE(libLTEPackage) #setup cpack
include(CTest)
set( CTEST_MEMORYCHECK_COMMAND valgrind )
######################################################################## ########################################################################
# Install Dirs # Install Dirs
######################################################################## ########################################################################

@ -0,0 +1,13 @@
## This file should be placed in the root directory of your project.
## Then modify the CMakeLists.txt file in the root directory of your
## project to incorporate the testing dashboard.
## # The following are required to uses Dart and the Cdash dashboard
## ENABLE_TESTING()
## INCLUDE(CTest)
set(CTEST_PROJECT_NAME "libLTE")
set(CTEST_NIGHTLY_START_TIME "00:00:00 GMT")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "my.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=libLTE")
set(CTEST_DROP_SITE_CDASH TRUE)

@ -32,12 +32,6 @@ target_link_libraries(ll_example lte)
add_executable(synch_test synch_test.c) add_executable(synch_test synch_test.c)
target_link_libraries(synch_test lte) target_link_libraries(synch_test lte)
add_executable(equalizer_test equalizer_test.c)
target_link_libraries(equalizer_test lte)
add_executable(viterbi_test viterbi_test.c)
target_link_libraries(viterbi_test lte)
add_executable(mib_test mib_test.c) add_executable(mib_test mib_test.c)
target_link_libraries(mib_test lte) target_link_libraries(mib_test lte)

@ -39,7 +39,7 @@
#endif #endif
char *output_file_name = NULL; char *output_file_name = NULL;
int nof_frames=-1; int nof_slots=-1;
int cell_id = 1; int cell_id = 1;
int nof_prb = 6; int nof_prb = 6;
char *uhd_args = ""; char *uhd_args = "";
@ -66,7 +66,7 @@ void usage(char *prog) {
printf("\t UHD is disabled. CUHD library not available\n"); printf("\t UHD is disabled. CUHD library not available\n");
#endif #endif
printf("\t-o output_file [Default USRP]\n"); printf("\t-o output_file [Default USRP]\n");
printf("\t-n number of frames [Default %d]\n", nof_frames); printf("\t-n number of frames [Default %d]\n", nof_slots);
printf("\t-c cell id [Default %d]\n", cell_id); printf("\t-c cell id [Default %d]\n", cell_id);
printf("\t-p nof_prb [Default %d]\n", nof_prb); printf("\t-p nof_prb [Default %d]\n", nof_prb);
printf("\t-v [set verbose to debug, default none]\n"); printf("\t-v [set verbose to debug, default none]\n");
@ -92,7 +92,7 @@ void parse_args(int argc, char **argv) {
output_file_name = argv[optind]; output_file_name = argv[optind];
break; break;
case 'n': case 'n':
nof_frames = atoi(argv[optind]); nof_slots = atoi(argv[optind]);
break; break;
case 'p': case 'p':
nof_prb = atoi(argv[optind]); nof_prb = atoi(argv[optind]);
@ -238,7 +238,7 @@ int main(int argc, char **argv) {
nf = 0; nf = 0;
while(nf<nof_frames || nof_frames == -1) { while(nf<nof_slots || nof_slots == -1) {
for (ns=0;ns<NSLOTS_X_FRAME;ns++) { for (ns=0;ns<NSLOTS_X_FRAME;ns++) {
bzero(slot_buffer, sizeof(cf_t) * slot_n_re); bzero(slot_buffer, sizeof(cf_t) * slot_n_re);

@ -1,213 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The libLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the libLTE library.
*
* libLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libLTE 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 Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include "lte.h"
char *input_file_name;
int nof_frames=1;
int cell_id = 0;
int port_id = 0;
int nof_prb = 6;
lte_cp_t cp = CPNORM;
int file_binary = 0;
int in_slot_length() {
if (CP_ISNORM(cp)) {
return SLOT_LEN_CPNORM(lte_symbol_sz(nof_prb));
} else {
return SLOT_LEN_CPEXT(lte_symbol_sz(nof_prb));
}
}
int slot_length() {
return CP_NSYMB(cp)*lte_symbol_sz(nof_prb);
}
void usage(char *prog) {
printf("Usage: %s [bncprev] -i input_file\n", prog);
printf("\t-b input file is binary [Default no]\n");
printf("\t-n number of slots [Default %d]\n", nof_frames);
printf("\t-c cell_id [Default %d]\n", cell_id);
printf("\t-p port_id [Default %d]\n", port_id);
printf("\t-r nof_prb [Default %d]\n", nof_prb);
printf("\t-e [extended cyclic prefix, Default normal]\n");
printf("\t-v [set verbose to debug, default none]\n");
}
void parse_args(int argc, char **argv) {
int opt;
while ((opt = getopt(argc, argv, "bincprev")) != -1) {
switch(opt) {
case 'b':
file_binary = 1;
break;
case 'i':
input_file_name = argv[optind];
break;
case 'n':
nof_frames = atoi(argv[optind]);
break;
case 'c':
cell_id = atoi(argv[optind]);
break;
case 'p':
port_id = atoi(argv[optind]);
break;
case 'r':
nof_prb = atoi(argv[optind]);
break;
case 'e':
cp = CPEXT;
break;
case 'v':
PRINT_DEBUG;
break;
default:
usage(argv[0]);
exit(-1);
}
}
if (!input_file_name) {
usage(argv[0]);
exit(-1);
}
}
int main(int argc, char **argv) {
filesource_t fsrc;
lte_fft_t fft;
FILE *f = NULL;
chest_t eq;
int slot_cnt;
cf_t *input = NULL;
cf_t *outfft = NULL;
cf_t *ce = NULL;
int i;
if (argc < 3) {
usage(argv[0]);
exit(-1);
}
parse_args(argc,argv);
if (filesource_init(&fsrc, input_file_name, file_binary?COMPLEX_FLOAT_BIN:COMPLEX_FLOAT)) {
fprintf(stderr, "Error opening file %s\n", input_file_name);
goto do_exit;
}
f = fopen("output.m", "w");
if (!f) {
perror("fopen");
goto do_exit;
}
input = malloc(in_slot_length()*sizeof(cf_t));
if (!input) {
perror("malloc");
goto do_exit;
}
outfft = malloc(slot_length()*sizeof(cf_t));
if (!outfft) {
perror("malloc");
goto do_exit;
}
ce = malloc(nof_prb * RE_X_RB * CP_NSYMB(cp) * sizeof(cf_t));
if (!ce) {
perror("malloc");
goto do_exit;
}
if (lte_fft_init(&fft, cp, nof_prb)) {
fprintf(stderr, "Error: initializing FFT\n");
goto do_exit;
}
if (chest_init(&eq, LINEAR, cp, nof_prb, port_id+1)) {
fprintf(stderr, "Error initializing equalizer\n");
goto do_exit;
}
if (chest_ref_LTEDL(&eq, cell_id)) {
fprintf(stderr, "Error initializing reference signal\n");
goto do_exit;
}
bzero(input, sizeof(cf_t) * in_slot_length());
bzero(outfft, sizeof(cf_t) * slot_length());
fprintf(f, "ce=zeros(%d, %d);\n", nof_frames * CP_NSYMB(cp), nof_prb * RE_X_RB);
/* read all file or nof_slots */
slot_cnt = 0;
while (in_slot_length() == filesource_read(&fsrc, input, in_slot_length())
&& (slot_cnt < nof_frames || nof_frames == -1)) {
fprintf(f, "infft=");
vec_fprint_c(f, input, in_slot_length());
fprintf(f, ";\n");
lte_fft_run(&fft, input, outfft);
fprintf(f, "outfft=");
vec_fprint_c(f, outfft, CP_NSYMB(cp) * nof_prb * RE_X_RB);
fprintf(f, ";\n");
chest_ce_slot_port(&eq, outfft, ce, slot_cnt%20, port_id);
chest_fprint(&eq, f, slot_cnt%20, port_id);
for (i=0;i<CP_NSYMB(cp);i++) {
fprintf(f, "ce(%d,:)=", slot_cnt * CP_NSYMB(cp) + i + 1);
vec_fprint_c(f, &ce[i * nof_prb * RE_X_RB], nof_prb * RE_X_RB);
}
slot_cnt++;
}
do_exit:
chest_free(&eq);
lte_fft_free(&fft);
if (ce) {
free(ce);
}
if (outfft) {
free(outfft);
}
if (input) {
free(input);
}
if (f) {
fclose(f);
}
filesource_free(&fsrc);
printf("Done processed %d slots\n", slot_cnt);
exit(0);
}

@ -34,7 +34,7 @@
#include "lte.h" #include "lte.h"
char *input_file_name = NULL; char *input_file_name = NULL;
int nof_frames=100; int nof_slots=100;
float corr_peak_threshold=30; float corr_peak_threshold=30;
int force_N_id_2=-1; int force_N_id_2=-1;
@ -53,7 +53,7 @@ cfo_t cfocorr;
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s [onlt] -i input_file\n", prog); printf("Usage: %s [onlt] -i input_file\n", prog);
printf("\t-n number of frames [Default %d]\n", nof_frames); printf("\t-n number of frames [Default %d]\n", nof_slots);
printf("\t-t correlation threshold [Default %g]\n", corr_peak_threshold); printf("\t-t correlation threshold [Default %g]\n", corr_peak_threshold);
printf("\t-v [set verbose to debug, default none]\n"); printf("\t-v [set verbose to debug, default none]\n");
printf("\t-f force_N_id_2 [Default %d]\n", force_N_id_2); printf("\t-f force_N_id_2 [Default %d]\n", force_N_id_2);
@ -67,7 +67,7 @@ void parse_args(int argc, char **argv) {
input_file_name = argv[optind]; input_file_name = argv[optind];
break; break;
case 'n': case 'n':
nof_frames = atoi(argv[optind]); nof_slots = atoi(argv[optind]);
break; break;
case 't': case 't':
corr_peak_threshold = atof(argv[optind]); corr_peak_threshold = atof(argv[optind]);
@ -266,7 +266,7 @@ int main(int argc, char **argv) {
printf("\n\n-- Initiating MIB search --\n\n"); printf("\n\n-- Initiating MIB search --\n\n");
while(frame_cnt < nof_frames) { while(frame_cnt < nof_slots) {
if (get_samples(read_samples, 0) == -1) { if (get_samples(read_samples, 0) == -1) {
fprintf(stderr, "Error reading %d samples\n", FLEN); fprintf(stderr, "Error reading %d samples\n", FLEN);
break; break;
@ -313,7 +313,7 @@ int main(int argc, char **argv) {
case DONE: case DONE:
INFO("State Done after %d frames\n", frame_cnt); INFO("State Done after %d frames\n", frame_cnt);
pbch_mib_fprint(stdout, &mib); pbch_mib_fprint(stdout, &mib);
frame_cnt = nof_frames; frame_cnt = nof_slots;
printf("Done\n"); printf("Done\n");
break; break;
} }

@ -58,7 +58,7 @@
#define NOF_PORTS 2 #define NOF_PORTS 2
float find_threshold = 40.0, track_threshold = 8.0; float find_threshold = 40.0, track_threshold = 8.0;
int max_track_lost = 9, nof_frames = -1; int max_track_lost = 9, nof_slots = -1;
int track_len=300; int track_len=300;
char *input_file_name = NULL; char *input_file_name = NULL;
int disable_plots = 0; int disable_plots = 0;
@ -89,7 +89,7 @@ void usage(char *prog) {
#else #else
printf("\t UHD is disabled. CUHD library not available\n"); printf("\t UHD is disabled. CUHD library not available\n");
#endif #endif
printf("\t-n nof_frames [Default %d]\n", nof_frames); printf("\t-n nof_frames [Default %d]\n", nof_slots);
#ifndef DISABLE_GRAPHICS #ifndef DISABLE_GRAPHICS
printf("\t-d disable plots [Default enabled]\n"); printf("\t-d disable plots [Default enabled]\n");
#else #else
@ -115,7 +115,7 @@ void parse_args(int argc, char **argv) {
uhd_freq = atof(argv[optind]); uhd_freq = atof(argv[optind]);
break; break;
case 'n': case 'n':
nof_frames = atoi(argv[optind]); nof_slots = atoi(argv[optind]);
break; break;
case 'd': case 'd':
disable_plots = 1; disable_plots = 1;
@ -370,7 +370,7 @@ int main(int argc, char **argv) {
sync_set_threshold(&sfind, find_threshold); sync_set_threshold(&sfind, find_threshold);
sync_force_N_id_2(&sfind, -1); sync_force_N_id_2(&sfind, -1);
while(!go_exit && (frame_cnt < nof_frames || nof_frames==-1)) { while(!go_exit && (frame_cnt < nof_slots || nof_slots==-1)) {
INFO(" ----- RECEIVING %d SAMPLES ---- \n", FLEN); INFO(" ----- RECEIVING %d SAMPLES ---- \n", FLEN);
if (input_file_name) { if (input_file_name) {
n = filesource_read(&fsrc, input_buffer, FLEN); n = filesource_read(&fsrc, input_buffer, FLEN);

@ -35,7 +35,7 @@
#include "lte.h" #include "lte.h"
#include "cuhd.h" #include "cuhd.h"
int nof_frames=1000; int nof_slots=1000;
int band; int band;
cf_t *input_buffer, *fft_buffer; cf_t *input_buffer, *fft_buffer;
@ -52,7 +52,7 @@ void usage(char *prog) {
printf("Usage: %s [nvse] -b band\n", prog); printf("Usage: %s [nvse] -b band\n", prog);
printf("\t-s earfcn_start [Default All]\n"); printf("\t-s earfcn_start [Default All]\n");
printf("\t-e earfcn_end [Default All]\n"); printf("\t-e earfcn_end [Default All]\n");
printf("\t-n number of frames [Default %d]\n", nof_frames); printf("\t-n number of frames [Default %d]\n", nof_slots);
printf("\t-v [set verbose to debug, default none]\n"); printf("\t-v [set verbose to debug, default none]\n");
} }
@ -70,7 +70,7 @@ void parse_args(int argc, char **argv) {
earfcn_end = atoi(argv[optind]); earfcn_end = atoi(argv[optind]);
break; break;
case 'n': case 'n':
nof_frames = atoi(argv[optind]); nof_slots = atoi(argv[optind]);
break; break;
case 'v': case 'v':
verbose++; verbose++;
@ -132,7 +132,7 @@ int main(int argc, char **argv) {
frame_cnt = 0; frame_cnt = 0;
nsamples=0; nsamples=0;
rssi[i]=0; rssi[i]=0;
while(frame_cnt < nof_frames) { while(frame_cnt < nof_slots) {
nsamples += cuhd_recv(uhd, input_buffer, 1920, 1); nsamples += cuhd_recv(uhd, input_buffer, 1920, 1);
rssi[i] += vec_avg_power_cf(input_buffer, 1920); rssi[i] += vec_avg_power_cf(input_buffer, 1920);
frame_cnt++; frame_cnt++;

@ -35,7 +35,7 @@
char *input_file_name; char *input_file_name;
char *output_file_name="abs_corr.txt"; char *output_file_name="abs_corr.txt";
int nof_frames=100, frame_length=9600, symbol_sz=128; int nof_slots=100, frame_length=9600, symbol_sz=128;
float corr_peak_threshold=25.0; float corr_peak_threshold=25.0;
int file_binary = 0; int file_binary = 0;
int out_N_id_2 = 0, force_N_id_2=-1; int out_N_id_2 = 0, force_N_id_2=-1;
@ -47,7 +47,7 @@ void usage(char *prog) {
printf("Usage: %s [onlt] -i input_file\n", prog); printf("Usage: %s [onlt] -i input_file\n", prog);
printf("\t-o output_file [Default %s]\n", output_file_name); printf("\t-o output_file [Default %s]\n", output_file_name);
printf("\t-l frame_length [Default %d]\n", frame_length); printf("\t-l frame_length [Default %d]\n", frame_length);
printf("\t-n number of frames [Default %d]\n", nof_frames); printf("\t-n number of frames [Default %d]\n", nof_slots);
printf("\t-t correlation threshold [Default %g]\n", corr_peak_threshold); printf("\t-t correlation threshold [Default %g]\n", corr_peak_threshold);
printf("\t-s symbol_sz [Default %d]\n", symbol_sz); printf("\t-s symbol_sz [Default %d]\n", symbol_sz);
printf("\t-b Input files is binary [Default %s]\n", file_binary?"yes":"no"); printf("\t-b Input files is binary [Default %s]\n", file_binary?"yes":"no");
@ -67,7 +67,7 @@ void parse_args(int argc, char **argv) {
output_file_name = argv[optind]; output_file_name = argv[optind];
break; break;
case 'n': case 'n':
nof_frames = atoi(argv[optind]); nof_slots = atoi(argv[optind]);
break; break;
case 'l': case 'l':
frame_length = atoi(argv[optind]); frame_length = atoi(argv[optind]);
@ -145,12 +145,12 @@ int main(int argc, char **argv) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
} }
cfo = malloc(nof_frames*sizeof(float)); cfo = malloc(nof_slots*sizeof(float));
if (!cfo) { if (!cfo) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
} }
exec_time = malloc(nof_frames*sizeof(int)); exec_time = malloc(nof_slots*sizeof(int));
if (!exec_time) { if (!exec_time) {
perror("malloc"); perror("malloc");
exit(-1); exit(-1);
@ -194,7 +194,7 @@ int main(int argc, char **argv) {
/* read all file or nof_frames */ /* read all file or nof_frames */
frame_cnt = 0; frame_cnt = 0;
while (frame_length == filesource_read(&fsrc, input, frame_length) while (frame_length == filesource_read(&fsrc, input, frame_length)
&& frame_cnt < nof_frames) { && frame_cnt < nof_slots) {
gettimeofday(&tdata[1], NULL); gettimeofday(&tdata[1], NULL);
if (force_cfo != CFO_AUTO) { if (force_cfo != CFO_AUTO) {

@ -24,9 +24,8 @@
# Build tests # Build tests
######################################################################## ########################################################################
#turn the test cpp file into an executable with an int main() function #turn the test cpp file into an executable with an int main() function
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
INCLUDE_DIRECTORIES(..) INCLUDE_DIRECTORIES(..)
ADD_EXECUTABLE(complexplot_test complexplot_test.cpp) ADD_EXECUTABLE(complexplot_test complexplot_test.cpp)
TARGET_LINK_LIBRARIES(complexplot_test ${Boost_LIBRARIES} graphics) TARGET_LINK_LIBRARIES(complexplot_test pthread graphics)
ADD_TEST(complexplot_test complexplot_test) ADD_TEST(complexplot_test complexplot_test)

@ -35,112 +35,112 @@
#include "Complexplot.h" #include "Complexplot.h"
#include <boost/scoped_ptr.hpp> #include <pthread.h>
#include <boost/thread/thread.hpp> #include <unistd.h>
#include <boost/progress.hpp> #include <stdio.h>
#include <boost/bind.hpp>
#include <qapplication.h> #include <qapplication.h>
#include <cstdlib> #include <cstdlib>
#include <complex> #include <complex>
#include <vector> #include <vector>
#include <boost/test/unit_test.hpp>
#define PI 3.14159265358979323846 #define PI 3.14159265358979323846
using namespace std; using namespace std;
typedef vector< complex<float> > FloatVec; typedef vector<complex<float> > FloatVec;
void threadMain1() void *threadMain1(void *arg) {
{
Complexplot plot; Complexplot plot;
plot.setTitle("Float"); plot.setTitle("Float");
plot.setXAxisRange(0,2); plot.setXAxisRange(0, 2);
plot.setYAxisScale(Complexplot::Magnitude, 0.9, 1.1); plot.setYAxisScale(Complexplot::Magnitude, 0.9, 1.1);
int n=1024; int n = 1024;
float step = 2.0*PI/n; float step = 2.0 * PI / n;
complex<float>* data = new complex<float>[n]; complex<float>* data = new complex<float> [n];
for(int i=0;i<n;i++) for (int i = 0; i < n; i++)
data[i] = polar(1.0f,step*i); data[i] = polar(1.0f, step * i);
plot.setNewData(data, n); plot.setNewData(data, n);
for(int i=0;i<n;i++) for (int i = 0; i < n; i++) {
{ rotate(data, data + 1, data + n);
rotate(data, data+1, data+n);
plot.setNewData(data, n); plot.setNewData(data, n);
boost::this_thread::sleep(boost::posix_time::milliseconds(1)); usleep(1000);
} }
return NULL;
} }
void threadMain2() void *threadMain2(void *arg) {
{
Complexplot plot; Complexplot plot;
plot.setTitle("Double"); plot.setTitle("Double");
plot.setXAxisRange(0,2); plot.setXAxisRange(0, 2);
plot.setYAxisScale(Complexplot::Magnitude, 0.9, 1.1); plot.setYAxisScale(Complexplot::Magnitude, 0.9, 1.1);
int n=1024; int n = 1024;
double step = 2.0*PI/n; double step = 2.0 * PI / n;
complex<double>* data = new complex<double>[n]; complex<double>* data = new complex<double> [n];
for(int i=0;i<n;i++) for (int i = 0; i < n; i++)
data[i] = polar(1.0,step*i); data[i] = polar(1.0, step * i);
plot.setNewData(data, n); plot.setNewData(data, n);
for(int i=0;i<n;i++) for (int i = 0; i < n; i++) {
{ rotate(data, data + 1, data + n);
rotate(data, data+1, data+n);
plot.setNewData(data, n); plot.setNewData(data, n);
boost::this_thread::sleep(boost::posix_time::milliseconds(1)); usleep(1000);
} }
return NULL;
} }
void threadMain3() void *threadMain3(void *arg) {
{
Complexplot plot; Complexplot plot;
plot.setTitle("FloatVec"); plot.setTitle("FloatVec");
plot.setXAxisRange(0,2); plot.setXAxisRange(0, 2);
plot.setYAxisScale(Complexplot::Magnitude, 0.9, 1.1); plot.setYAxisScale(Complexplot::Magnitude, 0.9, 1.1);
FloatVec data(1024); FloatVec data(1024);
int n=data.size(); int n = data.size();
float step = 2.0*PI/n; float step = 2.0 * PI / n;
for(int i=0;i<n;i++) for (int i = 0; i < n; i++)
data[i] = polar(1.0f,step*i); data[i] = polar(1.0f, step * i);
plot.setNewData(data.begin(), data.end()); plot.setNewData(data.begin(), data.end());
for(int i=0;i<n;i++) for (int i = 0; i < n; i++) {
{ rotate(data.begin(), data.begin() + 1, data.end());
rotate(data.begin(), data.begin()+1, data.end());
plot.setNewData(data.begin(), data.end()); plot.setNewData(data.begin(), data.end());
boost::this_thread::sleep(boost::posix_time::milliseconds(1)); usleep(1000);
} }
return NULL;
} }
BOOST_AUTO_TEST_SUITE (Complexplot_Test) int main(int argc, char *argv[]) {
int argc2 = 1;
char* argv2[] = { const_cast<char *>("Compleplot_Basic_Test"), NULL };
QApplication a(argc2, argv2);
pthread_t threads[3];
int i;
BOOST_AUTO_TEST_CASE(Complexplot_Basic_Test) if (pthread_create(&threads[0], NULL, threadMain1, NULL)) {
{ perror("pthread_create");
int argc = 1; exit(-1);
char* argv[] = { const_cast<char *>("Compleplot_Basic_Test"), NULL }; }
QApplication a(argc, argv); if (pthread_create(&threads[1], NULL, threadMain2, NULL)) {
perror("pthread_create");
boost::scoped_ptr< boost::thread > thread1_; exit(-1);
boost::scoped_ptr< boost::thread > thread2_; }
boost::scoped_ptr< boost::thread > thread3_; if (pthread_create(&threads[2], NULL, threadMain3, NULL)) {
perror("pthread_create");
thread1_.reset( new boost::thread( &threadMain1 ) ); exit(-1);
thread2_.reset( new boost::thread( &threadMain2 ) ); }
thread3_.reset( new boost::thread( &threadMain3 ) );
qApp->exec(); qApp->exec();
thread1_->join();
thread2_->join(); for (i=0;i<3;i++) {
thread3_->join(); pthread_join(threads[i], NULL);
}
exit(0);
} }
BOOST_AUTO_TEST_SUITE_END()

@ -24,9 +24,8 @@
# Build tests # Build tests
######################################################################## ########################################################################
#turn the test cpp file into an executable with an int main() function #turn the test cpp file into an executable with an int main() function
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
INCLUDE_DIRECTORIES(..) INCLUDE_DIRECTORIES(..)
ADD_EXECUTABLE(realplot_test realplot_test.cpp) ADD_EXECUTABLE(realplot_test realplot_test.cpp)
TARGET_LINK_LIBRARIES(realplot_test ${Boost_LIBRARIES} graphics) TARGET_LINK_LIBRARIES(realplot_test pthread graphics)
ADD_TEST(realplot_test realplot_test) ADD_TEST(realplot_test realplot_test)

@ -35,96 +35,91 @@
#include "Realplot.h" #include "Realplot.h"
#include <boost/scoped_ptr.hpp> #include <pthread.h>
#include <boost/thread/thread.hpp> #include <unistd.h>
#include <boost/progress.hpp> #include <stdio.h>
#include <boost/bind.hpp>
#include <qapplication.h> #include <qapplication.h>
#include <cstdlib> #include <cstdlib>
#include <complex> #include <complex>
#include <vector> #include <vector>
#include <boost/test/unit_test.hpp>
typedef std::vector<float> FloatVec; typedef std::vector<float> FloatVec;
template<class T> template<class T>
void getPoints(T* data, int numPoints) void getPoints(T* data, int numPoints) {
{ for (int i = 0; i < numPoints; i++) {
for(int i=0;i<numPoints;i++) data[i] = 10 * ((T) rand() / RAND_MAX);
{
data[i] = 10*((T)rand()/RAND_MAX);
} }
} }
template<class Iterator> template<class Iterator>
void getPoints(Iterator begin, Iterator end) void getPoints(Iterator begin, Iterator end) {
{ for (; begin != end; begin++) {
for(;begin!=end;begin++) *begin = 10 * ((double) rand() / RAND_MAX);
{
*begin = 10*((double)rand()/RAND_MAX);
} }
} }
void threadMain1() void *threadMain1(void *arg) {
{
Realplot plot; Realplot plot;
float data[1024]; float data[1024];
for(int i=0;i<10;i++) for (int i = 0; i < 100; i++) {
{
getPoints(data, 504); getPoints(data, 504);
plot.setNewData(data, 504); plot.setNewData(data, 504);
boost::this_thread::sleep(boost::posix_time::milliseconds(5)); boost::this_thread::sleep(boost::posix_time::milliseconds(5));
} }
return NULL;
} }
void threadMain2() void *threadMain2(void *arg) {
{
Realplot plot; Realplot plot;
double data[1024]; double data[1024];
for(int i=0;i<10000;i++) for (int i = 0; i < 100; i++) {
{
getPoints(data, 504); getPoints(data, 504);
plot.setNewData(data, 504); plot.setNewData(data, 504);
boost::this_thread::sleep(boost::posix_time::milliseconds(5)); usleep(5000);
} }
return NULL;
} }
void threadMain3() void *threadMain3(void *arg) {
{
Realplot plot; Realplot plot;
FloatVec v(1024); FloatVec v(1024);
for(int i=0;i<10000;i++) for (int i = 0; i < 100; i++) {
{
getPoints(v.begin(), v.end()); getPoints(v.begin(), v.end());
plot.setNewData(v.begin(), v.end()); plot.setNewData(v.begin(), v.end());
boost::this_thread::sleep(boost::posix_time::milliseconds(10)); usleep(5000);
} }
return NULL;
} }
BOOST_AUTO_TEST_SUITE (Realplot_Test) int main(int argc, char *argv[]) {
int argc2 = 1;
BOOST_AUTO_TEST_CASE(Realplot_Basic_Test) char* argv2[] = { const_cast<char *>("Realplot_Basic_Test"), NULL };
{ QApplication a(argc2, argv2);
int argc = 1; pthread_t threads[3];
char* argv[] = { const_cast<char *>("Realplot_Basic_Test"), NULL }; int i;
QApplication a(argc, argv);
boost::scoped_ptr< boost::thread > thread1_;
boost::scoped_ptr< boost::thread > thread2_;
boost::scoped_ptr< boost::thread > thread3_;
thread1_.reset( new boost::thread( &threadMain1 ) ); if (pthread_create(&threads[0], NULL, threadMain1, NULL)) {
thread2_.reset( new boost::thread( &threadMain2 ) ); perror("pthread_create");
thread3_.reset( new boost::thread( &threadMain3 ) ); exit(-1);
}
if (pthread_create(&threads[1], NULL, threadMain2, NULL)) {
perror("pthread_create");
exit(-1);
}
if (pthread_create(&threads[2], NULL, threadMain3, NULL)) {
perror("pthread_create");
exit(-1);
}
qApp->exec(); qApp->exec();
thread1_->join();
thread2_->join();
thread3_->join();
}
BOOST_AUTO_TEST_SUITE_END() for (i=0;i<3;i++) {
pthread_join(threads[i], NULL);
}
exit(0);
}

@ -23,10 +23,8 @@
######################################################################## ########################################################################
# Build tests # Build tests
######################################################################## ########################################################################
#turn the test cpp file into an executable with an int main() function
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN)
INCLUDE_DIRECTORIES(..) INCLUDE_DIRECTORIES(..)
ADD_EXECUTABLE(scatterplot_test scatterplot_test.cpp) ADD_EXECUTABLE(scatterplot_test scatterplot_test.cpp)
TARGET_LINK_LIBRARIES(scatterplot_test ${Boost_LIBRARIES} graphics) TARGET_LINK_LIBRARIES(scatterplot_test pthread graphics)
ADD_TEST(scatterplot_test scatterplot_test) ADD_TEST(scatterplot_test scatterplot_test)

@ -35,99 +35,94 @@
#include "Scatterplot.h" #include "Scatterplot.h"
#include <boost/scoped_ptr.hpp> #include <pthread.h>
#include <boost/thread/thread.hpp> #include <unistd.h>
#include <boost/progress.hpp> #include <stdio.h>
#include <boost/bind.hpp>
#include <qapplication.h> #include <qapplication.h>
#include <cstdlib> #include <cstdlib>
#include <complex> #include <complex>
#include <vector> #include <vector>
#include <boost/test/unit_test.hpp>
typedef std::complex<float> Cplx; typedef std::complex<float> Cplx;
typedef std::vector<Cplx> CplxVec; typedef std::vector<Cplx> CplxVec;
template<class T> template<class T>
void getPoints(std::complex<T>* data, int numPoints) void getPoints(std::complex<T>* data, int numPoints) {
{ for (int i = 0; i < numPoints; i++) {
for(int i=0;i<numPoints;i++) data[i] = std::complex<T>(2 * ((T) rand() / RAND_MAX) - 1,
{ 2 * ((T) rand() / RAND_MAX) - 1);
data[i] = std::complex<T>(2*((T)rand()/RAND_MAX)-1,
2*((T)rand()/RAND_MAX)-1);
} }
} }
template<class Iterator> template<class Iterator>
void getPoints(Iterator begin, Iterator end) void getPoints(Iterator begin, Iterator end) {
{ for (; begin != end; begin++) {
for(;begin!=end;begin++) float r = 2 * ((double) rand() / RAND_MAX) - 1;
{ float i = 2 * ((double) rand() / RAND_MAX) - 1;
float r = 2*((double)rand()/RAND_MAX)-1; *begin = Cplx(r, i);
float i = 2*((double)rand()/RAND_MAX)-1;
*begin = Cplx(r,i);
} }
} }
void threadMain1() void *threadMain1(void *arg) {
{
Scatterplot plot; Scatterplot plot;
std::complex<float> data[1024]; std::complex<float> data[1024];
for(int i=0;i<10;i++) for (int i = 0; i < 10; i++) {
{
getPoints(data, 1024); getPoints(data, 1024);
plot.setNewData(data, 1024); plot.setNewData(data, 1024);
boost::this_thread::sleep(boost::posix_time::milliseconds(100)); usleep(100000);
} }
return NULL;
} }
void threadMain2() void *threadMain2(void *arg) {
{
Scatterplot plot; Scatterplot plot;
std::complex<double> data[1024]; std::complex<double> data[1024];
for(int i=0;i<10;i++) for (int i = 0; i < 10; i++) {
{
getPoints(data, 1024); getPoints(data, 1024);
plot.setNewData(data, 1024); plot.setNewData(data, 1024);
boost::this_thread::sleep(boost::posix_time::milliseconds(100)); usleep(100000);
} }
return NULL;
} }
void threadMain3() void *threadMain3(void *arg) {
{
Scatterplot plot; Scatterplot plot;
CplxVec v(1024); CplxVec v(1024);
for(int i=0;i<10;i++) for (int i = 0; i < 10; i++) {
{
getPoints(v.begin(), v.end()); getPoints(v.begin(), v.end());
plot.setNewData(v.begin(), v.end()); plot.setNewData(v.begin(), v.end());
boost::this_thread::sleep(boost::posix_time::milliseconds(100)); boost::this_thread::sleep(boost::posix_time::milliseconds(100));
} }
return NULL;
} }
BOOST_AUTO_TEST_SUITE (Scatterplot_Test) int main(int argc, char *argv[]) {
int argc2 = 1;
BOOST_AUTO_TEST_CASE(Scatterplot_Basic_Test) char* argv2[] = { const_cast<char *>("Scatterplot_Basic_Test"), NULL };
{ QApplication a(argc2, argv2);
int argc = 1; pthread_t threads[3];
char* argv[] = { const_cast<char *>("Scatterplot_Basic_Test"), NULL }; int i;
QApplication a(argc, argv);
boost::scoped_ptr< boost::thread > thread1_; if (pthread_create(&threads[0], NULL, threadMain1, NULL)) {
boost::scoped_ptr< boost::thread > thread2_; perror("pthread_create");
boost::scoped_ptr< boost::thread > thread3_; exit(-1);
}
thread1_.reset( new boost::thread( &threadMain1 ) ); if (pthread_create(&threads[1], NULL, threadMain2, NULL)) {
thread2_.reset( new boost::thread( &threadMain2 ) ); perror("pthread_create");
thread3_.reset( new boost::thread( &threadMain3 ) ); exit(-1);
}
if (pthread_create(&threads[2], NULL, threadMain3, NULL)) {
perror("pthread_create");
exit(-1);
}
qApp->exec(); qApp->exec();
thread1_->join();
thread2_->join();
thread3_->join();
}
BOOST_AUTO_TEST_SUITE_END() for (i=0;i<3;i++) {
pthread_join(threads[i], NULL);
}
exit(0);
}

@ -35,94 +35,93 @@
#include "Waterfallplot.h" #include "Waterfallplot.h"
#include <boost/scoped_ptr.hpp>
#include <boost/thread/thread.hpp> #include <pthread.h>
#include <boost/progress.hpp> #include <unistd.h>
#include <boost/bind.hpp> #include <stdio.h>
#include <qapplication.h> #include <qapplication.h>
#include <cstdlib> #include <cstdlib>
#include <vector> #include <vector>
#include <boost/test/unit_test.hpp>
#define PI 3.14159265358979323846 #define PI 3.14159265358979323846
using namespace std; using namespace std;
void threadMain1() void *threadMain1(void *arg) {
{ int n = 2048;
int n=2048; Waterfallplot plot(n, n);
Waterfallplot plot(n,n);
plot.setTitle("Float"); plot.setTitle("Float");
float step = 1.0*PI/n; float step = 1.0 * PI / n;
float* data = new float[n*2]; float* data = new float[n * 2];
for(int i=0;i<n*2;i++) for (int i = 0; i < n * 2; i++)
data[i] = sinf(step*i); data[i] = sinf(step * i);
for(int i=0;i<n;i++) for (int i = 0; i < n; i++) {
{ plot.appendNewData(data + i, n);
plot.appendNewData(data+i, n); usleep(1000);
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
} }
return NULL;
} }
void threadMain2() void threadMain2() {
{ int n = 2048;
int n=2048; Waterfallplot plot(n, n);
Waterfallplot plot(n,n);
plot.setTitle("Double"); plot.setTitle("Double");
double step = 2.0*PI/n; double step = 2.0 * PI / n;
double* data = new double[n*2]; double* data = new double[n * 2];
for(int i=0;i<n*2;i++) for (int i = 0; i < n * 2; i++)
data[i] = sin(step*i); data[i] = sin(step * i);
for(int i=0;i<n;i++) for (int i = 0; i < n; i++) {
{ plot.appendNewData(data + i, n);
plot.appendNewData(data+i, n);
boost::this_thread::sleep(boost::posix_time::milliseconds(1)); boost::this_thread::sleep(boost::posix_time::milliseconds(1));
} }
} }
void threadMain3() void *threadMain3(void *arg) {
{ int n = 2048;
int n=2048; Waterfallplot plot(n, n);
Waterfallplot plot(n,n);
plot.setTitle("FloatVec"); plot.setTitle("FloatVec");
double step = 2.0*PI/n; double step = 2.0 * PI / n;
std::vector<float> data; std::vector<float> data;
data.resize(n*2); data.resize(n * 2);
for(int i=0;i<n*2;i++) for (int i = 0; i < n * 2; i++)
data[i] = sin(step*i); data[i] = sin(step * i);
for(int i=0;i<n;i++) for (int i = 0; i < n; i++) {
{ plot.appendNewData(data.begin() + i, data.begin() + i + n);
plot.appendNewData(data.begin()+i, data.begin()+i+n);
boost::this_thread::sleep(boost::posix_time::milliseconds(1)); boost::this_thread::sleep(boost::posix_time::milliseconds(1));
} }
} }
BOOST_AUTO_TEST_SUITE (Waterfallplot_Test) int main(int argc, char *argv[]) {
int argc2 = 1;
char* argv2[] = { const_cast<char *>("Waterfallplot_Init_Test"), NULL };
QApplication a(argc2, argv2);
pthread_t threads[3];
int i;
BOOST_AUTO_TEST_CASE(Waterfallplot_Init_Test) if (pthread_create(&threads[0], NULL, threadMain1, NULL)) {
{ perror("pthread_create");
int argc = 1; exit(-1);
char* argv[] = { const_cast<char *>("Waterfallplot_Init_Test"), NULL }; }
QApplication a(argc, argv); if (pthread_create(&threads[1], NULL, threadMain2, NULL)) {
perror("pthread_create");
exit(-1);
}
if (pthread_create(&threads[2], NULL, threadMain3, NULL)) {
perror("pthread_create");
exit(-1);
}
boost::scoped_ptr< boost::thread > thread1_; qApp->exec();
boost::scoped_ptr< boost::thread > thread2_;
boost::scoped_ptr< boost::thread > thread3_;
thread1_.reset( new boost::thread( &threadMain1 ) ); for (i = 0; i < 3; i++) {
thread2_.reset( new boost::thread( &threadMain2 ) ); pthread_join(threads[i], NULL);
thread3_.reset( new boost::thread( &threadMain3 ) ); }
exit(0);
qApp->exec();
thread1_->join();
thread2_->join();
thread3_->join();
} }
BOOST_AUTO_TEST_SUITE_END()

@ -30,6 +30,8 @@ INCLUDE_DIRECTORIES(${FFTW3F_INCLUDE_DIRS})
IF(${DISABLE_VOLK}) IF(${DISABLE_VOLK})
IF(${DISABLE_VOLK} EQUAL 0) IF(${DISABLE_VOLK} EQUAL 0)
FIND_PACKAGE(Volk) FIND_PACKAGE(Volk)
ELSE(${DISABLE_VOLK} EQUAL 0)
MESSAGE(STATUS "VOLK library disabled (DISABLE_VOLK=1)")
ENDIF(${DISABLE_VOLK} EQUAL 0) ENDIF(${DISABLE_VOLK} EQUAL 0)
ELSE(${DISABLE_VOLK}) ELSE(${DISABLE_VOLK})
FIND_PACKAGE(Volk) FIND_PACKAGE(Volk)
@ -63,7 +65,17 @@ ELSE(VOLK_FOUND)
ENDIF(VOLK_FOUND) ENDIF(VOLK_FOUND)
########################################################################
# Recurse subdirectories and find all directories with a CMakeLists.txt file in it
########################################################################
FILE(GLOB_RECURSE cmakefiles CMakeLists.txt)
FOREACH (_file ${cmakefiles})
GET_FILENAME_COMPONENT(dir ${_file} PATH)
IF (NOT ${dir} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
ADD_SUBDIRECTORY(${dir})
ENDIF ()
ENDFOREACH()

@ -0,0 +1,31 @@
#
# Copyright 2012-2013 The libLTE Developers. See the
# COPYRIGHT file at the top-level directory of this distribution.
#
# This file is part of the libLTE library.
#
# libLTE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# libLTE 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 Lesser General Public License for more details.
#
# A copy of the GNU Lesser General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
########################################################################
# Channel Estimation TEST
########################################################################
ADD_EXECUTABLE(chest_test chest_test.c)
TARGET_LINK_LIBRARIES(chest_test lte)
ADD_TEST(chest_test_all_cellids chest_test)

@ -0,0 +1,251 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The libLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the libLTE library.
*
* libLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libLTE 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 Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <complex.h>
#include "lte.h"
int cell_id = -1;
int nof_prb = 6;
lte_cp_t cp = CPNORM;
char *output_matlab = NULL;
void usage(char *prog) {
printf("Usage: %s [recov]\n", prog);
printf("\t-r nof_prb [Default %d]\n", nof_prb);
printf("\t-e extended cyclic prefix [Default normal]\n");
printf("\t-c cell_id (-1 tests all). [Default %d]\n", cell_id);
printf("\t-o output matlab file [Default %s]\n",output_matlab?output_matlab:"None");
printf("\t-v increase verbosity\n");
}
void parse_args(int argc, char **argv) {
int opt;
while ((opt = getopt(argc, argv, "recov")) != -1) {
switch(opt) {
case 'r':
nof_prb = atoi(argv[optind]);
break;
case 'e':
cp = CPEXT;
break;
case 'c':
cell_id = atoi(argv[optind]);
break;
case 'o':
output_matlab = argv[optind];
break;
case 'v':
verbose++;
break;
default:
usage(argv[0]);
exit(-1);
}
}
}
int check_mse(float mod, float arg, int n_port) {
INFO("mod=%.4f, arg=%.4f, n_port=%d\n", mod, arg, n_port);
switch(n_port) {
case 0:
if (mod > 0.029) {
return -1;
}
if (arg > 0.029) {
return -1;
}
break;
case 1:
if (mod > 0.012) {
return -1;
}
if (arg > 0.012) {
return -1;
}
break;
case 2:
case 3:
if (mod > 3.33) {
return -1;
}
if (arg > 0.63) {
return -1;
}
break;
default:
return -1;
}
return 0;
}
int main(int argc, char **argv) {
chest_t eq;
cf_t *input = NULL, *ce = NULL, *h = NULL;
refsignal_t refs;
int i, j, n_port, n_slot, cid, num_re;
int ret = -1;
int max_cid;
FILE *fmatlab = NULL;
float mse_mag, mse_phase;
parse_args(argc,argv);
if (output_matlab) {
fmatlab=fopen(output_matlab, "w");
if (!fmatlab) {
perror("fopen");
goto do_exit;
}
}
num_re = nof_prb * RE_X_RB * CP_NSYMB(cp);
input = malloc(num_re * sizeof(cf_t));
if (!input) {
perror("malloc");
goto do_exit;
}
h = malloc(num_re * sizeof(cf_t));
if (!h) {
perror("malloc");
goto do_exit;
}
ce = malloc(num_re * sizeof(cf_t));
if (!ce) {
perror("malloc");
goto do_exit;
}
if (cell_id == -1) {
cid = 0;
max_cid = 149;
} else {
cid = cell_id;
max_cid = cell_id;
}
while(cid <= max_cid) {
if (chest_init(&eq, LINEAR, cp, nof_prb, MAX_PORTS)) {
fprintf(stderr, "Error initializing equalizer\n");
goto do_exit;
}
if (chest_ref_LTEDL(&eq, cid)) {
fprintf(stderr, "Error initializing reference signal\n");
goto do_exit;
}
for (n_slot=0;n_slot<NSLOTS_X_FRAME;n_slot++) {
for (n_port=0;n_port<MAX_PORTS;n_port++) {
if (refsignal_init_LTEDL(&refs, n_port, n_slot, cid, cp, nof_prb)) {
fprintf(stderr, "Error initiating CRS slot=%d\n", i);
return -1;
}
bzero(input, sizeof(cf_t) * num_re);
for (i=0;i<num_re;i++) {
input[i] = 0.5-rand()/RAND_MAX+I*(0.5-rand()/RAND_MAX);
}
bzero(ce, sizeof(cf_t) * num_re);
bzero(h, sizeof(cf_t) * num_re);
refsignal_put(&refs, input);
refsignal_free(&refs);
for (i=0;i<CP_NSYMB(cp);i++) {
for (j=0;j<nof_prb * RE_X_RB;j++) {
float x = -1+(float) i/CP_NSYMB(cp) + cosf(2 * M_PI * (float) j/nof_prb/RE_X_RB);
h[i*nof_prb * RE_X_RB+j] = (3+x) * cexpf(I * x);
input[i*nof_prb * RE_X_RB+j] *= h[i*nof_prb * RE_X_RB+j];
}
}
chest_ce_slot_port(&eq, input, ce, n_slot, n_port);
mse_mag = mse_phase = 0;
for (i=0;i<num_re;i++) {
mse_mag += (cabsf(h[i]) - cabsf(ce[i])) * (cabsf(h[i]) - cabsf(ce[i])) / num_re;
mse_phase += (cargf(h[i]) - cargf(ce[i])) * (cargf(h[i]) - cargf(ce[i])) / num_re;
}
if (check_mse(mse_mag, mse_phase, n_port)) {
goto do_exit;
}
if (fmatlab) {
fprintf(fmatlab, "input=");
vec_fprint_c(fmatlab, input, num_re);
fprintf(fmatlab, ";\n");
fprintf(fmatlab, "h=");
vec_fprint_c(fmatlab, h, num_re);
fprintf(fmatlab, ";\n");
fprintf(fmatlab, "ce=");
vec_fprint_c(fmatlab, ce, num_re);
fprintf(fmatlab, ";\n");
chest_fprint(&eq, fmatlab, n_slot, n_port);
}
}
}
chest_free(&eq);
cid++;
INFO("cid=%d\n", cid);
}
ret = 0;
do_exit:
if (ce) {
free(ce);
}
if (input) {
free(input);
}
if (h) {
free(h);
}
if (!ret) {
printf("OK\n");
} else {
printf("Error at cid=%d, slot=%d, port=%d\n",cid, n_slot, n_port);
}
exit(ret);
}

@ -0,0 +1,51 @@
#
# Copyright 2012-2013 The libLTE Developers. See the
# COPYRIGHT file at the top-level directory of this distribution.
#
# This file is part of the libLTE library.
#
# libLTE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# libLTE 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 Lesser General Public License for more details.
#
# A copy of the GNU Lesser General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
########################################################################
# Viterbi TEST
########################################################################
ADD_EXECUTABLE(viterbi_test viterbi_test.c)
TARGET_LINK_LIBRARIES(viterbi_test lte)
ADD_TEST(viterbi_40_0 viterbi_test -n 1000 -s 1 -l 40 -k 7 -t -e 0.0)
ADD_TEST(viterbi_40_2 viterbi_test -n 1000 -s 1 -l 40 -k 7 -t -e 2.0)
ADD_TEST(viterbi_40_3 viterbi_test -n 1000 -s 1 -l 40 -k 7 -t -e 3.0)
ADD_TEST(viterbi_40_4 viterbi_test -n 1000 -s 1 -l 40 -k 7 -t -e 4.5)
ADD_TEST(viterbi_1000_0 viterbi_test -n 100 -s 1 -l 1000 -k 7 -t -e 0.0)
ADD_TEST(viterbi_1000_2 viterbi_test -n 100 -s 1 -l 1000 -k 7 -t -e 2.0)
ADD_TEST(viterbi_1000_3 viterbi_test -n 100 -s 1 -l 1000 -k 7 -t -e 3.0)
ADD_TEST(viterbi_1000_4 viterbi_test -n 100 -s 1 -l 1000 -k 7 -t -e 4.5)
########################################################################
# CRC TEST
########################################################################
ADD_EXECUTABLE(crc_test crc_test.c)
TARGET_LINK_LIBRARIES(crc_test lte)
ADD_TEST(crc_24A crc_test -n 5000 -l 24 -p 0x1864CFB -s 1)
ADD_TEST(crc_24B crc_test -n 5000 -l 24 -p 0x1800063 -s 1)
ADD_TEST(crc_16 crc_test -n 5000 -l 16 -p 0x11021 -s 1)
ADD_TEST(crc_8 crc_test -n 5000 -l 8 -p 0x19B -s 1)

@ -0,0 +1,119 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The libLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the libLTE library.
*
* libLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libLTE 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 Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
#include "lte.h"
#include "crc_test.h"
int num_bits = 1000, crc_length = 16;
unsigned int crc_poly = 0x11021;
unsigned int seed = 0;
void usage(char *prog) {
printf("Usage: %s [nlps]\n", prog);
printf("\t-n num_bits [Default %d]\n", num_bits);
printf("\t-l crc_length [Default %d]\n", crc_length);
printf("\t-p crc_poly (Hex) [Default 0x%x]\n", crc_poly);
printf("\t-s seed [Default 0=time]\n");
}
void parse_args(int argc, char **argv) {
int opt;
while ((opt = getopt(argc, argv, "nlps")) != -1) {
switch (opt) {
case 'n':
num_bits = atoi(argv[optind]);
break;
case 'l':
crc_length = atoi(argv[optind]);
break;
case 'p':
crc_poly = (unsigned int) strtoul(argv[optind], NULL, 16);
break;
case 's':
seed = (unsigned int) strtoul(argv[optind], NULL, 0);
break;
default:
usage(argv[0]);
exit(-1);
}
}
}
int main(int argc, char **argv) {
int i;
char *data;
unsigned int crc_word, expected_word;
parse_args(argc, argv);
data = malloc(sizeof(char) * (num_bits+crc_length));
if (!data) {
perror("malloc");
exit(-1);
}
if (!seed) {
seed = time(NULL);
}
srand(seed);
// Generate data
for (i=0;i<num_bits;i++) {
data[i] = rand()%2;
}
// generate CRC word
crc_word = crc(0, data, num_bits, crc_length, crc_poly, 1);
// check if result is zero
if (crc(0, data, num_bits + crc_length, crc_length, crc_poly, 0)) {
printf("CRC check is non-zero\n");
exit(-1);
}
free(data);
printf("CRC word: 0x%x\n", crc_word);
// check if generated word is as expected
if (get_expected_word(num_bits, crc_length, crc_poly, seed, &expected_word)) {
fprintf(stderr, "Test parameters not defined in test_results.h\n");
exit(-1);
}
exit(expected_word != crc_word);
}

@ -0,0 +1,68 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The libLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the libLTE library.
*
* libLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libLTE 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 Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include <stdbool.h>
typedef struct {
int n;
int l;
unsigned int p;
unsigned int s;
unsigned int word;
}expected_word_t;
static expected_word_t expected_words[] = {
{5000, 24, 0x1864CFB, 1, 0x4D0836}, // LTE CRC24A (36.212 Sec 5.1.1)
{5000, 24, 0X1800063, 1, 0x9B68F8}, // LTE CRC24B
{5000, 16, 0x11021, 1, 0xBFFA}, // LTE CRC16
{5000, 8, 0x19B, 1, 0xF8}, // LTE CRC8
{-1, -1, 0, 0, 0}
};
int get_expected_word(int n, int l, unsigned int p, unsigned int s, unsigned int *word) {
int i;
i=0;
while(expected_words[i].n != -1) {
if (expected_words[i].l == l
&& expected_words[i].p == p
&& expected_words[i].s == s) {
break;
} else {
i++;
}
}
if (expected_words[i].n == -1) {
return -1;
} else {
if (word) {
*word = expected_words[i].word;
}
return 0;
}
}

@ -35,9 +35,11 @@
#include "lte.h" #include "lte.h"
#include "viterbi_test.h"
typedef _Complex float cf_t; typedef _Complex float cf_t;
int frame_length = 1000, nof_frames = 128; int frame_length = 1000, nof_slots = 128;
float ebno_db = 100.0; float ebno_db = 100.0;
unsigned int seed = 0; unsigned int seed = 0;
bool tail_biting = false; bool tail_biting = false;
@ -52,7 +54,7 @@ int K = -1;
void usage(char *prog) { void usage(char *prog) {
printf("Usage: %s [nlestk]\n", prog); printf("Usage: %s [nlestk]\n", prog);
printf("\t-n nof_frames [Default %d]\n", nof_frames); printf("\t-n nof_frames [Default %d]\n", nof_slots);
printf("\t-l frame_length [Default %d]\n", frame_length); printf("\t-l frame_length [Default %d]\n", frame_length);
printf("\t-e ebno in dB [Default scan]\n"); printf("\t-e ebno in dB [Default scan]\n");
printf("\t-s seed [Default 0=time]\n"); printf("\t-s seed [Default 0=time]\n");
@ -65,7 +67,7 @@ void parse_args(int argc, char **argv) {
while ((opt = getopt(argc, argv, "nlstek")) != -1) { while ((opt = getopt(argc, argv, "nlstek")) != -1) {
switch (opt) { switch (opt) {
case 'n': case 'n':
nof_frames = atoi(argv[optind]); nof_slots = atoi(argv[optind]);
break; break;
case 'l': case 'l':
frame_length = atoi(argv[optind]); frame_length = atoi(argv[optind]);
@ -74,7 +76,7 @@ void parse_args(int argc, char **argv) {
ebno_db = atof(argv[optind]); ebno_db = atof(argv[optind]);
break; break;
case 's': case 's':
seed = atoi(argv[optind]); seed = (unsigned int) strtoul(argv[optind], NULL, 0);
break; break;
case 't': case 't':
tail_biting = true; tail_biting = true;
@ -89,6 +91,34 @@ void parse_args(int argc, char **argv) {
} }
} }
void output_matlab(float ber[NTYPES][SNR_POINTS], int snr_points,
convcoder_t cod[NCODS], int ncods) {
int i, j, n;
FILE *f = fopen("viterbi_snr.m", "w");
if (!f) {
perror("fopen");
exit(-1);
}
fprintf(f, "ber=[");
for (j = 0; j < NTYPES; j++) {
for (i = 0; i < snr_points; i++) {
fprintf(f, "%g ", ber[j][i]);
}
fprintf(f, "; ");
}
fprintf(f, "];\n");
fprintf(f, "snr=linspace(%g,%g-%g/%d,%d);\n", SNR_MIN, SNR_MAX, SNR_MAX,
snr_points, snr_points);
fprintf(f, "semilogy(snr,ber,snr,0.5*erfc(sqrt(10.^(snr/10))));\n");
fprintf(f, "legend('uncoded',");
for (n=0;n<ncods;n++) {
fprintf(f,"'1/3 K=%d%s',",cod[n].K,cod[n].tail_biting?" tb":"");
}
fprintf(f,"'theory-uncoded');");
fprintf(f, "grid on;\n");
fclose(f);
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
int frame_cnt; int frame_cnt;
float *llr; float *llr;
@ -225,7 +255,7 @@ int main(int argc, char **argv) {
for (j = 0; j < NTYPES; j++) { for (j = 0; j < NTYPES; j++) {
errors[j] = 0; errors[j] = 0;
} }
while (frame_cnt < nof_frames) { while (frame_cnt < nof_slots) {
/* generate data_tx */ /* generate data_tx */
for (j = 0; j < frame_length; j++) { for (j = 0; j < frame_length; j++) {
@ -257,19 +287,19 @@ int main(int argc, char **argv) {
} }
/* check errors */ /* check errors */
for (j = 0; j < NTYPES; j++) { for (j = 0; j < 1+ncods; j++) {
errors[j] += bit_diff(data_tx, data_rx[j], frame_length); errors[j] += bit_diff(data_tx, data_rx[j], frame_length);
} }
frame_cnt++; frame_cnt++;
printf("Eb/No: %3.2f %10d/%d ", printf("Eb/No: %3.2f %10d/%d ",
SNR_MIN + i * ebno_inc,frame_cnt,nof_frames); SNR_MIN + i * ebno_inc,frame_cnt,nof_slots);
for (n=0;n<NTYPES;n++) { for (n=0;n<1+ncods;n++) {
printf("BER: %.2e ",(float) errors[n] / (frame_cnt * frame_length)); printf("BER: %.2e ",(float) errors[n] / (frame_cnt * frame_length));
} }
printf("\r"); printf("\r");
} }
printf("\n"); printf("\n");
for (j = 0; j < NTYPES; j++) { for (j = 0; j < 1+ncods; j++) {
ber[j][i] = (float) errors[j] / (frame_cnt * frame_length); ber[j][i] = (float) errors[j] / (frame_cnt * frame_length);
} }
@ -282,33 +312,6 @@ int main(int argc, char **argv) {
} }
} }
} }
if (snr_points > 1) {
printf("\n");
FILE *f = fopen("output.m", "w");
if (!f) {
perror("fopen");
exit(-1);
}
fprintf(f, "ber=[");
for (j = 0; j < NTYPES; j++) {
for (i = 0; i < snr_points; i++) {
fprintf(f, "%g ", ber[j][i]);
}
fprintf(f, "; ");
}
fprintf(f, "];\n");
fprintf(f, "snr=linspace(%g,%g-%g/%d,%d);\n", SNR_MIN, SNR_MAX, SNR_MAX,
snr_points, snr_points);
fprintf(f, "semilogy(snr,ber,snr,0.5*erfc(sqrt(10.^(snr/10))));\n");
fprintf(f, "legend('uncoded',");
for (n=0;n<ncods;n++) {
fprintf(f,"'1/3 K=%d%s',",cod[n].K,cod[n].tail_biting?" tb":"");
}
fprintf(f,"'theory-uncoded');");
fprintf(f, "grid on;\n");
fclose(f);
}
for (n=0;n<ncods;n++) { for (n=0;n<ncods;n++) {
viterbi_free(&dec[n]); viterbi_free(&dec[n]);
} }
@ -316,10 +319,25 @@ int main(int argc, char **argv) {
free(data_tx); free(data_tx);
free(symbols); free(symbols);
free(llr); free(llr);
free(llr_c);
for (i = 0; i < NTYPES; i++) { for (i = 0; i < NTYPES; i++) {
free(data_rx[i]); free(data_rx[i]);
} }
if (snr_points == 1) {
int expected_errors = get_expected_errors(nof_slots,
seed, frame_length, K, tail_biting, ebno_db);
if (expected_errors == -1) {
fprintf(stderr, "Test parameters not defined in test_results.h\n");
exit(-1);
} else {
printf("errors =%d, expected =%d\n", errors[1], expected_errors);
exit(errors[1] > expected_errors);
}
} else {
printf("\n");
output_matlab(ber, snr_points, cod, ncods);
printf("Done\n"); printf("Done\n");
exit(0); exit(0);
}
} }

@ -0,0 +1,71 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The libLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the libLTE library.
*
* libLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libLTE 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 Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include <stdbool.h>
typedef struct {
int n;
unsigned int s;
int len;
int k;
bool tail;
float ebno;
int errors;
}expected_errors_t;
static expected_errors_t expected_errors[] = {
{1000, 1, 40, 7, true, 0.0, 5363},
{1000, 1, 40, 7, true, 2.0, 356},
{1000, 1, 40, 7, true, 3.0, 48},
{1000, 1, 40, 7, true, 4.5, 0},
{100, 1, 1000, 7, true, 0.0, 8753},
{100, 1, 1000, 7, true, 2.0, 350},
{100, 1, 1000, 7, true, 3.0, 33},
{100, 1, 1000, 7, true, 4.5, 0},
{-1, -1, -1, -1, true, -1.0, -1}
};
int get_expected_errors(int n, unsigned int s, int len, int k, bool tail, float ebno) {
int i;
i=0;
while(expected_errors[i].n != -1) {
if (expected_errors[i].n == n
&& expected_errors[i].s == s
&& expected_errors[i].len == len
&& expected_errors[i].k == k
&& expected_errors[i].tail == tail
&& expected_errors[i].ebno == ebno) {
break;
} else {
i++;
}
}
return expected_errors[i].errors;
}
Loading…
Cancel
Save