3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +01:00

test-runner: Fix kernel command line parsing

Kernel command line arguments were not being parsed properly, $PATH in
particular was completely screwed up and causing commands in user's
$PATH to fail
This commit is contained in:
Denis Kenzior 2018-06-14 14:36:09 -05:00
parent 86fef093c0
commit e15caa2288

View File

@ -2100,41 +2100,43 @@ static void run_tests(void)
} }
ptr = strstr(cmdline, "GDB="); ptr = strstr(cmdline, "GDB=");
if (ptr) { if (ptr) {
*ptr = '\0';
test_action_str = ptr + 5; test_action_str = ptr + 5;
ptr = strchr(test_action_str, '\''); ptr = strchr(test_action_str, '\'');
*ptr = '\0'; *ptr = '\0';
gdb_opt = l_strdup(test_action_str); gdb_opt = l_strdup(test_action_str);
} }
ptr = strstr(cmdline, "VALGRIND="); ptr = strstr(cmdline, "VALGRIND=");
if (ptr) { if (ptr) {
test_action_str = ptr + 9; char *end;
ptr += 1; unsigned long v;
*ptr = '\0'; *ptr = '\0';
test_action_str = ptr + 9;
valgrind = (bool) atoi(test_action_str); v = strtoul(test_action_str, &end, 10);
if ((v != 0 && v != 1) || end != test_action_str + 1) {
if (valgrind != true && valgrind != false) {
l_error("malformed valgrind option"); l_error("malformed valgrind option");
return; return;
} }
valgrind = (bool) v;
} }
ptr = strstr(cmdline, "PATH="); ptr = strstr(cmdline, "PATH=");
if (!ptr) { if (!ptr) {
l_error("No $PATH section found"); l_error("No $PATH section found");
return; return;
} }
ptr += 5; *ptr = '\0';
setenv("PATH", ptr, true); test_action_str = ptr + 6;
ptr = strchr(test_action_str, '\'');
*ptr = '\0';
l_info("%s", test_action_str);
setenv("PATH", test_action_str, true);
ptr = strstr(cmdline, "TESTARGS="); ptr = strstr(cmdline, "TESTARGS=");