mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 02:40:17 +01:00
platform/tests: add nmtstp_netns_select_random() util
This commit is contained in:
parent
22be2ae865
commit
5eb4dfe7ab
2 changed files with 23 additions and 0 deletions
|
|
@ -1554,6 +1554,25 @@ nmtstp_namespace_get_fd_for_process (pid_t pid, const char *ns_name)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nmtstp_netns_select_random (NMPlatform **platforms, gsize n_platforms, NMPNetns **netns)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_assert (platforms);
|
||||
g_assert (n_platforms && n_platforms <= G_MAXINT32);
|
||||
g_assert (netns && !*netns);
|
||||
for (i = 0; i < n_platforms; i++)
|
||||
g_assert (NM_IS_PLATFORM (platforms[i]));
|
||||
|
||||
i = nmtst_get_rand_int () % (n_platforms + 1);
|
||||
if (i == 0)
|
||||
return;
|
||||
g_assert (nm_platform_netns_push (platforms[i - 1], netns));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMTST_DEFINE();
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ int nmtstp_namespace_get_fd_for_process (pid_t pid, const char *ns_name);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
void nmtstp_netns_select_random (NMPlatform **platforms, gsize n_platforms, NMPNetns **netns);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
gulong handler_id;
|
||||
const char *name;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue