tests/trivial: rename nmtst_get_rand_int() to nmtst_get_rand_uint32()
nmtst_get_rand_int() was originally named that way, because it calls g_rand_int(). But I think if a function returns an uint32, it should also be named that way. Rename.
This commit is contained in:
@@ -601,7 +601,7 @@ test_nm_utils_strsplit_set (void)
|
||||
words_exp = g_ptr_array_new_with_free_func (g_free);
|
||||
for (test_run = 0; test_run < 100; test_run++) {
|
||||
gboolean f_allow_escaping = nmtst_get_rand_bool ();
|
||||
guint words_len = nmtst_get_rand_int () % 100;
|
||||
guint words_len = nmtst_get_rand_uint32 () % 100;
|
||||
gs_free char *str = NULL;
|
||||
guint i;
|
||||
|
||||
@@ -611,14 +611,14 @@ test_nm_utils_strsplit_set (void)
|
||||
char *word;
|
||||
guint j;
|
||||
|
||||
word_len = nmtst_get_rand_int ();
|
||||
word_len = nmtst_get_rand_uint32 ();
|
||||
if ((word_len % 100) < 30)
|
||||
word_len = 0;
|
||||
else
|
||||
word_len = (word_len >> 10) % 100;
|
||||
word = g_new (char, word_len + 3);
|
||||
for (j = 0; j < word_len; ) {
|
||||
guint32 p = nmtst_get_rand_int ();
|
||||
guint32 p = nmtst_get_rand_uint32 ();
|
||||
static const char delimiters_arr[] = { DELIMITERS_C };
|
||||
static const char regular_chars[] = "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
@@ -706,7 +706,7 @@ _do_test_c_list_sort (CListSort *elements, guint n_list, gboolean headless)
|
||||
c_list_init (&head);
|
||||
for (i = 0; i < n_list; i++) {
|
||||
el = &elements[i];
|
||||
el->val = nmtst_get_rand_int () % (2*n_list);
|
||||
el->val = nmtst_get_rand_uint32 () % (2*n_list);
|
||||
c_list_link_tail (&head, &el->lst);
|
||||
}
|
||||
|
||||
@@ -767,7 +767,7 @@ test_c_list_sort (void)
|
||||
elements = g_new0 (CListSort, N_ELEMENTS);
|
||||
for (n_list = 1; n_list < N_ELEMENTS; n_list++) {
|
||||
if (n_list > 150) {
|
||||
n_list += nmtst_get_rand_int () % n_list;
|
||||
n_list += nmtst_get_rand_uint32 () % n_list;
|
||||
if (n_list >= N_ELEMENTS)
|
||||
break;
|
||||
}
|
||||
@@ -775,7 +775,7 @@ test_c_list_sort (void)
|
||||
const guint N_REPEAT = n_list > 50 ? 1 : 5;
|
||||
|
||||
for (repeat = 0; repeat < N_REPEAT; repeat++)
|
||||
_do_test_c_list_sort (elements, n_list, nmtst_get_rand_int () % 2);
|
||||
_do_test_c_list_sort (elements, n_list, nmtst_get_rand_uint32 () % 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3501,7 +3501,7 @@ test_setting_compare_addresses (void)
|
||||
|
||||
nm_ip_address_unref (a);
|
||||
|
||||
if (nmtst_get_rand_int () % 2)
|
||||
if (nmtst_get_rand_uint32 () % 2)
|
||||
NMTST_SWAP (s1, s2);
|
||||
|
||||
success = nm_setting_compare (s1, s2, NM_SETTING_COMPARE_FLAG_EXACT);
|
||||
@@ -3533,7 +3533,7 @@ test_setting_compare_routes (void)
|
||||
|
||||
nm_ip_route_unref (r);
|
||||
|
||||
if (nmtst_get_rand_int () % 2)
|
||||
if (nmtst_get_rand_uint32 () % 2)
|
||||
NMTST_SWAP (s1, s2);
|
||||
|
||||
success = nm_setting_compare (s1, s2, NM_SETTING_COMPARE_FLAG_EXACT);
|
||||
@@ -6081,7 +6081,7 @@ test_hexstr2bin (void)
|
||||
static void
|
||||
_do_strquote (const char *str, gsize buf_len, const char *expected)
|
||||
{
|
||||
char canary = (char) nmtst_get_rand_int ();
|
||||
char canary = (char) nmtst_get_rand_uint32 ();
|
||||
gs_free char *buf_full = g_malloc (buf_len + 2);
|
||||
char *buf = &buf_full[1];
|
||||
const char *b;
|
||||
@@ -7214,7 +7214,7 @@ test_nm_utils_ptrarray_find_binary_search_with_duplicates (void)
|
||||
/* fill with random numbers... surely there are some duplicates
|
||||
* there... or maybe even there are none... */
|
||||
for (i = 0; i < i_len; i++)
|
||||
arr[i] = GINT_TO_POINTER (nmtst_get_rand_int () % (i_len + BIN_SEARCH_W_DUPS_JITTER));
|
||||
arr[i] = GINT_TO_POINTER (nmtst_get_rand_uint32 () % (i_len + BIN_SEARCH_W_DUPS_JITTER));
|
||||
g_qsort_with_data (arr,
|
||||
i_len,
|
||||
sizeof (gpointer),
|
||||
|
@@ -101,8 +101,8 @@ _connection_new_from_dbus_strict (GVariant *dict,
|
||||
* after accounting for normalization. */
|
||||
for (i = 0; i < 10; i++) {
|
||||
NMConnection *cons[] = { con_x_0, con_x_s, con_x_e, con_n_0, con_n_s, con_n_e };
|
||||
guint idx_a = (nmtst_get_rand_int () % G_N_ELEMENTS (cons));
|
||||
guint idx_b = (nmtst_get_rand_int () % G_N_ELEMENTS (cons));
|
||||
guint idx_a = (nmtst_get_rand_uint32 () % G_N_ELEMENTS (cons));
|
||||
guint idx_b = (nmtst_get_rand_uint32 () % G_N_ELEMENTS (cons));
|
||||
gboolean normalize_a, normalize_b;
|
||||
|
||||
if (idx_a <= 2 && idx_b <= 2) {
|
||||
@@ -137,14 +137,14 @@ _create_random_ipaddr (int addr_family, gboolean as_service)
|
||||
g_assert (NM_IN_SET (addr_family, AF_INET, AF_INET6));
|
||||
|
||||
if (as_service)
|
||||
num = (nmtst_get_rand_int () % 1000) + 30000;
|
||||
num = (nmtst_get_rand_uint32 () % 1000) + 30000;
|
||||
else
|
||||
num = addr_family == AF_INET ? 32 : 128;
|
||||
|
||||
if (addr_family == AF_INET)
|
||||
return g_strdup_printf ("192.168.%u.%u%c%d", nmtst_get_rand_int () % 256, nmtst_get_rand_int () % 256, delimiter, num);
|
||||
return g_strdup_printf ("192.168.%u.%u%c%d", nmtst_get_rand_uint32 () % 256, nmtst_get_rand_uint32 () % 256, delimiter, num);
|
||||
else
|
||||
return g_strdup_printf ("a:b:c::%02x:%02x%c%d", nmtst_get_rand_int () % 256, nmtst_get_rand_int () % 256, delimiter, num);
|
||||
return g_strdup_printf ("a:b:c::%02x:%02x%c%d", nmtst_get_rand_uint32 () % 256, nmtst_get_rand_uint32 () % 256, delimiter, num);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -2263,13 +2263,13 @@ _rndt_wired_add_s390_options (NMSettingWired *s_wired,
|
||||
n_opts = NM_PTRARRAY_LEN (option_names);
|
||||
opt_keys = g_new (const char *, (n_opts + 1));
|
||||
nmtst_rand_perm (NULL, opt_keys, option_names, sizeof (const char *), n_opts);
|
||||
n_opts = nmtst_get_rand_int () % (n_opts + 1);
|
||||
n_opts = nmtst_get_rand_uint32 () % (n_opts + 1);
|
||||
opt_keys[n_opts] = NULL;
|
||||
|
||||
opt_vals = g_new0 (char *, n_opts + 1);
|
||||
opt_found = g_new0 (bool, n_opts + 1);
|
||||
for (i = 0; i < n_opts; i++) {
|
||||
guint p = nmtst_get_rand_int () % 1000;
|
||||
guint p = nmtst_get_rand_uint32 () % 1000;
|
||||
|
||||
if (p < 200)
|
||||
opt_vals[i] = nm_strdup_int (i);
|
||||
@@ -2352,7 +2352,7 @@ _rndt_wg_peers_create (void)
|
||||
|
||||
wg_peers = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_wireguard_peer_unref);
|
||||
|
||||
n = nmtst_get_rand_int () % 10;
|
||||
n = nmtst_get_rand_uint32 () % 10;
|
||||
for (i = 0; i < n; i++) {
|
||||
NMWireGuardPeer *peer;
|
||||
guint8 public_key_buf[NM_WIREGUARD_PUBLIC_KEY_LEN];
|
||||
@@ -2383,12 +2383,12 @@ _rndt_wg_peers_create (void)
|
||||
NM_SETTING_SECRET_FLAG_AGENT_OWNED));
|
||||
|
||||
nm_wireguard_peer_set_persistent_keepalive (peer,
|
||||
nmtst_rand_select ((guint32) 0, nmtst_get_rand_int ()));
|
||||
nmtst_rand_select ((guint32) 0, nmtst_get_rand_uint32 ()));
|
||||
|
||||
if (!nm_wireguard_peer_set_endpoint (peer, nmtst_rand_select (s_endpoint, NULL), TRUE))
|
||||
g_assert_not_reached ();
|
||||
|
||||
n_aip = nmtst_rand_select (0, nmtst_get_rand_int () % 10);
|
||||
n_aip = nmtst_rand_select (0, nmtst_get_rand_uint32 () % 10);
|
||||
for (i_aip = 0; i_aip < n_aip; i_aip++) {
|
||||
gs_free char *aip = NULL;
|
||||
|
||||
@@ -2585,7 +2585,7 @@ test_roundtrip_conversion (gconstpointer test_data)
|
||||
const char *UUID= "63376701-b61e-4318-bf7e-664a1c1eeaab";
|
||||
const char *INTERFACE_NAME = nm_sprintf_bufa (100, "ifname%d", MODE);
|
||||
guint32 ETH_MTU = nmtst_rand_select ((guint32) 0u,
|
||||
nmtst_get_rand_int ());
|
||||
nmtst_get_rand_uint32 ());
|
||||
const char *WG_PRIVATE_KEY = nmtst_get_rand_bool ()
|
||||
? "yGXGK+5bVnxSJUejH4vbpXbq+ZtaG4NB8IHRK/aVtE0="
|
||||
: NULL;
|
||||
@@ -2593,9 +2593,9 @@ test_roundtrip_conversion (gconstpointer test_data)
|
||||
NM_SETTING_SECRET_FLAG_NOT_SAVED,
|
||||
NM_SETTING_SECRET_FLAG_AGENT_OWNED);
|
||||
const guint WG_LISTEN_PORT = nmtst_rand_select (0u,
|
||||
nmtst_get_rand_int () % 0x10000);
|
||||
nmtst_get_rand_uint32 () % 0x10000);
|
||||
const guint WG_FWMARK = nmtst_rand_select (0u,
|
||||
nmtst_get_rand_int ());
|
||||
nmtst_get_rand_uint32 ());
|
||||
gs_unref_ptrarray GPtrArray *kf_data_arr = g_ptr_array_new_with_free_func (g_free);
|
||||
gs_unref_ptrarray GPtrArray *wg_peers = NULL;
|
||||
const NMConnectionSerializationFlags dbus_serialization_flags[] = {
|
||||
|
@@ -858,7 +858,7 @@ nmtst_get_rand (void)
|
||||
}
|
||||
|
||||
static inline guint32
|
||||
nmtst_get_rand_int (void)
|
||||
nmtst_get_rand_uint32 (void)
|
||||
{
|
||||
return g_rand_int (nmtst_get_rand ());
|
||||
}
|
||||
@@ -866,7 +866,7 @@ nmtst_get_rand_int (void)
|
||||
static inline gboolean
|
||||
nmtst_get_rand_bool (void)
|
||||
{
|
||||
return nmtst_get_rand_int () % 2;
|
||||
return nmtst_get_rand_uint32 () % 2;
|
||||
}
|
||||
|
||||
static inline gpointer
|
||||
@@ -901,7 +901,7 @@ nmtst_rand_buf (GRand *rand, gpointer buffer, gsize buffer_length)
|
||||
({ \
|
||||
typeof (v0) NM_UNIQ_T (UNIQ, uniq)[1 + NM_NARG (__VA_ARGS__)] = { (v0), __VA_ARGS__ }; \
|
||||
\
|
||||
NM_UNIQ_T (UNIQ, uniq)[nmtst_get_rand_int () % G_N_ELEMENTS (NM_UNIQ_T (UNIQ, uniq))]; \
|
||||
NM_UNIQ_T (UNIQ, uniq)[nmtst_get_rand_uint32 () % G_N_ELEMENTS (NM_UNIQ_T (UNIQ, uniq))]; \
|
||||
})
|
||||
|
||||
#define nmtst_rand_select(...) \
|
||||
@@ -1933,7 +1933,7 @@ nmtst_assert_setting_is_equal (gconstpointer /* const NMSetting * */ a,
|
||||
NMSettingCompareFlags flags)
|
||||
{
|
||||
gs_unref_hashtable GHashTable *hash = NULL;
|
||||
guint32 r = nmtst_get_rand_int ();
|
||||
guint32 r = nmtst_get_rand_uint32 ();
|
||||
|
||||
g_assert (NM_IS_SETTING (a));
|
||||
g_assert (NM_IS_SETTING (b));
|
||||
|
@@ -149,10 +149,10 @@ test_nm_strndup_a (void)
|
||||
char ch;
|
||||
gsize i, l;
|
||||
|
||||
input = g_strnfill (nmtst_get_rand_int () % 20, 'x');
|
||||
input = g_strnfill (nmtst_get_rand_uint32 () % 20, 'x');
|
||||
|
||||
for (i = 0; input[i]; i++) {
|
||||
while ((ch = ((char) nmtst_get_rand_int ())) == '\0') {
|
||||
while ((ch = ((char) nmtst_get_rand_uint32 ())) == '\0') {
|
||||
/* repeat. */
|
||||
}
|
||||
input[i] = ch;
|
||||
@@ -175,7 +175,7 @@ test_nm_strndup_a (void)
|
||||
gs_free char *dup_free = NULL;
|
||||
const char *dup;
|
||||
|
||||
l = nmtst_get_rand_int () % 23;
|
||||
l = nmtst_get_rand_uint32 () % 23;
|
||||
dup = nm_strndup_a (10, input, l, &dup_free);
|
||||
g_assert (strncmp (dup, input, l) == 0);
|
||||
g_assert (strlen (dup) <= l);
|
||||
@@ -214,7 +214,7 @@ test_unaligned (void)
|
||||
guint8 val = 0;
|
||||
|
||||
while (val == 0)
|
||||
val = nmtst_get_rand_int () % 256;
|
||||
val = nmtst_get_rand_uint32 () % 256;
|
||||
|
||||
buf[shift] = val;
|
||||
|
||||
|
@@ -679,7 +679,7 @@ nmtstp_run_command_check_external_global (void)
|
||||
{
|
||||
if (!nmtstp_is_root_test ())
|
||||
return FALSE;
|
||||
switch (nmtst_get_rand_int () % 3) {
|
||||
switch (nmtst_get_rand_uint32 () % 3) {
|
||||
case 0:
|
||||
return -1;
|
||||
case 1:
|
||||
@@ -699,7 +699,7 @@ nmtstp_run_command_check_external (int external_command)
|
||||
}
|
||||
if (!nmtstp_is_root_test ())
|
||||
return FALSE;
|
||||
return (nmtst_get_rand_int () % 2) == 0;
|
||||
return (nmtst_get_rand_uint32 () % 2) == 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -843,7 +843,7 @@ _ip_address_add (NMPlatform *platform,
|
||||
g_assert (flags == 0);
|
||||
|
||||
if ( peer_address->addr4 != address->addr4
|
||||
|| nmtst_get_rand_int () % 2) {
|
||||
|| nmtst_get_rand_uint32 () % 2) {
|
||||
/* If the peer is the same as the local address, we can omit it. The result should be identical */
|
||||
nm_sprintf_buf (s_peer, " peer %s", nm_utils_inet4_ntop (peer_address->addr4, b2));
|
||||
} else
|
||||
@@ -1994,7 +1994,7 @@ nmtstp_netns_select_random (NMPlatform **platforms, gsize n_platforms, NMPNetns
|
||||
for (i = 0; i < n_platforms; i++)
|
||||
g_assert (NM_IS_PLATFORM (platforms[i]));
|
||||
|
||||
i = nmtst_get_rand_int () % (n_platforms + 1);
|
||||
i = nmtst_get_rand_uint32 () % (n_platforms + 1);
|
||||
if (i == 0)
|
||||
return;
|
||||
g_assert (nm_platform_netns_push (platforms[i - 1], netns));
|
||||
|
@@ -2100,7 +2100,7 @@ test_create_many_links_do (guint n_devices)
|
||||
char name[64];
|
||||
const NMPlatformLink *pllink;
|
||||
gs_unref_array GArray *ifindexes = g_array_sized_new (FALSE, FALSE, sizeof (int), n_devices);
|
||||
const int EX = ((int) (nmtst_get_rand_int () % 4)) - 1;
|
||||
const int EX = ((int) (nmtst_get_rand_uint32 () % 4)) - 1;
|
||||
|
||||
g_assert (EX >= -1 && EX <= 2);
|
||||
|
||||
@@ -2459,17 +2459,17 @@ test_netns_general (gpointer fixture, gconstpointer test_data)
|
||||
NMPlatform *p = (k == 0 ? platform_1 : platform_2);
|
||||
const char *id = (k == 0 ? "a" : "b");
|
||||
|
||||
for (i = 0, j = nmtst_get_rand_int () % 5; i < j; i++)
|
||||
for (i = 0, j = nmtst_get_rand_uint32 () % 5; i < j; i++)
|
||||
_ADD_DUMMY (p, nm_sprintf_buf (sbuf, "other-a-%s-%02d", id, i));
|
||||
|
||||
_ADD_DUMMY (p, "dummy1_");
|
||||
|
||||
for (i = 0, j = nmtst_get_rand_int () % 5; i < j; i++)
|
||||
for (i = 0, j = nmtst_get_rand_uint32 () % 5; i < j; i++)
|
||||
_ADD_DUMMY (p, nm_sprintf_buf (sbuf, "other-b-%s-%02d", id, i));
|
||||
|
||||
_ADD_DUMMY (p, nm_sprintf_buf (sbuf, "dummy2%s", id));
|
||||
|
||||
for (i = 0, j = nmtst_get_rand_int () % 5; i < j; i++)
|
||||
for (i = 0, j = nmtst_get_rand_uint32 () % 5; i < j; i++)
|
||||
_ADD_DUMMY (p, nm_sprintf_buf (sbuf, "other-c-%s-%02d", id, i));
|
||||
}
|
||||
|
||||
@@ -2491,17 +2491,17 @@ test_netns_general (gpointer fixture, gconstpointer test_data)
|
||||
NMPlatform *pl;
|
||||
const char *path;
|
||||
|
||||
j = nmtst_get_rand_int () % 2;
|
||||
j = nmtst_get_rand_uint32 () % 2;
|
||||
|
||||
if (nmtst_get_rand_int () % 2) {
|
||||
if (nmtst_get_rand_uint32 () % 2) {
|
||||
pl = platform_1;
|
||||
if (nmtst_get_rand_int () % 2)
|
||||
if (nmtst_get_rand_uint32 () % 2)
|
||||
path = "/proc/sys/net/ipv6/conf/dummy1_/disable_ipv6";
|
||||
else
|
||||
path = "/proc/sys/net/ipv6/conf/dummy2a/disable_ipv6";
|
||||
} else {
|
||||
pl = platform_2;
|
||||
if (nmtst_get_rand_int () % 2)
|
||||
if (nmtst_get_rand_uint32 () % 2)
|
||||
path = "/proc/sys/net/ipv6/conf/dummy1_/disable_ipv6";
|
||||
else
|
||||
path = "/proc/sys/net/ipv6/conf/dummy2b/disable_ipv6";
|
||||
@@ -2654,7 +2654,7 @@ test_netns_push (gpointer fixture, gconstpointer test_data)
|
||||
pl[2].platform = platform_2 = _test_netns_create_platform ();
|
||||
|
||||
pl_base = &pl[0];
|
||||
i = nmtst_get_rand_int () % (G_N_ELEMENTS (pl) + 1);
|
||||
i = nmtst_get_rand_uint32 () % (G_N_ELEMENTS (pl) + 1);
|
||||
if (i < G_N_ELEMENTS (pl)) {
|
||||
pl_base = &pl[i];
|
||||
g_assert (nm_platform_netns_push (pl[i].platform, &netns_pop));
|
||||
@@ -2674,7 +2674,7 @@ test_netns_push (gpointer fixture, gconstpointer test_data)
|
||||
g_ptr_array_add (device_names, tmp);
|
||||
pl[i].sysctl_path = tmp;
|
||||
|
||||
pl[i].sysctl_value = nmtst_get_rand_int () % 2 ? "1" : "0";
|
||||
pl[i].sysctl_value = nmtst_get_rand_uint32 () % 2 ? "1" : "0";
|
||||
|
||||
_ADD_DUMMY (pl[i].platform, pl[i].device_name);
|
||||
|
||||
@@ -2689,16 +2689,16 @@ test_netns_push (gpointer fixture, gconstpointer test_data)
|
||||
pl[i].ns_mnt = tmp;
|
||||
}
|
||||
|
||||
nstack = nmtst_get_rand_int () % (G_N_ELEMENTS (stack) + 1);
|
||||
nstack = nmtst_get_rand_uint32 () % (G_N_ELEMENTS (stack) + 1);
|
||||
for (i = 0; i < nstack; i++) {
|
||||
stack[i].pl = &pl[nmtst_get_rand_int () % G_N_ELEMENTS (pl)];
|
||||
stack[i].ns_types = ns_types_list[nmtst_get_rand_int () % G_N_ELEMENTS (ns_types_list)];
|
||||
stack[i].pl = &pl[nmtst_get_rand_uint32 () % G_N_ELEMENTS (pl)];
|
||||
stack[i].ns_types = ns_types_list[nmtst_get_rand_uint32 () % G_N_ELEMENTS (ns_types_list)];
|
||||
|
||||
nmp_netns_push_type (nm_platform_netns_get (stack[i].pl->platform), stack[i].ns_types);
|
||||
}
|
||||
|
||||
/* pop some again. */
|
||||
for (i = nmtst_get_rand_int () % (nstack + 1); i > 0; i--) {
|
||||
for (i = nmtst_get_rand_uint32 () % (nstack + 1); i > 0; i--) {
|
||||
g_assert (nstack > 0);
|
||||
nstack--;
|
||||
nmp_netns_pop (nm_platform_netns_get (stack[nstack].pl->platform));
|
||||
@@ -2789,7 +2789,7 @@ test_netns_bind_to_path (gpointer fixture, gconstpointer test_data)
|
||||
g_assert_cmpint (mount ("tmpfs", P_VAR_RUN, "tmpfs", MS_NOATIME | MS_NODEV | MS_NOSUID, "mode=0755,size=32K"), ==, 0);
|
||||
g_assert_cmpint (mkdir (P_VAR_RUN_NETNS, 755), ==, 0);
|
||||
|
||||
i = (nmtst_get_rand_int () % 2) + 1;
|
||||
i = (nmtst_get_rand_uint32 () % 2) + 1;
|
||||
netns = nm_platform_netns_get (platforms[i]);
|
||||
|
||||
_ADD_DUMMY (platforms[i], "dummy2b");
|
||||
@@ -2832,9 +2832,9 @@ test_sysctl_rename (void)
|
||||
ifindex[0] = nmtstp_link_dummy_add (PL, -1, IFNAME[0])->ifindex;
|
||||
ifindex[1] = nmtstp_link_dummy_add (PL, -1, IFNAME[1])->ifindex;
|
||||
|
||||
s = (nmtst_get_rand_int () % 2) ? NULL : ifname_buf;
|
||||
s = (nmtst_get_rand_uint32 () % 2) ? NULL : ifname_buf;
|
||||
|
||||
if (nmtst_get_rand_int () % 2) {
|
||||
if (nmtst_get_rand_uint32 () % 2) {
|
||||
/* bring the platform cache out of sync */
|
||||
nmtstp_run_command_check ("ip link set %s name %s", IFNAME[0], IFNAME[2]);
|
||||
nm_platform_process_events (PL);
|
||||
@@ -2847,7 +2847,7 @@ test_sysctl_rename (void)
|
||||
}
|
||||
|
||||
/* open dirfd for IFNAME[0] */
|
||||
i = nmtst_get_rand_int () % (2 + G_N_ELEMENTS (IFNAME));
|
||||
i = nmtst_get_rand_uint32 () % (2 + G_N_ELEMENTS (IFNAME));
|
||||
if (i == 0) {
|
||||
dirfd = nm_platform_sysctl_open_netdir (PL,
|
||||
ifindex[0],
|
||||
@@ -2866,7 +2866,7 @@ test_sysctl_rename (void)
|
||||
g_assert_cmpstr (s, ==, IFNAME[0]);
|
||||
|
||||
/* possibly rename the interfaces. */
|
||||
switch (nmtst_get_rand_int () % 4) {
|
||||
switch (nmtst_get_rand_uint32 () % 4) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
@@ -2879,11 +2879,11 @@ test_sysctl_rename (void)
|
||||
}
|
||||
|
||||
/* possibly, resync platform cache (should make no difference). */
|
||||
if (nmtst_get_rand_int () % 2)
|
||||
if (nmtst_get_rand_uint32 () % 2)
|
||||
nm_platform_process_events (PL);
|
||||
|
||||
/* check that we still read the same file. */
|
||||
switch (nmtst_get_rand_int () % 2) {
|
||||
switch (nmtst_get_rand_uint32 () % 2) {
|
||||
case 0: {
|
||||
gs_free char *c = NULL;
|
||||
|
||||
@@ -2930,7 +2930,7 @@ test_sysctl_netns_switch (void)
|
||||
platforms[0] = platform_0 = nm_linux_platform_new (TRUE, TRUE);
|
||||
platforms[1] = platform_1 = _test_netns_create_platform ();
|
||||
platforms[2] = platform_2 = _test_netns_create_platform ();
|
||||
PL = platforms[nmtst_get_rand_int () % 3];
|
||||
PL = platforms[nmtst_get_rand_uint32 () % 3];
|
||||
|
||||
nmtstp_netns_select_random (platforms, G_N_ELEMENTS (platforms), &netns_pop_1);
|
||||
|
||||
@@ -2938,7 +2938,7 @@ test_sysctl_netns_switch (void)
|
||||
|
||||
nmtstp_netns_select_random (platforms, G_N_ELEMENTS (platforms), &netns_pop_2);
|
||||
|
||||
s = (nmtst_get_rand_int () % 2) ? NULL : ifname_buf;
|
||||
s = (nmtst_get_rand_uint32 () % 2) ? NULL : ifname_buf;
|
||||
dirfd = nm_platform_sysctl_open_netdir (PL,
|
||||
ifindex,
|
||||
s);
|
||||
|
@@ -267,7 +267,7 @@ test_cache_link (void)
|
||||
struct udev_device *udev_device_3 = g_list_nth_data (global.udev_devices, 0);
|
||||
NMPCacheOpsType ops_type;
|
||||
nm_auto_unref_dedup_multi_index NMDedupMultiIndex *multi_idx = NULL;
|
||||
gboolean use_udev = nmtst_get_rand_int () % 2;
|
||||
gboolean use_udev = nmtst_get_rand_uint32 () % 2;
|
||||
|
||||
multi_idx = nm_dedup_multi_index_new ();
|
||||
|
||||
@@ -503,7 +503,7 @@ test_cache_qdisc (void)
|
||||
nm_auto_nmpobj NMPObject *obj2 = nmp_object_new (NMP_OBJECT_TYPE_QDISC, (NMPlatformObject *) &pl_qdisc_2);
|
||||
|
||||
multi_idx = nm_dedup_multi_index_new ();
|
||||
cache = nmp_cache_new (multi_idx, nmtst_get_rand_int () % 2);
|
||||
cache = nmp_cache_new (multi_idx, nmtst_get_rand_uint32 () % 2);
|
||||
|
||||
g_assert (nmp_cache_lookup_obj (cache, obj1a) == NULL);
|
||||
|
||||
|
@@ -445,7 +445,7 @@ test_ip4_route_get (void)
|
||||
result = nm_platform_ip_route_get (NM_PLATFORM_GET,
|
||||
AF_INET,
|
||||
&a,
|
||||
nmtst_get_rand_int () % 2 ? 0 : ifindex,
|
||||
nmtst_get_rand_uint32 () % 2 ? 0 : ifindex,
|
||||
&route);
|
||||
|
||||
g_assert (NMTST_NM_ERR_SUCCESS (result));
|
||||
@@ -607,7 +607,7 @@ test_ip6_route_get (void)
|
||||
result = nm_platform_ip_route_get (NM_PLATFORM_GET,
|
||||
AF_INET6,
|
||||
a,
|
||||
nmtst_get_rand_int () % 2 ? 0 : ifindex,
|
||||
nmtst_get_rand_uint32 () % 2 ? 0 : ifindex,
|
||||
&route);
|
||||
|
||||
g_assert (NMTST_NM_ERR_SUCCESS (result));
|
||||
@@ -815,9 +815,9 @@ test_ip (gconstpointer test_data)
|
||||
|
||||
if ( order_len == 0
|
||||
|| ( order_len < G_N_ELEMENTS (order_idx)
|
||||
&& nmtst_get_rand_int () % 2)) {
|
||||
&& nmtst_get_rand_uint32 () % 2)) {
|
||||
again_find_idx:
|
||||
idx = nmtst_get_rand_int () % G_N_ELEMENTS (iface_data);
|
||||
idx = nmtst_get_rand_uint32 () % G_N_ELEMENTS (iface_data);
|
||||
for (i = 0; i < order_len; i++) {
|
||||
if (order_idx[i] == idx)
|
||||
goto again_find_idx;
|
||||
@@ -827,7 +827,7 @@ again_find_idx:
|
||||
r->ifindex = iface_data[idx].ifindex;
|
||||
g_assert (NMTST_NM_ERR_SUCCESS (nm_platform_ip4_route_add (platform, NMP_NLM_FLAG_APPEND, r)));
|
||||
} else {
|
||||
i = nmtst_get_rand_int () % order_len;
|
||||
i = nmtst_get_rand_uint32 () % order_len;
|
||||
idx = order_idx[i];
|
||||
for (i++; i < order_len; i++)
|
||||
order_idx[i - 1] = order_idx[i];
|
||||
@@ -1129,17 +1129,17 @@ _rule_create_random (NMPlatform *platform)
|
||||
|
||||
addr_size = nm_utils_addr_family_to_size (rr->addr_family);
|
||||
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 1000u) < 50)
|
||||
rr->priority = 10000 + ((~p) % 20u);
|
||||
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 1000u) < 40)
|
||||
nm_sprintf_buf (rr->iifname, "t-iif-%u", (~p) % 20);
|
||||
else if ((p % 1000u) < 80)
|
||||
nm_sprintf_buf (rr->iifname, "%s", DEVICE_NAME);
|
||||
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 1000u) < 40)
|
||||
nm_sprintf_buf (rr->oifname, "t-oif-%d", (~p) % 20);
|
||||
else if ((p % 1000u) < 80)
|
||||
@@ -1149,14 +1149,14 @@ _rule_create_random (NMPlatform *platform)
|
||||
NMIPAddr *p_addr = i ? &rr->src : &rr->dst;
|
||||
guint8 *p_len = i ? &rr->src_len : &rr->dst_len;
|
||||
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 1000u) < 100) {
|
||||
/* if we set src_len/dst_len to zero, the src/dst is actually ignored.
|
||||
*
|
||||
* For fuzzying, still set the address. It shall have no further effect.
|
||||
* */
|
||||
*p_len = (~p) % (addr_size * 8 + 1);
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 3u) == 0) {
|
||||
if (rr->addr_family == AF_INET)
|
||||
p_addr->addr4 = nmtst_inet4_from_string (nm_sprintf_buf (saddr, "192.192.5.%u", (~p) % 256u));
|
||||
@@ -1167,12 +1167,12 @@ _rule_create_random (NMPlatform *platform)
|
||||
}
|
||||
}
|
||||
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 1000u) < 50)
|
||||
rr->tun_id = 10000 + ((~p) % 20);
|
||||
|
||||
again_action:
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 1000u) < 500)
|
||||
rr->action = FR_ACT_UNSPEC;
|
||||
else if ((p % 1000u) < 750)
|
||||
@@ -1180,22 +1180,22 @@ again_action:
|
||||
else
|
||||
rr->action = (~p) % 0x100u;
|
||||
|
||||
rr->priority = _rr_rand_choose_u32 (nmtst_get_rand_int ());
|
||||
rr->priority = _rr_rand_choose_u32 (nmtst_get_rand_uint32 ());
|
||||
|
||||
if ( rr->action == FR_ACT_GOTO
|
||||
&& rr->priority == G_MAXINT32)
|
||||
goto again_action;
|
||||
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 10000u) < 100)
|
||||
rr->goto_target = rr->priority + 1;
|
||||
else
|
||||
rr->goto_target = _rr_rand_choose_u32 (nmtst_get_rand_int ());
|
||||
rr->goto_target = _rr_rand_choose_u32 (nmtst_get_rand_uint32 ());
|
||||
if ( rr->action == FR_ACT_GOTO
|
||||
&& rr->goto_target <= rr->priority)
|
||||
goto again_action;
|
||||
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 1000u) < 25) {
|
||||
if (_rule_check_kernel_support (platform, FRA_L3MDEV)) {
|
||||
rr->l3mdev = TRUE;
|
||||
@@ -1205,7 +1205,7 @@ again_action:
|
||||
|
||||
again_table:
|
||||
if (!rr->l3mdev) {
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 1000u) < 700)
|
||||
rr->table = RT_TABLE_UNSPEC;
|
||||
else if ((p % 1000u) < 850)
|
||||
@@ -1217,33 +1217,33 @@ again_table:
|
||||
goto again_table;
|
||||
}
|
||||
|
||||
rr->fwmark = _rr_rand_choose_u32 (nmtst_get_rand_int ());
|
||||
rr->fwmask = _rr_rand_choose_u32 (nmtst_get_rand_int ());
|
||||
rr->fwmark = _rr_rand_choose_u32 (nmtst_get_rand_uint32 ());
|
||||
rr->fwmask = _rr_rand_choose_u32 (nmtst_get_rand_uint32 ());
|
||||
|
||||
rr->flow = _rr_rand_choose_u32 (nmtst_get_rand_int ());
|
||||
rr->flow = _rr_rand_choose_u32 (nmtst_get_rand_uint32 ());
|
||||
|
||||
if (_rule_check_kernel_support (platform, FRA_PROTOCOL))
|
||||
rr->protocol = _rr_rand_choose_u8 (nmtst_get_rand_int ());
|
||||
rr->protocol = _rr_rand_choose_u8 (nmtst_get_rand_uint32 ());
|
||||
|
||||
#define IPTOS_TOS_MASK 0x1E
|
||||
|
||||
again_tos:
|
||||
rr->tos = _rr_rand_choose_u8 (nmtst_get_rand_int ());
|
||||
rr->tos = _rr_rand_choose_u8 (nmtst_get_rand_uint32 ());
|
||||
if ( rr->addr_family == AF_INET
|
||||
&& rr->tos & ~IPTOS_TOS_MASK)
|
||||
goto again_tos;
|
||||
|
||||
if (_rule_check_kernel_support (platform, FRA_IP_PROTO))
|
||||
rr->ip_proto = _rr_rand_choose_u8 (nmtst_get_rand_int ());
|
||||
rr->ip_proto = _rr_rand_choose_u8 (nmtst_get_rand_uint32 ());
|
||||
|
||||
if (_rule_check_kernel_support (platform, FRA_SUPPRESS_PREFIXLEN))
|
||||
rr->suppress_prefixlen_inverse = ~_rr_rand_choose_u32 (nmtst_get_rand_int ());
|
||||
rr->suppress_prefixlen_inverse = ~_rr_rand_choose_u32 (nmtst_get_rand_uint32 ());
|
||||
|
||||
if (_rule_check_kernel_support (platform, FRA_SUPPRESS_IFGROUP))
|
||||
rr->suppress_ifgroup_inverse = ~_rr_rand_choose_u32 (nmtst_get_rand_int ());
|
||||
rr->suppress_ifgroup_inverse = ~_rr_rand_choose_u32 (nmtst_get_rand_uint32 ());
|
||||
|
||||
if (_rule_check_kernel_support (platform, FRA_UID_RANGE)) {
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
rr->uid_range_has = (p % 10000u) < 200;
|
||||
}
|
||||
|
||||
@@ -1265,10 +1265,10 @@ again_uid_range:
|
||||
if (!_rule_check_kernel_support (platform, attribute))
|
||||
continue;
|
||||
|
||||
p = nmtst_get_rand_int ();
|
||||
p = nmtst_get_rand_uint32 ();
|
||||
if ((p % 10000u) < 300) {
|
||||
while (range->start == 0) {
|
||||
p = p ^ nmtst_get_rand_int ();
|
||||
p = p ^ nmtst_get_rand_uint32 ();
|
||||
range->start = nmtst_rand_select (1u, 0xFFFEu, ((p ) % 0xFFFEu) + 1);
|
||||
range->end = nmtst_rand_select (1u, 0xFFFEu, ((p >> 16) % 0xFFFEu) + 1, range->start);
|
||||
if (range->end < range->start)
|
||||
@@ -1277,7 +1277,7 @@ again_uid_range:
|
||||
}
|
||||
}
|
||||
|
||||
p = nmtst_get_rand_int () % 1000u;
|
||||
p = nmtst_get_rand_uint32 () % 1000u;
|
||||
if (p < 100)
|
||||
rr->flags |= FIB_RULE_INVERT;
|
||||
|
||||
@@ -1482,10 +1482,10 @@ test_rule (gconstpointer test_data)
|
||||
|
||||
if (TEST_IDX != 1) {
|
||||
nmtst_rand_perm (NULL, objs->pdata, NULL, sizeof (gpointer), objs->len);
|
||||
g_ptr_array_set_size (objs, nmtst_get_rand_int () % (objs->len + 1));
|
||||
g_ptr_array_set_size (objs, nmtst_get_rand_uint32 () % (objs->len + 1));
|
||||
}
|
||||
|
||||
n = (TEST_IDX != 1) ? nmtst_get_rand_int () % 50u : 0u;
|
||||
n = (TEST_IDX != 1) ? nmtst_get_rand_uint32 () % 50u : 0u;
|
||||
for (i = 0; i < n; i++) {
|
||||
nm_auto_nmpobj const NMPObject *o = NULL;
|
||||
guint try = 0;
|
||||
@@ -1544,7 +1544,7 @@ again:
|
||||
-1,
|
||||
USER_TAG_2);
|
||||
}
|
||||
if (nmtst_get_rand_int () % objs_sync->len == 0) {
|
||||
if (nmtst_get_rand_uint32 () % objs_sync->len == 0) {
|
||||
nmp_rules_manager_sync (rules_manager, FALSE);
|
||||
g_assert_cmpint (nmtstp_platform_routing_rules_get_count (platform, AF_UNSPEC), ==, i + 1);
|
||||
}
|
||||
@@ -1554,7 +1554,7 @@ again:
|
||||
g_assert_cmpint (nmtstp_platform_routing_rules_get_count (platform, AF_UNSPEC), ==, objs_sync->len);
|
||||
|
||||
for (i = 0; i < objs_sync->len; i++) {
|
||||
switch (nmtst_get_rand_int () % 3) {
|
||||
switch (nmtst_get_rand_uint32 () % 3) {
|
||||
case 0:
|
||||
nmp_rules_manager_untrack (rules_manager,
|
||||
NMP_OBJECT_CAST_ROUTING_RULE (objs_sync->pdata[i]),
|
||||
@@ -1576,7 +1576,7 @@ again:
|
||||
USER_TAG_2);
|
||||
break;
|
||||
}
|
||||
if (nmtst_get_rand_int () % objs_sync->len == 0) {
|
||||
if (nmtst_get_rand_uint32 () % objs_sync->len == 0) {
|
||||
nmp_rules_manager_sync (rules_manager, FALSE);
|
||||
g_assert_cmpint (nmtstp_platform_routing_rules_get_count (platform, AF_UNSPEC), ==, objs_sync->len - i - 1);
|
||||
}
|
||||
|
@@ -310,7 +310,7 @@ _writer_new_connection_reread (NMConnection *connection,
|
||||
char *filename = NULL;
|
||||
gs_unref_object NMConnection *con_verified = NULL;
|
||||
gs_unref_object NMConnection *reread_copy = NULL;
|
||||
NMConnection **reread = out_reread ?: ((nmtst_get_rand_int () % 2) ? &reread_copy : NULL);
|
||||
NMConnection **reread = out_reread ?: ((nmtst_get_rand_uint32 () % 2) ? &reread_copy : NULL);
|
||||
|
||||
g_assert (NM_IS_CONNECTION (connection));
|
||||
g_assert (ifcfg_dir);
|
||||
@@ -9249,19 +9249,19 @@ test_team_reread_slave (void)
|
||||
|
||||
nmtst_assert_connection_equals (connection_1, FALSE, connection_2, FALSE);
|
||||
|
||||
_writer_new_connection_reread ((nmtst_get_rand_int () % 2) ? connection_1 : connection_2,
|
||||
_writer_new_connection_reread ((nmtst_get_rand_uint32 () % 2) ? connection_1 : connection_2,
|
||||
TEST_SCRATCH_DIR,
|
||||
&testfile,
|
||||
TEST_IFCFG_DIR"/ifcfg-team-slave-enp31s0f1-142.cexpected",
|
||||
&reread,
|
||||
&reread_same);
|
||||
_assert_reread_same ((nmtst_get_rand_int () % 2) ? connection_1 : connection_2, reread);
|
||||
_assert_reread_same ((nmtst_get_rand_uint32 () % 2) ? connection_1 : connection_2, reread);
|
||||
g_assert (reread_same);
|
||||
g_clear_object (&reread);
|
||||
|
||||
reread = _connection_from_file (testfile, NULL, TYPE_VLAN,
|
||||
NULL);
|
||||
nmtst_assert_connection_equals ((nmtst_get_rand_int () % 2) ? connection_1 : connection_2, FALSE,
|
||||
nmtst_assert_connection_equals ((nmtst_get_rand_uint32 () % 2) ? connection_1 : connection_2, FALSE,
|
||||
reread, FALSE);
|
||||
}
|
||||
|
||||
@@ -9426,7 +9426,7 @@ do_svUnescape_combine_ansi (GString *str_val, GString *str_exp, const UnescapeTe
|
||||
g_string_append (str_val, "$'");
|
||||
if (idx < 0) {
|
||||
for (i = -idx; i > 0; i--) {
|
||||
j = nmtst_get_rand_int () % data_len;
|
||||
j = nmtst_get_rand_uint32 () % data_len;
|
||||
if (!data_ansi[j].can_concat) {
|
||||
i++;
|
||||
continue;
|
||||
@@ -9625,7 +9625,7 @@ test_svUnescape (void)
|
||||
|
||||
/* different values can be just concatenated... */
|
||||
for (i = 0; i < 200; i++) {
|
||||
gsize num_concat = (nmtst_get_rand_int () % 5) + 2;
|
||||
gsize num_concat = (nmtst_get_rand_uint32 () % 5) + 2;
|
||||
|
||||
g_string_set_size (str_val, 0);
|
||||
g_string_set_size (str_exp, 0);
|
||||
@@ -9633,12 +9633,12 @@ test_svUnescape (void)
|
||||
while (num_concat > 0) {
|
||||
gsize idx;
|
||||
|
||||
if ((nmtst_get_rand_int () % 3 == 0)) {
|
||||
do_svUnescape_combine_ansi (str_val2, str_exp2, data_ansi, G_N_ELEMENTS (data_ansi), -((int) ((nmtst_get_rand_int () % 5) + 1)));
|
||||
if ((nmtst_get_rand_uint32 () % 3 == 0)) {
|
||||
do_svUnescape_combine_ansi (str_val2, str_exp2, data_ansi, G_N_ELEMENTS (data_ansi), -((int) ((nmtst_get_rand_uint32 () % 5) + 1)));
|
||||
continue;
|
||||
}
|
||||
|
||||
idx = nmtst_get_rand_int () % G_N_ELEMENTS (data_full);
|
||||
idx = nmtst_get_rand_uint32 () % G_N_ELEMENTS (data_full);
|
||||
if (!data_full[idx].can_concat)
|
||||
continue;
|
||||
g_string_append (str_val, data_full[idx].val);
|
||||
@@ -9646,7 +9646,7 @@ test_svUnescape (void)
|
||||
num_concat--;
|
||||
}
|
||||
|
||||
switch (nmtst_get_rand_int () % 3) {
|
||||
switch (nmtst_get_rand_uint32 () % 3) {
|
||||
case 0:
|
||||
g_string_append (str_val, " ");
|
||||
break;
|
||||
@@ -9654,7 +9654,7 @@ test_svUnescape (void)
|
||||
g_string_append (str_val, " ");
|
||||
break;
|
||||
}
|
||||
switch (nmtst_get_rand_int () % 3) {
|
||||
switch (nmtst_get_rand_uint32 () % 3) {
|
||||
case 0:
|
||||
g_string_append (str_val, " #");
|
||||
break;
|
||||
|
@@ -73,7 +73,7 @@ check_ip_route (NMSettingIPConfig *config, int idx, const char *destination, int
|
||||
\
|
||||
_connection = nms_keyfile_reader_from_file (full_filename, \
|
||||
NULL, \
|
||||
(nmtst_get_rand_int () % 2) ? &_error : NULL); \
|
||||
(nmtst_get_rand_uint32 () % 2) ? &_error : NULL); \
|
||||
nmtst_assert_success (_connection, _error); \
|
||||
nmtst_assert_connection_verifies_without_normalization (_connection); \
|
||||
\
|
||||
@@ -128,7 +128,7 @@ write_test_connection_reread (NMConnection *connection,
|
||||
gid_t owner_grp;
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
GError **p_error = (nmtst_get_rand_int () % 2) ? &error : NULL;
|
||||
GError **p_error = (nmtst_get_rand_uint32 () % 2) ? &error : NULL;
|
||||
gs_unref_object NMConnection *connection_normalized = NULL;
|
||||
|
||||
g_assert (NM_IS_CONNECTION (connection));
|
||||
|
@@ -541,7 +541,7 @@ test_nm_utils_new_vlan_name (void)
|
||||
guint vlan_id;
|
||||
|
||||
/* Create a random VLAN id between 0 and 4094 */
|
||||
vlan_id = nmtst_get_rand_int () % 4095;
|
||||
vlan_id = nmtst_get_rand_uint32 () % 4095;
|
||||
|
||||
vlan_id_s = g_strdup_printf (".%d", vlan_id);
|
||||
|
||||
|
@@ -147,7 +147,7 @@ test_nm_utils_ip6_address_same_prefix (void)
|
||||
nmtst_rand_buf (NULL, a.ptr, sizeof (a));
|
||||
nmtst_rand_buf (NULL, b.ptr, sizeof (b));
|
||||
again_plen:
|
||||
plen = nmtst_get_rand_int () % 129;
|
||||
plen = nmtst_get_rand_uint32 () % 129;
|
||||
if (!is_same && NM_IN_SET (plen, 0, 128))
|
||||
goto again_plen;
|
||||
|
||||
@@ -181,7 +181,7 @@ again_plen:
|
||||
for (n = 0; n < N; n++) {
|
||||
nmtst_rand_buf (NULL, a.ptr, sizeof (a));
|
||||
nmtst_rand_buf (NULL, b.ptr, sizeof (b));
|
||||
plen = nmtst_get_rand_int () % 129;
|
||||
plen = nmtst_get_rand_uint32 () % 129;
|
||||
|
||||
memset (addrmask.ptr, 0xFF, sizeof (addrmask));
|
||||
nm_utils_ip6_address_clear_host_address (&addrmask.val, &addrmask.val, plen);
|
||||
@@ -198,7 +198,7 @@ again_plen:
|
||||
|
||||
nmtst_rand_buf (NULL, a.ptr, sizeof (a));
|
||||
nmtst_rand_buf (NULL, b.ptr, sizeof (b));
|
||||
plen = nmtst_get_rand_int () % 129;
|
||||
plen = nmtst_get_rand_uint32 () % 129;
|
||||
|
||||
if (!plen)
|
||||
continue;
|
||||
@@ -1456,7 +1456,7 @@ test_nm_utils_strbuf_append (void)
|
||||
const char *_str_iter; \
|
||||
gs_free char *_str = NULL; \
|
||||
\
|
||||
switch (nmtst_get_rand_int () % 4) { \
|
||||
switch (nmtst_get_rand_uint32 () % 4) { \
|
||||
case 0: \
|
||||
nm_utils_strbuf_append (_buf, _len, (format), __VA_ARGS__); \
|
||||
break; \
|
||||
@@ -1484,7 +1484,7 @@ test_nm_utils_strbuf_append (void)
|
||||
gsize *_len = (len); \
|
||||
const char *_str = (str); \
|
||||
\
|
||||
switch (nmtst_get_rand_int () % 4) { \
|
||||
switch (nmtst_get_rand_uint32 () % 4) { \
|
||||
case 0: \
|
||||
nm_utils_strbuf_append (_buf, _len, "%s", _str ?: ""); \
|
||||
break; \
|
||||
@@ -1509,7 +1509,7 @@ test_nm_utils_strbuf_append (void)
|
||||
gsize *_len = (len); \
|
||||
char _ch = (ch); \
|
||||
\
|
||||
switch (nmtst_get_rand_int () % 4) { \
|
||||
switch (nmtst_get_rand_uint32 () % 4) { \
|
||||
case 0: \
|
||||
nm_utils_strbuf_append (_buf, _len, "%c", _ch); \
|
||||
break; \
|
||||
@@ -1527,7 +1527,7 @@ test_nm_utils_strbuf_append (void)
|
||||
|
||||
for (buf_len = 0; buf_len < 10; buf_len++) {
|
||||
for (rep = 0; rep < 50; rep++) {
|
||||
const int s_len = nmtst_get_rand_int () % (sizeof (str) - 5);
|
||||
const int s_len = nmtst_get_rand_uint32 () % (sizeof (str) - 5);
|
||||
char *t_buf;
|
||||
gsize t_len;
|
||||
int test_mode;
|
||||
@@ -1543,7 +1543,7 @@ test_nm_utils_strbuf_append (void)
|
||||
t_buf = buf;
|
||||
t_len = buf_len;
|
||||
|
||||
test_mode = nmtst_get_rand_int () % 5;
|
||||
test_mode = nmtst_get_rand_uint32 () % 5;
|
||||
|
||||
switch (test_mode) {
|
||||
case 0:
|
||||
@@ -1568,7 +1568,7 @@ test_nm_utils_strbuf_append (void)
|
||||
g_snprintf (t_buf, t_len, "%s", str);
|
||||
if ( t_len > 0
|
||||
&& strlen (str) >= buf_len
|
||||
&& (nmtst_get_rand_int () % 2)) {
|
||||
&& (nmtst_get_rand_uint32 () % 2)) {
|
||||
/* the string was truncated by g_snprintf(). That means, at the last position in the
|
||||
* buffer is now NUL.
|
||||
* Replace the NUL by the actual character, and check that nm_utils_strbuf_seek_end()
|
||||
@@ -1688,7 +1688,7 @@ test_duplicate_decl_specifier (void)
|
||||
(_a > _b ? _a : _b); \
|
||||
})
|
||||
|
||||
v_result[0] = TEST_MAX (v_const[0], nmtst_get_rand_int () % 5) + v2;
|
||||
v_result[0] = TEST_MAX (v_const[0], nmtst_get_rand_uint32 () % 5) + v2;
|
||||
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
@@ -157,7 +157,7 @@ test_sd_event (void)
|
||||
|
||||
g_assert_cmpint (sd_event_default (NULL), ==, 0);
|
||||
|
||||
for (i = 0, n = (nmtst_get_rand_int () % (G_N_ELEMENTS (other_events) + 1)); i < n; i++) {
|
||||
for (i = 0, n = (nmtst_get_rand_uint32 () % (G_N_ELEMENTS (other_events) + 1)); i < n; i++) {
|
||||
r = sd_event_default (&other_events[i]);
|
||||
g_assert (r >= 0 && other_events[i]);
|
||||
}
|
||||
@@ -177,7 +177,7 @@ test_sd_event (void)
|
||||
g_assert (!user_data.event_source);
|
||||
|
||||
event = sd_event_unref (event);
|
||||
for (i = 0, n = (nmtst_get_rand_int () % (G_N_ELEMENTS (other_events) + 1)); i < n; i++)
|
||||
for (i = 0, n = (nmtst_get_rand_uint32 () % (G_N_ELEMENTS (other_events) + 1)); i < n; i++)
|
||||
other_events[i] = sd_event_unref (other_events[i]);
|
||||
nm_clear_g_source (&sd_id);
|
||||
for (i = 0, n = G_N_ELEMENTS (other_events); i < n; i++)
|
||||
@@ -311,15 +311,15 @@ test_nm_sd_utils_unbase64mem (void)
|
||||
_test_unbase64mem ("YQ==", "a");
|
||||
_test_unbase64mem_inval ("YQ==a");
|
||||
|
||||
rnd_len = nmtst_get_rand_int () % sizeof (rnd_buf);
|
||||
rnd_len = nmtst_get_rand_uint32 () % sizeof (rnd_buf);
|
||||
for (i = 0; i < rnd_len; i++)
|
||||
rnd_buf[i] = nmtst_get_rand_int () % 256;
|
||||
rnd_buf[i] = nmtst_get_rand_uint32 () % 256;
|
||||
rnd_base64 = g_base64_encode (rnd_buf, rnd_len);
|
||||
_test_unbase64mem_mem (rnd_base64, rnd_buf, rnd_len);
|
||||
|
||||
_test_unbase64char ('=', FALSE);
|
||||
for (i = 0; i < 10; i++) {
|
||||
char ch = nmtst_get_rand_int () % 256;
|
||||
char ch = nmtst_get_rand_uint32 () % 256;
|
||||
|
||||
if (ch != '=')
|
||||
_test_unbase64char (ch, TRUE);
|
||||
|
Reference in New Issue
Block a user