* [PATCH BlueZ v1 1/3] gdbus: Add testing flags
@ 2024-04-23 22:46 Luiz Augusto von Dentz
2024-04-23 22:46 ` [PATCH BlueZ v1 2/3] main.conf: Add support for testing interfaces Luiz Augusto von Dentz
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2024-04-23 22:46 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds testing flags which are similar to experimental but are only
available for testing.
---
gdbus/gdbus.h | 23 +++++++++++++++++++++++
gdbus/object.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index 28b80229646c..6fe09b743221 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -72,6 +72,7 @@ typedef void (* GDBusSecurityFunction) (DBusConnection *connection,
enum GDBusFlags {
G_DBUS_FLAG_ENABLE_EXPERIMENTAL = (1 << 0),
+ G_DBUS_FLAG_ENABLE_TESTING = (1 << 1),
};
enum GDBusMethodFlags {
@@ -79,16 +80,19 @@ enum GDBusMethodFlags {
G_DBUS_METHOD_FLAG_NOREPLY = (1 << 1),
G_DBUS_METHOD_FLAG_ASYNC = (1 << 2),
G_DBUS_METHOD_FLAG_EXPERIMENTAL = (1 << 3),
+ G_DBUS_METHOD_FLAG_TESTING = (1 << 4),
};
enum GDBusSignalFlags {
G_DBUS_SIGNAL_FLAG_DEPRECATED = (1 << 0),
G_DBUS_SIGNAL_FLAG_EXPERIMENTAL = (1 << 1),
+ G_DBUS_SIGNAL_FLAG_TESTING = (1 << 2),
};
enum GDBusPropertyFlags {
G_DBUS_PROPERTY_FLAG_DEPRECATED = (1 << 0),
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL = (1 << 1),
+ G_DBUS_PROPERTY_FLAG_TESTING = (1 << 2),
};
enum GDBusSecurityFlags {
@@ -186,6 +190,20 @@ struct GDBusSecurityTable {
.function = _function, \
.flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_EXPERIMENTAL
+#define GDBUS_TESTING_METHOD(_name, _in_args, _out_args, _function) \
+ .name = _name, \
+ .in_args = _in_args, \
+ .out_args = _out_args, \
+ .function = _function, \
+ .flags = G_DBUS_METHOD_FLAG_TESTING
+
+#define GDBUS_TESTING_ASYNC_METHOD(_name, _in_args, _out_args, _function) \
+ .name = _name, \
+ .in_args = _in_args, \
+ .out_args = _out_args, \
+ .function = _function, \
+ .flags = G_DBUS_METHOD_FLAG_ASYNC | G_DBUS_METHOD_FLAG_TESTING
+
#define GDBUS_NOREPLY_METHOD(_name, _in_args, _out_args, _function) \
.name = _name, \
.in_args = _in_args, \
@@ -207,6 +225,11 @@ struct GDBusSecurityTable {
.args = _args, \
.flags = G_DBUS_SIGNAL_FLAG_EXPERIMENTAL
+#define GDBUS_TESTING_SIGNAL(_name, _args) \
+ .name = _name, \
+ .args = _args, \
+ .flags = G_DBUS_SIGNAL_FLAG_EXPERIMENTAL
+
void g_dbus_set_flags(int flags);
int g_dbus_get_flags(void);
diff --git a/gdbus/object.c b/gdbus/object.c
index f7c8c2be5d87..72d2d46e30ef 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdbool.h>
#include <glib.h>
#include <dbus/dbus.h>
@@ -115,6 +116,14 @@ static gboolean check_experimental(int flags, int flag)
return !(global_flags & G_DBUS_FLAG_ENABLE_EXPERIMENTAL);
}
+static bool check_testing(int flags, int flag)
+{
+ if (!(flags & flag))
+ return false;
+
+ return !(global_flags & G_DBUS_FLAG_ENABLE_TESTING);
+}
+
static void generate_interface_xml(GString *gstr, struct interface_data *iface)
{
const GDBusMethodTable *method;
@@ -126,6 +135,9 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
G_DBUS_METHOD_FLAG_EXPERIMENTAL))
continue;
+ if (check_testing(method->flags, G_DBUS_METHOD_FLAG_TESTING))
+ continue;
+
g_string_append_printf(gstr, "<method name=\"%s\">",
method->name);
print_arguments(gstr, method->in_args, "in");
@@ -146,6 +158,9 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
G_DBUS_SIGNAL_FLAG_EXPERIMENTAL))
continue;
+ if (check_testing(signal->flags, G_DBUS_SIGNAL_FLAG_TESTING))
+ continue;
+
g_string_append_printf(gstr, "<signal name=\"%s\">",
signal->name);
print_arguments(gstr, signal->args, NULL);
@@ -163,6 +178,10 @@ static void generate_interface_xml(GString *gstr, struct interface_data *iface)
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL))
continue;
+ if (check_testing(property->flags,
+ G_DBUS_PROPERTY_FLAG_TESTING))
+ continue;
+
g_string_append_printf(gstr, "<property name=\"%s\""
" type=\"%s\" access=\"%s%s\">",
property->name, property->type,
@@ -518,6 +537,9 @@ static void append_properties(struct interface_data *data,
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL))
continue;
+ if (check_testing(p->flags, G_DBUS_PROPERTY_FLAG_TESTING))
+ continue;
+
if (p->get == NULL)
continue;
@@ -749,6 +771,9 @@ static inline const GDBusPropertyTable *find_property(const GDBusPropertyTable *
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL))
break;
+ if (check_testing(p->flags, G_DBUS_PROPERTY_FLAG_TESTING))
+ break;
+
return p;
}
@@ -1061,6 +1086,9 @@ static DBusHandlerResult generic_message(DBusConnection *connection,
G_DBUS_METHOD_FLAG_EXPERIMENTAL))
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ if (check_testing(method->flags, G_DBUS_METHOD_FLAG_TESTING))
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
if (g_dbus_args_have_signature(method->in_args,
message) == FALSE)
continue;
@@ -1190,18 +1218,26 @@ static gboolean add_interface(struct generic_data *data,
if (!check_experimental(method->flags,
G_DBUS_METHOD_FLAG_EXPERIMENTAL))
goto done;
+
+ if (!check_testing(method->flags, G_DBUS_METHOD_FLAG_TESTING))
+ goto done;
}
for (signal = signals; signal && signal->name; signal++) {
if (!check_experimental(signal->flags,
G_DBUS_SIGNAL_FLAG_EXPERIMENTAL))
goto done;
+ if (!check_testing(signal->flags, G_DBUS_SIGNAL_FLAG_TESTING))
+ goto done;
}
for (property = properties; property && property->name; property++) {
if (!check_experimental(property->flags,
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL))
goto done;
+ if (!check_testing(property->flags,
+ G_DBUS_PROPERTY_FLAG_TESTING))
+ goto done;
}
/* Nothing to register */
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH BlueZ v1 2/3] main.conf: Add support for testing interfaces
2024-04-23 22:46 [PATCH BlueZ v1 1/3] gdbus: Add testing flags Luiz Augusto von Dentz
@ 2024-04-23 22:46 ` Luiz Augusto von Dentz
2024-04-23 22:46 ` [PATCH BlueZ v1 3/3] ccp: Mark plugin for testing Luiz Augusto von Dentz
2024-04-24 19:10 ` [PATCH BlueZ v1 1/3] gdbus: Add testing flags patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2024-04-23 22:46 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support for D-Bus testing interfaces and testing profile
drivers.
---
src/bluetoothd.rst.in | 9 +++++++--
src/btd.h | 1 +
src/main.c | 8 ++++++++
src/main.conf | 4 ++++
src/profile.c | 6 ++++++
src/profile.h | 5 +++++
6 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/bluetoothd.rst.in b/src/bluetoothd.rst.in
index 7a0fa1b24469..0b998f621595 100644
--- a/src/bluetoothd.rst.in
+++ b/src/bluetoothd.rst.in
@@ -64,8 +64,13 @@ OPTIONS
-C, --compat Provide deprecated command line interfaces.
--E, --experimental Enable experimental interfaces. Those interfaces are not
- guaranteed to be compatible or present in future releases.
+-E, --experimental Enable D-Bus experimental interfaces.
+ These interfaces are not guaranteed to be compatible or present in future
+ releases.
+
+-T, --testing Enable D-Bus testing interfaces.
+ These interfaces are only meant for test validation of the internals of
+ bluetoothd and shall not never be used by anything other than that.
-K, --kernel=<uuid1>,<uuid2>,...
Enable Kernel experimental features. Kernel experimental features are
diff --git a/src/btd.h b/src/btd.h
index 8c80059ac1d8..383bd7c19600 100644
--- a/src/btd.h
+++ b/src/btd.h
@@ -128,6 +128,7 @@ struct btd_opts {
bool fast_conn;
bool refresh_discovery;
bool experimental;
+ bool testing;
struct queue *kernel;
uint16_t did_source;
diff --git a/src/main.c b/src/main.c
index 78831ad02520..23af6781d931 100644
--- a/src/main.c
+++ b/src/main.c
@@ -87,6 +87,7 @@ static const char *supported_options[] = {
"TemporaryTimeout",
"RefreshDiscovery",
"Experimental",
+ "Testing",
"KernelExperimental",
"RemoteNameRequestRetryDelay",
NULL
@@ -1034,6 +1035,8 @@ static void parse_general(GKeyFile *config)
parse_secure_conns(config);
parse_config_bool(config, "General", "Experimental",
&btd_opts.experimental);
+ parse_config_bool(config, "General", "Testing",
+ &btd_opts.testing);
parse_kernel_exp(config);
parse_config_u32(config, "General", "RemoteNameRequestRetryDelay",
&btd_opts.name_request_retry_delay,
@@ -1344,6 +1347,8 @@ static GOptionEntry options[] = {
"Provide deprecated command line interfaces" },
{ "experimental", 'E', 0, G_OPTION_ARG_NONE, &btd_opts.experimental,
"Enable experimental D-Bus interfaces" },
+ { "testing", 'T', 0, G_OPTION_ARG_NONE, &btd_opts.testing,
+ "Enable testing D-Bus interfaces" },
{ "kernel", 'K', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
parse_kernel_experimental,
"Enable kernel experimental features" },
@@ -1410,6 +1415,9 @@ int main(int argc, char *argv[])
if (btd_opts.experimental)
gdbus_flags = G_DBUS_FLAG_ENABLE_EXPERIMENTAL;
+ if (btd_opts.testing)
+ gdbus_flags |= G_DBUS_FLAG_ENABLE_TESTING;
+
g_dbus_set_flags(gdbus_flags);
if (adapter_init() < 0) {
diff --git a/src/main.conf b/src/main.conf
index 49864b5c35f5..bea94640e627 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -126,6 +126,10 @@
# Possible values: true or false
#Experimental = false
+# Enables D-Bus testing interfaces
+# Possible values: true or false
+#Testing = false
+
# Enables kernel experimental features, alternatively a list of UUIDs
# can be given.
# Possible values: true,false,<UUID List>
diff --git a/src/profile.c b/src/profile.c
index ea188f36b6dd..c62224af9dd8 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -781,6 +781,12 @@ int btd_profile_register(struct btd_profile *profile)
return -ENOTSUP;
}
+ if (profile->testing && !(g_dbus_get_flags() &
+ G_DBUS_FLAG_ENABLE_TESTING)) {
+ DBG("D-Bus testing not enabled");
+ return -ENOTSUP;
+ }
+
profiles = g_slist_append(profiles, profile);
return 0;
}
diff --git a/src/profile.h b/src/profile.h
index 6871f2f0d7d8..424ce55ad657 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -33,6 +33,11 @@ struct btd_profile {
*/
bool experimental;
+ /* Indicates the profile for testing only and shall only be registered
+ * when testing has been enabled (see: main.conf:Testing).
+ */
+ bool testing;
+
int (*device_probe) (struct btd_service *service);
void (*device_remove) (struct btd_service *service);
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH BlueZ v1 3/3] ccp: Mark plugin for testing
2024-04-23 22:46 [PATCH BlueZ v1 1/3] gdbus: Add testing flags Luiz Augusto von Dentz
2024-04-23 22:46 ` [PATCH BlueZ v1 2/3] main.conf: Add support for testing interfaces Luiz Augusto von Dentz
@ 2024-04-23 22:46 ` Luiz Augusto von Dentz
2024-04-24 19:10 ` [PATCH BlueZ v1 1/3] gdbus: Add testing flags patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2024-04-23 22:46 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes ccp plugin for testing only rather than experimental since
it is only meant for test validation as platforms shall integrate CCP
directly into their telephony stack.
---
profiles/audio/ccp.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/profiles/audio/ccp.c b/profiles/audio/ccp.c
index fe678de9fede..ae17a31f7ed3 100644
--- a/profiles/audio/ccp.c
+++ b/profiles/audio/ccp.c
@@ -206,19 +206,17 @@ ccp_server_remove(struct btd_profile *p,
}
static struct btd_profile ccp_profile = {
- .name = "ccp",
- .priority = BTD_PROFILE_PRIORITY_MEDIUM,
+ .name = "ccp",
+ .priority = BTD_PROFILE_PRIORITY_MEDIUM,
.remote_uuid = GTBS_UUID_STR,
.device_probe = ccp_probe,
.device_remove = ccp_remove,
- .accept = ccp_accept,
- .connect = ccp_connect,
- .disconnect = ccp_disconnect,
-
+ .accept = ccp_accept,
+ .connect = ccp_connect,
+ .disconnect = ccp_disconnect,
.adapter_probe = ccp_server_probe,
.adapter_remove = ccp_server_remove,
-
- .experimental = true,
+ .testing = true,
};
static int ccp_init(void)
--
2.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH BlueZ v1 1/3] gdbus: Add testing flags
2024-04-23 22:46 [PATCH BlueZ v1 1/3] gdbus: Add testing flags Luiz Augusto von Dentz
2024-04-23 22:46 ` [PATCH BlueZ v1 2/3] main.conf: Add support for testing interfaces Luiz Augusto von Dentz
2024-04-23 22:46 ` [PATCH BlueZ v1 3/3] ccp: Mark plugin for testing Luiz Augusto von Dentz
@ 2024-04-24 19:10 ` patchwork-bot+bluetooth
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2024-04-24 19:10 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Tue, 23 Apr 2024 18:46:01 -0400 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This adds testing flags which are similar to experimental but are only
> available for testing.
> ---
> gdbus/gdbus.h | 23 +++++++++++++++++++++++
> gdbus/object.c | 36 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 59 insertions(+)
Here is the summary with links:
- [BlueZ,v1,1/3] gdbus: Add testing flags
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=d8f3a3fa497f
- [BlueZ,v1,2/3] main.conf: Add support for testing interfaces
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e7578f9ddd07
- [BlueZ,v1,3/3] ccp: Mark plugin for testing
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=02ade13c439f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-24 19:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 22:46 [PATCH BlueZ v1 1/3] gdbus: Add testing flags Luiz Augusto von Dentz
2024-04-23 22:46 ` [PATCH BlueZ v1 2/3] main.conf: Add support for testing interfaces Luiz Augusto von Dentz
2024-04-23 22:46 ` [PATCH BlueZ v1 3/3] ccp: Mark plugin for testing Luiz Augusto von Dentz
2024-04-24 19:10 ` [PATCH BlueZ v1 1/3] gdbus: Add testing flags patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).