summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* fix bug in parse_cell_id_ci_list()Stefan Sperling2018-03-161-0/+35
| | | | | | | | | | | Cell ID lists with CI were misparsed because parse_cell_id_ci_list() failed to report the amount of consumed bytes to its caller. Also add a regression test which uncovered the bug. Change-Id: Ife4e485e2b86c6f3321c9700611700115ad247b2 Depends: If6b941720de33dca66b6b1aa2cb95a3275708b7f Related: OS#2847
* use gsm48_decode_lai2() in gsm0808_dec_cell_id_list()Stefan Sperling2018-03-151-0/+57
| | | | | | | | This makes gsm0808_dec_cell_id_list() properly decode 3-digit MNCs. Add a test which encodes/decodes a LAI_AND_LAC list with 3-digit MNCs. Change-Id: If6b941720de33dca66b6b1aa2cb95a3275708b7f Related: OS#2847
* fix cell identifier decoding in libosmocoreStefan Sperling2018-03-151-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The cell ID list decoder merged in 11a4d9dd91216fe353e94bfdbbab53bc4f891c0d has a bug which was introduced part-way through the review process in gerrit at https://gerrit.osmocom.org/#/c/6509/ When Neels suggested "why not just {...}id_list[MAXLEN] once?" I changed the cell identifier list from a union of arrays to an array of unions. After this change, elements smaller than the largest type in the union were not laid out consecutively in memory anymore. E.g. uint16_t lac values now occur at offsets of sizeof(id_list[0]) instead of offsets of sizeof(uint16_t). The problem is that I forgot to adjust the decoder accordingly, so the decoder writes to the wrong offsets and returns cell identifier lists which appear to contain uninitialized values when read back by API consumers. I found this problem while adding new regression tests to libosmocore to test encoding and decoding. This commit adds one such tests for LAC list decoding, which failed due to the above bug. I plan to write more tests, however because this first test already uncovered a severe issue I chose to submit a fix now and work on additional tests in later commits. Change-Id: Ie1a5a9d858226be578cf11a03cf996d509bd51fb Related: OS#2847
* support for more cell ID list types in libosmocoreStefan Sperling2018-03-131-25/+22
| | | | | | | | | | | | | | | | | | | | | | | | Introduce gsm0808_dec_cell_id_list2() with supports additional types of cell identifier lists. The new parsing routines are based on similar routines used by the paging code in osmo-bsc's osmo_bsc_bssap.c. Likewise, introduce gsm0808_enc_cell_id_list2() with support for the same additional types of cell identifier lists. The old API using struct gsm0808_cell_id_list is deprecated. The previous definition was insufficient because it assumed that all decoded cell ID types could be represented with a single uint16_t. It was declared in a GSM protocol header (gsm/protocol/gsm_08_08.h) despite being a host-side representation of data in an IE. The only user I am aware of is in osmo-msc, where this struct is used for one local variable. osmo-msc releases >= 1.1.0 make use of this API. While here, fix a small bug in a test: test_gsm0808_enc_dec_cell_id_list_bss() set the cell ID type to 'LAC' but obviously wants to use type 'BSS'. Change-Id: Ib7e754f538df0c83298a3c958b4e15a32fcb8abb Related: OS#2847
* fix osmo_mnc_from_str(): don't try to parse NULLNeels Hofmeyr2018-03-052-15/+15
| | | | | | | | In osmo_mnc_from_str() do not try to return some values even if the validation fails; hence don't try to decode a NULL pointer. That whole idea was half-baked and a can of worms to begin with. Change-Id: Ibaaa128ac60b941a015a31134eb52aef56bc6e22
* gsm23003_test: fix: compare members instead of bcmpNeels Hofmeyr2018-03-011-1/+3
| | | | | | | | | | In certain builds (for me a build with no -O2 flag) the recently added gsm23003_test test_mnc_from_str() fails, because bcmp() compares all bytes of sizeof(struct test_mnc_from_str_result), which has valid data for 7 bytes plus one padding byte that may contain arbitrary values. Instead of bcmp(), rather compare the actual members one by one. Change-Id: I28b28457c7b0462c950612fd9b87b5c7181d8bad
* timer: Introduce osmo_clock_gettime to override clock_gettimePau Espin Pedrol2018-03-014-2/+108
| | | | Change-Id: I5bebc6e01fc9d238065bc2517058f0ba85620349
* gsm: add osmo_mnc_from_str(), osmo_mnc_cmp(), osmo_plmn_cmp() for 3-digit MNCNeels Hofmeyr2018-02-282-0/+72
| | | | | | | | | | | osmo_mnc_from_str() preserves leading zeros in the string and is useful for VTY config parsing (osmo-bsc, osmo-msc, osmo-sgsn, osmo-pcu). osmo_{plmn,mnc}_cmp() takes care of the slight intricacy of ignoring the 3-digit flag if the MNC is anyway >99. Will be used by osmo-sgsn.git and osmo-bsc.git. (All current users just care about identical MNC, but a proper cmp doesn't hurt.) Change-Id: Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6
* gsm0408_test: add test cases for MNC with leading zerosNeels Hofmeyr2018-02-282-0/+149
| | | | Change-Id: I9b387e09293a6bbef84b9620ccf21ee2f9ec751c
* gsm0408_test: test new gsm48_{decode,generate}_lai2() functionsNeels Hofmeyr2018-02-282-0/+50
| | | | Change-Id: I4c8492b8055803d2857f1ef30aede088778b085b
* gsm0408_test: check for new mnc_3_digits flagNeels Hofmeyr2018-02-282-4/+5
| | | | | | | Note that on the input side, the 3-digits flag may be left false when the MNC is >99 anyway. On the decoded side, the flag is set accurately. Change-Id: I89765613d8c5bd939a6957f7443ac88475f1b93c
* print BIG FAT ERROR message if osmo_fsm lacks event namesStefan Sperling2018-02-262-4/+11
| | | | | | | | | | | | Event names are displayed in VTY commands so all FSM should have them. Print an error message if an FSM is registered without event names. We could also return an error code, however at present no caller checks the return value of osmo_fsm_register() so this would be pointless. Add event names to the test FSM and update expected output accordingly. Change-Id: I08b100d62b5c50bf025ef87d31ea39072539cf37 Related: OS#3008
* coding: Add BER-reporting RACH decode functionsHarald Welte2018-02-261-2/+2
| | | | | | | | | | | | For all other decode operations we report the BER, but not for the RACH. This results in osmo-bts-trx not being able to report BER to the higher layers, which is possible on other BTS backends. Let's close this gap by introducing gsm0503_rach_ext_decode_ber() and gsm0503_rach_decode_ber() with the usual n_errors / n_bits_total arguments. Change-Id: I2b1926a37bde860dcfeb0d613eb55a71271928c5
* gsm0408_test: also test gsm48_generate_lai() and gsm48_decode_lai()Neels Hofmeyr2018-02-222-0/+53
| | | | Change-Id: Idd6cee090464bc92b654332904a9a08edf16e5c9
* gsm0408_test: RA test: include min/max value casesNeels Hofmeyr2018-02-222-0/+22
| | | | | | (Preparation for adding 3-digit MNC) Change-Id: Ifbc167de0cc039858112677b8d0cd14a2c8af086
* gsm0408_test: include BCD and leading zeros in test outputNeels Hofmeyr2018-02-222-5/+8
| | | | | | (Preparation for adding 3-digit MNC) Change-Id: I7f8ae05fa3e4a6fc004212757b05ca8a14c9ef45
* gsm0408_test: cosmetically re-order MCC to come before MNCNeels Hofmeyr2018-02-202-7/+7
| | | | | | For consistency in human readability, MCC simply should come first, always. Change-Id: Idb86a7088fac4d8a8c41190ab46f9801635f4eee
* cosmetic: gsm0408_test: RA test cases as array-of-structNeels Hofmeyr2018-02-201-8/+12
| | | | | | (Preparation for adding 3-digit MNC) Change-Id: Ic6c645ebf82d5f8d9d51c4c4cc804a0172008156
* Add test for gsm48_generate_mid_from_imsi()Max2018-02-152-0/+14
| | | | Change-Id: Ibe5c0831268c788ceecd10fd7b22ece6480da817
* tests: utils_test: Fix test failure when compiling with -O0Pau Espin Pedrol2018-02-081-0/+1
| | | | | | | | | It seems with default flags in_buf was being memzeroed by the compiler. When compiling with -O0, that's not the case anymore and printf prints after first 16 bytes, printing extra garbage which doesn't match the expected output. Change-Id: I736c1e4d625f647d3bb794fa717256e9dbf36e87
* tests: coding_test: Fix compilation with -O0Pau Espin Pedrol2018-02-081-2/+2
| | | | | | | | | | | | | | | | | inline keyword is a hint for the compiler to inline the function, but it's not mandatory. If no static or extern is specified, the definition is only visible in the current unit but the identifier still has external linkage. When running with -O0 it seems the compiler (gcc 7.2.1) decides to use the external linkage but at the same time it seems it's not generating the function symbol. Fix it by explicitly stating that we want to use static linking for this function. coding/coding_test.o: In function `test_xcch': libosmocore/tests/coding/coding_test.c:86: undefined reference to `dump_ubits' libosmocore/tests/coding/coding_test.c:87: undefined reference to `dump_sbits' Change-Id: I18018adec05ce1c2ddbca38653311d74c7454ce8
* GSUP: change osmo_gsup_encode() return typeMax2018-02-051-1/+3
| | | | | | | | | | * match return type of osmo_gsup_encode() with osmo_gsup_decode() to allow propagating error to caller * check return value of osmo_gsup_encode() in GSUP test * return errors instead of braking app with aseert Change-Id: Idaa1deecb6d9e15329bd51867b4f6a03357461f0 Related: OS#2864
* GSUP: don't fail test on first errorMax2018-01-222-4/+30
| | | | | | | | | | Instead of forcing test failure via assert on first error encountered, let it run until completion and print detailed error log. This simplifies troubleshooting by letting user to see more errors from single run and more details on each of the errors. Update test output with explicit test results. Change-Id: I016a28fe04f7b194e22c15e936095004c5f079d1
* tests/ussd: prevent uninitialized memory accessVadim Yanitskiy2018-01-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously an incorrect length value was passed to both gsm_7bit_decode_n_ussd() and gsm_7bit_encode_n_ussd() functions during test_7bit_ussd() execution, due to: octets_written = strlen(decoded); The problem is that a 7-bit encoded string takes less memory than its 8-bit equivalent. So, here strlen() returns one-byte bigger value, that octets_written is. This then causes the uninitialized memory access. Found using Valgrind: Conditional jump or move depends on uninitialised value(s) at 0x506DCCC: gsm_7bit_decode_n_ussd (gsm_utils.c:248) by 0x40134B: test_7bit_ussd (ussd_test.c:104) by 0x400F5D: main (ussd_test.c:161) Conditional jump or move depends on uninitialised value(s) at 0x506DBB7: gsm_7bit_decode_n_hdr (gsm_utils.c:220) by 0x506DC9E: gsm_7bit_decode_n_ussd (gsm_utils.c:246) by 0x40134B: test_7bit_ussd (ussd_test.c:104) by 0x400F5D: main (ussd_test.c:161) Conditional jump or move depends on uninitialised value(s) at 0x506DBCB: gsm_septet_lookup (gsm_utils.c:153) by 0x506DBCB: gsm_7bit_decode_n_hdr (gsm_utils.c:224) by 0x506DC9E: gsm_7bit_decode_n_ussd (gsm_utils.c:246) by 0x40134B: test_7bit_ussd (ussd_test.c:104) by 0x400F5D: main (ussd_test.c:161) Change-Id: Ic31805b6a5a917dfc6284edba6ffdd21246ac20c
* Embedded: add sercomm stubsMax2018-01-213-8/+12
| | | | | | | The sercomm functions are unavailable in case of embedded build. Add stub and link the tests against it. Change-Id: I9bc5cb2f822b1a3ffdc6ec29f46b6bac8288314e
* Embedded: disable stats testMax2018-01-211-1/+5
| | | | | | | | As of 67bdd80a96bdfc49d1aadbd32cca2b53f123d180 the stats.c is effectively disable so we should disable the corresponding tests as well. Change-Id: I42ff7a6619c0a5926fdc2ec779cf04689c567e15
* tests/ussd: fix wrong GSM 04.80 payload lengthVadim Yanitskiy2018-01-171-3/+7
| | | | | | | Previously the same length value was used for both ussd_request and interrogate_ss payloads, despite they are different. Change-Id: I90ae7c51b75dcdb9d8ee042af23d127e6db8771d
* libosmocodec: implement ECU (Error Concealment Unit) for FRPhilipp Maier2018-01-154-2/+352
| | | | | | | | | | | When a bad GSM voice frame is received, it's being replaced by a silence frame. This may cause unpleasant audio effects. This change implements a functionality to craft a replacement frame from the last known good frame. Currently, only FR is supported, support for other codecs may be added latter. Change-Id: I06a21f60db01bfe1c2b838f93866fad1d53fdcd1
* ussd_test.c: fix rc / len debug output confusionVadim Yanitskiy2018-01-132-52/+52
| | | | | | Both len and rc values were swapped in the test output. Change-Id: Iebd82531c6ced5d16b15dad4ff4ce654c82db309
* Use existing function for TLLI encodingMax2018-01-081-4/+4
| | | | | | Use bssgp_msgb_tlli_put() instead of copy-pasted code. Change-Id: I06d60566a19dcae701f8648c19fbd8db6d586f77
* Add function to properly encode RAIMax2018-01-082-7/+6
| | | | | | | | | | | | | Add gsm48_encode_ra() which takes appropriate struct as [out] parameter instead of generic buffer. Using uint8_t buffer instead of proper struct type prooved to be error-prone - see Coverity CID57877, CID57876. Old gsm48_construct_ra() is made into tiny wrapper around new function. The test output is adjusted because of the change in function return value which was constant and hence ignored anyway. Related: OS#1640 Change-Id: I31f9605277f4945f207c2c44ff82e62399f8db74
* ctrl: tighten CTRL input parsingNeels Hofmeyr2017-12-203-114/+74
| | | | | | | | | | | | | | | | Validate that incoming CTRL commands... - have decimal IDs, - return error on trailing characters, - have invalid characters in variable identifiers, - send detailed error messages as reply to the requestor. Adjust ctrl_test.{c,ok}, which best show the change in behavior. Message handling causes log messages on stderr; previously, stderr was empty. Add '[ignore]' in testsuite.at so that the nonempty stderr doesn't cause test failures. Change-Id: I96a9b6b6a3a5e0b80513aa9eaa727ae8c9c7d7a1
* rate_ctr: fix osmo-sgsn DoS: don't return NULL on already used indexNeels Hofmeyr2017-12-201-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent patch I563764af1d28043e909234ebb048239125ce6ecd introduced returning NULL from rate_ctr_group_alloc() when the index passed already exists. Instead of returning NULL, find an unused group index and use that, adjust the error message. In stats_test.c, adjust, and also assert allocated counter group indexes everywhere. Rationale: The original patch causes osmo-sgsn to crash as soon as the second subscriber attempts to establish an MM context. Of course osmo-sgsn is wrong to a) fail to check a NULL return value and crash and b) to fail to allocate an MM context just because the rate counter group could not be allocated (it still rejects the MM context completely if rate_ctr_group_alloc() fails). Nevertheless, the price we pay for rate counter correctness is, at least in this instance, way too high: osmo-sgsn becomes completely unusable for more than one subscriber. Numerous other places exist where rate_ctr_group_alloc() is called with a constant index number; from a quick grep magic I found these possible breaking points: osmo-sgsn/src/gprs/gb_proxy.c:1431: cfg->ctrg = rate_ctr_group_alloc(tall_bsc_ctx, &global_ctrg_desc, 0); osmo-sgsn/src/gprs/gprs_sgsn.c:139: sgsn->rate_ctrs = rate_ctr_group_alloc(tall_bsc_ctx, &sgsn_ctrg_desc, 0); osmo-sgsn/src/gprs/gprs_sgsn.c:270: ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, 0); osmo-sgsn/src/gprs/gtphub.c:888: b->counters_io = rate_ctr_group_alloc(osmo_gtphub_ctx, &gtphub_ctrg_io_desc, 0); osmo-bsc/src/libfilter/bsc_msg_acc.c:87: lst->stats = rate_ctr_group_alloc(lst, &bsc_cfg_acc_list_desc, 0); osmo-pcu/src/bts.cpp:228: m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, &bts_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:793: tbf->m_ctrs = rate_ctr_group_alloc(tbf, &tbf_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:879: tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_ul_egprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:880: tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_ul_gprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:970: tbf->m_dl_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_egprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:977: tbf->m_dl_gprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_gprs_ctrg_desc, 0); osmo-pcu/src/tbf.cpp:1475: ul_tbf->m_ctrs = rate_ctr_group_alloc(ul_tbf, &tbf_ctrg_desc, 0); osmo-pcu/src/bts.cpp:226: m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, &bts_ctrg_desc, 1); We can fix all of these callers and then reconsider returning NULL, but IMO even into the future, rate counter group indexes are not something worth failing to provide service for. For future bugs we should keep the automatic index picking in case of index collisions. We will get an error message barfed and can fix the issue in our own time, while the application remains completely usable, and even the rate counters can still be queried (at wrong indexes, but life is tough). Related: I49aa95b610f2faec52dede2e4816da47ca1dfb14 (osmo-sgsn's segfault) Change-Id: Iba6e41b8eeaea5ff6ed862bab3f34a62ab976914
* ctrl: on parse errors, return a detailed message to senderNeels Hofmeyr2017-12-181-1/+1
| | | | | | | | | | | The recently added ctrl_cmd_parse2() returns non-NULL cmd with error messages upon parsing errors. In handle_control_read(), use ctrl_cmd_parse2() and send those back to the CTRL command sender as reply. Retain the previous "Command parser error" reply only in case ctrl_cmd_parse2() should return NULL, which shouldn't actually happen at all. Change-Id: Ie35a02555b76913bb12734a76fc40fde7ffb244d
* ctrl_test: add two more current parsing bugs to prep for fixNeels Hofmeyr2017-12-182-0/+34
| | | | Change-Id: Id11bc326be2f0bc2746a928354e416495a18baf7
* ctrl: fix mem leak when handling GET_REPLY and SET_REPLYNeels Hofmeyr2017-12-182-5/+2
| | | | | | | | | | | | In ctrl_handle_msg() (code recently propagated from handle_control_read()), talloc_free() the parsed ctrl_cmd in all code paths. In particular, a free was missing in case ctrl_cmd_handle() returns CTRL_CMD_HANDLED. CTRL_CMD_HANDLED is triggered by GET_REPLY / SET_REPLY parsing, as show by ctrl_test.c. With the memleak fixed, adjust expected test output and make a detected mem leak abort the test immediately. Change-Id: Id583b413f8b8bd16e5cf92a8a9e8663903646381
* ctrl_test: show memleak when receiving GET_REPLY and SET_REPLY commandsNeels Hofmeyr2017-12-182-2/+40
| | | | | | | The "memleak!" output shows messages that lack a talloc_free() of the parsed ctrl command buffer. The leak shall be fixed in a subsequent patch. Change-Id: I2c3e4d08b769b9cd77593362ea36a28d681cd042
* ctrl_test: expand to test message handling and detect mem leaksNeels Hofmeyr2017-12-182-57/+197
| | | | | | | Subsequent patches that tighten CTRL input validation will make the results more interesting. Change-Id: Idd4cc7d193db1a7d761f72ed33ed46eea450a78f
* ctrl_test.c: replace print_escaped() with new osmo_escape_str()Neels Hofmeyr2017-12-182-60/+28
| | | | Change-Id: I12d3828dcc925f97fde11c360f1d60f3bd8cad8b
* utils: add osmo_escape_str()Neels Hofmeyr2017-12-182-0/+77
| | | | | | | | | | | | | To report invalid characters in identifiers, it is desirable to escape any weird characters. Otherwise we might print stray newlines or control characters in the log output. ctrl_test.c already uses a print_escaped() function, which will be replaced by osmo_escape_str() in a subsequent patch. control_cmd.c will use osmo_escape_str() to log invalid identifiers. Change-Id: Ic685eb63dead3967d01aaa4f1e9899e5461ca49a
* Do not allocate already existing counter groupMax2017-12-171-1/+6
| | | | | | | | Check that no group with the given name and index already exist before allocating it. Add corresponding test case. Change-Id: I563764af1d28043e909234ebb048239125ce6ecd Related: OS#2757
* gsm0808_create_cipher_reject: Fix encoding of Cause IEHarald Welte2017-12-171-1/+1
| | | | | | | | | The Cause IE in the 08.08 CIPHER MODE REJECT is a normal TLV IE, and not just a value. Let's make sure we encode the cause value properly. Change-Id: I4f5b231edf6dcb0a9c2bbafb2a59f301f3b2402b Closes: OS#2766
* Add functions for extended RACH codingMax2017-12-113-2/+30767
| | | | | | | | | | | Add support for extended RACH (11 bit) according 3GPP TS 45.003 ยง5.3.2: * convolutional code with puncturing * encoding/decoding routines * corresponding tests Change-Id: I85a34a82d5cd39a594ee89d91a2338226066ab5d Related: OS#1548
* Fix malformed Abis/RSL messages with extra L3 Information fieldPau Espin Pedrol2017-12-102-8/+2
| | | | | | | | | | | | | | | | | Some Abis/RSL messages such as "Release Indication" contained 3 extra bytes from an L3 Information header which should not be there according to specs in GSM 08.58 (section 8.3 "Radio link layer management messages"). Other RSL messages were affected by the same issue, except for "Establish Indication", which had already a workaround in send_rslms_dlsap. This commit fixes the issue in a generic way, removes the "Establish Indication" and fixes the test accounting for the bug, as it otherwise fails after applying the changes. Fixes: OS#1635, OS#2336 Change-Id: Ibb116214e8b1798d65a8b0917150496a3c14f344
* license: Fix the license to GPLHolger Hans Peter Freyther2017-12-093-12/+15
| | | | | | | | This was always intended to be GPL and not AGPL. "kat" did the development as part of an internship paid by me and we agreed to shared copyright. Change-Id: Ied2041ba20c5737bd967dfaa3017edf72a95b31c
* Embedded: fix sercomm testMax2017-12-051-0/+4
| | | | | | | | | | | The external sercomm_drv_[un]lock() functions are defined as stubs in case of non-embedded build only which causes linking issue with sercomm_test. Let's define the same stubs in sercomm_test unconditionally - the implementation details of the locking are irrelevant for the test anyway. Related: OS#2708 Change-Id: I3dab4f3348871b66b5d6c9fd10b2e448c61f9e73
* embedded: fix testsMax2017-12-041-5/+5
| | | | | | | | | | | In case of embedded build some tests are failing to link properly. Fix it: * do not run fsm_test unless CTRL is enabled * do not run fr_test unless GB is enabled * do not link loggingrb_test with libosmovty Change-Id: Icedad5ba3ed311ccdb97fa3ccd3002f5fda8be68
* coding test: use OSMO_ASSERTMax2017-11-301-17/+10
| | | | Change-Id: I896d6aaae3c36b87243b7dc270267090dcb44afe
* coding test: move bit dump into functionsMax2017-11-281-123/+48
| | | | Change-Id: I65c75e56831420d3daf386ea280c13ae9cb64d1b
* coding test: enable debug outputMax2017-11-282-125/+4293
| | | | Change-Id: I1ec23ca3cf0d973c77b8c4e7e23e0e75a4f0a7a3