summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-03-01 15:26:14 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-03-01 15:26:14 -0800
commitb9f27b814d9acf5b3320e2af797f6484c1ceb781 (patch)
treec947b31da4930696cfbaa985d8f3ff353656056f /tools
parentab943bf8330603dfb292da9300566b483b2800cf (diff)
downloadbluez-b9f27b814d9acf5b3320e2af797f6484c1ceb781.tar.gz
test-runner: Fix parsing of command line
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'
Diffstat (limited to 'tools')
-rw-r--r--tools/test-runner.c28
1 files 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);
}