tests: replace xargs workaround with bash array expansion
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 3 Jul 2019 22:09:56 +0000 (18:09 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 8 Jul 2019 20:45:56 +0000 (16:45 -0400)
commit53cc240b958d74a423d0f22752c080f4e3a986db
treed14699afd55f693eef3075b416eeb66ba25a69fe
parent6162e6b7a6d907974d954419c2375f654f39eb72
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.025348 seconds and 4 git commands to generate.