aboutsummaryrefslogtreecommitdiff
path: root/src/tests/test-modem-helpers.c
AgeCommit message (Collapse)Author
8 daysmodem-helpers: add utility function to split DTMF runsDan Williams
Split into groups of non-pause characters and single pause characters by themselves and return as an array of strings. Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-23broadband-modem,modem-helpers: move +CPIN response parsing to modem helpersDan Williams
Unit test it better, plus remove code duplication in various plugins. Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-20modem-helpers: handle spaces in +CPMS query responseDan Williams
Fixes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/990 Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-19broadband-modem: support +CGEREP values different than 2Daniele Palmas
Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
2025-05-14tests,modem-helpers: add cases for multidigit "stat" value in CREG responseKirill Buksha
Signed-off-by: Kirill Buksha <kirbuk200@gmail.com>
2025-05-08modem-helpers: add IPv6 support to +CGCONTRDP parsingDan Williams
Add some test responses from the Quectel EG915Q and some other Quectel devices. Then try to parse those responses. Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-04-12modem-helpers: fix checking of CDMA/EVDO access technologyDan Williams
Missing ! for strncmp() meant the test was backwards and would erroneously report 1xRTT and EVDOr0 when those access technologies were not in use. Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-03-28modem-helpers: Add helpers to parse channel listsGuido Günther
`CSCB` has the form ``` CSCB: [0|1],"<channel-list>","<data-coding-scheme>" ``` If the first parameter is `0` this specifies the accepted types if `1` it specifies rejected. So far seen in the wild were CSCB strings with accepted types only and a coding scheme of "" so this is what we handle for the moment. Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-09-25sim: add common helpers to parse operator name and mnc lengthMichal Mazur
2024-09-10tests: test mm_split_string_groups()Dan Williams
Signed-off-by: Dan Williams <dan@ioncontrol.co>
2024-03-12modem-helpers: rework AT string quote operation and add unit testsAleksander Morgado
Rework the AT string quote operation to build the output with the GString helper, instead of manually calculating how many bytes we'll need in the output. It just makes it clearer.
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.