diff mbox series

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

Message ID c49b98ccde558527a7ff2ade4c84b37f2c4d9b3a.1710440408.git.pav@iki.fi (mailing list archive)
State Superseded
Headers show
Series tests: add TX timestamping tests | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch fail ERROR:INITIALISED_STATIC: do not initialise statics to NULL #108: FILE: src/shared/tester.c:115: +static const char *option_name = NULL; /github/workspace/src/src/13592656.patch total: 1 errors, 0 warnings, 27 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/src/13592656.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/GitLint success Gitlint PASS

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,