tests: replace xargs workaround with bash array expansion
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 3 Jul 2019 22:09:56 +0000 (18:09 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 15:53:34 +0000 (11:53 -0400)
commitb241db8f670d5e7e024c4f8cc4ecab703393dfdf
tree535cab00d0b025a2bbf915010538e83d105bf782
parentd126826ca1f3fc7c869b2c3ebc9162d82d1e21f0
tests: replace xargs workaround with bash array expansion

Bash has a nice feature called 'Quoted array expansion' which we can
use to pass parameters between functions without convoluted quote
escaping. The syntax might not be extremmely clear at first though,
for example:

  "${myarray[@]}"

will be expanded to:

  "${myarray[1]}" "${myarray[2]}" ... "${myarray[n]}"

Which can be passed as a series of parameters to a function and then
converted back to a array for further use with :

 local params=("$@")

This uses the special '$@' variable which is an array of all the
parameters to a function, 'shift' can be used to skip some parameters at
the beginning of the array.

An array can also be expanded as a single string with the members
separated by a space, with this syntax:

  "${myarray[*]}"

Using this, I reworked the bt_diff functions to get rid of the xargs
call, I had to move the expected file parameter to the beginning so it
could be shifted and the rest of the parameters passed directly to CLI
executable.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: Ie107c5259c9561fe158f923a53eeb0eaf7ee8b00
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1627
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
tests/plugins/flt.utils.trimmer/test_trimming
tests/plugins/sink.ctf.fs/succeed/test_succeed
tests/plugins/src.ctf.fs/succeed/test_succeed
tests/utils/utils.sh
This page took 0.025331 seconds and 4 git commands to generate.