aboutsummaryrefslogtreecommitdiff
path: root/src/tests
AgeCommit message (Collapse)Author
2025-05-22serial-parsers,port-serial-at: move echo removal into serial parserDan Williams
Mainly because we need somewhere to stash the call end regex, and it's silly to have a 3rd instance of that in MMPortSerialAt when we already have one in the serial parsers that MMPortSerialAt relies on pretty heavily. 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-05-08broadband-modem-qmi,broadband-modem-mbim: always use SMS_PART_INVALID_INDEX ↵Dan Williams
unstored parts MMSmsList has logic to allow multiple unstored messages as long as they use SMS_PART_INVALID_INDEX. These messages aren't stored so they don't have an index. But the MBIM and QMI modems used index 0 for unstored messages, meaning there could only ever be one and also that multipart messages would fail to be combined. Let's fix that by just using SMS_PART_INVALID_INDEX for every scenario where an unstored message comes in. Fixes: https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/979 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-04-09modem-helpers-qmi: better handle no supported modesDan Williams
Dell Snapdragon X62 before FCC Unlock reports no radio interfaces from QMI and no device capabilities from MBIM. Instead of asserting in mm_filter_supported_modes() when called from mm_supported_modes_from_qmi_supported_modes_context() gracefully handle the lack of supported modes. Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-04-03tests: add tests for mm_signal_from_mbim_signal_state()Dan Williams
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-12-01cbm: Add parsing bits for cell broadcast messagesGuido Günther
This allows to parse the CBMs parameters like channel, part number and message text. We parse uncompressed GSM7 and UCS2 encodings as described in 3GPP TS 23.038. 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.
2023-10-26modem-helpers-qmi: register QMI error translationsAleksander Morgado
We register translations for QMI core and QMI protocol errors. These translations are a best-effort, and they are not meant to be exhaustive. The original error description is included in the translated GError, so that the details of the issue are not lost.
2023-10-26modem-helpers-mbim: register MBIM error translationsAleksander Morgado
We register translations for MBIM core, MBIM protocol and MBIM status errors. These translations are a best-effort, and they are not meant to be exhaustive. The original error description is included in the translated GError, so that the details of the issue are not lost.
2023-10-26core,error-helpers: new method to normalize GErrorsAleksander Morgado
The ModemManager API should not expose or return error types out of the error domains it supports. Default to a generic core error "Failed", while keeping the original error description.
2023-04-27libmm-glib: separate files for flags and enums typesAleksander Morgado
This allows us to skip needing to include the non-existent build_string_from_mask() or get_string() counterparts in the documentation index.
2023-03-30sms-part-cdma: fix invalid reads due to wrong byte counts in read_bitsAleksander Morgado
==174467== Invalid read of size 1 ==174467== at 0x10B80C: read_bits (mm-sms-part-cdma.c:255) ==174467== by 0x10B886: read_bits (mm-sms-part-cdma.c:260) ==174467== by 0x10DC2F: read_bearer_data_user_data (mm-sms-part-cdma.c:882) ==174467== by 0x10DC2F: read_bearer_data (mm-sms-part-cdma.c:1000) ==174467== by 0x10DC2F: mm_sms_part_cdma_new_from_binary_pdu (mm-sms-part-cdma.c:1180) ==174467== by 0x10DF24: mm_sms_part_cdma_new_from_pdu (mm-sms-part-cdma.c:331) ==174467== by 0x10A91D: common_test_valid_part_from_hexpdu (test-sms-part-cdma.c:114) ==174467== by 0x10B0AC: common_test_valid_part_from_pdu (test-sms-part-cdma.c:126) ==174467== by 0x10B0AC: test_invalid_ascii_user_data (test-sms-part-cdma.c:412) ==174467== by 0x4A0264D: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x4A02B1A: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== Address 0x51a6457 is 0 bytes after a block of size 7 alloc'd ==174467== at 0x48455EF: calloc (vg_replace_malloc.c:1328) ==174467== by 0x49DF6C0: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x48ABD24: mm_utils_hexstr2bin (mm-common-helpers.c:1884) ==174467== by 0x10DF06: mm_sms_part_cdma_new_from_pdu (mm-sms-part-cdma.c:325) ==174467== by 0x10A91D: common_test_valid_part_from_hexpdu (test-sms-part-cdma.c:114) ==174467== by 0x10B0AC: common_test_valid_part_from_pdu (test-sms-part-cdma.c:126) ==174467== by 0x10B0AC: test_invalid_ascii_user_data (test-sms-part-cdma.c:412) ==174467== by 0x4A0264D: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==174467== by 0x4A02B1A: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2)
2023-03-30sms-part-cdma: fix invalid memory read when parsing empty ascii textAleksander Morgado
Same fix also applied to latin encoded text as it also makes sense there. ==158856== Invalid read of size 1 ==158856== at 0x10B814: read_bits (mm-sms-part-cdma.c:257) ==158856== by 0x10DB07: read_bearer_data_user_data (mm-sms-part-cdma.c:878) ==158856== by 0x10DB07: read_bearer_data (mm-sms-part-cdma.c:990) ==158856== by 0x10DB07: mm_sms_part_cdma_new_from_binary_pdu (mm-sms-part-cdma.c:1170) ==158856== by 0x10DE54: mm_sms_part_cdma_new_from_pdu (mm-sms-part-cdma.c:333) ==158856== by 0x10A916: common_test_invalid_part_from_hexpdu (test-sms-part-cdma.c:90) ==158856== by 0x10A916: common_test_invalid_part_from_pdu (test-sms-part-cdma.c:104) ==158856== by 0x4A0264D: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A02B1A: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A02BBC: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x10A509: main (test-sms-part-cdma.c:595) ==158856== Address 0x51a627b is 0 bytes after a block of size 11 alloc'd ==158856== at 0x48455EF: calloc (vg_replace_malloc.c:1328) ==158856== by 0x49DF6C0: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x48ABD24: mm_utils_hexstr2bin (mm-common-helpers.c:1884) ==158856== by 0x10DE36: mm_sms_part_cdma_new_from_pdu (mm-sms-part-cdma.c:327) ==158856== by 0x10A916: common_test_invalid_part_from_hexpdu (test-sms-part-cdma.c:90) ==158856== by 0x10A916: common_test_invalid_part_from_pdu (test-sms-part-cdma.c:104) ==158856== by 0x4A0264D: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A023B4: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A02B1A: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856== by 0x4A02BBC: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==158856==
2023-03-30sms-part-cdma: fix warning when attempting g_convert() with NULL inputAleksander Morgado
GLib-CRITICAL **: 21:21:51.419: g_convert: assertion 'str != NULL' failed Program received signal SIGTRAP, Trace/breakpoint trap. 0x00007ffff7db3e82 in g_logv () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 (gdb) bt #0 0x00007ffff7db3e82 in g_logv () at /lib/x86_64-linux-gnu/libglib-2.0.so.0 #1 0x00007ffff7db40ef in g_log () at /lib/x86_64-linux-gnu/libglib-2.0.so.0 #2 0x00007ffff7d8a5da in g_convert () at /lib/x86_64-linux-gnu/libglib-2.0.so.0 #3 0x00005555555592cf in read_bearer_data_user_data (log_object=0x0, subparameter=<optimized out>, sms_part=0x555555578000) at ../src/mm-sms-part-cdma.c:929 #4 read_bearer_data (log_object=0x0, parameter=<optimized out>, sms_part=0x555555578000) at ../src/mm-sms-part-cdma.c:982 #5 mm_sms_part_cdma_new_from_binary_pdu
2023-03-30sms-part-3gpp: fix invalid memory ready by checking UDH length byte can be readAleksander Morgado
[debug] parsing PDU (0)... [debug] no SMSC address given [debug] submit type PDU detected [debug] message reference: 1 [debug] address size: 1 digits (1 bytes) [debug] number parsed: 00 [debug] validity available, format relative [debug] PID: 0 [debug] user data encoding is GSM7 [debug] user data length: 0 elements [debug] user data length: 0 bytes ==125780== Command: ./build/test/mmsmspdu --pdu=00F101010C0000000000 --verbose ==125780== ==125780== Invalid read of size 1 ==125780== at 0x10B422: mm_sms_part_3gpp_new_from_binary_pdu (mm-sms-part-3gpp.c:698) ==125780== by 0x10BF57: mm_sms_part_3gpp_new_from_pdu (mm-sms-part-3gpp.c:368) ==125780== by 0x10A44D: main (mmsmspdu.c:242) ==125780== Address 0x519988a is 0 bytes after a block of size 10 alloc'd ==125780== at 0x48455EF: calloc (vg_replace_malloc.c:1328) ==125780== by 0x49DF6C0: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==125780== by 0x48ABD24: mm_utils_hexstr2bin (mm-common-helpers.c:1884) ==125780== by 0x10BF36: mm_sms_part_3gpp_new_from_pdu (mm-sms-part-3gpp.c:362) ==125780== by 0x10A44D: main (mmsmspdu.c:242)
2023-03-30sms-part-3gpp: avoid underflow in tp_user_data_size_elementsAleksander Morgado
==101461== Command: ./build/test/mmsmspdu --pdu=004100010100014B00002E --verbose ==101461== [debug] parsing PDU (0)... [debug] no SMSC address given [debug] submit type PDU detected [debug] message reference: 0 [debug] address size: 1 digits (1 bytes) [debug] number parsed: 00 [debug] PID: 1 [debug] user data encoding is GSM7 [debug] user data length: 0 elements [debug] user data length: 0 bytes [debug] decoding SMS text with 4294967294 elements Based on a patch from Michal Mazur <mkm@semihalf.com>.
2023-03-30sms-part-3gpp: fix invalid memory read due to wrong size check when reading ↵Aleksander Morgado
address Before the actual number digits there is always a Type of Address byte that we were not considering during the size check. [debug] parsing PDU (0)... [debug] no SMSC address given [debug] deliver type PDU detected [debug] address size: 1 digits (1 bytes) ==90832== Command: ./build/test/mmsmspdu --pdu=001C011C --verbose ==90832== ==90832== Invalid read of size 1 ==90832== at 0x10AC90: sms_semi_octets_to_bcd_string (mm-sms-part-3gpp.c:71) ==90832== by 0x10AC90: sms_decode_address (mm-sms-part-3gpp.c:157) ==90832== by 0x10B0C5: mm_sms_part_3gpp_new_from_binary_pdu (mm-sms-part-3gpp.c:512) ==90832== by 0x10BF77: mm_sms_part_3gpp_new_from_pdu (mm-sms-part-3gpp.c:368) ==90832== by 0x10A44D: main (mmsmspdu.c:242) ==90832== Address 0x5199874 is 0 bytes after a block of size 4 alloc'd ==90832== at 0x48455EF: calloc (vg_replace_malloc.c:1328) ==90832== by 0x49DF6C0: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==90832== by 0x48ABD24: mm_utils_hexstr2bin (mm-common-helpers.c:1884) ==90832== by 0x10BF56: mm_sms_part_3gpp_new_from_pdu (mm-sms-part-3gpp.c:362) ==90832== by 0x10A44D: main (mmsmspdu.c:242)
2023-03-30sms-part-3gpp: fix invalid memory read parsing addressAleksander Morgado
[debug] parsing PDU (0)... [debug] no SMSC address given [debug] status report type PDU detected [debug] message reference: 191 [debug] address size: 0 digits (0 bytes) ==78906== Command: ./build/test/mmsmspdu --pdu=000ABF00 --verbose ==78906== ==78906== Invalid read of size 1 ==78906== at 0x10AA80: sms_decode_address (mm-sms-part-3gpp.c:132) ==78906== by 0x10AF7C: mm_sms_part_3gpp_new_from_binary_pdu (mm-sms-part-3gpp.c:507) ==78906== by 0x10BE17: mm_sms_part_3gpp_new_from_pdu (mm-sms-part-3gpp.c:368) ==78906== by 0x10A44D: main (mmsmspdu.c:202) ==78906== Address 0x5199874 is 0 bytes after a block of size 4 alloc'd ==78906== at 0x48455EF: calloc (vg_replace_malloc.c:1328) ==78906== by 0x49DF6C0: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7400.2) ==78906== by 0x48ABD24: mm_utils_hexstr2bin (mm-common-helpers.c:1884) ==78906== by 0x10BDF6: mm_sms_part_3gpp_new_from_pdu (mm-sms-part-3gpp.c:362) ==78906== by 0x10A44D: main (mmsmspdu.c:202)
2023-03-30test-sms-part-3gpp: prepare common invalid PDU tester operationAleksander Morgado
2023-03-30sms-part-3gpp|cdma: new fuzzer testsAleksander Morgado
2022-11-10test,modem-helpers-qmi: unit tests for NAS system info registration processingAleksander Morgado
Requires the response parser methods in libqmi.
2022-11-07build: drop autotoolsAleksander Morgado
2022-09-13charsets: Add test_text_split_two_pdu_gsm7_extended_chars to use extended ↵Andrey Skvortsov
character
2022-09-13charsets: move mm_sms_part_3gpp_util_split_text to mm_charset_util_split_textAndrey Skvortsov
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-29core: remove "all rights reserved" from copyright linesAleksander Morgado
The rights each contributor has are the ones stated by the GPL/LGPL, not more and not less.
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.
2022-01-31shared-qmi: filter out modes not currently availableAleksander Morgado
Do not build the mask of "all" modes based only on the supported radio interfaces, also filter out those modes that would not be available based on the current capabilities enabled.
2022-01-31modem-helpers-qmi: multimode devices shouldn't always have 4G/5G only modesAleksander Morgado
In GSM/UMTS+CDMA/EVDO multimode devices, the 4G and 5G mode switching operations are exclusively limited to the capability selection that has LTE+5GNR exclusively. We cannot allow switching to 4G-only, 5G-only or 4G+5G if the current capabilities have GSM/UMTS or CDMA/EVDO. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/503
2022-01-31tests,modem-helpers-qmi: add tests for supported modes loadingAleksander Morgado
2022-01-31tests,modem-helpers-qmi: add additional tests for supported capabilities loadingAleksander Morgado
Including tests for 5G-only and non-multimode 5G+4G and 5G+4G+3G devices.
2022-01-31tests,modem-helpers-qmi: add tests for supported capabilities loadingAleksander Morgado
2022-01-31modem-helpers-qmi: refer explicitly to current capabilities in helper methodAleksander Morgado
The helper method for which we have unit tests available refers exclusively to the current capabilities loading, so rename it to clarify that.
2022-01-30test-modem-helpers-qmi: add unit test for generic 5g modemPrakash Pabba
2022-01-30test-modem-helpers-qmi: Fix tests for UML290Prakash Pabba
Change due to update in current capabilities loading logic.
2021-11-09kerneldevice,generic: input pattern to string match is not regexAleksander Morgado
The input pattern given to the string_match() method is not a regex pattern and we cannot use it as that, because all the special characters (e.g. '.') would not be treated correctly. Also, the prefix matching with the wildcard at the end of the string needs to be converted to a proper regex wildcard, i.e. '.*'. This logic also adds support for suffix matching, with a wildcard at the beginning of the string, e.g. as the ones used for the wwan kernel device name matching rules (i.e. '*MBIM'). Unit tests are added to cover all cases, most of these tests were failing without the fixes implemented here.
2021-11-04core: replace 'slave' with 'secondary'Aleksander Morgado
2021-11-04core: replace 'master' with 'main'Aleksander Morgado
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.