3 # SPDX-License-Identifier: GPL-2.0-only
5 # Copyright (C) 2019 EfficiOS Inc.
10 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
11 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
13 UTILSSH
="$(dirname "$0")/../utils/utils.sh"
16 # shellcheck source=../utils/utils.sh
19 data_dir
="$BT_TESTS_DATADIR/cli/exit_status"
20 source_name
="src.test_exit_status.StatusSrc"
22 test_interrupted_graph
() {
23 local cli_args
=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"INTERRUPTED\"")
27 actual_stdout
=$
(mktemp
-t test_cli_exit_status_stdout_actual.XXXXXX
)
28 actual_stderr
=$
(mktemp
-t test_cli_exit_status_stderr_actual.XXXXXX
)
30 bt_cli
"$actual_stdout" "$actual_stderr" "${cli_args[@]}"
32 is $?
2 "Interrupted graph exits with status 2"
34 bt_diff
/dev
/null
"$actual_stdout"
35 ok $?
"Interrupted graph gives no stdout"
37 bt_diff
/dev
/null
"$actual_stderr"
38 ok $?
"Interrupted graph gives no stderr"
40 rm -f "${actual_stdout}"
41 rm -f "${actual_stderr}"
45 local cli_args
=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"ERROR\"")
49 actual_stdout
=$
(mktemp
-t test_cli_exit_status_stdout_actual.XXXXXX
)
50 actual_stderr
=$
(mktemp
-t test_cli_exit_status_stderr_actual.XXXXXX
)
52 bt_cli
"$actual_stdout" "$actual_stderr" "${cli_args[@]}"
54 is $?
1 "Erroring graph exits with status 1"
56 bt_diff
/dev
/null
"$actual_stdout"
57 ok $?
"Erroring graph gives expected stdout"
59 like
"$(cat "${actual_stderr}")" "TypeError: Raising type error" \
60 "Erroring graph gives expected error message"
62 rm -f "${actual_stdout}"
63 rm -f "${actual_stderr}"
67 local cli_args
=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"STOP\"")
71 actual_stdout
=$
(mktemp
-t test_cli_exit_status_stdout_actual.XXXXXX
)
72 actual_stderr
=$
(mktemp
-t test_cli_exit_status_stderr_actual.XXXXXX
)
74 bt_cli
"$actual_stdout" "$actual_stderr" "${cli_args[@]}"
76 is $?
0 "Successful graph exits with status 0"
78 bt_diff
/dev
/null
"$actual_stdout"
79 ok $?
"Successful graph gives no stdout"
81 bt_diff
/dev
/null
"$actual_stderr"
82 ok $?
"Successful graph gives no stderr"
84 rm -f "${actual_stdout}"
85 rm -f "${actual_stderr}"
90 test_interrupted_graph