Skip to content

Commit

Permalink
scripts/sanitycheck: fix merging OVERLAY_CONFIG extra args
Browse files Browse the repository at this point in the history
Overlay files were concatenated into single string with no whitespace
between them. If '--extra-args OVERLAY_CONFIG="overlay-1.conf"
--extra-args OVERLAY_CONFIG="overlay-2.conf"' was used, then the result
was OVERLAY_CONFIG="overlay-1.confoverlay-2.conf".

Another thing was that overlay extra args were not properly removed from
the list of regular arguments. As a result we had incorrect list of
overlays and incorrect list of other arguments.

Rework code to extract overlays in loop in a safe manner. Use for that a
list of strings instead of string directly. Join those strings and form
a single OVERLAY_CONFIG argument just before running cmake.

Tested with following testcase.yaml line:

  extra_args: ARG1 OVERLAY_CONFIG="overlay-1.conf"
              ARG2 OVERLAY_CONFIG="overlay-2.conf"

Before this patch we got:

  args = ['OVERLAY_CONFIG="overlay-1.conf"',
    'OVERLAY_CONFIG="overlay-2.conf"']

After this patch we get:

  args = ['ARG1', 'ARG2',
    'OVERLAY_CONFIG="overlay-1.conf overlay-2.conf"']

While at it, fix also regex pattern by removing requirement of double
quotes around value. Match any option value instead and strip both
single and double quotes when match is positive. Tested with:

  $ ./scripts/sanitycheck -T samples/hello_world/ -p qemu_x86 \
      --extra-args OVERLAY_CONFIG=overlay1.conf '
      --extra-args OVERLAY_CONFIG=\"overlay2.conf\" '
      --extra-args OVERLAY_CONFIG=\'overlay3.conf\'

Signed-off-by: Marcin Niestroj <[email protected]>
  • Loading branch information
mniestroj authored and nashif committed Jan 31, 2020
1 parent 8345434 commit be0f5fe
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions scripts/sanitycheck
Original file line number Diff line number Diff line change
Expand Up @@ -2231,20 +2231,29 @@ class ProjectBuilder(FilterBuilder):
args += instance.handler.args

# merge overlay files into one variable
overlays = ""
idx = 0
for arg in args:
match = re.search('OVERLAY_CONFIG="(.*)"', arg)
if match:
overlays += match.group(1)
del args[idx]
idx += 1
def extract_overlays(args):
re_overlay = re.compile('OVERLAY_CONFIG=(.*)')
other_args = []
overlays = []
for arg in args:
match = re_overlay.search(arg)
if match:
overlays.append(match.group(1).strip('\'"'))
else:
other_args.append(arg)

args[:] = other_args
return overlays

overlays = extract_overlays(args)

if (self.testcase.extra_configs or self.coverage or
self.asan):
args.append("OVERLAY_CONFIG=\"%s %s\"" % (overlays,
os.path.join(instance.build_dir,
"sanitycheck", "testcase_extra.conf")))
overlays.append(os.path.join(instance.build_dir,
"sanitycheck", "testcase_extra.conf"))

if overlays:
args.append("OVERLAY_CONFIG=\"%s\"" % (" ".join(overlays)))

results = self.run_cmake(args)
return results
Expand Down

0 comments on commit be0f5fe

Please sign in to comment.