3 # Copyright (C) 2019 EfficiOS Inc.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License, version 2 only, as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
21 UTILSSH
="$BT_TESTS_SRCDIR/utils/utils.sh"
23 UTILSSH
="$(dirname "$0")/../utils/utils.sh"
26 # shellcheck source=../utils/utils.sh
29 data_dir
="$BT_TESTS_DATADIR/cli/exit_status"
30 source_name
="src.test_exit_status.StatusSrc"
32 test_interrupted_graph
() {
33 local cli_args
=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"INTERRUPTED\"")
34 local actual_stdout
=$
(mktemp
-t test_cli_exit_status_stdout_actual.XXXXXX
)
35 local actual_stderr
=$
(mktemp
-t test_cli_exit_status_stderr_actual.XXXXXX
)
37 bt_cli
"$actual_stdout" "$actual_stderr" "${cli_args[@]}"
39 is $?
2 "Interrupted graph exits with status 2"
41 bt_diff
/dev
/null
"$actual_stdout"
42 ok $?
"Interrupted graph gives no stdout"
44 bt_diff
/dev
/null
"$actual_stderr"
45 ok $?
"Interrupted graph gives no stderr"
47 rm -f "${actual_stdout}"
48 rm -f "${actual_stderr}"
52 local cli_args
=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"ERROR\"")
53 local actual_stdout
=$
(mktemp
-t test_cli_exit_status_stdout_actual.XXXXXX
)
54 local actual_stderr
=$
(mktemp
-t test_cli_exit_status_stderr_actual.XXXXXX
)
56 bt_cli
"$actual_stdout" "$actual_stderr" "${cli_args[@]}"
58 is $?
1 "Erroring graph exits with status 1"
60 bt_diff
/dev
/null
"$actual_stdout"
61 ok $?
"Erroring graph gives expected stdout"
63 like
"$(cat "${actual_stderr}")" "TypeError: Raising type error" \
64 "Erroring graph gives expected error message"
66 rm -f "${actual_stdout}"
67 rm -f "${actual_stderr}"
71 local cli_args
=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"STOP\"")
72 local actual_stdout
=$
(mktemp
-t test_cli_exit_status_stdout_actual.XXXXXX
)
73 local actual_stderr
=$
(mktemp
-t test_cli_exit_status_stderr_actual.XXXXXX
)
75 bt_cli
"$actual_stdout" "$actual_stderr" "${cli_args[@]}"
77 is $?
0 "Successful graph exits with status 0"
79 bt_diff
/dev
/null
"$actual_stdout"
80 ok $?
"Successful graph gives no stdout"
82 bt_diff
/dev
/null
"$actual_stderr"
83 ok $?
"Successful graph gives no stderr"
85 rm -f "${actual_stdout}"
86 rm -f "${actual_stderr}"
91 test_interrupted_graph