mirror of https://github.com/pvnis/srsRAN_4G.git
Using CTest for testing
parent
034b003a85
commit
c4e0e403ce
@ -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)
|
@ -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);
|
|
||||||
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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…
Reference in New Issue