From: Holger Hans Peter Freyther holger@moiji-mobile.com
--- .gitignore | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/.gitignore b/.gitignore index 032b9cf..4f418d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.o *.lo *.a +*.sw? Makefile.in Makefile .deps @@ -22,3 +23,7 @@ core core.*
osmoappdesc.pyc + +# binaries +src/osmo-pcu +src/osmo-pcu-remote
From: Holger Hans Peter Freyther holger@moiji-mobile.com
Fixes: csn1.cpp:124:20: warning: 'CSN_DESCR_type' defined but not used [-Wunused-variable] --- src/csn1.cpp | 38 -------------------------------------- 1 file changed, 38 deletions(-)
diff --git a/src/csn1.cpp b/src/csn1.cpp index 38d8860..de1db73 100644 --- a/src/csn1.cpp +++ b/src/csn1.cpp @@ -118,44 +118,6 @@ ProcessError( unsigned readIndex, const char* sz, gint16 err, const CSN_DESCR* p return err; }
-//#if 0 -static const char* CSN_DESCR_type[]= -{ - "CSN_END", - "CSN_BIT", - "CSN_UINT", - "CSN_TYPE", - "CSN_CHOICE", - "CSN_UNION", - "CSN_UNION_LH", - "CSN_UINT_ARRAY", - "CSN_TYPE_ARRAY", - "CSN_BITMAP", - "CSN_VARIABLE_BITMAP", - "CSN_VARIABLE_BITMAP_1", - "CSN_LEFT_ALIGNED_VAR_BMP", - "CSN_LEFT_ALIGNED_VAR_BMP_1", - "CSN_VARIABLE_ARRAY", - "CSN_VARIABLE_TARRAY", - "CSN_VARIABLE_TARRAY_OFFSET", - "CSN_RECURSIVE_ARRAY", - "CSN_RECURSIVE_TARRAY", - "CSN_RECURSIVE_TARRAY_1", - "CSN_RECURSIVE_TARRAY_2", - "CSN_EXIST", - "CSN_EXIST_LH", - "CSN_NEXT_EXIST", - "CSN_NEXT_EXIST_LH", - "CSN_NULL", - "CSN_FIXED", - "CSN_CALLBACK", - "CSN_UINT_OFFSET", - "CSN_UINT_LH", - "CSN_SERIALIZE", - "CSN_TRAP_ERROR" - "CSN_???" -}; -//#endif
/** * ================================================================================================
From: Holger Hans Peter Freyther holger@moiji-mobile.com
This might clash with C++11 and literal values but we will see that once the compilers enable that by default.
Fixes: csn1.cpp: In function 'gint16 csnStreamDecoder(csnStream_t*, const CSN_DESCR*, bitvec*, unsigned int&, void*)': csn1.cpp:864:17: warning: format '%d' expects argument of type 'int', but argument 8 has type 'guint64 {aka long unsigned int}' [-Wformat] csn1.cpp:1144:15: warning: format '%u' expects argument of type 'unsigned int', but argument 7 has type 'uint64_t {aka long long unsigned int}' [-Wformat] csn1.cpp:1150:15: warning: format '%u' expects argument of type 'unsigned int', but argument 7 has type 'uint64_t {aka long long unsigned int}' [-Wformat] csn1.cpp: In function 'gint16 csnStreamEncoder(csnStream_t*, const CSN_DESCR*, bitvec*, unsigned int&, void*)': csn1.cpp:2119:17: warning: format '%d' expects argument of type 'int', but argument 8 has type 'guint64 {aka long unsigned int}' [-Wformat] --- src/csn1.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/csn1.cpp b/src/csn1.cpp index de1db73..45cc848 100644 --- a/src/csn1.cpp +++ b/src/csn1.cpp @@ -32,6 +32,8 @@ #include <cstdlib> #include <assert.h> #include <string.h> +#define __STDC_FORMAT_MACROS +#include <inttypes.h> #include "csn1.h" #include <gprs_debug.h>
@@ -861,7 +863,7 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig guint64 ui64 = bitvec_read_field(vector, readIndex, no_of_bits); pui64 = pui64DATA(data, pDescr->offset); *pui64 = ui64; - LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui64); + LOGPC(DCSN1, LOGL_NOTICE, "%s = %lu | ", pDescr->sz , *pui64); } else { @@ -1141,13 +1143,13 @@ csnStreamDecoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector, unsig guint8 bits_to_handle = remaining_bits_len%8; if (bits_to_handle > 0) { - LOGPC(DCSN1, LOGL_NOTICE, "%u|", bitvec_read_field(vector, readIndex, bits_to_handle)); + LOGPC(DCSN1, LOGL_NOTICE, "%"PRIu64"|", bitvec_read_field(vector, readIndex, bits_to_handle)); remaining_bits_len -= bits_to_handle; bit_offset += bits_to_handle; } else if (bits_to_handle == 0) { - LOGPC(DCSN1, LOGL_NOTICE, "%u|", bitvec_read_field(vector, readIndex, 8)); + LOGPC(DCSN1, LOGL_NOTICE, "%"PRIu64"|", bitvec_read_field(vector, readIndex, 8)); remaining_bits_len -= 8; bit_offset += 8; } @@ -2116,7 +2118,7 @@ gint16 csnStreamEncoder(csnStream_t* ar, const CSN_DESCR* pDescr, bitvec *vector { pui64 = pui64DATA(data, pDescr->offset); bitvec_write_field(vector, writeIndex, *pui64, no_of_bits); - LOGPC(DCSN1, LOGL_NOTICE, "%s = %d | ", pDescr->sz , *pui64); + LOGPC(DCSN1, LOGL_NOTICE, "%s = %lu | ", pDescr->sz , *pui64); } else {
From: Holger Hans Peter Freyther holger@moiji-mobile.com
femtobts.c:250:2: warning: excess elements in array initializer [enabled by default] { SuperFemto_ClkSrcId_NetList, "nwl" }, ^ femtobts.c:250:2: warning: (near initialization for ‘femtobts_clksrc_names’) [enabled by default] femtobts.c:251:2: warning: excess elements in array initializer [enabled by default] { 0, NULL } ^ femtobts.c:251:2: warning: (near initialization for ‘femtobts_clksrc_names’) [enabled by default] --- src/femtobts.c | 13 ------------- src/femtobts.h | 2 -- 2 files changed, 15 deletions(-)
diff --git a/src/femtobts.c b/src/femtobts.c index 69b33be..f6957d2 100644 --- a/src/femtobts.c +++ b/src/femtobts.c @@ -238,19 +238,6 @@ const struct value_string femtobts_tch_pl_names[] = { { 0, NULL } };
-const struct value_string femtobts_clksrc_names[] = { - { SuperFemto_ClkSrcId_None, "None" }, - { SuperFemto_ClkSrcId_Ocxo, "ocxo" }, - { SuperFemto_ClkSrcId_Tcxo, "tcxo" }, - { SuperFemto_ClkSrcId_External, "ext" }, - { SuperFemto_ClkSrcId_GpsPps, "gps" }, - { SuperFemto_ClkSrcId_Trx, "trx" }, - { SuperFemto_ClkSrcId_Rx, "rx" }, - { SuperFemto_ClkSrcId_Edge, "edge" }, - { SuperFemto_ClkSrcId_NetList, "nwl" }, - { 0, NULL } -}; - const struct value_string femtobts_dir_names[] = { { GsmL1_Dir_TxDownlink, "TxDL" }, { GsmL1_Dir_TxUplink, "TxUL" }, diff --git a/src/femtobts.h b/src/femtobts.h index f2ac59d..7e45578 100644 --- a/src/femtobts.h +++ b/src/femtobts.h @@ -33,8 +33,6 @@ const struct value_string femtobts_tracef_names[29];
const struct value_string femtobts_tch_pl_names[15];
-const struct value_string femtobts_clksrc_names[8]; - const struct value_string femtobts_dir_names[6];
enum pdch_cs {
From: Holger Hans Peter Freyther holger@moiji-mobile.com
pcu_l1_if.cpp:195:13: warning: 'void pcu_l1if_tx_bcch(uint8_t*, int)' defined but not used [-Wunused-function] --- src/pcu_l1_if.cpp | 6 ------ 1 file changed, 6 deletions(-)
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 037cf60..4452f0f 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -191,12 +191,6 @@ void pcu_l1if_tx_pch(bitvec * block, int plen, char *imsi) pcu_tx_data_req(0, 0, PCU_IF_SAPI_PCH, 0, 0, 0, data, 23+3); }
-// FIXME: remove this, when changed from c++ to c. -static void pcu_l1if_tx_bcch(uint8_t *data, int len) -{ - pcu_tx_data_req(0, 0, PCU_IF_SAPI_BCCH, 0, 0, 0, data, len); -} - extern "C" int pcu_rx_data_ind_pdtch(uint8_t trx, uint8_t ts, uint8_t *data, uint8_t len, uint32_t fn, int8_t rssi) {
From: Holger Hans Peter Freyther holger@moiji-mobile.com
Fixes: bitvector.cpp: In function 'int bitvec_pack(bitvec*, uint8_t*)': bitvector.cpp:53:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] bitvector.cpp: In function 'int bitvec_unpack(bitvec*, uint8_t*)': bitvector.cpp:63:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] bitvector.cpp: In function 'uint64_t bitvec_read_field(bitvec*, unsigned int&, unsigned int)': bitvector.cpp:91:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] bitvector.cpp: In function 'int bitvec_write_field(bitvec*, unsigned int&, uint64_t, unsigned int)': bitvector.cpp:108:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] --- src/bitvector.cpp | 13 +++++++------ src/bitvector.h | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/bitvector.cpp b/src/bitvector.cpp index 36ef798..43feebc 100644 --- a/src/bitvector.cpp +++ b/src/bitvector.cpp @@ -47,9 +47,9 @@ void bitvec_free(struct bitvec *bv) talloc_free(bv); }
-int bitvec_pack(struct bitvec *bv, uint8_t *buffer) +unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer) { - int i = 0; + unsigned int i = 0; for (i = 0; i < bv->data_len; i++) { buffer[i] = bv->data[i]; @@ -57,9 +57,9 @@ int bitvec_pack(struct bitvec *bv, uint8_t *buffer) return i; }
-int bitvec_unpack(struct bitvec *bv, uint8_t *buffer) +unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer) { - int i = 0; + unsigned int i = 0; for (i = 0; i < bv->data_len; i++) { bv->data[i] = buffer[i]; @@ -84,7 +84,7 @@ int bitvec_unhex(struct bitvec *bv, const char* src)
uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len) { - int i; + unsigned int i; uint64_t ui = 0; bv->cur_bit = read_index;
@@ -103,7 +103,8 @@ uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len
int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len) { - int i, rc; + unsigned int i; + int rc; bv->cur_bit = write_index; for (i = 0; i < len; i++) { int bit = 0; diff --git a/src/bitvector.h b/src/bitvector.h index 7409d55..36bdbab 100644 --- a/src/bitvector.h +++ b/src/bitvector.h @@ -35,8 +35,8 @@ extern "C" { struct bitvec *bitvec_alloc(unsigned size); void bitvec_free(struct bitvec *bv); int bitvec_unhex(struct bitvec *bv, const char* src); -int bitvec_pack(struct bitvec *bv, uint8_t *buffer); -int bitvec_unpack(struct bitvec *bv, uint8_t *buffer); +unsigned int bitvec_pack(struct bitvec *bv, uint8_t *buffer); +unsigned int bitvec_unpack(struct bitvec *bv, uint8_t *buffer); uint64_t bitvec_read_field(struct bitvec *bv, unsigned& read_index, unsigned len); int bitvec_write_field(struct bitvec *bv, unsigned& write_index, uint64_t val, unsigned len);
From: Holger Hans Peter Freyther holger@moiji-mobile.com
Call things by what they do. This method is creating and then connecting a BSSGP.. --- src/gprs_bssgp_pcu.cpp | 2 +- src/gprs_bssgp_pcu.h | 2 +- src/pcu_l1_if.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp index e994f9f..ae47fb2 100644 --- a/src/gprs_bssgp_pcu.cpp +++ b/src/gprs_bssgp_pcu.cpp @@ -592,7 +592,7 @@ static void bvc_timeout(void *_priv) }
/* create BSSGP/NS layer instances */ -int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, +int gprs_bssgp_create_and_connect(uint16_t local_port, uint32_t sgsn_ip, uint16_t sgsn_port, uint16_t nsei, uint16_t nsvci, uint16_t bvci, uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac, uint16_t cell_id) diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h index dff86a3..b611a19 100644 --- a/src/gprs_bssgp_pcu.h +++ b/src/gprs_bssgp_pcu.h @@ -49,7 +49,7 @@ int gprs_bssgp_pcu_rx_sign(struct msgb *msg, struct tlv_parsed *tp, struct bssgp
int gprs_bssgp_pcu_rcvmsg(struct msgb *msg);
-int gprs_bssgp_create(uint16_t local_port, uint32_t sgsn_ip, uint16_t +int gprs_bssgp_create_and_connect(uint16_t local_port, uint32_t sgsn_ip, uint16_t sgsn_port, uint16_t nsei, uint16_t nsvci, uint16_t bvci, uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac, uint16_t cell_id); diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp index 4452f0f..b7b0269 100644 --- a/src/pcu_l1_if.cpp +++ b/src/pcu_l1_if.cpp @@ -418,7 +418,7 @@ bssgp_failed: ia.s_addr = htonl(info_ind->remote_ip[0]); LOGP(DL1IF, LOGL_DEBUG, " remote_ip=%s\n", inet_ntoa(ia));
- rc = gprs_bssgp_create(info_ind->local_port[0], + rc = gprs_bssgp_create_and_connect(info_ind->local_port[0], info_ind->remote_ip[0], info_ind->remote_port[0], info_ind->nsei, info_ind->nsvci[0], info_ind->bvci, info_ind->mcc, info_ind->mnc, info_ind->lac, info_ind->rac,
From: Holger Hans Peter Freyther holger@moiji-mobile.com
--- Makefile.am | 13 +------------ configure.ac | 1 + tests/Makefile.am | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 tests/Makefile.am
diff --git a/Makefile.am b/Makefile.am index e23a40f..4cbc114 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,16 +1,5 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6
-SUBDIRS = src examples +SUBDIRS = src examples tests EXTRA_DIST = osmoappdesc.py
-if ENABLE_VTY_TESTS -python-tests: $(BUILT_SOURCES) - osmotestvty.py -p $(top_srcdir) -w $(builddir) -v - osmotestconfig.py -p $(top_srcdir) -w $(builddir) -v -else -python-tests: $(BUILT_SOURCES) - @echo "Not running python-based tests (determined at configure-time)" -endif - -check-local: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) python-tests diff --git a/configure.ac b/configure.ac index 6510bf4..58cbc35 100644 --- a/configure.ac +++ b/configure.ac @@ -60,4 +60,5 @@ AM_CONDITIONAL(ENABLE_VTY_TESTS, test "x$enable_vty_tests" = "xyes") AC_OUTPUT( src/Makefile examples/Makefile + tests/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..7581ea9 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,16 @@ + + + +# Python testing +if ENABLE_VTY_TESTS +python-tests: $(BUILT_SOURCES) + osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v + osmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v + +else +python-tests: $(BUILT_SOURCES) + @echo "Not running python-based tests (determined at configure-time)" +endif + +check-local: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) python-tests
Hi Holger,
I don't see real files being moved (osmotestvty.py and osmotestconfig.py). Probably you forgot to stage them?
On Tue, Jul 30, 2013 at 11:26 PM, Holger Hans Peter Freyther hfreyther@sysmocom.de wrote:
From: Holger Hans Peter Freyther holger@moiji-mobile.com
Makefile.am | 13 +------------ configure.ac | 1 + tests/Makefile.am | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 tests/Makefile.am
diff --git a/Makefile.am b/Makefile.am index e23a40f..4cbc114 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,16 +1,5 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6
-SUBDIRS = src examples +SUBDIRS = src examples tests EXTRA_DIST = osmoappdesc.py
-if ENABLE_VTY_TESTS -python-tests: $(BUILT_SOURCES)
osmotestvty.py -p $(top_srcdir) -w $(builddir) -vosmotestconfig.py -p $(top_srcdir) -w $(builddir) -v-else -python-tests: $(BUILT_SOURCES)
@echo "Not running python-based tests (determined at configure-time)"-endif
-check-local: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) python-testsdiff --git a/configure.ac b/configure.ac index 6510bf4..58cbc35 100644 --- a/configure.ac +++ b/configure.ac @@ -60,4 +60,5 @@ AM_CONDITIONAL(ENABLE_VTY_TESTS, test "x$enable_vty_tests" = "xyes") AC_OUTPUT( src/Makefile examples/Makefile
- tests/Makefile Makefile)
diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..7581ea9 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,16 @@
+# Python testing +if ENABLE_VTY_TESTS +python-tests: $(BUILT_SOURCES)
osmotestvty.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -vosmotestconfig.py -p $(abs_top_srcdir) -w $(abs_top_builddir) -v+else +python-tests: $(BUILT_SOURCES)
@echo "Not running python-based tests (determined at configure-time)"+endif
+check-local: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) python-tests-- 1.8.3.2
On Wed, Jul 31, 2013 at 09:48:36AM +0400, Alexander Chemeris wrote:
Hi Holger,
I don't see real files being moved (osmotestvty.py and osmotestconfig.py). Probably you forgot to stage them?
I think I didn't miss a file. The osmotestvty/osmotestconfig are two installed scripts and they read the app config from the abs_topsrcdir. It is mostly there to start using the test/ directory for tests. E.g RLCMACTest is moved there, the emulator PCU will be there and other tests while I move code around.
thanks for taking a look holger
On Wed, Jul 31, 2013 at 10:13 AM, Holger Hans Peter Freyther hfreyther@sysmocom.de wrote:
On Wed, Jul 31, 2013 at 09:48:36AM +0400, Alexander Chemeris wrote:
Hi Holger,
I don't see real files being moved (osmotestvty.py and osmotestconfig.py). Probably you forgot to stage them?
I think I didn't miss a file. The osmotestvty/osmotestconfig are two installed scripts and they read the app config from the abs_topsrcdir. It is mostly there to start using the test/ directory for tests. E.g RLCMACTest is moved there, the emulator PCU will be there and other tests while I move code around.
Ok, sorry for false alert. Looked through this from a tablet and assumed that all files are in-tree.
Hi Holger,
I committed this patchset to master branch.
2013/7/31 Alexander Chemeris alexander.chemeris@gmail.com
On Wed, Jul 31, 2013 at 10:13 AM, Holger Hans Peter Freyther hfreyther@sysmocom.de wrote:
On Wed, Jul 31, 2013 at 09:48:36AM +0400, Alexander Chemeris wrote:
Hi Holger,
I don't see real files being moved (osmotestvty.py and osmotestconfig.py). Probably you forgot to stage them?
I think I didn't miss a file. The osmotestvty/osmotestconfig are two installed scripts and they read the app config from the abs_topsrcdir. It is mostly there to start using the test/ directory for tests. E.g RLCMACTest is moved there, the emulator PCU will be there and other tests while I move code around.
Ok, sorry for false alert. Looked through this from a tablet and assumed that all files are in-tree.
-- Regards, Alexander Chemeris. CEO, Fairwaves LLC / ООО УмРадио http://fairwaves.ru
On Fri, Aug 02, 2013 at 01:56:47PM +0400, Ivan Kluchnikov wrote:
Hi Holger,
I committed this patchset to master branch.
thanks a lot. I will post my PCU emu code. It is a manual test for our SGSN (but can also be a testbed for moving LLC code from OpenBSC to libosmocore, now I copy and pasted some routines/defines). I plan to extend this to also enable PDCHs.. and deal with csn1 packed bits at the end. Do you think it makes sense to keep it in the PCU?
Another thing I will do is to start re-factoring these giant methods into smaller and unit-tested methods. I will also refactor the lookup of a TBF. It should really be based on TLLI and not only on IMSI, but more importantly the decision/logic of finding or creating a new TBF should really really really not be burried inside the Downlink-Data message routine.
holger
From: Holger Hans Peter Freyther holger@moiji-mobile.com
--- .gitignore | 8 ++ configure.ac | 1 + src/Makefile.am | 11 +-- src/RLCMACTest.cpp | 218 -------------------------------------------- tests/Makefile.am | 50 +++++++++- tests/rlcmac/RLCMACTest.cpp | 218 ++++++++++++++++++++++++++++++++++++++++++++ tests/rlcmac/RLCMACTest.err | 0 tests/rlcmac/RLCMACTest.ok | 58 ++++++++++++ tests/testsuite.at | 10 ++ 9 files changed, 346 insertions(+), 228 deletions(-) delete mode 100644 src/RLCMACTest.cpp create mode 100644 tests/rlcmac/RLCMACTest.cpp create mode 100644 tests/rlcmac/RLCMACTest.err create mode 100644 tests/rlcmac/RLCMACTest.ok create mode 100644 tests/testsuite.at
diff --git a/.gitignore b/.gitignore index 4f418d8..fec1b98 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,11 @@ osmoappdesc.pyc # binaries src/osmo-pcu src/osmo-pcu-remote + +# tests +tests/atconfig +tests/package.m4 +tests/rlcmac/.dirstamp +tests/rlcmac/RLCMACTest +tests/testsuite +tests/testsuite.log diff --git a/configure.ac b/configure.ac index 58cbc35..3b2f380 100644 --- a/configure.ac +++ b/configure.ac @@ -4,6 +4,7 @@ AC_INIT([osmo-pcu], [osmocom-pcu@lists.osmocom.org])
AM_INIT_AUTOMAKE([dist-bzip2]) +AC_CONFIG_TESTDIR(tests)
dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) diff --git a/src/Makefile.am b/src/Makefile.am index b20b0a9..38a4b3c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,12 +50,11 @@ libgprs_la_SOURCES += \ openbts_sock.cpp endif
-noinst_PROGRAMS = \ - RLCMACTest - bin_PROGRAMS = \ osmo-pcu
+noinst_PROGRAMS = + if ENABLE_SYSMODSP noinst_PROGRAMS += \ osmo-pcu-remote @@ -75,12 +74,6 @@ noinst_HEADERS = \ sysmo_l1_if.h \ femtobts.h
-RLCMACTest_SOURCES = RLCMACTest.cpp -RLCMACTest_LDADD = \ - libgprs.la \ - $(LIBOSMOCORE_LIBS) \ - $(COMMON_LA) - osmo_pcu_SOURCES = pcu_main.cpp
if ENABLE_SYSMODSP diff --git a/src/RLCMACTest.cpp b/src/RLCMACTest.cpp deleted file mode 100644 index 843dc21..0000000 --- a/src/RLCMACTest.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* RLCMACTest.cpp - * - * Copyright (C) 2011 Ivan Klyuchnikov - * - * This program 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 2 - * of the License, or (at your option) any later version. - * - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - - - -//#include <BitVector.h> -#include <iostream> -#include <cstdlib> -#include <cstring> -#include "csn1.h" -#include "gsm_rlcmac.h" -extern "C" { -extern const struct log_info gprs_log_info; -#include "pcu_vty.h" -#include <osmocom/vty/telnet_interface.h> -#include <osmocom/vty/logging.h> -#include <osmocom/core/application.h> -} -using namespace std; - -void printSizeofRLCMAC() -{ - cout << "sizeof RlcMacUplink_t " << sizeof(RlcMacUplink_t) << endl; - cout << "sizeof Packet_Cell_Change_Failure_t " << sizeof(Packet_Cell_Change_Failure_t) << endl; - cout << "sizeof Packet_Control_Acknowledgement_t " << sizeof(Packet_Control_Acknowledgement_t) << endl; - cout << "sizeof Packet_Downlink_Ack_Nack_t " << sizeof(Packet_Downlink_Ack_Nack_t) << endl; - cout << "sizeof EGPRS_PD_AckNack_t " << sizeof(EGPRS_PD_AckNack_t) << endl; - cout << "sizeof Packet_Uplink_Dummy_Control_Block_t " << sizeof(Packet_Uplink_Dummy_Control_Block_t) << endl; - cout << "sizeof Packet_Measurement_Report_t " << sizeof(Packet_Measurement_Report_t) << endl; - cout << "sizeof Packet_Resource_Request_t " << sizeof(Packet_Resource_Request_t) << endl; - cout << "sizeof Packet_Mobile_TBF_Status_t " << sizeof(Packet_Mobile_TBF_Status_t) << endl; - cout << "sizeof Packet_PSI_Status_t " << sizeof(Packet_PSI_Status_t) << endl; - cout << "sizeof Packet_Enh_Measurement_Report_t " << sizeof(Packet_Enh_Measurement_Report_t) << endl; - cout << "sizeof Packet_Cell_Change_Notification_t " << sizeof(Packet_Cell_Change_Notification_t) << endl; - cout << "sizeof Packet_SI_Status_t " << sizeof(Packet_SI_Status_t) << endl; - cout << "sizeof Additional_MS_Rad_Access_Cap_t " << sizeof(Additional_MS_Rad_Access_Cap_t) << endl; - cout << "sizeof Packet_Pause_t " << sizeof(Packet_Pause_t) << endl; - - cout << "sizeof RlcMacDownlink_t " << sizeof(RlcMacDownlink_t) << endl; - cout << "sizeof Packet_Access_Reject_t " << sizeof(Packet_Access_Reject_t) << endl; - cout << "sizeof Packet_Cell_Change_Order_t " << sizeof(Packet_Cell_Change_Order_t) << endl; - cout << "sizeof Packet_Downlink_Assignment_t " << sizeof(Packet_Downlink_Assignment_t) << endl; - cout << "sizeof Packet_Measurement_Order_Reduced_t " << sizeof(Packet_Measurement_Order_Reduced_t) << endl; - cout << "sizeof Packet_Neighbour_Cell_Data_t " << sizeof(Packet_Neighbour_Cell_Data_t) << endl; - cout << "sizeof Packet_Serving_Cell_Data_t " << sizeof(Packet_Serving_Cell_Data_t) << endl; - cout << "sizeof Packet_Paging_Request_t " << sizeof(Packet_Paging_Request_t) << endl; - cout << "sizeof Packet_PDCH_Release_t " << sizeof(Packet_PDCH_Release_t) << endl; - cout << "sizeof Packet_Polling_Request_t " << sizeof(Packet_Polling_Request_t) << endl; - cout << "sizeof Packet_Power_Control_Timing_Advance_t " << sizeof(Packet_Power_Control_Timing_Advance_t) << endl; - cout << "sizeof Packet_PRACH_Parameters_t " << sizeof(Packet_PRACH_Parameters_t) << endl; - cout << "sizeof Packet_Queueing_Notification_t " << sizeof(Packet_Queueing_Notification_t) << endl; - cout << "sizeof Packet_Timeslot_Reconfigure_t " << sizeof(Packet_Timeslot_Reconfigure_t) << endl; - cout << "sizeof Packet_TBF_Release_t " << sizeof(Packet_TBF_Release_t) << endl; - cout << "sizeof Packet_Uplink_Ack_Nack_t " << sizeof(Packet_Uplink_Ack_Nack_t) << endl; - cout << "sizeof Packet_Uplink_Assignment_t " << sizeof(Packet_Uplink_Assignment_t) << endl; - cout << "sizeof Packet_Cell_Change_Continue_t " << sizeof(Packet_Cell_Change_Continue_t) << endl; - cout << "sizeof Packet_Handover_Command_t " << sizeof(Packet_Handover_Command_t) << endl; - cout << "sizeof Packet_PhysicalInformation_t " << sizeof(Packet_PhysicalInformation_t) << endl; - cout << "sizeof Packet_Downlink_Dummy_Control_Block_t " << sizeof(Packet_Downlink_Dummy_Control_Block_t) << endl; - cout << "sizeof PSI1_t " << sizeof(PSI1_t) << endl; - cout << "sizeof PSI2_t " << sizeof(PSI2_t) << endl; - cout << "sizeof PSI3_t " << sizeof(PSI3_t) << endl; - cout << "sizeof PSI3_BIS_t " << sizeof(PSI3_BIS_t) << endl; - cout << "sizeof PSI4_t " << sizeof(PSI4_t) << endl; - cout << "sizeof PSI13_t " << sizeof(PSI13_t) << endl; - cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl; -} - -void testRlcMacDownlink() -{ - struct bitvec *resultVector = bitvec_alloc(23); - bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); - - std::string testData[] = { - "4e082500e3f1a81d080820800b2b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment - "48282407a6a074227201000b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment - "47240c00400000000000000079eb2ac9402b2b2b2b2b2b", // Packet Uplink Ack Nack - "47283c367513ba333004242b2b2b2b2b2b2b2b2b2b2b2b" // Packet Uplink Assignment - "4913e00850884013a8048b2b2b2b2b2b2b2b2b2b2b2b2b" - "412430007fffffffffffffffefd19c7ba12b2b2b2b2b2b" - "41942b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b" - }; - - int testDataSize = sizeof(testData)/sizeof(testData[0]); - - cout << " DOWNLINK " << endl; - for (int i = 0; i < testDataSize; i++) - { - bitvec *vector = bitvec_alloc(23); - bitvec_unhex(vector, testData[i].c_str()); - cout << "vector1 = "; - for (int i = 0; i < 23; i++) - { - cout << hex << (unsigned)*(vector->data + i); - } - cout << endl; - RlcMacDownlink_t * data = (RlcMacDownlink_t *)malloc(sizeof(RlcMacDownlink_t)); - cout << "=========Start DECODE===========" << endl; - decode_gsm_rlcmac_downlink(vector, data); - cout << "+++++++++Finish DECODE++++++++++" << endl; - cout << "=========Start ENCODE=============" << endl; - encode_gsm_rlcmac_downlink(resultVector, data); - cout << "+++++++++Finish ENCODE+++++++++++" << endl; - cout << "vector1 = "; - for (int i = 0; i < 23; i++) - { - cout << (unsigned)*(vector->data + i); - } - cout << endl; - cout << "vector2 = "; - for (int i = 0; i < 23; i++) - { - cout << (unsigned)*(resultVector->data + i); - } - cout << endl; - if (memcmp(vector->data, resultVector->data, 23) == 0) - { - cout << "vector1 == vector2 : TRUE" << endl; - } - else - { - cout << "vector1 == vector2 : FALSE" << endl; - } - bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); - bitvec_free(vector); - free(data); - } - - bitvec_free(resultVector); -} - - -void testRlcMacUplink() -{ - struct bitvec *resultVector = bitvec_alloc(23); - bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); - - std::string testData[] = { - "400e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Dummy Control Block - "400b8020000000000000002480e00b2b2b2b2b2b2b2b2b", // Packet Downlink Ack/Nack - "4016713dc094270ca2ae57ef909006aa0fc0001f80222b" // Packet Resource Request - "400a9020000000000000003010012a0800132b2b2b2b2b" - }; - - int testDataSize = sizeof(testData)/sizeof(testData[0]); - - - cout << " UPLINK " << endl; - for (int i = 0; i < testDataSize; i++) - { - bitvec *vector = bitvec_alloc(23); - bitvec_unhex(vector, testData[i].c_str()); - cout << "vector1 = "; - for (int i = 0; i < 23; i++) - { - cout << hex << (unsigned)*(vector->data + i); - } - cout << endl; - RlcMacUplink_t * data = (RlcMacUplink_t *)malloc(sizeof(RlcMacUplink_t)); - cout << "=========Start DECODE===========" << endl; - decode_gsm_rlcmac_uplink(vector, data); - cout << "+++++++++Finish DECODE++++++++++" << endl; - cout << "=========Start ENCODE=============" << endl; - encode_gsm_rlcmac_uplink(resultVector, data); - cout << "+++++++++Finish ENCODE+++++++++++" << endl; - cout << "vector1 = "; - for (int i = 0; i < 23; i++) - { - cout << (unsigned)*(vector->data + i); - } - cout << endl; - cout << "vector2 = "; - for (int i = 0; i < 23; i++) - { - cout << (unsigned)*(resultVector->data + i); - } - cout << endl; - if (memcmp(vector->data, resultVector->data, 23) == 0) - { - cout << "vector1 == vector2 : TRUE" << endl; - } - else - { - cout << "vector1 == vector2 : FALSE" << endl; - } - bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); - bitvec_free(vector); - free(data); - } - - bitvec_free(resultVector); -} - -int main(int argc, char *argv[]) -{ - osmo_init_logging(&gprs_log_info); - - //printSizeofRLCMAC(); - testRlcMacDownlink(); - testRlcMacUplink(); - -} diff --git a/tests/Makefile.am b/tests/Makefile.am index 7581ea9..1faa5f4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,38 @@ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGB_CFLAGS) $(LIBOSMOGSM_CFLAGS) -I$(top_srcdir)/src/
+check_PROGRAMS = rlcmac/RLCMACTest
+rlcmac_RLCMACTest_SOURCES = rlcmac/RLCMACTest.cpp +rlcmac_RLCMACTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ + $(LIBOSMOCORE_LIBS) \ + $(COMMON_LA) + +# The `:;' works around a Bash 3.2 bug when the output is not writeable. +$(srcdir)/package.m4: $(top_srcdir)/configure.ac + :;{ \ + echo '# Signature of the current package.' && \ + echo 'm4_define([AT_PACKAGE_NAME],' && \ + echo ' [$(PACKAGE_NAME)])' && \ + echo 'm4_define([AT_PACKAGE_TARNAME],' && \ + echo ' [$(PACKAGE_TARNAME)])' && \ + echo 'm4_define([AT_PACKAGE_VERSION],' && \ + echo ' [$(PACKAGE_VERSION)])' && \ + echo 'm4_define([AT_PACKAGE_STRING],' && \ + echo ' [$(PACKAGE_STRING)])' && \ + echo 'm4_define([AT_PACKAGE_BUGREPORT],' && \ + echo ' [$(PACKAGE_BUGREPORT)])'; \ + echo 'm4_define([AT_PACKAGE_URL],' && \ + echo ' [$(PACKAGE_URL)])'; \ + } >'$(srcdir)/package.m4' + +EXTRA_DIST = \ + testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \ + rlcmac/RLCMACTest.ok rlcmac/RLCMACTest.err + +DISTCLEANFILES = atconfig + +TESTSUITE = $(srcdir)/testsuite
# Python testing if ENABLE_VTY_TESTS @@ -12,5 +45,20 @@ python-tests: $(BUILT_SOURCES) @echo "Not running python-based tests (determined at configure-time)" endif
-check-local: $(BUILT_SOURCES) +check-local: $(BUILT_SOURCES) $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) $(MAKE) $(AM_MAKEFLAGS) python-tests + +installcheck-local: atconfig $(TESTSUITE) + $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \ + $(TESTSUITEFLAGS) + +clean-local: + test ! -f '$(TESTSUITE)' || \ + $(SHELL) '$(TESTSUITE)' --clean + +AUTOM4TE = $(SHELL) $(top_srcdir)/missing --run autom4te +AUTOTEST = $(AUTOM4TE) --language=autotest +$(TESTSUITE): $(srcdir)/testsuite.at $(srcdir)/package.m4 + $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at + mv $@.tmp $@ diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp new file mode 100644 index 0000000..66bc53c --- /dev/null +++ b/tests/rlcmac/RLCMACTest.cpp @@ -0,0 +1,218 @@ +/* RLCMACTest.cpp + * + * Copyright (C) 2011 Ivan Klyuchnikov + * + * This program 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 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + + +//#include <BitVector.h> +#include <iostream> +#include <cstdlib> +#include <cstring> +#include "csn1.h" +#include "gsm_rlcmac.h" +extern "C" { +extern const struct log_info gprs_log_info; +#include "pcu_vty.h" +#include <osmocom/vty/telnet_interface.h> +#include <osmocom/vty/logging.h> +#include <osmocom/core/application.h> +} +using namespace std; + +void printSizeofRLCMAC() +{ + cout << "sizeof RlcMacUplink_t " << sizeof(RlcMacUplink_t) << endl; + cout << "sizeof Packet_Cell_Change_Failure_t " << sizeof(Packet_Cell_Change_Failure_t) << endl; + cout << "sizeof Packet_Control_Acknowledgement_t " << sizeof(Packet_Control_Acknowledgement_t) << endl; + cout << "sizeof Packet_Downlink_Ack_Nack_t " << sizeof(Packet_Downlink_Ack_Nack_t) << endl; + cout << "sizeof EGPRS_PD_AckNack_t " << sizeof(EGPRS_PD_AckNack_t) << endl; + cout << "sizeof Packet_Uplink_Dummy_Control_Block_t " << sizeof(Packet_Uplink_Dummy_Control_Block_t) << endl; + cout << "sizeof Packet_Measurement_Report_t " << sizeof(Packet_Measurement_Report_t) << endl; + cout << "sizeof Packet_Resource_Request_t " << sizeof(Packet_Resource_Request_t) << endl; + cout << "sizeof Packet_Mobile_TBF_Status_t " << sizeof(Packet_Mobile_TBF_Status_t) << endl; + cout << "sizeof Packet_PSI_Status_t " << sizeof(Packet_PSI_Status_t) << endl; + cout << "sizeof Packet_Enh_Measurement_Report_t " << sizeof(Packet_Enh_Measurement_Report_t) << endl; + cout << "sizeof Packet_Cell_Change_Notification_t " << sizeof(Packet_Cell_Change_Notification_t) << endl; + cout << "sizeof Packet_SI_Status_t " << sizeof(Packet_SI_Status_t) << endl; + cout << "sizeof Additional_MS_Rad_Access_Cap_t " << sizeof(Additional_MS_Rad_Access_Cap_t) << endl; + cout << "sizeof Packet_Pause_t " << sizeof(Packet_Pause_t) << endl; + + cout << "sizeof RlcMacDownlink_t " << sizeof(RlcMacDownlink_t) << endl; + cout << "sizeof Packet_Access_Reject_t " << sizeof(Packet_Access_Reject_t) << endl; + cout << "sizeof Packet_Cell_Change_Order_t " << sizeof(Packet_Cell_Change_Order_t) << endl; + cout << "sizeof Packet_Downlink_Assignment_t " << sizeof(Packet_Downlink_Assignment_t) << endl; + cout << "sizeof Packet_Measurement_Order_Reduced_t " << sizeof(Packet_Measurement_Order_Reduced_t) << endl; + cout << "sizeof Packet_Neighbour_Cell_Data_t " << sizeof(Packet_Neighbour_Cell_Data_t) << endl; + cout << "sizeof Packet_Serving_Cell_Data_t " << sizeof(Packet_Serving_Cell_Data_t) << endl; + cout << "sizeof Packet_Paging_Request_t " << sizeof(Packet_Paging_Request_t) << endl; + cout << "sizeof Packet_PDCH_Release_t " << sizeof(Packet_PDCH_Release_t) << endl; + cout << "sizeof Packet_Polling_Request_t " << sizeof(Packet_Polling_Request_t) << endl; + cout << "sizeof Packet_Power_Control_Timing_Advance_t " << sizeof(Packet_Power_Control_Timing_Advance_t) << endl; + cout << "sizeof Packet_PRACH_Parameters_t " << sizeof(Packet_PRACH_Parameters_t) << endl; + cout << "sizeof Packet_Queueing_Notification_t " << sizeof(Packet_Queueing_Notification_t) << endl; + cout << "sizeof Packet_Timeslot_Reconfigure_t " << sizeof(Packet_Timeslot_Reconfigure_t) << endl; + cout << "sizeof Packet_TBF_Release_t " << sizeof(Packet_TBF_Release_t) << endl; + cout << "sizeof Packet_Uplink_Ack_Nack_t " << sizeof(Packet_Uplink_Ack_Nack_t) << endl; + cout << "sizeof Packet_Uplink_Assignment_t " << sizeof(Packet_Uplink_Assignment_t) << endl; + cout << "sizeof Packet_Cell_Change_Continue_t " << sizeof(Packet_Cell_Change_Continue_t) << endl; + cout << "sizeof Packet_Handover_Command_t " << sizeof(Packet_Handover_Command_t) << endl; + cout << "sizeof Packet_PhysicalInformation_t " << sizeof(Packet_PhysicalInformation_t) << endl; + cout << "sizeof Packet_Downlink_Dummy_Control_Block_t " << sizeof(Packet_Downlink_Dummy_Control_Block_t) << endl; + cout << "sizeof PSI1_t " << sizeof(PSI1_t) << endl; + cout << "sizeof PSI2_t " << sizeof(PSI2_t) << endl; + cout << "sizeof PSI3_t " << sizeof(PSI3_t) << endl; + cout << "sizeof PSI3_BIS_t " << sizeof(PSI3_BIS_t) << endl; + cout << "sizeof PSI4_t " << sizeof(PSI4_t) << endl; + cout << "sizeof PSI13_t " << sizeof(PSI13_t) << endl; + cout << "sizeof PSI5_t " << sizeof(PSI5_t) << endl; +} + +void testRlcMacDownlink() +{ + struct bitvec *resultVector = bitvec_alloc(23); + bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + + std::string testData[] = { + "4e082500e3f1a81d080820800b2b2b2b2b2b2b2b2b2b2b", // Packet Downlink Assignment + "48282407a6a074227201000b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Assignment + "47240c00400000000000000079eb2ac9402b2b2b2b2b2b", // Packet Uplink Ack Nack + "47283c367513ba333004242b2b2b2b2b2b2b2b2b2b2b2b" // Packet Uplink Assignment + "4913e00850884013a8048b2b2b2b2b2b2b2b2b2b2b2b2b" + "412430007fffffffffffffffefd19c7ba12b2b2b2b2b2b" + "41942b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b" + }; + + int testDataSize = sizeof(testData)/sizeof(testData[0]); + + cout << " DOWNLINK " << endl; + for (int i = 0; i < testDataSize; i++) + { + bitvec *vector = bitvec_alloc(23); + bitvec_unhex(vector, testData[i].c_str()); + cout << "vector1 = "; + for (int i = 0; i < 23; i++) + { + cout << hex << (unsigned)*(vector->data + i); + } + cout << endl; + RlcMacDownlink_t * data = (RlcMacDownlink_t *)malloc(sizeof(RlcMacDownlink_t)); + cout << "=========Start DECODE===========" << endl; + decode_gsm_rlcmac_downlink(vector, data); + cout << "+++++++++Finish DECODE++++++++++" << endl; + cout << "=========Start ENCODE=============" << endl; + encode_gsm_rlcmac_downlink(resultVector, data); + cout << "+++++++++Finish ENCODE+++++++++++" << endl; + cout << "vector1 = "; + for (int i = 0; i < 23; i++) + { + cout << (unsigned)*(vector->data + i); + } + cout << endl; + cout << "vector2 = "; + for (int i = 0; i < 23; i++) + { + cout << (unsigned)*(resultVector->data + i); + } + cout << endl; + if (memcmp(vector->data, resultVector->data, 23) == 0) + { + cout << "vector1 == vector2 : TRUE" << endl; + } + else + { + cout << "vector1 == vector2 : FALSE" << endl; + } + bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + bitvec_free(vector); + free(data); + } + + bitvec_free(resultVector); +} + + +void testRlcMacUplink() +{ + struct bitvec *resultVector = bitvec_alloc(23); + bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + + std::string testData[] = { + "400e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b", // Packet Uplink Dummy Control Block + "400b8020000000000000002480e00b2b2b2b2b2b2b2b2b", // Packet Downlink Ack/Nack + "4016713dc094270ca2ae57ef909006aa0fc0001f80222b" // Packet Resource Request + "400a9020000000000000003010012a0800132b2b2b2b2b" + }; + + int testDataSize = sizeof(testData)/sizeof(testData[0]); + + + cout << " UPLINK " << endl; + for (int i = 0; i < testDataSize; i++) + { + bitvec *vector = bitvec_alloc(23); + bitvec_unhex(vector, testData[i].c_str()); + cout << "vector1 = "; + for (int i = 0; i < 23; i++) + { + cout << hex << (unsigned)*(vector->data + i); + } + cout << endl; + RlcMacUplink_t * data = (RlcMacUplink_t *)malloc(sizeof(RlcMacUplink_t)); + cout << "=========Start DECODE===========" << endl; + decode_gsm_rlcmac_uplink(vector, data); + cout << "+++++++++Finish DECODE++++++++++" << endl; + cout << "=========Start ENCODE=============" << endl; + encode_gsm_rlcmac_uplink(resultVector, data); + cout << "+++++++++Finish ENCODE+++++++++++" << endl; + cout << "vector1 = "; + for (int i = 0; i < 23; i++) + { + cout << (unsigned)*(vector->data + i); + } + cout << endl; + cout << "vector2 = "; + for (int i = 0; i < 23; i++) + { + cout << (unsigned)*(resultVector->data + i); + } + cout << endl; + if (memcmp(vector->data, resultVector->data, 23) == 0) + { + cout << "vector1 == vector2 : TRUE" << endl; + } + else + { + cout << "vector1 == vector2 : FALSE" << endl; + } + bitvec_unhex(resultVector, "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + bitvec_free(vector); + free(data); + } + + bitvec_free(resultVector); +} + +int main(int argc, char *argv[]) +{ + osmo_init_logging(&gprs_log_info); + + //printSizeofRLCMAC(); + testRlcMacDownlink(); + testRlcMacUplink(); + +} diff --git a/tests/rlcmac/RLCMACTest.err b/tests/rlcmac/RLCMACTest.err new file mode 100644 index 0000000..e69de29 diff --git a/tests/rlcmac/RLCMACTest.ok b/tests/rlcmac/RLCMACTest.ok new file mode 100644 index 0000000..a931636 --- /dev/null +++ b/tests/rlcmac/RLCMACTest.ok @@ -0,0 +1,58 @@ + DOWNLINK +vector1 = 4e8250e3f1a81d882080b2b2b2b2b2b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 4e8250e3f1a81d882080b2b2b2b2b2b2b2b2b2b2b +vector2 = 4e8250e3f1a81d882080b2b2b2b2b2b2b2b2b2b2b +vector1 == vector2 : TRUE +vector1 = 4828247a6a074227210b2b2b2b2b2b2b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 4828247a6a074227210b2b2b2b2b2b2b2b2b2b2b2b +vector2 = 4828247a6a074227210b2b2b2b2b2b2b2b2b2b2b2b +vector1 == vector2 : TRUE +vector1 = 4724c040000000079eb2ac9402b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 4724c040000000079eb2ac9402b2b2b2b2b2b +vector2 = 4724c040000000079eb2ac9402b2b2b2b2b2b +vector1 == vector2 : TRUE +vector1 = 47283c367513ba33304242b2b2b2b2b2b2b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 47283c367513ba33304242b2b2b2b2b2b2b2b2b2b2b2b +vector2 = 47283c367513ba33304242b2b2b2b2b2b2b2b2b2b2b2b +vector1 == vector2 : TRUE + UPLINK +vector1 = 40e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 40e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b +vector2 = 40e1e61d11f2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b +vector1 == vector2 : TRUE +vector1 = 40b802000000002480e0b2b2b2b2b2b2b2b2b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 40b802000000002480e0b2b2b2b2b2b2b2b2b +vector2 = 40b802000000002480e0b2b2b2b2b2b2b2b2b +vector1 == vector2 : TRUE +vector1 = 4016713dc09427ca2ae57ef90906aafc001f80222b +=========Start DECODE=========== ++++++++++Finish DECODE++++++++++ +=========Start ENCODE============= ++++++++++Finish ENCODE+++++++++++ +vector1 = 4016713dc09427ca2ae57ef90906aafc001f80222b +vector2 = 4016713dc09427ca2ae57ef90906aafc001f80222b +vector1 == vector2 : TRUE diff --git a/tests/testsuite.at b/tests/testsuite.at new file mode 100644 index 0000000..824c274 --- /dev/null +++ b/tests/testsuite.at @@ -0,0 +1,10 @@ +AT_INIT +AT_BANNER([Regression tests]) + + +AT_SETUP([rlcmac]) +AT_KEYWORDS([rlcmac]) +cat $abs_srcdir/rlcmac/RLCMACTest.ok > expout +cat $abs_srcdir/rlcmac/RLCMACTest.err > experr +AT_CHECK([$abs_top_builddir/tests/rlcmac/RLCMACTest], [0], [expout], [experr]) +AT_CLEANUP
osmocom-net-gprs@lists.osmocom.org