From c0317fba1fb8d89a3aeb7c622c3b14101aec2ef0 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 26 Jul 2022 22:15:56 -0400 Subject: [PATCH] twister: handler quotes in extra_args Escape quotes provided in extra arguments on the command line. example: ... -x "CONFIG_COMPILER_OPT=\"-fanalyzer\"" Fixes #46382 Signed-off-by: Anas Nashif --- scripts/pylib/twister/twisterlib/runner.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/pylib/twister/twisterlib/runner.py b/scripts/pylib/twister/twisterlib/runner.py index 7c7168d810a..045dbfc0577 100644 --- a/scripts/pylib/twister/twisterlib/runner.py +++ b/scripts/pylib/twister/twisterlib/runner.py @@ -234,7 +234,7 @@ class CMake: return results - def run_cmake(self, args=[]): + def run_cmake(self, args=""): if not self.options.disable_warnings_as_errors: ldflags = "-Wl,--fatal-warnings" @@ -257,7 +257,6 @@ class CMake: f'-G{self.env.generator}' ] - args = ["-D{}".format(a.replace('"', '')) for a in args] cmake_args.extend(args) cmake_opts = ['-DBOARD={}'.format(self.platform.name)] @@ -659,7 +658,6 @@ class ProjectBuilder(FilterBuilder): instance = self.instance args = self.testsuite.extra_args[:] - args += self.options.extra_args if instance.handler: args += instance.handler.args @@ -689,7 +687,9 @@ class ProjectBuilder(FilterBuilder): if overlays: args.append("OVERLAY_CONFIG=\"%s\"" % (" ".join(overlays))) - res = self.run_cmake(args) + args_expanded = ["-D{}".format(a.replace('"', '\"')) for a in self.options.extra_args] + args_expanded = args_expanded + ["-D{}".format(a.replace('"', '')) for a in args] + res = self.run_cmake(args_expanded) return res def build(self):