aboutsummaryrefslogtreecommitdiffstats
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2016-11-16build: make check: disable sim_test when built with --disable-pcscNeels Hofmeyr3-2/+8
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-10bitcomp: Remove the t4 decoding from libosmocoreHolger Hans Peter Freyther2-22/+0
As outlined by mail on the 13th of July the tree based approach to decoding in the PCU is faster by order of magnitude. Instead of having a slow implementation in the library and a quick one in the PCU, let's only have a quick one in the PCU and at some point in the future move it to libosmocore. Execute the plan and remove t4_decode. Change-Id: I021424444625a097560d086c217c81eac4a5ee44
2016-11-08Add logging and testing for FSM deallocationMax1-4/+5
osmo_fsm_inst_alloc() logs allocation but osmo_fsm_inst_free() is silent. Fix this by adding log message for deallocation to make FSM lifecycle tracking easier. Also make sure it's covered by test suite. Change-Id: I7e5b55a1fff8e36cf61c7fb61d3e79c1f00e29d2
2016-11-07Add null-pointer check to osmo_amr_rtp_dec()Max1-3/+9
Check that RTP payload we're about to decode is not NULL and return proper error code instead of segfaulting. Add corresponding test case. Change-Id: Ib6cda9900a41ed16bbfbde9df3de9d38e0a7469b
2016-11-02Add osmo_fsm_unregister() to headerMax1-0/+1
Previously function was defined but not exposed so there were a way to register FSM but no way to unregister it. Change-Id: I2e749d896009784b77d6d5952fcc38e1c131db2b
2016-09-27gsm0408_test: initialize msgb talloc ctxNeels Hofmeyr1-0/+1
Change-Id: Ib26214add1932e93651c248cc09fbc68339b4dce
2016-09-26bitrev_test: don't omit last byte from test result checkNeels Hofmeyr2-25/+28
The osmo_hexdump of the output in sh_chk() omitted the last byte of the returned bytes from the osmo_nibble_shift_*() functions. Determine the number of bytes from nibbles divided by two plus one for any odd nibble number. Output this number of bytes of output data. Memset the output buffer to get well-defined bytes for unwritten places. Also assert that we have enough buffer length for all nibbles. Change-Id: I011f42bca555caec0dfe8688ff1f28303fa04fad
2016-09-26Fix ASAN failure in bitrev_testMax2-3/+3
Previously while testing osmo_nibble_shift_left_unal() following error was triggered by AddressSanitizer upon offs == 12 and the last sh_chk line, i.e. shift left of 12 nibbles from in2: ==3890== ERROR: AddressSanitizer: stack-buffer-overflow on address 0xbff5b5b6 at pc 0xb6186862 bp 0xbff5b4a8 sp 0xbff5b49c READ of size 1 at 0xbff5b5b6 thread T0 #0 0xb6186861 (/home/msuraev/source/gsm/libosmocore/src/.libs/libosmocore.so.7.0.0+0xc861) #1 0x8049d8b (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x8049d8b) #2 0x804a9d1 (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x804a9d1) #3 0xb5fe3af2 (/lib/i386-linux-gnu/libc-2.19.so+0x19af2) #4 0x8048a30 (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x8048a30) Address 0xbff5b5b6 is located at offset 38 in frame <main> of T0's stack: This frame has 3 object(s): [32, 38) 'in2' [96, 104) 'out' [160, 168) 'in1' The reason is incorrect range in test cycle. Fix it and adjust test output accordingly. Tweaked-by: Neels Hofmeyr <nhofmeyr@sysmocom.de> Fixes: OW#1589 ("undefined behavior in libosmocore triggered by tests") Change-Id: I5eb3f600290c05b4ab9ac2450a28d616e6b415fd
2016-09-22timer_test: set 8 as default steps, use the default in testsuite.atNeels Hofmeyr3-16/+281
Change-Id: I5070578e9fe2bdacaad000eaafb8dc5f549d6f3e
2016-09-22timer_test: print more details to stdout to checkNeels Hofmeyr2-4/+116
The test is now fully deterministic, so include all detail in stdout, to check for. Change-Id: Iecf6387f1d25253fcf1260777673853030c1d326
2016-09-22timer_test: redirect some output from stderr to stdoutNeels Hofmeyr2-20/+24
This way we can check the output in timer_test.ok. Change-Id: Ia3bba1c650be3558d370e0f59d4ee7f36ef97506
2016-09-22timer_test: remove all random elementsNeels Hofmeyr1-3/+6
Change-Id: I9833031407e99f5d7a1144c26b68a7e320b2020d
2016-09-22timer_test: do not use real time: deterministic and fasterNeels Hofmeyr1-20/+15
Use osmo_gettimeofday_override* to decouple the timer test from real time. No longer call osmo_select_main(), since select() actually waits for real time. This reduces the timer_test to the osmo_timer_* logic and excludes the real time and osmo_timers_nearest() accuracy testing with actual waiting involved. This may be seen as a loss, but is more fit for a test suite. The main point here is to get deterministic results in jenkins, so that we don't have to retrigger jobs based on timing failures; added bonus is that the test runs much faster now. Change-Id: Ic5649512df86dd17070daa2f314159eafaf8feb8
2016-09-22add osmo_gettimeofday as a shim around gettimeofdayNeels Hofmeyr2-4/+4
This allows feeding a custom time for unit tests by overriding osmo_gettimeofday. Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
2016-09-22timer_test: remove unused precision values and confusing logNeels Hofmeyr2-8/+2
Change-Id: I1570b7096c757d63d23e0950feeeb7230f8a5c9f
2016-09-22timer_test: also report early finishes, report timing on errorNeels Hofmeyr2-5/+19
When a timer was late, show the timing details. Also count whether timers fired early, for completeness' sake. Change-Id: Id3942637d77a28b5092ffffcc3e6d9d67c2b8e68
2016-09-22fix timer_test: don't forget to set tv_usec on the stop timeNeels Hofmeyr1-0/+1
The timer_test schedules timers and records the desired stop time. Also store the usec value of the desired stop time, because scheduling at e.g. sec N usec 999999 but recording sec N usec 0, and then receiving a timer at sec N+1 usec 0 is only 1 usec late, but records as 1000000 usecs late. This might have been the main cause of the timer test not working well on the osmocom build server. Change-Id: I13bb60f7d341a397f95d13d9c63c40188b6cd5a0
2016-09-10build: tests: don't link system installed libosmogsm.Neels Hofmeyr1-5/+10
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-07-12ussd: Decode interrogateSS that doesn't have testHolger Hans Peter Freyther2-0/+13
Keith of Rhizomatica has an issue of a unrejected interrogateSS. Start with just decoding the message and printing the empty test and the code. What is kind of missing is the classification between invoke, returnResult and returnResultLast that we need to add in the long run. Change-Id: Iadfa156707a96f2a34f3948c7cc9a74435f17114
2016-07-11Add GEA3 & GEA4 ciphersMax4-2/+94
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-06-29tests: test actual support status for auth. algoMax4-4/+10
Check if library actually support Milenage, COMP128 v2 and v3 algorithms instead of just printing enum values or nothing. Change-Id: I2b98481f56a8381058d4b29db5e8a36eb193eee9
2016-06-20Add octet-aligned/unaligned shift functionsMax2-0/+130
The actual code is from OsmoBTS' tch.c by Harald Welte. Add unit tests, doxygen annotation and extra memory safety check. Those functions are used in several BTS implementations but seems generic enough to be generally useful. Change-Id: I2b1901c4161e8035f059585901dca593b661556d
2016-06-16Add Finite State Machine abstraction codeHarald Welte5-2/+179
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-01Add functions to detect HR/FR SID framesMax2-0/+34
Add functions which check if given FR or HR frame (packed in RTP) contains SID (SIlence Descriptor) and corresponding tests. Related: OS#22 Change-Id: I4051e3c0d4fb9ee93d7e9e0ef4abaf9f18e227ca Reviewed-on: https://gerrit.osmocom.org/160 Tested-by: Jenkins Builder Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-05-31Add helper functions for AMR codecMax4-3/+106
* 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-06import gprs_gsup_message.[ch] from openbsc as gsup.[ch]0.9.4Harald Welte4-2/+289
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-05tlv: Import osmo_shift_* and osmo_match_shift_* from openbscHarald Welte4-2/+263
These routines have nothing to do with specifically the BSC, so import them to the TLV parser we keep in libosmogsm.
2016-04-29Add code generator for convolutional codesMax Suraev msuraev@sysmocom.de2-195/+90
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-12Add ubit <-> sbit convertorsMax1-21/+2
Move functions for conversion between soft and unpacked bits to main library as they are generally useful.
2016-03-21sim: Fix compiler warning and by this fixing the test resultHolger Hans Peter Freyther1-0/+1
2016-03-17sim: Add simplistic unit test for APDU class tablesHarald Welte4-2/+75
2016-03-17Add function to add bits from array to bitvecMax2-0/+76
Add function which adds specified number of bits from each element of array to the bit vector prefixing each addition with one and finishing entire sequence with adding 0. This is very common patter for various repetitive data structures described with CSN.1 in 3GPP standards. Corresponding test vectors and doxygen headers are added too.
2016-02-29logging: Move the filter check up as wellHolger Hans Peter Freyther2-7/+15
There doesn't seem to be a reason not to check the filter. Update and extend the test. Currently the filter function will be called once for the log check and once for the output of it.
2016-02-29log/test: Extend test case for log_check_levelJacob Erlbeck2-1/+11
This commit adds OSMO_ASSERTs for mandatory conditions related to log_check_level, and fprintfs for optional conditions, since it is always safe for log_check_level to return != 0. Sponsored-by: On-Waves ehf
2016-02-25Add byte printing macrosMax1-12/+1
It's sometimes handy for debugging to be able to immediately see which bits are set in a given byte. Generalize macro used for that in bitvec tests and make it available for the rest of the library.
2016-02-22gb: Add bssgp_msgb_copy functionJacob Erlbeck2-0/+38
This function originates from openbsc/src/gprs but is just specific to BSSGP/Gb on the same level like bssgp_msgb_alloc. This commit puts the former gprs_msgb_copy function beside bssgp_msgb_alloc. Renamed function: gprs_msgb_copy -> bssgp_msgb_copy Sponsored-by: On-Waves ehf
2016-02-18Add T4 bit map compression routinesMax4-2/+106
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-18Expand bitvec interfaceMax2-2/+258
Add bit filling, shifting and other functions necessary for bit compression implementation. Add corresponding tests.
2016-01-30bivec: Fix the output of the testcaseHolger Hans Peter Freyther2-12/+16
osmo_hexdump_nospc/osmo_hexdump is an old school C routine with a static internal array. This means that printf will most likely one of the two strings twice. For Linux/glibc this is the first string (for whatever reason?) and for FreeBSD it is the last call of the osmo_hexdump_nospc. We could have noticed by both strings being of the same length besides the different length input. The second issue is that we cast a hexstring to uint8_t and dump the string as hex. So the two strings should not match at all. Fix it by printing the hex string as plain hex and separating the two printf calls. Update the test output.
2016-01-30bitvec: Test and fix regression for C++->C conversionHolger Hans Peter Freyther2-0/+31
bitvec_read_field/bitvec_write_field in the PCU used a C++ reference and when porting to C it was decided to pass the parameter by value and this lost the "back propagation" of the new index. Change the parameter to be an in/out parameter and this way do not have a silent semantic break in the osmo-pcu (where we copy the reference in csn.1 by value) and have a true compile failure. Add Max's simple test for bitvec_unhex function leaving the checking of bitvec_read_field and the side effect in the datastructure about the number of bits still open.
2015-11-09test: Fix compiler warnings on 64bit systemsHolger Hans Peter Freyther6-17/+18
Use %td to print ptrdiff_t use %zu to print size_t, include time.h on FreeBSD. Some more compiler warnings are left but they require more thinking.
2016-01-21kasumi: Fix build with gcc5 that changed behavior of inlineHolger Hans Peter Freyther1-1/+1
GCC 5 has changed inline semantics (https://gcc.gnu.org/gcc-5/porting_to.html) and apparently that now fails to link.
2016-01-15msgb/test: Add test case for error casesJacob Erlbeck2-0/+24
Include a test for msgb_trim. Sponsored-by: On-Waves ehf
2016-01-15msgb/test: Add tests for msgb_resize_area and msgb_copyJacob Erlbeck2-0/+149
Sponsored-by: On-Waves ehf
2016-01-15msgb/test: Add functions to catch and check exceptionsJacob Erlbeck2-1/+32
Currently the msgb error handling cannot be fully tested, since in many cases osmo_panic will be called. This will in turn call abort(). Using an osmo_panic_handler that just returns will not help, since many msgb functions rely on MSGB_ABORT to not return at all. This commit uses an alternative osmo_panic_raise handler that just calls longjmp to return to the test function. Since some of this activity is logged to stderr where the strings may contain variable parts like pointer addresses, stderr checking is disabled in testsuite.at. Sponsored-by: On-Waves ehf
2016-01-15msgb/test: Add test for msgb message buffersJacob Erlbeck4-2/+136
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-15bitvec: Add get/set byte sequencesJacob Erlbeck4-2/+77
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-15gsm: Add APN conversion functionsJacob Erlbeck4-3/+136
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
2015-12-17ns: Force a defined state when sending NS RESETJacob Erlbeck2-0/+102
Currently the state is assumed to remain the same while the reset procedure is active. While this works correctly in general, a single unexpected BLOCK_ACK or UNBLOCK_ACK can change the state but will not stop the reset procedure. The leads to repeated RESET messages, where the corresponding RESET_ACK is ignored. This is a stable state which can only be left by manual intervention or by reception of a RESET message from the peer. This commit changes the RESET timeout handler to set the state to BLOCKED/RESET when sending the new NS RESET message. Note that this should ensure a clean restart even if the state has been screwed up. It does not fix the handling of BLOCK_ACK or UNBLOCK_ACK in abnormal cases. Addresses: gprs_ns.c:349 NSEI=8895 Tx NS RESET (NSVCI=8895, cause=O&M intervention) gprs_ns.c:878 NSVCI=8895 Rx NS RESET ACK (NSEI=8895, NSVCI=8895) gprs_ns.c:887 NS RESET ACK Discarding unexpected message for NS-VCI 8895 from SGSN NSEI=8895 Ticket: OW#1551 Sponsored-by: On-Waves ehf
2015-12-05remove our internal copy of talloc, use system libtallocHarald Welte1-1/+2
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.