tests/utils/utils.sh: aerate the code
[babeltrace.git] / tests / utils / utils.sh
CommitLineData
644e0364 1#!/bin/bash
644e0364 2#
0235b0db 3# SPDX-License-Identifier: GPL-2.0-only
644e0364 4#
0235b0db 5# Copyright (c) 2019 Michael Jeanson <mjeanson@efficios.com>
07ff3b19 6# Copyright (C) 2019-2023 Philippe Proulx <pproulx@efficios.com>
644e0364 7
07ff3b19
PP
8# Source this file at the beginning of a shell script test to access
9# useful testing variables and functions:
10#
11# SH_TAP=1
12#
13# if [[ -n ${BT_TESTS_SRCDIR:-} ]]; then
14# UTILSSH=$BT_TESTS_SRCDIR/utils/utils.sh
15# else
16# UTILSSH=$(dirname "$0")/../utils/utils.sh
17# fi
18#
19# # shellcheck source=../utils/utils.sh
20# source "$UTILSSH"
21#
22# Make sure the relative path to `utils.sh` (this file) above is
23# correct (twice).
644e0364 24
07ff3b19 25# An unbound variable is an error
644e0364
MJ
26set -u
27
07ff3b19
PP
28# Name of the OS on which we're running, if not set.
29#
30# One of:
31#
32# `mingw`: MinGW (Windows)
33# `darwin`: macOS
34# `linux`: Linux
35# `cygwin`: Cygwin (Windows)
36# `unsupported`: Anything else
37#
38# See <https://en.wikipedia.org/wiki/Uname#Examples> for possible values
39# of `uname -s`.
40#
41# Do some translation to ease our life down the road for comparison.
42# Export it so that executed commands can use it.
c0d75ae3
PP
43if [[ -z ${BT_TESTS_OS_TYPE:-} ]]; then
44 BT_TESTS_OS_TYPE=$(uname -s)
7121d33d 45
c0d75ae3 46 case $BT_TESTS_OS_TYPE in
5058d31b 47 MINGW*)
c0d75ae3 48 BT_TESTS_OS_TYPE=mingw
5058d31b
JR
49 ;;
50 Darwin)
c0d75ae3 51 BT_TESTS_OS_TYPE=darwin
5058d31b
JR
52 ;;
53 Linux)
c0d75ae3 54 BT_TESTS_OS_TYPE=linux
5058d31b 55 ;;
df9db467 56 CYGWIN*)
c0d75ae3 57 BT_TESTS_OS_TYPE=cygwin
df9db467 58 ;;
5058d31b 59 *)
c0d75ae3 60 BT_TESTS_OS_TYPE=unsupported
5058d31b
JR
61 ;;
62 esac
63fi
7121d33d 64
a0baab4a 65export BT_TESTS_OS_TYPE
5058d31b 66
7030f9fe
PP
67# Sets and exports, if not set:
68#
69# • `BT_TESTS_SRCDIR` to the base source directory of tests.
70# • `BT_TESTS_BUILDDIR` to the base build directory of tests.
71_set_vars_srcdir_builddir() {
72 # If `readlink -f` is available, then get a resolved absolute path
73 # to the tests source directory. Otherwise, make do with a relative
74 # path.
c0d75ae3 75 local -r scriptdir=$(dirname "${BASH_SOURCE[0]}")
7030f9fe 76 local testsdir
644e0364 77
c0d75ae3 78 if readlink -f . &> /dev/null; then
7030f9fe
PP
79 testsdir=$(readlink -f "$scriptdir/..")
80 else
c0d75ae3 81 testsdir=$scriptdir/..
7030f9fe
PP
82 fi
83
84 # Base source directory of tests
c0d75ae3
PP
85 if [[ -z ${BT_TESTS_SRCDIR:-} ]]; then
86 BT_TESTS_SRCDIR=$testsdir
7030f9fe 87 fi
7121d33d 88
7030f9fe
PP
89 export BT_TESTS_SRCDIR
90
91 # Base build directory of tests
c0d75ae3
PP
92 if [[ -z ${BT_TESTS_BUILDDIR:-} ]]; then
93 BT_TESTS_BUILDDIR=$testsdir
7030f9fe 94 fi
7121d33d 95
7030f9fe
PP
96 export BT_TESTS_BUILDDIR
97}
644e0364 98
7030f9fe
PP
99_set_vars_srcdir_builddir
100unset -f _set_vars_srcdir_builddir
e46cbefe 101
4a162893
PP
102# Sources the generated environment file (`env.sh`) if it exists.
103_source_env_sh() {
c0d75ae3 104 local -r env_sh_path=$BT_TESTS_BUILDDIR/utils/env.sh
4a162893 105
ad42b27e 106 if [[ -f $env_sh_path ]]; then
4a162893 107 # shellcheck disable=SC1090,SC1091
ad42b27e 108 . "$env_sh_path"
4a162893
PP
109 fi
110}
111
112_source_env_sh
113unset -f _source_env_sh
644e0364 114
07ff3b19 115# Path to the `babeltrace2` command, if not set
c0d75ae3
PP
116if [[ -z ${BT_TESTS_BT2_BIN:-} ]]; then
117 BT_TESTS_BT2_BIN=$BT_TESTS_BUILDDIR/../src/cli/babeltrace2
7121d33d 118
c0d75ae3
PP
119 if [[ $BT_TESTS_OS_TYPE == mingw ]]; then
120 BT_TESTS_BT2_BIN+=.exe
27e2c58d 121 fi
644e0364 122fi
7121d33d 123
644e0364
MJ
124export BT_TESTS_BT2_BIN
125
07ff3b19
PP
126# This doesn't need to be exported, but it needs to remain set for
127# run_python_bt2() to use it.
128#
129# TODO: Remove when `tests/bindings/python/bt2/test_plugin.py` is fixed.
ad42b27e 130_bt_tests_plugins_path=$BT_TESTS_BUILDDIR/../src/plugins
644e0364 131
07ff3b19 132# Colon-separated list of project plugin paths, if not set
c0d75ae3 133if [[ -z ${BT_TESTS_BABELTRACE_PLUGIN_PATH:-} ]]; then
ad42b27e 134 BT_TESTS_BABELTRACE_PLUGIN_PATH=$_bt_tests_plugins_path/ctf:$_bt_tests_plugins_path/utils:$_bt_tests_plugins_path/text:$_bt_tests_plugins_path/lttng-utils
644e0364 135fi
7121d33d 136
e46cbefe 137export BT_TESTS_BABELTRACE_PLUGIN_PATH
644e0364 138
07ff3b19 139# Directory containing the Python plugin provider library, if not set
c0d75ae3 140if [[ -z ${BT_TESTS_PROVIDER_DIR:-} ]]; then
ad42b27e 141 BT_TESTS_PROVIDER_DIR=$BT_TESTS_BUILDDIR/../src/python-plugin-provider/.libs
b14c7bf1 142fi
7121d33d 143
e46cbefe 144export BT_TESTS_PROVIDER_DIR
b14c7bf1 145
07ff3b19 146# Directory containing the built `bt2` Python package, if not set
c0d75ae3 147if [[ -z ${BT_TESTS_PYTHONPATH:-} ]]; then
ad42b27e 148 BT_TESTS_PYTHONPATH=$BT_TESTS_BUILDDIR/../src/bindings/python/bt2/build/build_lib
644e0364 149fi
7121d33d 150
e46cbefe 151export BT_TESTS_PYTHONPATH
644e0364 152
07ff3b19 153# Name of the `awk` command to use when testing, if not set
c0d75ae3 154if [[ -z ${BT_TESTS_AWK_BIN:-} ]]; then
644e0364
MJ
155 BT_TESTS_AWK_BIN="awk"
156fi
7121d33d 157
644e0364
MJ
158export BT_TESTS_AWK_BIN
159
07ff3b19 160# Name of the `grep` command to use when testing, if not set
c0d75ae3 161if [[ -z ${BT_TESTS_GREP_BIN:-} ]]; then
644e0364
MJ
162 BT_TESTS_GREP_BIN="grep"
163fi
7121d33d 164
644e0364
MJ
165export BT_TESTS_GREP_BIN
166
07ff3b19 167# Name of the `python3` command to use when testing, if not set
c0d75ae3
PP
168if [[ -z ${BT_TESTS_PYTHON_BIN:-} ]]; then
169 BT_TESTS_PYTHON_BIN=python3
644e0364 170fi
7121d33d 171
644e0364
MJ
172export BT_TESTS_PYTHON_BIN
173
07ff3b19
PP
174# Major and minor version of the `python3` command to use when testing.
175#
176# This doesn't need to be exported, but it needs to remain set for
177# run_python() to use it.
315323f4 178_bt_tests_py3_version=$("$BT_TESTS_PYTHON_BIN" -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))')
7747a39f 179
07ff3b19 180# Name of the `python3-config` command to use when testing, if not set
c0d75ae3
PP
181if [[ -z ${BT_TESTS_PYTHON_CONFIG_BIN:-} ]]; then
182 BT_TESTS_PYTHON_CONFIG_BIN=python3-config
e23e08c4 183fi
7121d33d 184
242ddcb7 185export BT_TESTS_PYTHON_CONFIG_BIN
e23e08c4 186
07ff3b19 187# Name of the `sed` command to use when testing, if not set
c0d75ae3 188if [[ -z ${BT_TESTS_SED_BIN:-} ]]; then
644e0364
MJ
189 BT_TESTS_SED_BIN="sed"
190fi
7121d33d 191
644e0364
MJ
192export BT_TESTS_SED_BIN
193
07ff3b19 194# Name of the `cc` command to use when testing, if not set
c0d75ae3
PP
195if [[ -z ${BT_TESTS_CC_BIN:-} ]]; then
196 BT_TESTS_CC_BIN=cc
0b0893d4 197fi
7121d33d 198
0b0893d4
SM
199export BT_TESTS_CC_BIN
200
07ff3b19 201# Whether or not to enable AddressSanitizer, `0` (disabled) if not set.
ea81414f
PP
202#
203# This doesn't need to be exported from the point of view of this file,
204# but the sourced `env.sh` above does export it.
c0d75ae3
PP
205if [[ -z ${BT_TESTS_ENABLE_ASAN:-} ]]; then
206 BT_TESTS_ENABLE_ASAN=0
0b0893d4 207fi
0b0893d4 208
07ff3b19 209# Directory containing test data
ad42b27e 210BT_TESTS_DATADIR=$BT_TESTS_SRCDIR/data
07ff3b19
PP
211
212# Directory containing test CTF traces
ad42b27e 213BT_CTF_TRACES_PATH=$BT_TESTS_DATADIR/ctf-traces
644e0364 214
07ff3b19 215# Source the shell TAP utilities if `SH_TAP` is `1`
c0d75ae3 216if [[ ${SH_TAP:-} == 1 ]]; then
e46cbefe 217 # shellcheck source=./tap/tap.sh
ad42b27e 218 . "$BT_TESTS_SRCDIR/utils/tap/tap.sh"
e46cbefe
MJ
219fi
220
07ff3b19
PP
221# Removes the CR characters from the file having the path `$1`.
222#
223# This is sometimes needed on Windows with text files.
224#
225# We can't use the `--string-trailing-cr` option of `diff` because
226# Solaris doesn't have it.
90a8a0f2 227bt_remove_cr() {
717a01a7 228 "$BT_TESTS_SED_BIN" -i'' -e 's/\r//g' "$1"
90a8a0f2
SM
229}
230
07ff3b19 231# Prints `$1` without CR characters.
10ba5f69 232bt_remove_cr_inline() {
07ff3b19 233 "$BT_TESTS_SED_BIN" 's/\r//g' "$1"
10ba5f69
OD
234}
235
07ff3b19
PP
236# Runs the `$BT_TESTS_BT2_BIN` command within an environment which can
237# import the `bt2` Python package, redirecting the standard output to
238# the `$1` file and the standard error to the `$2` file.
22703f66 239#
07ff3b19
PP
240# The remaining arguments are forwarded to the `$BT_TESTS_BT2_BIN`
241# command.
22703f66 242#
07ff3b19 243# Returns the exit status of the executed `$BT_TESTS_BT2_BIN`.
22703f66 244bt_cli() {
c0d75ae3
PP
245 local -r stdout_file=$1
246 local -r stderr_file=$2
7121d33d 247
22703f66 248 shift 2
7121d33d 249
0824c914 250 local -r args=("$@")
22703f66 251
4a5ed599 252 echo "Running: \`$BT_TESTS_BT2_BIN ${args[*]}\`" >&2
22703f66
SM
253 run_python_bt2 "$BT_TESTS_BT2_BIN" "${args[@]}" 1>"$stdout_file" 2>"$stderr_file"
254}
644e0364 255
07ff3b19 256# Checks the differences between:
ff89ed28 257#
07ff3b19 258# • The (expected) contents of the file having the path `$1`.
ff89ed28 259#
07ff3b19 260# • The contents of another file having the path `$2`.
ff89ed28 261#
07ff3b19
PP
262# Both files are passed through bt_remove_cr_inline() to remove CR
263# characters.
264#
265# Returns 0 if there's no difference, or not zero otherwise.
ff89ed28 266bt_diff() {
c0d75ae3
PP
267 local -r expected_file=$1
268 local -r actual_file=$2
ff89ed28 269
10ba5f69 270 diff -u <(bt_remove_cr_inline "$expected_file") <(bt_remove_cr_inline "$actual_file") 1>&2
ff89ed28
MJ
271}
272
58db335e
FD
273# Checks the difference between:
274#
07ff3b19
PP
275# • What the `$BT_TESTS_BT2_BIN` command prints to its standard output
276# when given the third and following arguments of this function.
277#
278# • The file having the path `$1`.
279#
280# as well as the difference between:
58db335e 281#
07ff3b19
PP
282# • What the `$BT_TESTS_BT2_BIN` command prints to its standard error
283# when given the third and following arguments of this function.
58db335e 284#
07ff3b19 285# • The file having the path `$2`.
644e0364 286#
07ff3b19
PP
287# Returns 0 if there's no difference, or 1 otherwise, also printing said
288# difference to the standard error.
644e0364 289bt_diff_cli() {
c0d75ae3
PP
290 local -r expected_stdout_file=$1
291 local -r expected_stderr_file=$2
7121d33d 292
58db335e 293 shift 2
53cc240b 294
7121d33d 295 local -r args=("$@")
c0d75ae3
PP
296 local -r temp_stdout_output_file=$(mktemp -t actual-stdout.XXXXXX)
297 local -r temp_stderr_output_file=$(mktemp -t actual-stderr.XXXXXX)
644e0364 298
22703f66 299 bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" "${args[@]}"
a70b6702 300 bt_diff "$expected_stdout_file" "$temp_stdout_output_file" "${args[@]}"
7121d33d 301
af34d92b 302 local -r ret_stdout=$?
7121d33d 303
a70b6702 304 bt_diff "$expected_stderr_file" "$temp_stderr_output_file" "${args[@]}"
7121d33d 305
af34d92b 306 local -r ret_stderr=$?
a70b6702 307
ff89ed28 308 rm -f "$temp_stdout_output_file" "$temp_stderr_output_file"
a5102ddb 309 return $((ret_stdout || ret_stderr))
ff89ed28
MJ
310}
311
07ff3b19
PP
312# Checks the difference between:
313#
314# • The content of the file having the path `$1`.
315#
316# • What the `$BT_TESTS_BT2_BIN` command prints to the standard output
317# when executed with:
318#
319# 1. The CTF trace directory `$2`.
320# 2. The arguments `-c` and `sink.text.details`.
321# 3. The third and following arguments of this function.
644e0364 322#
07ff3b19
PP
323# Returns 0 if there's no difference, or 1 otherwise, also printing said
324# difference to the standard error.
644e0364 325bt_diff_details_ctf_single() {
c0d75ae3
PP
326 local -r expected_stdout_file=$1
327 local -r trace_dir=$2
7121d33d 328
53cc240b 329 shift 2
7121d33d 330
30723e1c 331 local -r extra_details_args=("$@")
644e0364
MJ
332
333 # Compare using the CLI with `sink.text.details`
568f4bd1 334 bt_diff_cli "$expected_stdout_file" /dev/null "$trace_dir" \
c0d75ae3 335 -c sink.text.details "${extra_details_args[@]+${extra_details_args[@]}}"
644e0364
MJ
336}
337
07ff3b19
PP
338# Like bt_diff_details_ctf_single(), except that `$1` is the path to a
339# program which generates the CTF trace to compare to.
340#
341# The program `$1` receives the path to a temporary, empty directory
342# where to write the CTF trace as its first argument.
644e0364 343bt_diff_details_ctf_gen_single() {
c0d75ae3
PP
344 local -r ctf_gen_prog_path=$1
345 local -r expected_stdout_file=$2
7121d33d 346
53cc240b 347 shift 2
644e0364 348
7121d33d 349 local -r extra_details_args=("$@")
c0d75ae3 350 local -r temp_trace_dir=$(mktemp -d)
644e0364
MJ
351
352 # Run the CTF trace generator program to get a CTF trace
353 if ! "$ctf_gen_prog_path" "$temp_trace_dir" 2>/dev/null; then
4a5ed599 354 echo "ERROR: \`$ctf_gen_prog_path $temp_trace_dir\` failed" >&2
644e0364
MJ
355 rm -rf "$temp_trace_dir"
356 return 1
357 fi
358
359 # Compare using the CLI with `sink.text.details`
8b729209
PP
360 bt_diff_details_ctf_single "$expected_stdout_file" "$temp_trace_dir" \
361 "${extra_details_args[@]+${extra_details_args[@]}}"
7121d33d 362
69b5f89d 363 local -r ret=$?
7121d33d 364
644e0364
MJ
365 rm -rf "$temp_trace_dir"
366 return $ret
367}
368
07ff3b19 369# Like `grep`, but using `$BT_TESTS_GREP_BIN`.
407d3b10
SM
370bt_grep() {
371 "$BT_TESTS_GREP_BIN" "$@"
372}
644e0364 373
53be3c12
PP
374# Only if `tap.sh` is sourced because bt_grep_ok() uses ok()
375if [[ ${SH_TAP:-} == 1 ]]; then
376 # ok() with the test name `$3` on the result of bt_grep() matching
377 # the pattern `$1` within the file `$2`.
378 bt_grep_ok() {
379 local -r pattern=$1
380 local -r file=$2
381 local -r test_name=$3
382
383 bt_grep --silent "$pattern" "$file"
384
385 local -r ret=$?
386
387 if ! ok $ret "$test_name"; then
388 {
389 echo "Pattern \`$pattern\` doesn't match the contents of \`$file\`:"
390 echo '--- 8< ---'
391 cat "$file"
392 echo '--- >8 ---'
393 } >&2
394 fi
395
396 return $ret
397 }
398fi
db01f759 399
07ff3b19 400# Forwards the arguments to `coverage run`.
4958be54 401_bt_tests_check_coverage() {
644e0364
MJ
402 coverage run "$@"
403}
404
07ff3b19
PP
405# Executes a command within an environment which can import the testing
406# Python modules (in `tests/utils/python`).
1e14ec65 407run_python() {
ad42b27e 408 local our_pythonpath=$BT_TESTS_SRCDIR/utils/python
7747a39f 409
315323f4 410 if [[ $_bt_tests_py3_version =~ 3.[45] ]]; then
07ff3b19
PP
411 # Add a local directory containing a `typing.py` to `PYTHONPATH`
412 # for Python 3.4 and Python 3.5 which either don't offer the
413 # `typing` module at all, or offer a partial one.
ad42b27e 414 our_pythonpath=$our_pythonpath:$BT_TESTS_SRCDIR/utils/python/typing
7747a39f
PP
415 fi
416
ad42b27e 417 PYTHONPATH=$our_pythonpath${PYTHONPATH:+:}${PYTHONPATH:-} "$@"
1e14ec65
PP
418}
419
07ff3b19
PP
420# Executes a command within an environment which can import the testing
421# Python modules (in `tests/utils/python`) and the `bt2` Python package.
644e0364 422run_python_bt2() {
ad42b27e
PP
423 local -x BABELTRACE_PLUGIN_PATH=$BT_TESTS_BABELTRACE_PLUGIN_PATH
424 local -x LIBBABELTRACE2_PLUGIN_PROVIDER_DIR=$BT_TESTS_PROVIDER_DIR
425 local -x BT_TESTS_DATADIR=$BT_TESTS_DATADIR
426 local -x BT_CTF_TRACES_PATH=$BT_CTF_TRACES_PATH
427 local -x BT_PLUGINS_PATH=$_bt_tests_plugins_path
428 local -x PYTHONPATH=$BT_TESTS_PYTHONPATH${PYTHONPATH:+:}${PYTHONPATH:-}
ad42b27e 429 local -r main_lib_path=$BT_TESTS_BUILDDIR/../src/lib/.libs
0408934a 430
07ff3b19
PP
431 # Set the library search path so that the Python 3 interpreter can
432 # load `libbabeltrace2`.
c0d75ae3 433 if [[ $BT_TESTS_OS_TYPE == mingw || $BT_TESTS_OS_TYPE == cygwin ]]; then
ad42b27e 434 local -x PATH=$main_lib_path${PATH:+:}${PATH:-}
c0d75ae3 435 elif [[ $BT_TESTS_OS_TYPE == darwin ]]; then
ad42b27e 436 local -x DYLD_LIBRARY_PATH=$main_lib_path${DYLD_LIBRARY_PATH:+:}${DYLD_LIBRARY_PATH:-}
644e0364 437 else
ad42b27e 438 local -x LD_LIBRARY_PATH=$main_lib_path${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH:-}
e23e08c4
MJ
439 fi
440
07ff3b19
PP
441 # On Windows, an embedded Python 3 interpreter needs a way to locate
442 # the path to its internal modules: set the `PYTHONHOME` variable to
443 # the prefix from `python3-config`.
c0d75ae3 444 if [[ $BT_TESTS_OS_TYPE == mingw ]]; then
1e14ec65
PP
445 local -x PYTHONHOME
446
e612f2da 447 PYTHONHOME=$("$BT_TESTS_PYTHON_CONFIG_BIN" --prefix)
644e0364
MJ
448 fi
449
07ff3b19 450 # If AddressSanitizer is used, we must preload `libasan.so` so that
0b0893d4
SM
451 # libasan doesn't complain about not being the first loaded library.
452 #
07ff3b19
PP
453 # Python and sed (executed as part of the Libtool wrapper) produce
454 # some leaks, so we must unfortunately disable leak detection.
455 #
456 # Append it to existing `ASAN_OPTIONS` variable, such that we
457 # override the user's value if it contains `detect_leaks=1`.
c0d75ae3 458 if [[ ${BT_TESTS_ENABLE_ASAN:-} == 1 ]]; then
ad42b27e
PP
459 if "$BT_TESTS_CC_BIN" --version | head -n 1 | bt_grep -q '^gcc'; then
460 local -r lib_asan=$("$BT_TESTS_CC_BIN" -print-file-name=libasan.so)
461 local -x LD_PRELOAD=$lib_asan${LD_PRELOAD:+:}${LD_PRELOAD:-}
2d12d310 462 fi
0b0893d4 463
c0d75ae3 464 local -x ASAN_OPTIONS=${ASAN_OPTIONS:-}${ASAN_OPTIONS:+,}detect_leaks=0
0b0893d4
SM
465 fi
466
1e14ec65 467 run_python "$@"
644e0364
MJ
468}
469
07ff3b19
PP
470# Runs the Python tests matching the pattern `$2` (optional, `*` if
471# missing) in the directory `$1` using `testrunner.py`.
644e0364 472#
07ff3b19
PP
473# This function uses run_python_bt2(), therefore such tests can import
474# the testing Python modules (in `tests/utils/python`) and the `bt2`
475# Python package.
644e0364 476run_python_bt2_test() {
c0d75ae3
PP
477 local -r test_dir=$1
478 local -r test_pattern=${2:-*}
7c577b1d
PP
479 local python_exec
480
c0d75ae3
PP
481 if [[ ${BT_TESTS_COVERAGE:-} == 1 ]]; then
482 python_exec=_bt_tests_check_coverage
644e0364 483 else
ad42b27e 484 python_exec=$BT_TESTS_PYTHON_BIN
644e0364
MJ
485 fi
486
487 run_python_bt2 \
7121d33d
PP
488 "$python_exec" "$BT_TESTS_SRCDIR/utils/python/testrunner.py" \
489 --pattern "$test_pattern" "$test_dir"
a818a617 490
04c029a2 491 local -r ret=$?
644e0364 492
c0d75ae3 493 if [[ ${BT_TESTS_COVERAGE_REPORT:-} == 1 ]]; then
644e0364
MJ
494 coverage report -m
495 fi
496
c0d75ae3 497 if [[ ${BT_TESTS_COVERAGE_HTML:-} == 1 ]]; then
644e0364
MJ
498 coverage html
499 fi
500
501 return $ret
502}
89ec984e 503
07ff3b19
PP
504# Generates a CTF trace into the directory `$2` from the moultipart
505# document `$1` using `mctf.py`.
89ec984e 506gen_mctf_trace() {
c0d75ae3
PP
507 local -r input_file=$1
508 local -r base_dir=$2
ce8c884d
PP
509 local -r cmd=(
510 "$BT_TESTS_PYTHON_BIN" "$BT_TESTS_SRCDIR/utils/python/mctf.py"
511 --base-dir "$base_dir"
512 "$input_file"
513 )
514
515 echo "Running: \`${cmd[*]}\`" >&2
516 run_python "${cmd[@]}"
89ec984e 517}
This page took 0.084774 seconds and 4 git commands to generate.