aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-28 16:45:54 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-30 21:24:26 +0200
commit4610f3d17473c4c2191598b3838c3e8f0098918e (patch)
treecf7477d3e64a8f13219d2e3f30eb5bbe1a7cf663 /tests
parentc0a6938d0ede31b7c94e74ad598efb952aa2a613 (diff)
tests: Move the RLCMACTest into the test directory and setup autotestzecke/misc/cleanups
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am50
-rw-r--r--tests/rlcmac/RLCMACTest.cpp218
-rw-r--r--tests/rlcmac/RLCMACTest.err0
-rw-r--r--tests/rlcmac/RLCMACTest.ok58
-rw-r--r--tests/testsuite.at10
5 files changed, 335 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7581ea95..1faa5f42 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 00000000..66bc53c8
--- /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 00000000..e69de29b
--- /dev/null
+++ b/tests/rlcmac/RLCMACTest.err
diff --git a/tests/rlcmac/RLCMACTest.ok b/tests/rlcmac/RLCMACTest.ok
new file mode 100644
index 00000000..a931636c
--- /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 00000000..824c2744
--- /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