From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] test-runner: Fix parsing of command line
Date: Tue, 1 Mar 2022 15:30:53 -0800 [thread overview]
Message-ID: <20220301233053.109920-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Instead of parsing the command line, which can contain a shell script,
run using /bin/sh so it allows more complex command line to be tested:
sudo tools/test-runner -l -d -k <pathto/bzImage> --
'client/bluetoothctl power on && sleep 2 && client/bluetoothctl power
off'
---
tools/test-runner.c | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/tools/test-runner.c b/tools/test-runner.c
index e0e002dd6..3dea38bc6 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -716,25 +716,7 @@ start_next:
argv[0] = (char *) test_table[idx];
argv[1] = "-q";
argv[2] = NULL;
- } else {
- while (1) {
- char *ptr;
-
- ptr = strchr(cmdname, ' ');
- if (!ptr) {
- argv[pos++] = cmdname;
- break;
- }
-
- *ptr = '\0';
- argv[pos++] = cmdname;
- if (pos > 8)
- break;
-
- cmdname = ptr + 1;
- }
-
- argv[pos] = NULL;
+ cmdname = NULL;
}
pos = 0;
@@ -743,7 +725,7 @@ start_next:
envp[pos++] = home;
envp[pos] = NULL;
- printf("Running command %s\n", argv[0]);
+ printf("Running command %s\n", cmdname ? cmdname : argv[0]);
pid = fork();
if (pid < 0) {
@@ -758,7 +740,11 @@ start_next:
perror("Failed to change directory");
}
- execve(argv[0], argv, envp);
+ if (!cmdname)
+ execve(argv[0], argv, envp);
+ else
+ execl("/bin/sh", "sh", "-c", cmdname, NULL);
+
exit(EXIT_SUCCESS);
}
--
2.35.1
next reply other threads:[~2022-03-01 23:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 23:30 Luiz Augusto von Dentz [this message]
2022-03-02 0:39 ` [BlueZ] test-runner: Fix parsing of command line bluez.test.bot
2022-03-02 23:22 ` Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220301233053.109920-1-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox