Commit | Line | Data |
---|---|---|
10ba5f69 OD |
1 | #!/bin/bash |
2 | # | |
3 | # SPDX-License-Identifier: GPL-2.0-only | |
4 | # | |
5 | # Copyright (C) 2023 Efficios, Inc. | |
6 | ||
7 | SH_TAP=1 | |
8 | ||
9 | if [[ -n ${BT_TESTS_SRCDIR:-} ]]; then | |
10 | UTILSSH=$BT_TESTS_SRCDIR/utils/utils.sh | |
11 | else | |
12 | UTILSSH=$(dirname "$0")/../../../utils/utils.sh | |
13 | fi | |
14 | ||
15 | # shellcheck source=../../../utils/utils.sh | |
16 | source "$UTILSSH" | |
17 | ||
18 | # Directory containing the plugin | |
19 | data_dir=$BT_TESTS_DATADIR/plugins/src.ctf.fs/field | |
20 | ||
21 | test_pass() { | |
22 | local -r mp_path=$1 | |
23 | local -r output_dir=$(mktemp -d) | |
ed7395d5 PP |
24 | local -r py_cmd=( |
25 | "$BT_TESTS_PYTHON_BIN" "$data_dir/data_from_mp.py" | |
26 | "$mp_path" "$output_dir" | |
27 | ) | |
10ba5f69 | 28 | |
ed7395d5 PP |
29 | if ! bt_run_in_py_env "${py_cmd[@]}"; then |
30 | fail "Failed to run \`${py_cmd[*]}\`" | |
31 | return 1 | |
32 | fi | |
10ba5f69 OD |
33 | |
34 | local -r res_path=$(mktemp) | |
ed7395d5 PP |
35 | local -r cli_cmd=( |
36 | "$res_path" /dev/null --plugin-path="$data_dir" | |
10ba5f69 | 37 | -c sink.test-text.single "$output_dir/trace" |
ed7395d5 PP |
38 | ) |
39 | ||
40 | if ! bt_cli "${cli_cmd[@]}"; then | |
41 | fail "Failed to run \`bt_cli ${cli_cmd[*]}\`" | |
42 | return 1 | |
43 | fi | |
44 | ||
10ba5f69 OD |
45 | bt_diff "$res_path" "$output_dir/expect" |
46 | ok $? "$mp_path" | |
47 | rm -rf "$output_dir" "$res_path" | |
48 | } | |
49 | ||
50 | plan_tests 6 | |
51 | ||
52 | for mp_path in "$data_dir"/ctf-1/pass-*.mp; do | |
53 | test_pass "$mp_path" | |
54 | done |