aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-01-13 14:43:40 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2014-01-16 12:04:30 +0100
commit9444d4f8e264d425867d6430883afa754fe7bedc (patch)
tree03cddc105cd64b513b3b6195efa578ef130fefca
parent4b903b4afb5d593603b0d75a7d244f6c00e039ad (diff)
si/test: Merge si tests into gsm48 tests
Currently tests covering features of the GSM 04.08 specification are spread over the si and gsm0408 subdirs in tests. This commit merges all tests from 'si' into 'gsm0408' and removes the 'si' test sub-directory. Sponsored-by: On-Waves ehf
-rw-r--r--openbsc/configure.ac1
-rw-r--r--openbsc/tests/Makefile.am2
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.c146
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.ok20
-rw-r--r--openbsc/tests/si/Makefile.am12
-rw-r--r--openbsc/tests/si/si_test.c156
-rw-r--r--openbsc/tests/si/si_test.ok20
-rw-r--r--openbsc/tests/testsuite.at6
8 files changed, 167 insertions, 196 deletions
diff --git a/openbsc/configure.ac b/openbsc/configure.ac
index fe9956976..5d29af717 100644
--- a/openbsc/configure.ac
+++ b/openbsc/configure.ac
@@ -166,7 +166,6 @@ AC_OUTPUT(
tests/mgcp/Makefile
tests/gprs/Makefile
tests/gbproxy/Makefile
- tests/si/Makefile
tests/abis/Makefile
tests/smpp/Makefile
tests/trau/Makefile
diff --git a/openbsc/tests/Makefile.am b/openbsc/tests/Makefile.am
index d4bb954a6..31b2bb4c7 100644
--- a/openbsc/tests/Makefile.am
+++ b/openbsc/tests/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = gsm0408 db channel mgcp gprs si abis gbproxy trau
+SUBDIRS = gsm0408 db channel mgcp gprs abis gbproxy trau
if BUILD_NAT
SUBDIRS += bsc-nat bsc-nat-trie
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index 721b283bb..3a6bbddff 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -42,6 +42,16 @@
exit(-1); \
}
+#define DBG(...)
+
+#define VERIFY(res, cmp, wanted) \
+ if (!(res cmp wanted)) { \
+ printf("ASSERT failed: %s:%d Wanted: %d %s %d\n", \
+ __FILE__, __LINE__, res, # cmp, wanted); \
+ }
+
+
+
/*
* Test Location Area Identifier formatting. Table 10.5.3 of 04.08
*/
@@ -306,6 +316,138 @@ static void test_range_encoding()
test_random_range_encoding(ARFCN_RANGE_1024, 16);
}
+static int freqs1[] = {
+ 12, 70, 121, 190, 250, 320, 401, 475, 520, 574, 634, 700, 764, 830, 905, 980
+};
+
+static int freqs2[] = {
+ 402, 460, 1, 67, 131, 197, 272, 347,
+};
+
+static int freqs3[] = {
+ 68, 128, 198, 279, 353, 398, 452,
+
+};
+
+static int w_out[] = {
+ 122, 2, 69, 204, 75, 66, 60, 70, 83, 3, 24, 67, 54, 64, 70, 9,
+};
+
+static int range128[] = {
+ 1, 1 + 127,
+};
+
+static int range256[] = {
+ 1, 1 + 128,
+};
+
+static int range512[] = {
+ 1, 1+ 511,
+};
+
+
+static void test_arfcn_filter()
+{
+ int arfcns[50], i, res, f0_included;
+ for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
+ arfcns[i] = (i + 1) * 2;
+
+ /* check that the arfcn is taken out. f0_included is only set for Range1024 */
+ f0_included = 24;
+ res = range_enc_filter_arfcns(ARFCN_RANGE_512, arfcns, ARRAY_SIZE(arfcns),
+ arfcns[0], &f0_included);
+ VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
+ VERIFY(f0_included, ==, 0);
+ for (i = 0; i < res; ++i)
+ VERIFY(arfcns[i], ==, ((i+2) * 2) - (2+1));
+
+ /* check with range1024 */
+ for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
+ arfcns[i] = (i + 1) * 2;
+ res = range_enc_filter_arfcns(ARFCN_RANGE_1024, arfcns, ARRAY_SIZE(arfcns),
+ arfcns[0], &f0_included);
+ VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
+ VERIFY(f0_included, ==, 1);
+ for (i = 0; i < res; ++i)
+ VERIFY(arfcns[i], ==, ((i + 2) * 2) - 1);
+
+ /* check with range1024, not included */
+ for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
+ arfcns[i] = (i + 1) * 2;
+ res = range_enc_filter_arfcns(ARFCN_RANGE_1024, arfcns, ARRAY_SIZE(arfcns),
+ 11, &f0_included);
+ VERIFY(res, ==, ARRAY_SIZE(arfcns));
+ VERIFY(f0_included, ==, 0);
+ for (i = 0; i < res; ++i)
+ VERIFY(arfcns[i], ==, ((i + 1) * 2) - 1);
+}
+
+static void test_print_encoding()
+{
+ int rc;
+ int w[17];
+ uint8_t chan_list[16];
+ memset(chan_list, 0x23, sizeof(chan_list));
+
+ for (rc = 0; rc < ARRAY_SIZE(w); ++rc)
+ switch (rc % 3) {
+ case 0:
+ w[rc] = 0xAAAA;
+ break;
+ case 1:
+ w[rc] = 0x5555;
+ break;
+ case 2:
+ w[rc] = 0x9696;
+ break;
+ }
+
+ rc = range_enc_range512(chan_list, (1 << 9) | 0x96, w);
+ VERIFY(rc, ==, 0);
+
+ printf("Range512: %s\n", osmo_hexdump(chan_list, ARRAY_SIZE(chan_list)));
+}
+
+static void test_si_range_helpers()
+{
+ int ws[(sizeof(freqs1)/sizeof(freqs1[0]))];
+ int i, f0 = 0xFFFFFF;
+
+ memset(&ws[0], 0x23, sizeof(ws));
+
+ i = range_enc_find_index(1023, freqs1, ARRAY_SIZE(freqs1));
+ printf("Element is: %d => freqs[i] = %d\n", i, freqs1[i]);
+ VERIFY(i, ==, 2);
+
+ i = range_enc_find_index(511, freqs2, ARRAY_SIZE(freqs2));
+ printf("Element is: %d => freqs[i] = %d\n", i, freqs2[i]);
+ VERIFY(i, ==, 2);
+
+ i = range_enc_find_index(511, freqs3, ARRAY_SIZE(freqs3));
+ printf("Element is: %d => freqs[i] = %d\n", i, freqs3[i]);
+ VERIFY(i, ==, 0);
+
+ i = range_enc_arfcns(1023, freqs1, ARRAY_SIZE(freqs1), ws, 0);
+ VERIFY(i, ==, 0);
+
+ for (i = 0; i < sizeof(freqs1)/sizeof(freqs1[0]); ++i) {
+ printf("w[%d]=%d\n", i, ws[i]);
+ VERIFY(ws[i], ==, w_out[i]);
+ }
+
+ i = range_enc_determine_range(range128, ARRAY_SIZE(range128), &f0);
+ VERIFY(i, ==, ARFCN_RANGE_128);
+ VERIFY(f0, ==, 1);
+
+ i = range_enc_determine_range(range256, ARRAY_SIZE(range256), &f0);
+ VERIFY(i, ==, ARFCN_RANGE_256);
+ VERIFY(f0, ==, 1);
+
+ i = range_enc_determine_range(range512, ARRAY_SIZE(range512), &f0);
+ VERIFY(i, ==, ARFCN_RANGE_512);
+ VERIFY(f0, ==, 1);
+}
+
int main(int argc, char **argv)
{
osmo_init_logging(&log_info);
@@ -313,6 +455,10 @@ int main(int argc, char **argv)
test_location_area_identifier();
test_mi_functionality();
+
+ test_si_range_helpers();
+ test_arfcn_filter();
+ test_print_encoding();
test_range_encoding();
printf("Done.\n");
diff --git a/openbsc/tests/gsm0408/gsm0408_test.ok b/openbsc/tests/gsm0408/gsm0408_test.ok
index a92b8792b..545866962 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.ok
+++ b/openbsc/tests/gsm0408/gsm0408_test.ok
@@ -2,6 +2,26 @@ Testing test location area identifier
Testing parsing and generating TMSI/IMSI
hex: 17 08 99 78 56 34 12 90 78 36
hex: 17 09 91 78 56 34 12 90 78 56 f4
+Element is: 2 => freqs[i] = 121
+Element is: 2 => freqs[i] = 1
+Element is: 0 => freqs[i] = 68
+w[0]=122
+w[1]=2
+w[2]=69
+w[3]=204
+w[4]=75
+w[5]=66
+w[6]=60
+w[7]=70
+w[8]=83
+w[9]=3
+w[10]=24
+w[11]=67
+w[12]=54
+w[13]=64
+w[14]=70
+w[15]=9
+Range512: 89 4b 2a 95 65 95 55 2c a9 55 aa 55 6a 95 59 55
Range test 0: range 511, num ARFCNs 12
chan_list = 88 00 98 34 85 36 7c 50 22 dc 5e ec 00 00 00 00
Decoded freqs 12 (expected 12)
diff --git a/openbsc/tests/si/Makefile.am b/openbsc/tests/si/Makefile.am
deleted file mode 100644
index 795bd3081..000000000
--- a/openbsc/tests/si/Makefile.am
+++ /dev/null
@@ -1,12 +0,0 @@
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
-AM_CFLAGS=-Wall -ggdb3 $(LIBOSMOCORE_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(COVERAGE_CFLAGS)
-
-EXTRA_DIST = si_test.ok
-
-noinst_PROGRAMS = si_test
-
-si_test_SOURCES = si_test.c
-
-si_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
- $(top_builddir)/src/libcommon/libcommon.a \
- $(LIBOSMOCORE_LIBS) -lrt $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS)
diff --git a/openbsc/tests/si/si_test.c b/openbsc/tests/si/si_test.c
deleted file mode 100644
index fd840f301..000000000
--- a/openbsc/tests/si/si_test.c
+++ /dev/null
@@ -1,156 +0,0 @@
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <openbsc/arfcn_range_encode.h>
-
-#include <osmocom/core/utils.h>
-
-#define DBG(...)
-
-#define VERIFY(res, cmp, wanted) \
- if (!(res cmp wanted)) { \
- printf("ASSERT failed: %s:%d Wanted: %d %s %d\n", \
- __FILE__, __LINE__, res, # cmp, wanted); \
- }
-
-
-static int freqs1[] = {
- 12, 70, 121, 190, 250, 320, 401, 475, 520, 574, 634, 700, 764, 830, 905, 980
-};
-
-static int freqs2[] = {
- 402, 460, 1, 67, 131, 197, 272, 347,
-};
-
-static int freqs3[] = {
- 68, 128, 198, 279, 353, 398, 452,
-
-};
-
-static int w_out[] = {
- 122, 2, 69, 204, 75, 66, 60, 70, 83, 3, 24, 67, 54, 64, 70, 9,
-};
-
-static int range128[] = {
- 1, 1 + 127,
-};
-
-static int range256[] = {
- 1, 1 + 128,
-};
-
-static int range512[] = {
- 1, 1+ 511,
-};
-
-
-static void test_arfcn_filter()
-{
- int arfcns[50], i, res, f0_included;
- for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
- arfcns[i] = (i + 1) * 2;
-
- /* check that the arfcn is taken out. f0_included is only set for Range1024 */
- f0_included = 24;
- res = range_enc_filter_arfcns(ARFCN_RANGE_512, arfcns, ARRAY_SIZE(arfcns),
- arfcns[0], &f0_included);
- VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
- VERIFY(f0_included, ==, 0);
- for (i = 0; i < res; ++i)
- VERIFY(arfcns[i], ==, ((i+2) * 2) - (2+1));
-
- /* check with range1024 */
- for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
- arfcns[i] = (i + 1) * 2;
- res = range_enc_filter_arfcns(ARFCN_RANGE_1024, arfcns, ARRAY_SIZE(arfcns),
- arfcns[0], &f0_included);
- VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
- VERIFY(f0_included, ==, 1);
- for (i = 0; i < res; ++i)
- VERIFY(arfcns[i], ==, ((i + 2) * 2) - 1);
-
- /* check with range1024, not included */
- for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
- arfcns[i] = (i + 1) * 2;
- res = range_enc_filter_arfcns(ARFCN_RANGE_1024, arfcns, ARRAY_SIZE(arfcns),
- 11, &f0_included);
- VERIFY(res, ==, ARRAY_SIZE(arfcns));
- VERIFY(f0_included, ==, 0);
- for (i = 0; i < res; ++i)
- VERIFY(arfcns[i], ==, ((i + 1) * 2) - 1);
-}
-
-static void test_print_encoding()
-{
- int rc;
- int w[17];
- uint8_t chan_list[16];
- memset(chan_list, 0x23, sizeof(chan_list));
-
- for (rc = 0; rc < ARRAY_SIZE(w); ++rc)
- switch (rc % 3) {
- case 0:
- w[rc] = 0xAAAA;
- break;
- case 1:
- w[rc] = 0x5555;
- break;
- case 2:
- w[rc] = 0x9696;
- break;
- }
-
- rc = range_enc_range512(chan_list, (1 << 9) | 0x96, w);
- VERIFY(rc, ==, 0);
-
- printf("Range512: %s\n", osmo_hexdump(chan_list, ARRAY_SIZE(chan_list)));
-}
-
-int main(int argc, char **argv)
-{
- int ws[(sizeof(freqs1)/sizeof(freqs1[0]))];
- int i, f0 = 0xFFFFFF;
-
- memset(&ws[0], 0x23, sizeof(ws));
-
- i = range_enc_find_index(1023, freqs1, ARRAY_SIZE(freqs1));
- printf("Element is: %d => freqs[i] = %d\n", i, freqs1[i]);
- VERIFY(i, ==, 2);
-
- i = range_enc_find_index(511, freqs2, ARRAY_SIZE(freqs2));
- printf("Element is: %d => freqs[i] = %d\n", i, freqs2[i]);
- VERIFY(i, ==, 2);
-
- i = range_enc_find_index(511, freqs3, ARRAY_SIZE(freqs3));
- printf("Element is: %d => freqs[i] = %d\n", i, freqs3[i]);
- VERIFY(i, ==, 0);
-
- i = range_enc_arfcns(1023, freqs1, ARRAY_SIZE(freqs1), ws, 0);
- VERIFY(i, ==, 0);
-
- for (i = 0; i < sizeof(freqs1)/sizeof(freqs1[0]); ++i) {
- printf("w[%d]=%d\n", i, ws[i]);
- VERIFY(ws[i], ==, w_out[i]);
- }
-
- i = range_enc_determine_range(range128, ARRAY_SIZE(range128), &f0);
- VERIFY(i, ==, ARFCN_RANGE_128);
- VERIFY(f0, ==, 1);
-
- i = range_enc_determine_range(range256, ARRAY_SIZE(range256), &f0);
- VERIFY(i, ==, ARFCN_RANGE_256);
- VERIFY(f0, ==, 1);
-
- i = range_enc_determine_range(range512, ARRAY_SIZE(range512), &f0);
- VERIFY(i, ==, ARFCN_RANGE_512);
- VERIFY(f0, ==, 1);
-
-
- test_arfcn_filter();
- test_print_encoding();
-
- return 0;
-}
diff --git a/openbsc/tests/si/si_test.ok b/openbsc/tests/si/si_test.ok
deleted file mode 100644
index 6a3ee513c..000000000
--- a/openbsc/tests/si/si_test.ok
+++ /dev/null
@@ -1,20 +0,0 @@
-Element is: 2 => freqs[i] = 121
-Element is: 2 => freqs[i] = 1
-Element is: 0 => freqs[i] = 68
-w[0]=122
-w[1]=2
-w[2]=69
-w[3]=204
-w[4]=75
-w[5]=66
-w[6]=60
-w[7]=70
-w[8]=83
-w[9]=3
-w[10]=24
-w[11]=67
-w[12]=54
-w[13]=64
-w[14]=70
-w[15]=9
-Range512: 89 4b 2a 95 65 95 55 2c a9 55 aa 55 6a 95 59 55
diff --git a/openbsc/tests/testsuite.at b/openbsc/tests/testsuite.at
index 652cfe96c..b2c551859 100644
--- a/openbsc/tests/testsuite.at
+++ b/openbsc/tests/testsuite.at
@@ -57,12 +57,6 @@ cat $abs_srcdir/bsc-nat-trie/bsc_nat_trie_test.ok > expout
AT_CHECK([$abs_top_builddir/tests/bsc-nat-trie/bsc_nat_trie_test], [], [expout], [ignore])
AT_CLEANUP
-AT_SETUP([si])
-AT_KEYWORDS([si])
-cat $abs_srcdir/si/si_test.ok > expout
-AT_CHECK([$abs_top_builddir/tests/si/si_test], [], [expout], [ignore])
-AT_CLEANUP
-
AT_SETUP([abis])
AT_KEYWORDS([abis])
cat $abs_srcdir/abis/abis_test.ok > expout