aboutsummaryrefslogtreecommitdiffstats
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
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.
2015-11-26stats/test: Add memory leak checkJacob Erlbeck1-4/+9
Adds a rudimentary leak check for the counters and stat items. Sponsored-by: On-Waves ehf
2015-11-26stats/test: Add test for reportingJacob Erlbeck2-17/+369
This tests uses a dedicated test reported to check several aspects of the value reporting. - addition/removal of stats reporter - addition/removal of counters/items - setting of max_class - initial value flush - updating single counters/items - reporter retrieval - enable/disable Sponsored-by: On-Waves ehf
2015-08-22stats/test: Add tests to check VTY configurationJacob Erlbeck2-0/+194
This commit adds tests to verify the stats related VTY configuration commands. Sponsored-by: On-Waves ehf
2015-08-22vty/test: Refactor vty creation/deletion into separate functionsJacob Erlbeck1-29/+46
Currently this is part of the only test function that uses the vty directly. In preperation for more such test cases, this commit moves this code into separate functions. Sponsored-by: On-Waves ehf
2015-08-22test: Remove unneeded linking to libosmovty.laJacob Erlbeck1-4/+4
The addition of libosmovty.la to several test cases as done in commit 738d9e22108a8e47245 (stats: Add vty_out_stat_item_group) is not needed. This commit removes them. Sponsored-by: On-Waves ehf
2015-11-02stats: Add osmo_ name prefix to identifiersJacob Erlbeck1-55/+55
Since the the stat_item and stats functions and data types are meant to be exported, they get an osmo_ prefix. Sponsored-by: On-Waves ehf [hfreyther: Prepended the enum values too. This was requested by Jacob]
2015-10-29stats/vty: Add stats configurationJacob Erlbeck1-3/+3
This commit provides stats configuration similar to the log configuration. The following vty commands are added to the config node: stats reporter statsd Create/Modify a statsd reporter no stats reporter statsd Remove a statsd reporter To actually configure a reporter, the config-stats node is entered when the "stats reporter" command has succeeded. The following new vty commands are available there: local-ip ADDR Set the IP address to which we bind locally no local-ip Do not bind to a certain IP address remote-ip ADDR Set the remote IP address to which we connect remote-port <1-65535> Set the remote port to which we connect prefix PREFIX Set the item/counter name prefix no prefix Do not use a prefix enable Enable the reporter disable Disable the reporter Sponsored-by: On-Waves ehf
2015-10-28stats: Use a global index for stat item valuesJacob Erlbeck1-14/+29
Currently each stat item has a separate index value which basically counts each single value added to the item and which can be used by a reporter to get all new values that have not been reported yet. The drawback is, that such an index must be stored for each stat item. This commit introduces a global index which is incremented for each new stat item value. This index is then stored together with the item value. So a single stored index per reporter is sufficient to make sure that only new values are reported. Sponsored-by: On-Waves ehf
2015-10-28stats: Add vty_out_stat_item_groupJacob Erlbeck1-4/+4
This functions dumps a whole stat item group to the VTY. Sponsored-by: On-Waves ehf
2015-10-28stats: Add stat_item for value monitoringJacob Erlbeck4-2/+209
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-09-16build: have a disable-static build succeedJan Engelhardt1-4/+2
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-08-19tests: Don't reference file in src/ to test hidden func. Use static link.Sylvain Munaut1-2/+3
Taken from: https://qiaomuf.wordpress.com/2011/03/27/handling-unit-test-with-c-visibilityhidden/ Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-06-19bssgp/test: Add missing START/END printfsJacob Erlbeck2-1/+8
Sponsored-by: On-Waves ehf
2015-06-02ipa: Properly parse LV stream of a ID_GET requestHolger Hans Peter Freyther2-1/+62
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-05-17build: Fix the building of tests as wellHolger Hans Peter Freyther1-1/+1
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-06bssgp: Fix bssgp_tx_fc_bvc parameter typeJacob Erlbeck2-0/+79
Currently large values for Bmax default MS get sliced since a uint16_t is used as the type of the corresponding parameter of bssgp_tx_fc_bvc. GSM 48.018, 11.3.2 which in turn refers to 11.3.5 specifies a maximum of 6MB (0xffff * 100). This commit changes the type to uint32_t to cover the full value range. Sponsored-by: On-Waves ehf
2015-05-04bssgp/test: Fix bssgp-fc testJacob Erlbeck1-30/+0
The fix in the commit "bssgp: Fix call to llist_entry in fc_queue_timer_cfg" prevents the flow control code from generating certain logging messages ("-BSSGP-FC: fc_timer_cb() but still not able to send PDU of 10 bytes") during the tests. This breaks the test suite, since the update of the correseponding stderr output file misses. This commit updates the bssgp_fc_tests.err file accordingly. Sponsored-by: On-Waves ehf
2015-04-11logginrb: Fix compiler warning about fprintfHolger Hans Peter Freyther1-2/+2
loggingrb/loggingrb_test.c:76:18: warning: format string is not a string literal (potentially insecure) [-Wformat-security] fprintf(stderr, log_target_rb_get(ringbuf_target, 0)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ loggingrb/loggingrb_test.c:77:18: warning: format string is not a string literal (potentially insecure) [-Wformat-security] fprintf(stderr, log_target_rb_get(ringbuf_target, 1)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2015-04-07bssgp: Ensure non-NULL bctx before calling bssgp_rx_ptp (Coverity)Jacob Erlbeck1-0/+17
Currently bssgp_rx_ptp might be called with bctx being NULL, when the NS BVCI is neither BVCI_SIGNALLING nor BVCI_PTM, but the message is a BVC_RESET or it contains an BVCI IE != BVCI_SIGNALLING where the BVCI is not known. This patch ensures that bssgp_rx_ptp will only be called with a non-NULL bctx. A log message will be issued, if the bctx is NULL when this was not expected. Fixes: Coverity CID 1040674 Sponsored-by: On-Waves ehf
2015-04-07fix compiler warnings for a5 testsMax1-0/+4
Signed-off-by: Max <max.suraev@fairwaves.co>
2015-04-01Tests: Fix broken loggingrb testcase.Michael McTernan2-7/+6
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-03-28gsm: Add A5/3-4 cipher supportMax3-15/+79
Signed-off-by: Max <max.suraev@fairwaves.co> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-03-18bssgp: Handle BSSGP STATUS messagesJacob Erlbeck2-0/+39
Currently incoming BSSGP STATUS messages are just logged and no other action is taken. This makes it impossible for higher layers to react to failures which are indicated by corresponding STATUS messages unless a timeout is triggered as a result of that failure later on. This commit adds a bssgp_rx_status() function and calls it on incoming STATUS messages. That function logs a message, increments the new BSSGP_CTR_STATUS counter if the bctx context exists and invokes an NM_STATUS status indication. The latter will allow the application to handle failures immediately. Since all STATUS messages should be handled, the function is already called in bssgp_rcvmsg and the message is no longer handled in (and will not reach) bssgp_rx_sign and bssgp_rx_ptp. Ticket: OW#1414 Sponsored-by: On-Waves ehf
2015-01-01Supplementary Services (de)activation, interrogation addedTobias Engel1-7/+7
These patches enhance the Supplementary Service (SS) processing from only being able to handle USSD to other SS, specifically activation, deactivation and interrogation of those SS. Registration is not yet implemented. include/osmocom/gsm/protocol/gsm_09_02.h has been added with needed values for SS. Modified by Harald Welte to keep the old ussd-only functiosn for API/ABI stability.
2014-12-30SMS-CB: introduce and use GSM341_7BIT_PADDINGHarald Welte1-2/+3
2014-12-30use the new GSM341 / GSM412 size constantsHarald Welte1-3/+3
2014-12-30smscb/gsm0341_test: Add \r padding to the messageDaniel Willmann1-1/+7
2014-12-30testHarald Welte1-1/+4