build: disable Test interface in base manager if building without tests
There is no real need for this interface if tests are not being built.
This commit is contained in:
@@ -90,6 +90,7 @@ cc_args = cc.get_supported_arguments([
|
|||||||
|
|
||||||
# tests are enabled by default
|
# tests are enabled by default
|
||||||
enable_tests = get_option('tests')
|
enable_tests = get_option('tests')
|
||||||
|
config_h.set('WITH_TESTS', enable_tests)
|
||||||
|
|
||||||
# strict flags to use in debug builds
|
# strict flags to use in debug builds
|
||||||
if get_option('buildtype').contains('debug')
|
if get_option('buildtype').contains('debug')
|
||||||
|
@@ -97,7 +97,9 @@ bus_acquired_cb (GDBusConnection *connection,
|
|||||||
!mm_context_get_no_auto_scan (),
|
!mm_context_get_no_auto_scan (),
|
||||||
mm_context_get_filter_policy (),
|
mm_context_get_filter_policy (),
|
||||||
mm_context_get_initial_kernel_events (),
|
mm_context_get_initial_kernel_events (),
|
||||||
|
#if defined WITH_TESTS
|
||||||
mm_context_get_test_enable (),
|
mm_context_get_test_enable (),
|
||||||
|
#endif
|
||||||
&error);
|
&error);
|
||||||
if (!manager) {
|
if (!manager) {
|
||||||
mm_warn ("could not create manager: %s", error->message);
|
mm_warn ("could not create manager: %s", error->message);
|
||||||
|
@@ -41,7 +41,9 @@
|
|||||||
|
|
||||||
#include <mm-errors-types.h>
|
#include <mm-errors-types.h>
|
||||||
#include <mm-gdbus-manager.h>
|
#include <mm-gdbus-manager.h>
|
||||||
#include <mm-gdbus-test.h>
|
#if defined WITH_TESTS
|
||||||
|
# include <mm-gdbus-test.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "mm-context.h"
|
#include "mm-context.h"
|
||||||
#include "mm-base-manager.h"
|
#include "mm-base-manager.h"
|
||||||
@@ -66,9 +68,11 @@ enum {
|
|||||||
PROP_CONNECTION,
|
PROP_CONNECTION,
|
||||||
PROP_AUTO_SCAN,
|
PROP_AUTO_SCAN,
|
||||||
PROP_FILTER_POLICY,
|
PROP_FILTER_POLICY,
|
||||||
PROP_ENABLE_TEST,
|
|
||||||
PROP_PLUGIN_DIR,
|
PROP_PLUGIN_DIR,
|
||||||
PROP_INITIAL_KERNEL_EVENTS,
|
PROP_INITIAL_KERNEL_EVENTS,
|
||||||
|
#if defined WITH_TESTS
|
||||||
|
PROP_ENABLE_TEST,
|
||||||
|
#endif
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -79,8 +83,6 @@ struct _MMBaseManagerPrivate {
|
|||||||
gboolean auto_scan;
|
gboolean auto_scan;
|
||||||
/* Filter policy (mask of enabled rules) */
|
/* Filter policy (mask of enabled rules) */
|
||||||
MMFilterRule filter_policy;
|
MMFilterRule filter_policy;
|
||||||
/* Whether the test interface is enabled */
|
|
||||||
gboolean enable_test;
|
|
||||||
/* Path to look for plugins */
|
/* Path to look for plugins */
|
||||||
gchar *plugin_dir;
|
gchar *plugin_dir;
|
||||||
/* Path to the list of initial kernel events */
|
/* Path to the list of initial kernel events */
|
||||||
@@ -99,8 +101,12 @@ struct _MMBaseManagerPrivate {
|
|||||||
/* The map of inhibited devices */
|
/* The map of inhibited devices */
|
||||||
GHashTable *inhibited_devices;
|
GHashTable *inhibited_devices;
|
||||||
|
|
||||||
|
#if defined WITH_TESTS
|
||||||
|
/* Whether the test interface is enabled */
|
||||||
|
gboolean enable_test;
|
||||||
/* The Test interface support */
|
/* The Test interface support */
|
||||||
MmGdbusTest *test_skeleton;
|
MmGdbusTest *test_skeleton;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined WITH_UDEV
|
#if defined WITH_UDEV
|
||||||
/* The UDev client */
|
/* The UDev client */
|
||||||
@@ -1297,6 +1303,8 @@ handle_inhibit_device (MmGdbusOrgFreedesktopModemManager1 *manager,
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Test profile setup */
|
/* Test profile setup */
|
||||||
|
|
||||||
|
#if defined WITH_TESTS
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_set_profile (MmGdbusTest *skeleton,
|
handle_set_profile (MmGdbusTest *skeleton,
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
@@ -1358,6 +1366,8 @@ out:
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
@@ -1374,7 +1384,9 @@ mm_base_manager_new (GDBusConnection *connection,
|
|||||||
gboolean auto_scan,
|
gboolean auto_scan,
|
||||||
MMFilterRule filter_policy,
|
MMFilterRule filter_policy,
|
||||||
const gchar *initial_kernel_events,
|
const gchar *initial_kernel_events,
|
||||||
|
#if defined WITH_TESTS
|
||||||
gboolean enable_test,
|
gboolean enable_test,
|
||||||
|
#endif
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
|
g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
|
||||||
@@ -1387,8 +1399,10 @@ mm_base_manager_new (GDBusConnection *connection,
|
|||||||
MM_BASE_MANAGER_AUTO_SCAN, auto_scan,
|
MM_BASE_MANAGER_AUTO_SCAN, auto_scan,
|
||||||
MM_BASE_MANAGER_FILTER_POLICY, filter_policy,
|
MM_BASE_MANAGER_FILTER_POLICY, filter_policy,
|
||||||
MM_BASE_MANAGER_INITIAL_KERNEL_EVENTS, initial_kernel_events,
|
MM_BASE_MANAGER_INITIAL_KERNEL_EVENTS, initial_kernel_events,
|
||||||
MM_BASE_MANAGER_ENABLE_TEST, enable_test,
|
|
||||||
"version", MM_DIST_VERSION,
|
"version", MM_DIST_VERSION,
|
||||||
|
#if defined WITH_TESTS
|
||||||
|
MM_BASE_MANAGER_ENABLE_TEST, enable_test,
|
||||||
|
#endif
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1415,11 +1429,13 @@ set_property (GObject *object,
|
|||||||
mm_obj_dbg (self, "stopping connection in object manager server");
|
mm_obj_dbg (self, "stopping connection in object manager server");
|
||||||
g_dbus_object_manager_server_set_connection (self->priv->object_manager, NULL);
|
g_dbus_object_manager_server_set_connection (self->priv->object_manager, NULL);
|
||||||
}
|
}
|
||||||
|
#if defined WITH_TESTS
|
||||||
if (self->priv->test_skeleton &&
|
if (self->priv->test_skeleton &&
|
||||||
g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (self->priv->test_skeleton))) {
|
g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (self->priv->test_skeleton))) {
|
||||||
mm_obj_dbg (self, "stopping connection in test skeleton");
|
mm_obj_dbg (self, "stopping connection in test skeleton");
|
||||||
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->priv->test_skeleton));
|
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->priv->test_skeleton));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1429,9 +1445,6 @@ set_property (GObject *object,
|
|||||||
case PROP_FILTER_POLICY:
|
case PROP_FILTER_POLICY:
|
||||||
self->priv->filter_policy = g_value_get_flags (value);
|
self->priv->filter_policy = g_value_get_flags (value);
|
||||||
break;
|
break;
|
||||||
case PROP_ENABLE_TEST:
|
|
||||||
self->priv->enable_test = g_value_get_boolean (value);
|
|
||||||
break;
|
|
||||||
case PROP_PLUGIN_DIR:
|
case PROP_PLUGIN_DIR:
|
||||||
g_free (self->priv->plugin_dir);
|
g_free (self->priv->plugin_dir);
|
||||||
self->priv->plugin_dir = g_value_dup_string (value);
|
self->priv->plugin_dir = g_value_dup_string (value);
|
||||||
@@ -1440,6 +1453,11 @@ set_property (GObject *object,
|
|||||||
g_free (self->priv->initial_kernel_events);
|
g_free (self->priv->initial_kernel_events);
|
||||||
self->priv->initial_kernel_events = g_value_dup_string (value);
|
self->priv->initial_kernel_events = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
|
#if defined WITH_TESTS
|
||||||
|
case PROP_ENABLE_TEST:
|
||||||
|
self->priv->enable_test = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -1464,15 +1482,17 @@ get_property (GObject *object,
|
|||||||
case PROP_FILTER_POLICY:
|
case PROP_FILTER_POLICY:
|
||||||
g_value_set_flags (value, self->priv->filter_policy);
|
g_value_set_flags (value, self->priv->filter_policy);
|
||||||
break;
|
break;
|
||||||
case PROP_ENABLE_TEST:
|
|
||||||
g_value_set_boolean (value, self->priv->enable_test);
|
|
||||||
break;
|
|
||||||
case PROP_PLUGIN_DIR:
|
case PROP_PLUGIN_DIR:
|
||||||
g_value_set_string (value, self->priv->plugin_dir);
|
g_value_set_string (value, self->priv->plugin_dir);
|
||||||
break;
|
break;
|
||||||
case PROP_INITIAL_KERNEL_EVENTS:
|
case PROP_INITIAL_KERNEL_EVENTS:
|
||||||
g_value_set_string (value, self->priv->initial_kernel_events);
|
g_value_set_string (value, self->priv->initial_kernel_events);
|
||||||
break;
|
break;
|
||||||
|
#if defined WITH_TESTS
|
||||||
|
case PROP_ENABLE_TEST:
|
||||||
|
g_value_set_boolean (value, self->priv->enable_test);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -1498,8 +1518,10 @@ mm_base_manager_init (MMBaseManager *self)
|
|||||||
/* By default, enable autoscan */
|
/* By default, enable autoscan */
|
||||||
self->priv->auto_scan = TRUE;
|
self->priv->auto_scan = TRUE;
|
||||||
|
|
||||||
|
#if defined WITH_TESTS
|
||||||
/* By default, no test interface */
|
/* By default, no test interface */
|
||||||
self->priv->enable_test = FALSE;
|
self->priv->enable_test = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Setup Object Manager Server */
|
/* Setup Object Manager Server */
|
||||||
self->priv->object_manager = g_dbus_object_manager_server_new (MM_DBUS_PATH);
|
self->priv->object_manager = g_dbus_object_manager_server_new (MM_DBUS_PATH);
|
||||||
@@ -1565,6 +1587,7 @@ initable_init (GInitable *initable,
|
|||||||
g_dbus_object_manager_server_set_connection (self->priv->object_manager,
|
g_dbus_object_manager_server_set_connection (self->priv->object_manager,
|
||||||
self->priv->connection);
|
self->priv->connection);
|
||||||
|
|
||||||
|
#if defined WITH_TESTS
|
||||||
/* Setup the Test skeleton and export the interface */
|
/* Setup the Test skeleton and export the interface */
|
||||||
if (self->priv->enable_test) {
|
if (self->priv->enable_test) {
|
||||||
self->priv->test_skeleton = mm_gdbus_test_skeleton_new ();
|
self->priv->test_skeleton = mm_gdbus_test_skeleton_new ();
|
||||||
@@ -1578,6 +1601,7 @@ initable_init (GInitable *initable,
|
|||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* All good */
|
/* All good */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -1613,8 +1637,10 @@ finalize (GObject *object)
|
|||||||
if (self->priv->object_manager)
|
if (self->priv->object_manager)
|
||||||
g_object_unref (self->priv->object_manager);
|
g_object_unref (self->priv->object_manager);
|
||||||
|
|
||||||
|
#if defined WITH_TESTS
|
||||||
if (self->priv->test_skeleton)
|
if (self->priv->test_skeleton)
|
||||||
g_object_unref (self->priv->test_skeleton);
|
g_object_unref (self->priv->test_skeleton);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (self->priv->connection)
|
if (self->priv->connection)
|
||||||
g_object_unref (self->priv->connection);
|
g_object_unref (self->priv->connection);
|
||||||
@@ -1678,14 +1704,6 @@ mm_base_manager_class_init (MMBaseManagerClass *manager_class)
|
|||||||
MM_FILTER_RULE_NONE,
|
MM_FILTER_RULE_NONE,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
g_object_class_install_property
|
|
||||||
(object_class, PROP_ENABLE_TEST,
|
|
||||||
g_param_spec_boolean (MM_BASE_MANAGER_ENABLE_TEST,
|
|
||||||
"Enable tests",
|
|
||||||
"Enable the Test interface",
|
|
||||||
FALSE,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
||||||
|
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_PLUGIN_DIR,
|
(object_class, PROP_PLUGIN_DIR,
|
||||||
g_param_spec_string (MM_BASE_MANAGER_PLUGIN_DIR,
|
g_param_spec_string (MM_BASE_MANAGER_PLUGIN_DIR,
|
||||||
@@ -1701,4 +1719,14 @@ mm_base_manager_class_init (MMBaseManagerClass *manager_class)
|
|||||||
"Path to a file with the list of initial kernel events",
|
"Path to a file with the list of initial kernel events",
|
||||||
NULL,
|
NULL,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
|
||||||
|
#if defined WITH_TESTS
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_ENABLE_TEST,
|
||||||
|
g_param_spec_boolean (MM_BASE_MANAGER_ENABLE_TEST,
|
||||||
|
"Enable tests",
|
||||||
|
"Enable the Test interface",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,8 @@
|
|||||||
#ifndef MM_BASE_MANAGER_H
|
#ifndef MM_BASE_MANAGER_H
|
||||||
#define MM_BASE_MANAGER_H
|
#define MM_BASE_MANAGER_H
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
@@ -34,9 +36,11 @@
|
|||||||
#define MM_BASE_MANAGER_CONNECTION "connection" /* Construct-only */
|
#define MM_BASE_MANAGER_CONNECTION "connection" /* Construct-only */
|
||||||
#define MM_BASE_MANAGER_AUTO_SCAN "auto-scan" /* Construct-only */
|
#define MM_BASE_MANAGER_AUTO_SCAN "auto-scan" /* Construct-only */
|
||||||
#define MM_BASE_MANAGER_FILTER_POLICY "filter-policy" /* Construct-only */
|
#define MM_BASE_MANAGER_FILTER_POLICY "filter-policy" /* Construct-only */
|
||||||
#define MM_BASE_MANAGER_ENABLE_TEST "enable-test" /* Construct-only */
|
|
||||||
#define MM_BASE_MANAGER_PLUGIN_DIR "plugin-dir" /* Construct-only */
|
#define MM_BASE_MANAGER_PLUGIN_DIR "plugin-dir" /* Construct-only */
|
||||||
#define MM_BASE_MANAGER_INITIAL_KERNEL_EVENTS "initial-kernel-events" /* Construct-only */
|
#define MM_BASE_MANAGER_INITIAL_KERNEL_EVENTS "initial-kernel-events" /* Construct-only */
|
||||||
|
#if defined WITH_TESTS
|
||||||
|
#define MM_BASE_MANAGER_ENABLE_TEST "enable-test" /* Construct-only */
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct _MMBaseManagerPrivate MMBaseManagerPrivate;
|
typedef struct _MMBaseManagerPrivate MMBaseManagerPrivate;
|
||||||
|
|
||||||
@@ -57,7 +61,9 @@ MMBaseManager *mm_base_manager_new (GDBusConnection *bus,
|
|||||||
gboolean auto_scan,
|
gboolean auto_scan,
|
||||||
MMFilterRule filter_policy,
|
MMFilterRule filter_policy,
|
||||||
const gchar *initial_kernel_events,
|
const gchar *initial_kernel_events,
|
||||||
|
#if defined WITH_TESTS
|
||||||
gboolean enable_test,
|
gboolean enable_test,
|
||||||
|
#endif
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
void mm_base_manager_start (MMBaseManager *manager,
|
void mm_base_manager_start (MMBaseManager *manager,
|
||||||
|
@@ -226,7 +226,9 @@ mm_context_get_log_personal_info (void)
|
|||||||
/* Test context */
|
/* Test context */
|
||||||
|
|
||||||
static gboolean test_session;
|
static gboolean test_session;
|
||||||
|
#if defined WITH_TESTS
|
||||||
static gboolean test_enable;
|
static gboolean test_enable;
|
||||||
|
#endif
|
||||||
static gchar *test_plugin_dir;
|
static gchar *test_plugin_dir;
|
||||||
#if defined WITH_UDEV
|
#if defined WITH_UDEV
|
||||||
static gboolean test_no_udev;
|
static gboolean test_no_udev;
|
||||||
@@ -249,11 +251,13 @@ static const GOptionEntry test_entries[] = {
|
|||||||
"Run in session DBus",
|
"Run in session DBus",
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
#if defined WITH_TESTS
|
||||||
{
|
{
|
||||||
"test-enable", 0, 0, G_OPTION_ARG_NONE, &test_enable,
|
"test-enable", 0, 0, G_OPTION_ARG_NONE, &test_enable,
|
||||||
"Enable the Test interface in the daemon",
|
"Enable the Test interface in the daemon",
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
"test-plugin-dir", 0, 0, G_OPTION_ARG_FILENAME, &test_plugin_dir,
|
"test-plugin-dir", 0, 0, G_OPTION_ARG_FILENAME, &test_plugin_dir,
|
||||||
"Path to look for plugins",
|
"Path to look for plugins",
|
||||||
@@ -320,11 +324,13 @@ mm_context_get_test_session (void)
|
|||||||
return test_session;
|
return test_session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined WITH_TESTS
|
||||||
gboolean
|
gboolean
|
||||||
mm_context_get_test_enable (void)
|
mm_context_get_test_enable (void)
|
||||||
{
|
{
|
||||||
return test_enable;
|
return test_enable;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
mm_context_get_test_plugin_dir (void)
|
mm_context_get_test_plugin_dir (void)
|
||||||
|
@@ -45,7 +45,9 @@ gboolean mm_context_get_log_personal_info (void);
|
|||||||
|
|
||||||
/* Testing support */
|
/* Testing support */
|
||||||
gboolean mm_context_get_test_session (void);
|
gboolean mm_context_get_test_session (void);
|
||||||
|
#if defined WITH_TESTS
|
||||||
gboolean mm_context_get_test_enable (void);
|
gboolean mm_context_get_test_enable (void);
|
||||||
|
#endif
|
||||||
const gchar *mm_context_get_test_plugin_dir (void);
|
const gchar *mm_context_get_test_plugin_dir (void);
|
||||||
#if defined WITH_UDEV
|
#if defined WITH_UDEV
|
||||||
gboolean mm_context_get_test_no_udev (void);
|
gboolean mm_context_get_test_no_udev (void);
|
||||||
|
Reference in New Issue
Block a user