diff options
author | Thomas Haller <thaller@redhat.com> | 2017-03-17 16:18:48 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-03-17 17:40:00 +0100 |
commit | b869d9cc0dda4fe5300f5ec5b5a090199ecd4e3e (patch) | |
tree | 654c693a00aaf40f3293c8b9f452c8622f777138 /src/tests | |
parent | 4c6edb22b70249c302209dc4af29c5caa88a764d (diff) | |
download | NetworkManager-b869d9cc0dda4fe5300f5ec5b5a090199ecd4e3e.tar.gz |
device: add spec "driver:" to match devices
Changing the MAC address of devices is known to fail with
certain drivers. Add a device-spec to allow disabling it
for for such devices.
Related: https://bugzilla.gnome.org/show_bug.cgi?id=777523
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/test-general.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/tests/test-general.c b/src/tests/test-general.c index cecce83f2c..498615822e 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -986,13 +986,25 @@ test_connection_sort_autoconnect_priority (void) /*****************************************************************************/ #define MATCH_S390 "S390:" +#define MATCH_DRIVER "DRIVER:" static NMMatchSpecMatchType _test_match_spec_device (const GSList *specs, const char *match_str) { if (match_str && g_str_has_prefix (match_str, MATCH_S390)) - return nm_match_spec_device (specs, NULL, NULL, NULL, &match_str[NM_STRLEN (MATCH_S390)]); - return nm_match_spec_device (specs, match_str, NULL, NULL, NULL); + return nm_match_spec_device (specs, NULL, NULL, NULL, NULL, NULL, &match_str[NM_STRLEN (MATCH_S390)]); + if (match_str && g_str_has_prefix (match_str, MATCH_DRIVER)) { + gs_free char *s = g_strdup (&match_str[NM_STRLEN (MATCH_DRIVER)]); + char *t; + + t = strchr (s, '|'); + if (t) { + t[0] = '\0'; + t++; + } + return nm_match_spec_device (specs, NULL, NULL, s, t, NULL, NULL); + } + return nm_match_spec_device (specs, match_str, NULL, NULL, NULL, NULL, NULL); } static void @@ -1142,6 +1154,23 @@ test_match_spec_device (void) NULL, S (NULL), S (MATCH_S390"0.0.1000", MATCH_S390"0.0.1000,deadbeef", MATCH_S390"0.0.1000,0.0.1001", MATCH_S390"0.0.1000,0.0.1002")); + + _do_test_match_spec_device ("driver:DRV", + S (MATCH_DRIVER"DRV", MATCH_DRIVER"DRV|1.6"), + S (MATCH_DRIVER"DR", MATCH_DRIVER"DR*"), + NULL); + _do_test_match_spec_device ("driver:DRV//", + S (MATCH_DRIVER"DRV/"), + S (MATCH_DRIVER"DRV/|1.6", MATCH_DRIVER"DR", MATCH_DRIVER"DR*"), + NULL); + _do_test_match_spec_device ("driver:DRV//*", + S (MATCH_DRIVER"DRV/", MATCH_DRIVER"DRV/|1.6"), + S (MATCH_DRIVER"DR", MATCH_DRIVER"DR*"), + NULL); + _do_test_match_spec_device ("driver:DRV//1.5*", + S (MATCH_DRIVER"DRV/|1.5", MATCH_DRIVER"DRV/|1.5.2"), + S (MATCH_DRIVER"DRV/", MATCH_DRIVER"DRV/|1.6", MATCH_DRIVER"DR", MATCH_DRIVER"DR*"), + NULL); #undef S } |