Merge request !1334 from 'modem-helpers-act-fix'

modem-helpers: fix checking of CDMA/EVDO access technology

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1334
This commit is contained in:
Dan Williams
2025-04-13 04:41:51 +00:00
2 changed files with 28 additions and 3 deletions
+3 -3
View File
@@ -4160,11 +4160,11 @@ mm_string_to_access_tech (const gchar *string)
* are included in other strings too.
*/
len = strlen (string);
if (strncmp (string, "EVDO", 4) && (len >= 4 && !isalnum (string[4])))
if (!strncmp (string, "EVDO", 4) && (len >= 4 && !isalnum (string[4])))
act |= MM_MODEM_ACCESS_TECHNOLOGY_EVDO0;
if (strncmp (string, "CDMA", 4) && (len >= 4 && !isalnum (string[4])))
if (!strncmp (string, "CDMA", 4) && (len >= 4 && !isalnum (string[4])))
act |= MM_MODEM_ACCESS_TECHNOLOGY_1XRTT;
if (strncmp (string, "CDMA-EVDO", 9) && (len >= 9 && !isalnum (string[9])))
if (!strncmp (string, "CDMA-EVDO", 9) && (len >= 9 && !isalnum (string[9])))
act |= MM_MODEM_ACCESS_TECHNOLOGY_1XRTT | MM_MODEM_ACCESS_TECHNOLOGY_EVDO0;
return act;
+25
View File
@@ -4866,6 +4866,29 @@ test_mnc_length (void)
/*****************************************************************************/
typedef struct {
const gchar *str;
const MMModemAccessTechnology act;
} TestActData;
static const TestActData test_act_data[] = {
{ "EDGE", MM_MODEM_ACCESS_TECHNOLOGY_EDGE },
/* Ensure WCDMA does not get counted as 3GPP2 CDMA */
{ "WCDMA", MM_MODEM_ACCESS_TECHNOLOGY_UMTS },
{ "CDMA-EVDO", MM_MODEM_ACCESS_TECHNOLOGY_1XRTT | MM_MODEM_ACCESS_TECHNOLOGY_EVDO0 },
};
static void
test_string_to_access_tech (void)
{
guint i;
for (i = 0; i < G_N_ELEMENTS (test_act_data); i++)
g_assert_cmpint (mm_string_to_access_tech (test_act_data[i].str), ==, test_act_data[i].act);
}
/*****************************************************************************/
#define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (GTestFixtureFunc) t, NULL)
int main (int argc, char **argv)
@@ -5111,6 +5134,8 @@ int main (int argc, char **argv)
g_test_suite_add (suite, TESTCASE (test_spn_to_utf8, NULL));
g_test_suite_add (suite, TESTCASE (test_mnc_length, NULL));
g_test_suite_add (suite, TESTCASE (test_string_to_access_tech, NULL));
result = g_test_run ();
reg_test_data_free (reg_data);