aboutsummaryrefslogtreecommitdiff
path: root/src/tests/test-modem-helpers.c
AgeCommit message (Collapse)Author
2023-12-01modem-helpers: improve CGDCONT read response parsingPetr Krasnoshchekov
SIM A7600E-H sends only 3 parameters in CGDCONT read response (+CGDCONT: 1,"IP","nate.sktelecom.com"). The parsing regex requeres 4 parameters, so the response is not matched. In addition fourth parameter is not used by parsing code.
2022-09-05core: port GRegex/GMatchInfo to use autoptr()Aleksander Morgado
The behavior of GRegex changed in 2.73.2 once it was ported from pcre1 to pcre2. In some cases it was made more strict, which is fine, in other cases it exposed some change in how it behaves on certain matches that is not extremely clear whether it's ok or not. See https://gitlab.gnome.org/GNOME/glib/-/issues/2729 See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/601 See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/621 Either way, one thing that was assumed was that initializing all GRegex/GMatchInfo variables to NULL and making sure they're NULL before they're initialized by glib (especially the GMatchInfo) was a good and safer approach. So, whenever possible, g_autoptr() is used to cleanup the allocated GMatchInfo/GRegex variables, and otherwise, g_clear_pointer() is used to ensure that no free/unref is attempted unless the given variable is not NULL, and also so that the variable is reseted to NULL after being disposed.
2022-09-02test-modem-helpers: add EOL to strings matched with G_REGEX_NEWLINE_CRLFAleksander Morgado
Looks like pcre2 (used since glib 2.73.2) requires EOLs to match if G_REGEX_NEWLINE_CRLF is explicitly used. The tests are updated accordingly, because the modem responses will anyway have the EOLs as well. See https://gitlab.gnome.org/GNOME/glib/-/issues/2729#note_1544130 Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/601
2022-03-16test,modem-helpers: add test for the EM9191 COPS=? responseAleksander Morgado
Including 5GNR network reporting (act=12) https://forum.sierrawireless.com/t/5g-network-scan-with-the-em9191-operation-not-allowed/26374/9
2022-03-16modem-helpers: improve and fix COPS=? numeric fields parsingAleksander Morgado
The numeric fields in the +COPS=? response were relying on a very weak parsing logic, assuming that they were single-digit numeric values and not using the common string to integer conversion utilities. This commit improves the conversion from the 3GPP/ETSI defined network availability and access technology values to the MM defined ones, providing enum-based matches even if the numeric values are the same. The commit also fixes the parsing of access technology values > 10, required to report 5G related values.
2021-10-22cli, plugins: factorize usage of iso8601 datetime formatFrederic Martinsons
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com> Includes updates by Aleksander Morgado to fix coding style issues.
2021-09-08mm-modem-helpers: only parse calls in voice modeDylan Van Assche
Calls in a CLCC response in data-only or fax-only mode do not count as actuall calls.
2021-08-02test,modem-helpers: add test case of AT+CPOL? response parsingTeijo Kinnunen
2021-06-16helpers: skip g_warning() in mm_3gpp_parse_ws46_test_response()Aleksander Morgado
Use mm_obj_warn() instead.
2021-05-17modem-helpers: add 3 digit MNC output to mm_3gpp_parse_operator_id()Teijo Kinnunen
MNC digit count information is lost on conversion to integers. Make it possible for the caller to get this information through a separate boolean.
2021-04-29modem-helpers: new profile list helpersAleksander Morgado
The new helpers allow converting a PDP context list returned from the +CGDCONT? parser to a list of 3GPP profile objects. The new mm_3gpp_profile_list_find_best() method is equivalent to the mm_3gpp_select_best_cid() one, but using profile objects as input/output instead of specific settings. The unit tests that were testing mm_3gpp_select_best_cid() are also converted to use mm_3gpp_profile_list_find_best().
2021-02-23helpers: rework normalize_operator() to use str_to_utf8()Aleksander Morgado
Instead of blindly assuming that we can take whatever string given as valid UTF-8, we'll always attempt to convert from the current modem charset into UTF-8. Before we were doing this for hex-encoded UCS2, but not for example for GSM-7. And due to the now applied GSM-7 conversion, the mf627a/mf627b +COPS parsing unit tests are updated accordingly, because when converting from an input string that contains byte 0x40 ('@' in UTF-8) as if it were GSM-7, the 0x40 is taken as character '¡', encoded as 0xc2,0xa1 in UTF-8).
2020-10-16mm-modem-helpers: add low_nybble_first argument to mm_bcd_to_stringEric Caruso
All BCD-encoded strings used by MM currently have the low nybble of each byte come before the high nybble, but some strings (such as the EID string returned by QMI Get Slot Status) are meant to be read in order with the high nybble before the low one. As such, extend mm_bcd_to_string to decode both.
2020-04-09tests,modem-helpers: regex number is index of an array, so starts at 0Aleksander Morgado
2020-04-09test,modem-helpers: use MMModem3gppRegistrationState values in testsAleksander Morgado
2020-04-09broadband-modem: run +C5GREG state checksAleksander Morgado
The generic CREG parser is improved to also allow parsing +C5GREG responses and URCs.
2020-04-09helpers: use generic number parsing methods in CREG parserAleksander Morgado
This fixes the s8500 wave unit test, which was incorrectly parsing the Act field reported as 'B' as "GSM" (strtol(B)=0) Also, given that the generic parsing methods are able to parse numbers from quoted strings, this change allows us to remove the Thuraya specific CREG matching that just took into consideration quoted strings. The Thuraya unit tests are also fixed up to provide proper testing of the logic.
2020-04-09test,modem-helpers: remove obsolete comments in u-blox CREG testsAleksander Morgado
We already support "SMS only" registration state.
2020-04-08log: common logging method definition for all testers and helpersAleksander Morgado
2020-04-08modem-helpers: make cpms test parser return error on failureAleksander Morgado
2020-04-08modem-helpers: port ccwa service query parser to use object loggingAleksander Morgado
2020-04-08modem-helpers: port cesq response parser to use object loggingAleksander Morgado
2020-04-08modem-helpers: port creg response parser to use object loggingAleksander Morgado
2020-04-08modem-helpers: port clcc list parser to use object loggingAleksander Morgado
2020-04-08modem-helpers: remove unused supported capabilities filterAleksander Morgado
2020-04-08modem-helpers: port cmer test parser to use object loggingAleksander Morgado
2020-04-08modem-helpers: parse cgdcont test parser to use object loggingAleksander Morgado
2020-04-08modem-helpers: port cid selection helper to use object loggingAleksander Morgado
2020-04-08modem-helpers: port cops test parser to use object loggingAleksander Morgado
2020-04-08modem-helpers: port ifc test parser to use object loggingAleksander Morgado
2020-04-08modem-helpers: port supported modes filtering to use object loggingAleksander Morgado
2020-04-08modem-helpers: port device identifier to use object logging and autoptrAleksander Morgado
2020-04-08log: new object logging supportAleksander Morgado
So that we can provide the specific object id in every log associated to a given object.
2020-01-31test-modem-helpers: fix warnings with -Wswitch-enumAleksander Morgado
test-modem-helpers.c: In function ‘test_cgev_indication’: test-modem-helpers.c:2165:9: error: enumeration value ‘MM_3GPP_CGEV_UNKNOWN’ not handled in switch [-Werror=switch-enum] 2165 | switch (type) { | ^~~~~~ cc1: all warnings being treated as errors
2020-01-31test-modem-helpers: fix warnings with -Wsign-compareAleksander Morgado
test-modem-helpers.c: In function ‘test_creg_match’: test-modem-helpers.c:1127:19: error: comparison of integer expressions of different signedness: ‘int’ and ‘guint’ {aka ‘unsigned int’} [-Werror=sign-compare] 1127 | for (i = 0; i < array->len; i++) { | ^
2020-01-31test-modem-helpers: fix warnings with -Wdiscarded-qualifiersAleksander Morgado
test-modem-helpers.c: In function ‘test_cmgl_response_generic’: test-modem-helpers.c:294:20: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] 294 | .pdu = "07914306073011F00405812261F700003130916191314095C27" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...
2020-01-06broadband-modem: +COPS=? response may give strings in UCS2Aleksander Morgado
If the charset selected via CSCS is UCS2, the modem may decide to return all the strings in the +COPS=? response in UCS2: <debug> (ttyACM0): --> 'AT+COPS=?<CR>' <debug> (ttyACM0): <-- '<CR><LF>+COPS: (2,"004D006F007600690073007400610072","004D006F007600690073007400610072","00320031003400300037",7) <debug> Found network '00320031003400300037' ('004D006F007600690073007400610072','004D006F007600690073007400610072'); availability: current, access tech: lte
2019-10-17sim: load emergency numbers from EF_ECCAleksander Morgado
2019-10-14tests: print MM logs only on verbose test modeAleksander Morgado
Therefore, avoid needing ENABLE_TEST_MESSAGE_TRACES build symbol.
2019-10-14tests: avoid g_print() and use g_debug() insteadAleksander Morgado
The debug-level logs won't be printed e.g. during 'make check', but will be included when running the tester manually.
2019-09-13broadband-bearer: setup cid selection as a testable methodAleksander Morgado
Rework how the broadband bearer runs CGDCONT? and CGDCONT=? and setup a helper method to perform the CID selection logic. Also, implement unit tests for the CID selection logic.
2019-07-19broadband-modem,voice: implement call waiting status setup/query with +CCWAAleksander Morgado
2019-07-11helpers: new '+CLCC' test response parserAleksander Morgado
2019-07-11broadband-modem: implement +CCWA URC handlingAleksander Morgado
2019-06-28modem-helpers: ignore format of unneeded fields in +CLIP URCAleksander Morgado
The regex was expecting empty values in several of the fields, which is wrong. Instead of matching empty fields, just ignore all fields that we don't require in our logic.
2018-11-26broadband-modem: enable and handle +CGEV indicationsAleksander Morgado
The +CGEV indications allow us to get notified of packet domain events like network-initiated or ME-initiated disconnections on specific connected contexts, as well as full PS detach events (all contexts disconnected). If the modem supports these indications, we will enable them with +CGEREP and will then process them when they are emitted by the modem. If a full PS detach event happens, we will explicitly disconnect all connected bearers. If a deactivation inidication is received for a single context, we will look for the associated bearer by CID and explicitly disconnect it.
2018-10-26modem-helpers: new helper to convert binary-coded decimalsBen Chan
This patch adds a mm_bcd_to_string() helper function to convert a byte array representing a binary-coded decimal (BCD) number to a string representing the equivalent decimal number.
2018-09-12helpers,tests: update ICCID related unit testsAleksander Morgado
Fix the test for invalid characters, because now I allow hex chars in the account number. And add new tests with real China Mobile ICCIDs that contain hex chars in the account number.
2018-09-12helpers: allow 19-digit reported ICCIDsAleksander Morgado
The mm_3gpp_parse_iccid() method does validation of the ICCID string and was originally implemented to handle +CRSM reported values. The implementation was looking for 20-digit strings, even for 19-digit ICCIDs (those finished with a trailing 'F'). We now extend the logic to also validate ICCID strings reported as 19-digit values directly, and when that happens we won't allow swapping of the digits (a +CRSM specific requirement) or trailing 'F' characters (as that is only required when reporting 19-digit ICCIDs with 20-digit strings). This change allows us to e.g. use the u-blox specific AT+CCID command and validate the returned ICCID with the same helper method, which currently fails: (ttyACM2): --> 'AT+CCID<CR>' (ttyACM2): <-- '<CR><LF>+CCID: 8934077700015848638<CR><LF><CR><LF>OK<CR><LF>' couldn't load SIM identifier: 'Invalid ICCID response size (was 19, expected 20)'
2018-08-29test,modem-helpers: remove unnecessary NULL check for g_free()Ben Chan
g_free() handles a NULL pointer properly, so there is no need to have a NULL check before calling g_free().