Commit Graph

67 Commits

Author SHA1 Message Date
Neels Hofmeyr d3b58730d5 add osmo-auc-gen_test
Add test for osmo-auc-gen invocations to ensure stability across upcoming SQN
increment scheme changes.

The test comprises of a shell script that invokes the osmo-auc-gen binary with
various milenage parameters, of which the stdout/stderr are verified.

More osmo-auc-gen invocations could be added, but my main focus is on the SEQ
changes. Instead of manually testing that it still works for each SQN patch, I
want this test to do it for me.

To make sure that osmo-auc-gen is build before the tests are launched, place
'utils' before 'tests' in the root Makefile.am.

Related: OS#1968
Change-Id: Ib4af34201cd2e7d76037bcd31dd89ef18c1a9aec
2017-03-15 12:46:08 +00:00
Vadim Yanitskiy 3262f820b5 libosmocoding: migrate transcoding routines from OsmoBTS
There are some projects, such as GR-GSM and OsmocomBB, which would
benefit from using one shared implementation of GSM 05.03 code. So,
this commit introduces a new sub-library called libosmocoding, which
(for now) provides GSM, GPRS and EDGE transcoding routines, migrated
from OsmoBTS.

The original GSM 05.03 code from OsmoBTS was relicensed under
GPLv2-or-later with permission of copyright holders (Andreas Eversberg,
Alexander Chemeris and Tom Tsou).

The following data types are currently supported:

 - xCCH
 - PDTCH (CS 1-4 and MCS 1-9)
 - TCH/FR
 - TCH/HR
 - TCH/AFS
 - RCH/AHS
 - RACH
 - SCH

Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1
2017-03-07 01:06:38 +07:00
Vadim Yanitskiy 68930e85b5 tests/conv: separate test logic
To be able to add some more tests, related to convolutional coding,
without duplication of code, the test logic was separated from the
conv_test.c into conv.c and conv.h.

Change-Id: Idbdc7e19cb9b9a36cd1fccd621cd858e87530d98
2017-03-06 17:06:45 +00:00
Max 70c7d4160d Use value_string for ctrl_type
Use value_string for enum ctrl_type instead of custom code. Add
corresponding unit tests.

Related: OS#1615
Change-Id: Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28
2017-03-01 16:37:59 +00:00
Neels Hofmeyr bd9de2f66f gsup_test: also check stderr
Configure logging to be deterministic and add stderr checking to testuite.at.

However, exclude the thousands of message modification log lines from the log
to not have a huge test expectation file.

Change-Id: I0dd7112967a64a168556b62e5ec15107b7608ffb
2017-02-22 07:29:46 +00:00
Harald Welte 4ffb43f654 Add minimal testing of socket.c helper functions
Change-Id: I2773b3859a206f96fb8fa095d50a653d9eeb8d79
2017-02-08 18:23:06 +01:00
Neels Hofmeyr d981efa976 oap: add encode/decode unit test
Change-Id: I0e14099e2fc18e333a73d38bda059d53a8ca9944
2016-12-11 03:42:58 +01:00
Holger Hans Peter Freyther c7f52c4c84 wqueue: Reject messges if queue is considered full
The write queue was always meant to not queue more than the
max_length messages but the implementation never rejected a
message.

Begin to log and enforce the queue size limit, add a testcase
to verify the code and initialize except_cb as part of a fix
for that new test case.

Real applications might now run into the queue limit and drop
messages where they just queued them before. It is unfortunate
but I still think it is good to implement the routine as it was
intended. We need to review osmo_wqueue_enqueue once more to
see that no msgb is leaked.

Change-Id: I1e6aef30f3e73d4bcf2967bc49f0783aa65395ae
2016-12-09 11:37:37 +01:00
Neels Hofmeyr 96831049d9 build: make check: disable sim_test when built with --disable-pcsc
Numerous issues caused sim_test to be attempted even though libosmosim was not
built:

In configure.ac, the ENABLE_PCSC variable lacked an AC_SUBST() to be exported.

Furthermore in configure.ac, no value 'yes'/'no' was assigned to the
ENABLE_PCSC variable, only to the enable_pcsc value.

In testsuite.at, encapsulating the sim_test in 'if ENABLE_PCSC' seems to have
no effect, regardless (not even when using a variable that should be defined
accurately).

So fix with these steps, similarly to how we do it in openbsc:

In AC_ARG_ENABLE, directly use 'ENABLE_PCSC' to assign 'yes'/'no'.
Export the same using AC_SUBST().
Add tests/atlocal.in to translate ENABLE_PCSC to enable_sim_test (also add
atlocal to AC_OUTPUT and distclean).
Use enable_sim_test in testuite.at, as seen in openbsc: use AT_CHECK() to
indicate skipping the test if enable_sim_test isn't 'yes'.

Change-Id: I9e8740c7d2dfbd272e22fee85972ef3fda7184a8
2016-11-16 16:40:44 +00:00
Neels Hofmeyr d95f01d204 build: tests: don't link system installed libosmogsm.
Add src/gsm/libosmogsm.la explicitly to some test linkages, because otherwise
the linker would pick the libosmogsm already installed on the system instead of
the one that was just built in the source tree.

I noticed because a libosmogsm needing some more symbols from libosmocodec was
still installed, while the patch that cause it was already removed. Thus I
caught all(?) test binaries that linked libosmogsm from $PREFIX.

Change-Id: Ie61d60e1506f16de20add70fd0f44ebfa7a00a75
2016-09-10 12:03:39 +00:00
Max 4f169500df Add GEA3 & GEA4 ciphers
Corresponding test code include both official test vectors from the
specs and data from over-the-air tests.

This obsoletes libosmo-crypt-a53 as it was last missing piece
unimplemented in libosmogsm.

Change-Id: I939e4f6b91b4a7c591ef3761fe2d46ed1c2fb2d3
Related: OS#1582
2016-07-11 19:15:24 +00:00
Harald Welte 136e73764e Add Finite State Machine abstraction code
This code is supposed to formalize some of the state machine handling in
Osmocom code.

Change-Id: I0b0965a912598c1f6b84042a99fea9d522642466
Reviewed-on: https://gerrit.osmocom.org/163
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-16 21:43:45 +00:00
Max 92db150488 Add helper functions for AMR codec
* add functions to encode/decode various codec paramters from RTP payload with
  AMR frame according to RFC 4867
* those functions are extended version based on code from osmo-bts'
  amr.c by Andreas Eversberg
* add corresponding enum types and strings for logging
* add regression tests

It's useful both to replace manual parsing in osmo-bts with fuctions
covered by test suite and as a debugging helpers for issues related to
AMR.

Change-Id: Ia217679a07d3fbc970f435e20f6eac33d34bd597
Related: OS#1562
Reviewed-on: https://gerrit.osmocom.org/118
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-31 10:11:51 +00:00
Harald Welte 3b6fb0880c import gprs_gsup_message.[ch] from openbsc as gsup.[ch]
Move those routines from OpenBSC to libosmogsm, so they can be
re-used from other programs.  I think it was a mistake to add them only
inside the openbsc repository in the first place.  We need to pay more
attention to this in the future.
2016-05-06 11:21:06 +02:00
Harald Welte fbd02fa8cc tlv: Import osmo_shift_* and osmo_match_shift_* from openbsc
These routines have nothing to do with specifically the BSC, so import
them to the TLV parser we keep in libosmogsm.
2016-05-05 18:49:27 +02:00
Harald Welte 84da22f964 Add code generator for convolutional codes
Add python utility to generate .c code with convolutional
encoder/decoder based on polynomial description of the code. If argument
given it'll be interpreted as intended output directory, otherwise
current working directory is used.

Codes for *CCH, CS2/3 and TCH/AFS are generated. Corresponding manual
implementations are removed from tests. This introduce build-time
dependency on python.

The main work for this patch was generously contributed by Sylvain
Munaut.

Fixes: OS#1629
2016-04-29 13:17:22 +02:00
Harald Welte 676e534462 sim: Add simplistic unit test for APDU class tables 2016-03-17 16:55:11 +01:00
Max 5c18e26bc2 Add T4 bit map compression routines
Add bit map encoder and decoder functions: decoder is fully functional
while encoder is good enough for testing - no backtracking to find
the best possible compression is implemented. If somebody is willing to
implement MS side of EDGE than this has to be expanded.
Add corresponding tests.
N. B: the encoding is implemented according to ETSI TS 44.060 which is
slightly different from T4 used for fax according to CCITT G31D (RFC 804).

Ticket: OW#2407
Sponsored-by: On-Waves ehf

Signed-off-by: Max <msuraev@sysmocom.de>
2016-02-18 19:45:44 +01:00
Jacob Erlbeck 7cd8a1b063 msgb/test: Add test for msgb message buffers
This tests several API functions of the msgb by checking the
invariant and by dumping resulting message buffers as hex.

Sponsored-by: On-Waves ehf

Conflicts:
	tests/Makefile.am
2016-01-15 18:09:06 +01:00
Jacob Erlbeck 5f349be820 bitvec: Add get/set byte sequences
The new functions bitvec_get_bytes and bitvec_set_bytes copy
byte sequences from bitvecs to uint8_t arrays and vice versa.
While the bytes in the bitvecs do not need to be aligned, the uint8_t
arrays always are. In case the bytes in the bitvec are aligned, the
implementation uses memcpy.

Note that the implementation like the other existing functions assume
MSB first encoding.

[hfreyther: Squash the comment fix into this commit as well]

Sponsored-by: On-Waves ehf
2016-01-15 14:51:32 +01:00
Jacob Erlbeck 8114294bf2 gsm: Add APN conversion functions
These functions are currently part of openbsc but also needed by
other projects.

The function have been renamed as follows:

  gprs_apn_to_str -> osmo_apn_to_str
  gprs_str_to_apn -> osmo_apn_from_str

Sponsored-by: On-Waves ehf
2016-01-15 14:46:19 +01:00
Harald Welte 90e614f7cc remove our internal copy of talloc, use system libtalloc
Shipping our own private copy of talloc was a good idea in 2008,
when it was not readily available on most target platforms.  Today,
the situation is quite different, as it is a standard library on
major Linux distributions.
2015-12-05 23:38:18 +01:00
Jacob Erlbeck ee2657f6af test: Remove unneeded linking to libosmovty.la
The addition of libosmovty.la to several test cases as done in
commit 738d9e2210 (stats: Add vty_out_stat_item_group)
is not needed.

This commit removes them.

Sponsored-by: On-Waves ehf
2015-08-22 01:31:23 +00:00
Jacob Erlbeck 738d9e2210 stats: Add vty_out_stat_item_group
This functions dumps a whole stat item group to the VTY.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:12 +01:00
Jacob Erlbeck 9732cb4a92 stats: Add stat_item for value monitoring
This commit adds instrumentation function to gather measurement
and statistical values similar to counter groups.

Multiple values can be stored per item, which can be retrieved in
FIFO order. Getting values from the item does not modify its state to
allow for multiple independant backends (e.g. VTY and statd).

When a new value is set, the oldest value gets silently overwritten.
Lost values are skipped when getting values from the item.

Sponsored-by: On-Waves ehf
2015-10-28 23:51:04 +01:00
Jan Engelhardt c2ddc4f555 build: have a disable-static build succeed
When using configure --disable-static, no libosmogsm.a will be
created, and the tests fail to link because symbols like _a5_3 and
_a5_4 are not exported through the only remaining libosmogsm.so.

A method to overcome this is an intermediate private non-distributed
library, examples of which are present in e.g. libabc, kmod and
systemd.

With this, disable-static can now be the default and practical compile
time be halved.
2015-09-16 18:08:48 +02:00
Sylvain Munaut 0d72785568 tests: Don't reference file in src/ to test hidden func. Use static link.
Taken from:
https://qiaomuf.wordpress.com/2011/03/27/handling-unit-test-with-c-visibilityhidden/

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-08-19 11:14:23 +02:00
Holger Hans Peter Freyther f558ed4bb9 ipa: Properly parse LV stream of a ID_GET request
For some reason the structure is closer to be a LV (length
and value). The value is actually a tag but it is counted
inside the length. Introduce an overload of the parse function
to provide an offset for the length. This will be taken from
the returned length.
2015-06-02 15:52:06 +02:00
Holger Hans Peter Freyther 0d86c21f6a build: Fix the building of tests as well
In file included from ../../include/osmocom/core/msgb.h:25:0,
                 from ../../tests/sms/sms_test.c:31:
../../include/osmocom/core/bits.h:6:35: fatal error: osmocom/core/bit16gen.h: No such file or directory
 #include <osmocom/core/bit16gen.h>
2015-05-17 19:55:53 +02:00
Michael McTernan 4e0543f730 Tests: Fix broken loggingrb testcase.
The loggingrb (ringbuffer) test case was not actually being built or ran, instead still using the normal logging test.

This patch fixes the makefile, then the loggingrb testcase is changed to use the current loggingrb API so that it builds and passes.

Signed-off-by: Michael McTernan <mike.mcternan@wavemobile.com>
2015-04-01 20:50:26 +02:00
Max f8699ca51e gsm: Add A5/3-4 cipher support
Signed-off-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-03-28 18:07:05 +01:00
Harald Welte 783d073a37 add gsm0341_test to generate SMSCB hex strings
Those hex strings can then be copy+pasted into the OSmoNITB VTY
2014-12-29 17:09:11 +01:00
Jacob Erlbeck cdebf7484a gprs/test: Add BSSGP tests
This patch adds a test suite for the BSSGP protocol.
The first (and only) test checks the handling of BSSGP
SUSPEND/RESUME.

Sponsored-by: On-Waves ehf
2014-10-23 18:52:56 +02:00
Jan Engelhardt c60de4f35f build: fix linker error with kasumi_test
When the osmocore package is configured with --disable-static,
building of kasumi_test fails. This seems quite legit, given
the function _kasumi_kgcore is not exported.
Don't try to workaround the build system. Include the code.

  CCLD     kasumi/kasumi_test
kasumi_test.o: In function `test_expansion':
~tests/kasumi/kasumi_test.c:25: undefined reference to `_kasumi_key_expand'
kasumi_test.o: In function `main':
~tests/kasumi/kasumi_test.c:56: undefined reference to `_kasumi'
~tests/kasumi/kasumi_test.c💯 undefined reference to `_kasumi_key_expand'
~tests/kasumi/kasumi_test.c:112: undefined reference to `_kasumi_kgcore'
[...]
2014-10-03 08:48:31 +02:00
Jan Engelhardt 9ffeb9756a build: remove unused all_includes and use AM_CPPFLAGS
Preprocessor flags are best placed in AM_CPPFLAGS. Remove use of the
unused all_includes variable, which is never set.
2014-10-03 08:48:31 +02:00
Sylvain Munaut 579a7103a1 gsm: Add Kasumi cipher implementation
Submitted-by: Max <max.suraev@fairwaves.co>
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2014-06-16 14:59:30 +02:00
Holger Hans Peter Freyther b79a148eca utils: Add a simple testcase for osmo_hexdump
This code makes a simple dump and tests for the corner case
2014-01-02 13:59:10 +01:00
Max 4f0abc0e3e Refactor COMP128v23 implementation and add test suit 2013-12-07 18:10:38 +01:00
Jacob Erlbeck dcce196be9 tests/gb: Add test for GPRS NS protocol
This tests the connection establishment by directly calling
gprs_ns_rcvmsg() and printing the resulting messages and the
NS-VC list.
2013-10-08 14:00:24 +02:00
Jacob Erlbeck ae15a2cac1 vty: Fix misusage of snprintf in vty/utils.c
Compiled with ubuntu 1204 (precise), where -Wformat-security is enabled by
-Wall.

Test yields ok, but the current implementation doesn't properly support
multi-character separators and end strings. So the test output is truncated.

Addresses:
utils.c: In function 'vty_cmd_string_from_valstr':
utils.c:84:2: warning: format not a string literal and no format arguments [-Wformat-security]
utils.c:84:2: warning: format not a string literal and no format arguments [-Wformat-security]
utils.c:108:2: warning: format not a string literal and no format arguments [-Wformat-security]
utils.c:108:2: warning: format not a string literal and no format arguments [-Wformat-security]
2013-08-06 14:56:30 +02:00
Holger Hans Peter Freyther 14df1c07ec fr: Fix the linking of the test and use $(LIBRARY_DL) for linking
On Ubuntu 13.04 the build was failing on the OBS with:
/usr/bin/ld: fr_test.o: undefined reference to symbol 'dlsym@@GLIBC_2.2.5'
/usr/bin/ld: note: 'dlsym@@GLIBC_2.2.5' is defined in DSO /lib/x86_64-linux-gnu/libdl.so.2 so try adding it to the linker command line
/lib/x86_64-linux-gnu/libdl.so.2: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
2013-06-26 07:56:45 +02:00
Katerina Barone-Adesi 3309a43ef5 Added a ring buffer log target to store the last N log messages.
The log target can be used via log alarms and show alarms.
Why? This feature was proposed/requested at
http://openbsc.osmocom.org/trac/wiki/Tasks/ErrorLogTarget
All messages use the same amount of space, prioritizing simplicity.
2013-02-27 15:13:45 +01:00
Holger Hans Peter Freyther efd2bd691f Revert "Added a ring buffer log target to store the last N log messages."
I noticed some more issues and it is the easiest to revert and include
the fixed version.

This reverts commit 73377229bb.
2013-02-27 14:51:33 +01:00
Katerina Barone-Adesi 73377229bb Added a ring buffer log target to store the last N log messages.
The log target can be used via log alarms and show alarms.
Why? This feature was proposed/requested at
http://openbsc.osmocom.org/trac/wiki/Tasks/ErrorLogTarget
All messages use the same amount of space, prioritizing simplicity.
2013-02-27 14:45:48 +01:00
Holger Hans Peter Freyther 97602d9734 fr: Begin with a GRE/FrameRelay test due the recent regression
The framerelay code is seldomly used and the socket clean ups introduced
a regression. Create a testcase that will work as a user not having the
right capabilities to create raw sockets.

We have to make sure that this test is working even when not ran as root.
The easiest way to do this is to provide our own socket implementation.
This is done with dlopen/dlsym to convert the raw socket request to an UDP
one.
2013-01-15 20:06:40 +01:00
Daniel Willmann 13bb169d71 tests: Don't delete atconfig in clean
This file is created in ./configure so we shouldn't remove it with make.
Otherwise ./configure && make clean && make check fails with:

make[3]: *** No rule to make target `atconfig', needed by `check-local'.
Stop.
2012-12-26 10:56:14 +01:00
Sylvain Munaut 5689a3b744 build: Don't use the deprecated INCLUDES in the various Makefile.am
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2012-12-11 23:59:31 +01:00
Holger Hans Peter Freyther 4b54cab476 logging: Move the logging test from OpenBSC into libosmocore
Add a testcase for the logging facility. The test is coming from
the OpenBSC code.
2012-09-27 16:29:54 +02:00
Holger Hans Peter Freyther c302eca2c6 tests: Make the gb test work with srcdir != builddir
* Disable color and printing the filename of the stderr log target,
  update the results
* Add the .ok, .err and .sh files to the extra_dist
* Execute the shell script from the source directory
2012-09-11 11:49:35 +02:00
Harald Welte 57e5b94e90 BSSGP flow-control: Add unit test for algorithm tests 2012-09-07 12:07:54 +02:00