aboutsummaryrefslogtreecommitdiffstats
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2017-09-27vty: install 'exit', 'end',... commands on *all* nodesNeels Hofmeyr1-3/+0
In many callers of the VTY API, we are lacking the vty_install_default() step at certain node levels. This creates nodes that lack the 'exit' command, and hence the only way to exit such a node is to restart the telnet session. Historically, the VTY looked for missing commands on the immediate parent node, and hence possibly found the parent's 'exit' command when the local node was missing it. That is why we so far did not notice the missing default commands. Furthermore, some callers call install_default() instead of vty_install_default(). Only vty_install_default() also includes the 'exit' and 'end' commands. There is no reason why there are two sets of default commands. To end this confusion, to catch all missing 'exit' commands and to prevent this from re-appearing in the future, simply *always* install all default commands implicitly when calling install_node(). In cmd_init(), there are some top-level nodes that apparently do not want the default commands installed. Keep those the way they are, by changing the invocation to new install_node_bare() ({VIEW,AUTH,AUTH_ENABLE}_NODE). Make both install_default() and vty_install_default() no-ops so that users of the API may still call them without harm. Do not yet deprecate yet, which follows in Icf5d83f641e838cebcccc635a043e94ba352abff. Drop all invocations to these two functions found in libosmocore. Change-Id: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
2017-09-20vty_test: add artificial node levels for better testingNeels Hofmeyr13-39/+440
In vty_test, add three levels of parent nodes (level1, level2, level3) with each having a leaf child (child1, child2, child3). Use these to enhance the vty_test cfg files and test more diverse situations. The current VTY code expects a go_parent_cb() to be present, otherwise it will bump right back to the CONFIG_NODE, which will not work with more than one node level below the CONFIG_NODE. Hence provide a minimal go_parent_cb(). Change-Id: Ib9bcf58b655fbd85e196f363fb7d8305d7dfc997
2017-09-20fix vty regression: empty parent nodeNeels Hofmeyr4-0/+6
The recent exit-by-indent patch breaks a VTY case where a node is entered but directly followed by a sibling or ancestor without listing any child nodes. Regression introduced by I24cbb3f6de111f2d31110c3c484c066f1153aac9. An example is a common usage in osmo-bts, where 'phy N' / 'instance N' is a parent node that is commonly left empty: phy 0 instance 0 bts 0 band 1800 Before this patch, this case produces the error: There is no such command. Error occurred during reading the below line: bts 0 Fix indentation parsing logic in command.c to accomodate this case. Add a unit test for empty parent node. Change-Id: Ia0880a17ae55accb092ae8585cc3a1bec9986891
2017-09-19VTY: implicit node exit by de-indenting, not parent lookupNeels Hofmeyr14-1/+95
Note: This will break users' config files if they do not use consistent indenting. (see below for a definition of "consistent".) When reading VTY commands from a file, use indenting as means to implicitly exit child nodes. Do not look for commands in the parent node implicitly. The VTY so far implies 'exit' commands if a VTY line cannot be parsed on the current node, but succeeds on the parent node. That is the mechanism by which our VTY config files do not need 'exit' at the end of each child node. We've hit problems with this in the following scenarios, which will show improved user experience after this patch: *) When both a parent and its child node have commands with identical names: cs7 instace 0 point-code 1.2.3 sccp-address osmo-msc point-code 0.0.1 If I put the parent's command below the child, it is still interpreted in the context of the child node: cs7 instace 0 sccp-address osmo-msc point-code 0.0.1 point-code 1.2.3 Though the indenting lets me assume I am setting the cs7 instance's global PC to 1.2.3, I'm actually overwriting osmo-msc's PC with 1.2.3 and discarding the 0.0.1. *) When a software change moves a VTY command from a child to a parent. Say 'timezone' moved from 'bts' to 'network' level: network timezone 1 2 Say a user still has an old config file with 'timezone' on the child level: network bts 0 timezone 1 2 trx 0 The user would expect an error message that 'timezone' is invalid on the 'bts' level. Instead, the VTY finds the parent node's 'timezone', steps out of 'bts' to the 'network' level, and instead says that the 'trx' command does not exist. Format: Consistent means that two adjacent indenting lines have the exact same indenting characters for the common length: Weird mix if you ask me, but correct and consistent: ROOT <space>PARENT <space><tab><space>CHILD <space><tab><space><tab><tab>GRANDCHILD <space><tab><space><tab><tab>GRANDCHILD2 <space>SIBLING Inconsistent: ROOT <space>PARENT <tab><space>CHILD <space><space><tab>GRANDCHILD <space><tab><tab>GRANDCHILD2 <tab>SIBLING Also, when going back to a parent level, the exact same indenting must be used as before in that node: Incorrect: ROOT <tab>PARENT <tab><tab><tab>CHILD <tab><tab>SIBLING As not really intended side effect, it is also permitted to indent the entire file starting from the root level. We could guard against it but there's no harm: Correct and consistent: <tab>ROOT <tab><tab>PARENT <tab><tab><tab><tab>CHILD <tab><tab>SIBLING Implementation: Track parent nodes state: whenever a command enters a child node, push a parent node onto an llist to remember the exact indentation characters used for that level. As soon as the first line on a child node is parsed, remember this new indentation (which must have a longer strlen() than its parent level) to apply to all remaining child siblings and grandchildren. If the amount of spaces that indent a following VTY command are less than this expected indentation, call vty_go_parent() until it matches up. At any level, if the common length of indentation characters mismatch, abort parsing in error. Transitions to child node are spread across VTY implementations and are hard to change. But transitions to the parent node are all handled by vty_go_parent(). By popping a parent from the list of parents in vty_go_parent(), we can also detect that a command has changed the node without changing the parent, hence it must have stepped into a child node, and we can push a parent frame. The behavior on the interactive telnet VTY remains unchanged. Change-Id: I24cbb3f6de111f2d31110c3c484c066f1153aac9
2017-09-08VTY: interactive: never look for matching commands on parent nodeNeels Hofmeyr2-7/+3
For interactive telnet VTY, remove the implicit move up to the parent node when a command did not succeed on the current node level. When reading config files, this behavior was useful to allow skipping explicit 'exit' commands. (A different patch deals with that.) In the telnet VTY, this behavior was never necessary. Explicit 'exit' commands can move to the parent node, and typically uninformed users expect to require that. On a telnet VTY, counting indents like for reading config files is not an option: a user will always type from the first column or may paste some leading spaces without intended meaning. After this patch, it is thus no longer possible to paste a complete config across several node levels directly to a telnet session, unless it contains 'exit' commands. Change-Id: Id73cba2dd34676bad8a130e9c45e67a272f19588
2017-09-01libosmogsm: add Routing Area Identifier testMax2-0/+57
Ensure that gsm48_parse_ra() and gsm48_construct_ra() behave properly. Change-Id: I27117fe728407dd10886459e89ba4ff9d5e53e6b
2017-08-29umts aka: add sqn_ms out-param, print SQN.MS in osmo-auc-genNeels Hofmeyr1-0/+9
When doing UMTS AKA with AUTS, it can be interesting to know the SQN.MS that was encoded in the AUTS. The only way to know this is to provide it as a separate out-parameter from milenage_gen_vec_auts(), because the SQN.MS from AUTS stored in umts.sqn is immediately modified non-trivially by milenage_gen_vec(). Add sqn_ms to struct osmo_sub_auth_data to retain SQN.MS even after a vector was generated. Use this to print out SQN.MS for 'osmo-auc-gen -3 -A'. Adjust test suite expectations. Related: OS#2464 Change-Id: I9fc05bbf169d06716f40b995154fd42a3f91bef3
2017-08-29osmo-auc-gen: umts: print out the IND of the SQN usedNeels Hofmeyr1-0/+15
Make ind_mask available in the main(){} scope, in order to print out IND = SQN & ind_mask. Adjust test suite expectations. Related: OS#2465 Change-Id: I91eac53c4af66a58b9372d9baf5781fc9f29b1fc
2017-08-29osmo-auc-gen: umts: add --ind-len argNeels Hofmeyr3-0/+88
osmo-auc-gen so far does not allow indicating the IND bit length of SQN. A default of 5 serves most practical cases, nevertheless we should allow passing arbitrary IND lengths. Enhance the test suite to test --ind-len. Related: OS#2465 Change-Id: Ia1d8b6a823ffc92290b3e39e4e4665aeff80ccc0
2017-08-29osmo-auc-gen: umts: add --ind argNeels Hofmeyr3-1/+91
During UMTS AKA, the caller typically indicates which IND slot the next used SQN should belong to. Without this option, osmo-auc-gen will always produce SQN from IND-slot 0. Add --ind option. Enhance the osmo-auc-gen_test.sh to expect errors with useful printouts on stderr, and add tests that verify valid --ind ranges. Related: OS#2465 Change-Id: Ib60eec80d58ca9a0a01e7fbd2bcbbd4339b1a6d8
2017-08-29osmo-auc-gen: umts: use default of ind_bitlen = 5 instead of 0Neels Hofmeyr1-2/+2
Most USIM out there seem to use IND-length = 5 bits, so do sysmousim-sjs1. Currently from initialization we are using an IND length of zero in osmo-auc-gen, which produces confusing SQN results after AUTS: Where want SQN to be incremented to the next IND array, usually +32, an IND-len of 0 makes for only +1. As result, the osmo-auc-gen_test.sh produces SQN 32 instead of 24 after receiving SQN.MS = 23 from AUTS: adjust test expectations. Related: OS#2465 Change-Id: I9fcc11fa2b5816302dcc6b72249b1ee40d5a61f5
2017-08-29osmo-auc-gen: umts: remove erratic SQN.MS printoutNeels Hofmeyr1-1/+0
osmo-auc-gen tries to be helpful by deriving the SQN.MS from the SQN that resulted from AUTS + milenage_gen_vec(), but there is actually no way to derive the actual AUTS SQN.MS from the resulting SQN. Completely drop the printout to prevent confusion. Adjust test suite expectations. Related: OS#2464 Change-Id: Ie2432c6d6a23818f7b3a29b1295dcbb505e2be53
2017-08-29cosmetic: test for osmo-auc-gen: print error for missing binaryNeels Hofmeyr1-0/+6
Change-Id: I98c23ae6378a16cf3b76c90d4ea0dfcf61ff3033
2017-07-10Add pseudo-random bit sequence generator to libosmcooreHarald Welte4-2/+74
These PRBS sequences are specified in ITU-T O.150. They are typically used as test data to be transmitted for BER (bit error rate) testing. Change-Id: I227b6a6e86a251460ecb816afa9a7439d5fb94d1
2017-07-07gsup: Add encoding/decoding for the pdp charging characteristicsHolger Hans Peter Freyther2-5/+8
These fields can be in the ISD and the PDP Context inofmration. Store pointers to this IE in both cases. It needs to be used by the SGSN when opening a PDP context. Change-Id: Iedc7c02adcf77ca5c9545119e19c968dfbbb3e6b
2017-07-03osmo_sock_get_name(): clearly indicate local and remoteNeels Hofmeyr1-3/+3
In a string like 127.0.0.1:2905<->127.0.0.1:60661 it is hard to tell which is the local part. I'd have expected it on the left, but it is actually on the right. To avoid doubt and bypass bikesheds on which side should be what, clearly mark the two sides as remote and local. (r=127.0.0.1:2905<->l=127.0.0.1:60661) Change-Id: I43dcc6a1906429bd0955fd7fe2eb5b8495b592d8
2017-06-22sercomm_test.c: return correctly in mainPau Espin Pedrol1-0/+1
Change-Id: I57fd3e1bf74ec24dec692710359a1ce00ecde75a
2017-06-22gsm0808: fix AoIP speech codec element parser/generatorPhilipp Maier1-41/+36
The implementation of the parser/generator for the speech codec information element slightly wrong, making it impossible to use it properly. (See also: 3GPP TS 48.008, 3.2.2.103) Change-Id: Idabb0f9620659557672e1c6b90c75481192e5c89
2017-06-22abis_test.c: Fix warning appearing on some buggy gcc versionsPau Espin Pedrol1-2/+4
Change-Id: I31d5ffc0cf461d207d6c3d43aa0a25a5448d7000
2017-06-21lapd_test.c: Convert compilation warning to level messagePau Espin Pedrol1-1/+1
This way we clean the build of warnings completely and we can enable -Werror but we still see this FIXME message while compiling. Change-Id: I24c11226cd5bb5b6032f4ece7d1a0695dc82f0dd
2017-06-18tlv_test.c: Fix compilation warningsPau Espin Pedrol1-19/+25
Several warnings like the one below are fixed: warning: array subscript is below array bounds [-Warray-bounds] uint8_t *unchanged_ptr = buf - 1; Change-Id: I35d7d926939c14700cbca732bd64e588c75424b4
2017-06-18gprs_ns_test.c: Remove unused byte arraysPau Espin Pedrol1-49/+0
Commit 0d4e949e229a649ffd0503d8e930dba8be7dd34d changed the code to use functions with local variables holding the bytes, but forgot to remove the old global variables. This test fixes compilation warnings. Change-Id: I140de30038222b0419423d8c4f9da1946651a4e7
2017-06-18sms_test.c: Remove test of deprecated wrapper functionPau Espin Pedrol2-27/+0
The deprecated function is just a wrapper, and it triggers a compilation warning. Change-Id: Iaac701bdf0c0e66c343f68cc31d82550a024ef57
2017-06-13ctrl_test.c: fix build with GCC 7.1.1Vadim Yanitskiy1-1/+1
According to GCC's online docs: When an inline function is not static, then the compiler must assume that there may be calls from other source files; since a global symbol can be defined only once in any program, the function must not be defined in the other source files, so the calls therein cannot be integrated. Therefore, a non-static inline function is always compiled on its own in the usual fashion. There is no any (performance or size) benefit from 'inline' keyword in this particular file, so let's replace one by 'static'. Change-Id: I11e1f1cfea09c6f0cf8225239e782b551d3eb52f
2017-06-09Fix wrongful GSM FR codec SID frame detection in DTX.Jean-Francois Dionne2-1/+17
Based on ETSI TS 101 318 section 5.1.2 the 95 bits SID code word is not detected correctly due to a wrongful offset in the bits location indexes. Change-Id: I45d98c6edf267f313883503a65385190ffbc65ca
2017-06-09introduce proper test case for GSM FR detectionHarald Welte2-0/+98
our code is actually wrong, so let's skip the test until the fix is applied in a follow-up patch. Change-Id: I710c7871f959671deb3d18ab9062588f3056fd7c
2017-05-18tests/Makefile.am: do not test disabled featuresVadim Yanitskiy1-4/+19
Compiling tests for disabled features breaks build. Change-Id: Iebcc24b493092a5a8e3561d7642a0b4608a8beae
2017-05-17add sercomm unit testHarald Welte4-2/+169
Change-Id: I9e2e7fcda28e7c6844d5faa09e02acf537cea44d
2017-05-15fsm_test.c: fix unreachable checkVadim Yanitskiy1-1/+3
Change-Id: Ic3d5da00f7ece6dbcd4c999187a5748c9331e60f
2017-05-15introduce byteswap.h with osmo_{htonl,ntohl,htons,ntohs}Harald Welte4-2/+45
We need to have an architecture-independend way of endian conversion / byte swapping functions which will also work on embedded (bare iron) builds. Let's introduce osmocom/core/bytesawp.h for this purpose. Change-Id: Ibc0cc1e36d4ed63a35cf8ceff3af0f26e5ac7a3d
2017-05-14kasumi_test.c: fix incomplete checkVadim Yanitskiy1-8/+8
Previously the 'passed' variable in test_expansion() was being overwritten on every call of _compare_mem(), so only the result of last call influenced the test result. Change-Id: Ibf3ab453c20c7eeec234b95bfe14b497c572c35f
2017-05-09timer: add osmo_timer_setup()Pablo Neira Ayuso1-6/+3
Add a new function timer function to set up the timer, similar to what we have in the Linux kernel. This patch also converts existing opencoded timer setup in the libosmocore tree as initial client of this new function. This patch implicitly removes function callback passed by reference that defeat compile time type validation. Compile-tested only, but I ran make check that reports success when testing timer infrastructure. Change-Id: I2fa49972ecaab3748b25168b26d92034e9145666
2017-05-09vty: cleanup logging functionsMax1-1/+1
* remove unused parameter from logging_vty_add_cmds() * mark log level descriptors static * change internal static function int check_log_to_target() to more appropriate bool should_log_to_target() * deprecate log_vty_command_*() from public API as it should only be used by logging_vty_add_cmds() Change-Id: I0e9ddd7ba3ce211302d99a3494eb408907a2916e Related: OS#71
2017-04-30tests/conv: add GSM 05.03 specific testVadim Yanitskiy5-5/+354
This change extends the convolutional code test coverage, adding the GSM 05.03 specific test vectors, generated by the conv_gen.py. Inspired by Tom's patch: http://lists.osmocom.org/pipermail/openbsc/2014-April/007364.html Change-Id: I76d1cd4032d2f74c5bb93bde4fab99aa655b7f1a
2017-04-28Add SW Description (de)marshallingMax4-2/+260
* data structure representing 3GPP TS 52.021 ยง9.4.62 SW Description * function to serialize it into msgb * function to deserialize it from buffer * functions to extract/estimate buffer size for SW Description * test harness (partially taken from OpenBSC) There are several similar functions to deal with SW Description in OpenBSC, there's also need to use similar functionality in OsmoBTS. Hence it's better to put the code into common library with proper tests and documentation. Change-Id: Ib63b6b5e83b8914864fc7edd789f8958cdc993cd Related: OS#1614
2017-04-27control_if: Add control interface commands for FSMsHarald Welte2-11/+45
This allows programmatic access to introspection of FSM instances, which is quite handy from e.g. external test cases: Send a message to the code, then use the CTRL interface to check if that message has triggered the right kind of state transition. Change-Id: I0f80340ee9c61c88962fdd6764a6098a844d0d1e
2017-04-27control_if: Add helper function for 'local execution' of control commandHarald Welte1-1/+1
Sometimes (particularly when testing), we may want to parse+execute an arbitrary control command simply form a string buffer, rather than from a msgb. Let's add a helper for that. Change-Id: Iaca748e0d942bb2a1ee7c2776b37485e1439eb0c
2017-04-16osmo_fsm: Lookup functions to find FSM Instance by name or IDHarald Welte2-9/+15
Introduce two lookup helper functions to resolve a fsm_instance based on the FSM and name or ID. Also, add related test cases. Change-Id: I707f3ed2795c28a924e64adc612d378c21baa815
2017-04-09Add osmo_sock_init2() function, allowing both BIND *and* CONNECTHarald Welte3-0/+57
The old osmo_sock_init() function allows only either a bind (for a server socket), or a connect (for a client socket), but not both together. So there's no way to have a client socket that is bound to a specific local IP and/or port, which is needed for some use cases. Change-Id: Idab124bcca47872f55311a82d6818aed590965e6
2017-04-08gsm0808: make gsm0808_create_reset_ack() accessiblePhilipp Maier2-0/+14
The create function to generate the RESET ACKNOWLEDGE message is not accessible from outside, as it does not appear in limosmogsm.map. It also has not testcase. This commit adds gsm0808_create_reset_ack() to the map file and also adds a testcase. Change-Id: I82d3411484f82b4a9205d407fa0442244678f183
2017-04-08gsm0808: Add create functions for BSS_MAP_MSG_ASSIGMENT_RQSTPhilipp Maier2-0/+51
gsm0808.h/c lacks functionality to generate BSS_MAP_MSG_ASSIGMENT_RQST messages. These messages are required if the code is used in an MSC implementation. This commit adds a gsm0808_create_assignment() function, that generates an A/AoiP BSS_MAP_MSG_PAGING message. Change-Id: I4d1d455a1e1cf95407e23ded7b7defbcf2dd6ff0
2017-04-08gsm0808: Add create functions for BSS_MAP_MSG_PAGINGPhilipp Maier2-0/+43
gsm0808.h/c lacks functionality to generate BSS_MAP_MSG_PAGING messages. These messages are required if the code is used in an MSC implementation. This commit adds a gsm0808_create_paging() function, that generates an A/AoiP BSS_MAP_MSG_PAGING message. Change-Id: I9afecf0109305ca5153bf081bb29cd94071dd2b7
2017-04-08gsm0808: Add create functions for CIPHER MODE COMMANDPhilipp Maier2-0/+42
gsm0808.h/c lacks functionality to generate CIPHER MODE COMMAND messages. These messages are required if the code is used in an MSC implementation. This commit adds a gsm0808_create_cipher() function, that generates an A/AoiP CIPHER MODE COMMAND message. Change-Id: I8eb1c357860c3e740b0f5d17e1c256bc87920958
2017-04-08gsm0808: Add utils for Cell Identifier ListPhilipp Maier1-0/+85
The planned support for true A over IP requires the encoding of the a Cell Identifier List element (see also BSS_MAP_MSG_PAGING). This commt adds encoding/decoding functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: I625245dd1dd396fc2bc189e8cd2c444a33042528
2017-04-08gsm0808: Add utils for Encryption InformationPhilipp Maier1-0/+40
The planned support for true A over IP requires the encoding of the an Encryption Information element (see also BSS_MAP_MSG_CIPHER_MODE_CMD). This commt adds encoding/decoding functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: I8262050a9d9fd3f17462cfbb046c6e034dccc6fb
2017-04-08gsm0808: Add utils for Channel TypePhilipp Maier1-0/+31
The planned support for true A over IP requires the encoding of the a Channel Type element (see also ASSIGNMENT REQUEST). This commt adds encoding/decoding functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: Id0e2164d84b8cbcc6fe6a090fc7f40a1251421d7
2017-04-08gsm0808: Add AoIP specific elements to gsm0808_create_... functionsPhilipp Maier2-0/+118
the classic A implementation in libosmocore lacks support for AoIP message elements. This patch adds support for AoIP by adding a set of new gsm0808_create_..., which support the missing AoIP message elements Change-Id: I77f866abec1822d19871052f3c647ad782785b34
2017-04-08gsm0808: Add utils for Speech Codec List and Speech CodecPhilipp Maier1-0/+124
The planned support for true A over IP requires the encoding and decoding of a so called "Speech Codec Element" element. This commt adds parsing functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: I0e1e2edf47adaa45b22d4b0bcae3640dba7ca200
2017-04-08gsm0808: Add utils for AoIP Transport Layer AddressPhilipp Maier1-0/+64
The planned support for true A over IP requires the encoding and decoding of a so called "AoIP Transport Layer Address" element. This commt adds parsing functionality and tests for the element mentioned above, however, it is not yet actively used. Change-Id: I57933b0a06a3f54ec2a41e6ecb6ced9fbbc89332
2017-03-15ctrl_type_vals: explicitly terminateNeels Hofmeyr1-1/+1
Don't use CTRL_TYPE_UNKNOWN as value_string[] terminator, use an explicit, more obvious { 0, NULL } termination. Set an explicit string for CTRL_TYPE_UNKNOWN. No other value_string[]s to date have such a "hidden" terminator. BTW, a { 0, "string" } item is not a terminator, only { 0, NULL } is, so we can set a string for CTRL_TYPE_UNKNOWN == 0. Also, having a string value for CTRL_TYPE_UNKNOWN is not harmful because all code paths explicitly check for the CTRL_TYPE_*s that are valid. Adjust the test expectation. From the ctrl_type_vals enum, remove the = 0, because it is implicitly 0 anyway. One motivation to press this fixup: I am trying to add a script that checks whether all value_string[]s are terminated to our jenkins jobs, and to find that this one is terminated, it would need to interpret the CTRL_TYPE_UNKNOWN constant, which would make things far more complex. At this point, all of the value_string[]s have an explicit termination, and I would like to enforce this from now on -- for readable code and to not spend more time on the validator. The patch adding ctrl_type_vals (Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28) was accepted by another reviewer before I could reconfirm my -1, so this is a fixup to enable the termination checking script patches. Related: I2bc93ab4781487e7685cfb63091a489cd126b1a8 (adds script to libosmocore) I7fe3678b524d602fc6aa14bc0ed06308df809a3e (uses in jenkins.sh) Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28 (adds ctrl_type_vals) Change-Id: Ia99f37464c7b36b587da2cc78f52c82725f02cbc