mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 06:00:08 +01:00
platform/test: refactor detection of root-test
This commit is contained in:
parent
bdb2f94519
commit
313af401d3
3 changed files with 13 additions and 6 deletions
|
|
@ -4,6 +4,15 @@
|
|||
|
||||
#include "nm-test-utils.h"
|
||||
|
||||
|
||||
gboolean
|
||||
nmtst_platform_is_root_test ()
|
||||
{
|
||||
NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare")
|
||||
return (SETUP == nm_linux_platform_setup);
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
}
|
||||
|
||||
SignalData *
|
||||
add_signal_full (const char *name, NMPlatformSignalChangeType change_type, GCallback callback, int ifindex, const char *ifname)
|
||||
{
|
||||
|
|
@ -257,8 +266,7 @@ main (int argc, char **argv)
|
|||
|
||||
init_tests (&argc, &argv);
|
||||
|
||||
NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare")
|
||||
if (SETUP == nm_linux_platform_setup && getuid() != 0) {
|
||||
if (nmtst_platform_is_root_test () && getuid() != 0) {
|
||||
/* Try to exec as sudo, this function does not return, if a sudo-cmd is set. */
|
||||
nmtst_reexec_sudo ();
|
||||
|
||||
|
|
@ -270,7 +278,6 @@ main (int argc, char **argv)
|
|||
return 77;
|
||||
#endif
|
||||
}
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
|
||||
SETUP ();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ typedef struct {
|
|||
const char *ifname;
|
||||
} SignalData;
|
||||
|
||||
gboolean nmtst_platform_is_root_test (void);
|
||||
|
||||
SignalData *add_signal_full (const char *name, NMPlatformSignalChangeType change_type, GCallback callback, int ifindex, const char *ifname);
|
||||
#define add_signal(name, change_type, callback) add_signal_full (name, change_type, (GCallback) callback, 0, NULL)
|
||||
#define add_signal_ifindex(name, change_type, callback, ifindex) add_signal_full (name, change_type, (GCallback) callback, ifindex, NULL)
|
||||
|
|
|
|||
|
|
@ -365,14 +365,12 @@ test_bridge (void)
|
|||
static void
|
||||
test_bond (void)
|
||||
{
|
||||
NM_PRAGMA_WARNING_DISABLE("-Wtautological-compare")
|
||||
if (SETUP == nm_linux_platform_setup &&
|
||||
if (nmtst_platform_is_root_test () &&
|
||||
!g_file_test ("/proc/1/net/bonding", G_FILE_TEST_IS_DIR) &&
|
||||
system("modprobe --show bonding") != 0) {
|
||||
g_test_skip ("Skipping test for bonding: bonding module not available");
|
||||
return;
|
||||
}
|
||||
NM_PRAGMA_WARNING_REENABLE
|
||||
|
||||
test_software (NM_LINK_TYPE_BOND, "bond");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue