diff options
| author | Michael Biebl <biebl@debian.org> | 2020-04-11 21:30:33 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2020-04-11 21:30:33 +0200 |
| commit | f914c41532a9e4f2bb44be074466b62e4cac8db3 (patch) | |
| tree | 046e8e7a186afecf299cd80d62fa1c93903dbecf /src/devices/wifi/tests | |
| parent | 19e73abd360f0198f94ce49f36ddf009056f6324 (diff) | |
| parent | 1e5977b62f896e844b548c3007ace9e1dfa7f9ed (diff) | |
Update upstream source from tag 'upstream/1.23.90'
Update to upstream version '1.23.90' with Debian dir 38c3873648b51c73a9e448ccb2ac18152c2b3f85
Diffstat (limited to 'src/devices/wifi/tests')
| -rw-r--r-- | src/devices/wifi/tests/test-devices-wifi.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/devices/wifi/tests/test-devices-wifi.c b/src/devices/wifi/tests/test-devices-wifi.c index a960e7a2..bde36307 100644 --- a/src/devices/wifi/tests/test-devices-wifi.c +++ b/src/devices/wifi/tests/test-devices-wifi.c @@ -6,6 +6,7 @@ #include "nm-default.h" #include "devices/wifi/nm-wifi-utils.h" +#include "devices/wifi/nm-device-wifi.h" #include "nm-core-internal.h" #include "nm-test-utils-core.h" @@ -1337,6 +1338,60 @@ test_strength_all (void) /*****************************************************************************/ +static void +do_test_ssids_options_to_ptrarray (const char *const*ssids) +{ + GVariantBuilder builder; + gs_unref_variant GVariant *variant = NULL; + gs_unref_ptrarray GPtrArray *ssids_arr = NULL; + gs_free_error GError *error = NULL; + gsize len; + gsize i; + + g_assert (ssids); + + len = NM_PTRARRAY_LEN (ssids); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("aay")); + for (i = 0; i < len; i++) { + const char *ssid = ssids[i]; + + g_variant_builder_add (&builder, + "@ay", + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, ssid, strlen (ssid), 1)); + } + variant = g_variant_builder_end (&builder); + + if (nmtst_get_rand_bool ()) + g_variant_ref_sink (variant); + + ssids_arr = nmtst_ssids_options_to_ptrarray (variant, &error); + g_assert (!error); + if (len == 0) { + g_assert (!ssids_arr); + return; + } + g_assert_cmpint (len, ==, ssids_arr->len); + for (i = 0; i < len; i++) { + const char *ssid = ssids[i]; + GBytes *bytes = ssids_arr->pdata[i]; + + g_assert (nm_utils_gbytes_equal_mem (bytes, + ssid, + strlen (ssid))); + } +} + +static void +test_ssids_options_to_ptrarray (void) +{ + do_test_ssids_options_to_ptrarray (NM_PTRARRAY_EMPTY (const char *)); + do_test_ssids_options_to_ptrarray (NM_MAKE_STRV ("ab")); + do_test_ssids_options_to_ptrarray (NM_MAKE_STRV ("ab", "cd", "fsdfdsf")); +} + +/*****************************************************************************/ + NMTST_DEFINE (); int @@ -1501,5 +1556,7 @@ main (int argc, char **argv) g_test_add_func ("/wifi/strength/all", test_strength_all); + g_test_add_func ("/wifi/ssids_options_to_ptrarray", test_ssids_options_to_ptrarray); + return g_test_run (); } |