diff mbox series

[BlueZ,v2,6/9] shared/tester: run test with given name

Message ID c49b98ccde558527a7ff2ade4c84b37f2c4d9b3a.1710440408.git.pav@iki.fi
State New
Headers show
Series tests: add TX timestamping tests | expand

Commit Message

Pauli Virtanen March 14, 2024, 6:21 p.m. UTC
Add option for running a single test with given name.  Useful when some
test names have a common prefix, so that neither -s or -p can
distinguish them.
---
 src/shared/tester.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/src/shared/tester.c b/src/shared/tester.c
index a1ee5b687..280f509b9 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -112,6 +112,7 @@  static gboolean option_monitor = FALSE;
 static gboolean option_list = FALSE;
 static const char *option_prefix = NULL;
 static const char *option_string = NULL;
+static const char *option_name = NULL;
 
 struct monitor_hdr {
 	uint16_t opcode;
@@ -285,6 +286,12 @@  void tester_add_full(const char *name, const void *test_data,
 	if (!test_func)
 		return;
 
+	if (option_name && strcmp(name, option_name)) {
+		if (destroy)
+			destroy(user_data);
+		return;
+	}
+
 	if (option_prefix && !g_str_has_prefix(name, option_prefix)) {
 		if (destroy)
 			destroy(user_data);
@@ -829,6 +836,8 @@  static GOptionEntry options[] = {
 				"Enable monitor output" },
 	{ "list", 'l', 0, G_OPTION_ARG_NONE, &option_list,
 				"Only list the tests to be run" },
+	{ "name", 'n', 0, G_OPTION_ARG_STRING, &option_name,
+				"Run test with given name" },
 	{ "prefix", 'p', 0, G_OPTION_ARG_STRING, &option_prefix,
 				"Run tests matching provided prefix" },
 	{ "string", 's', 0, G_OPTION_ARG_STRING, &option_string,