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\"")
37 actual_stdout
=$
(mktemp
-t test_cli_exit_status_stdout_actual.XXXXXX
)
38 actual_stderr
=$
(mktemp
-t test_cli_exit_status_stderr_actual.XXXXXX
)
40 bt_cli
"$actual_stdout" "$actual_stderr" "${cli_args[@]}"
42 is $?
2 "Interrupted graph exits with status 2"
44 bt_diff
/dev
/null
"$actual_stdout"
45 ok $?
"Interrupted graph gives no stdout"
47 bt_diff
/dev
/null
"$actual_stderr"
48 ok $?
"Interrupted graph gives no stderr"
50 rm -f "${actual_stdout}"
51 rm -f "${actual_stderr}"
55 local cli_args
=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"ERROR\"")
59 actual_stdout
=$
(mktemp
-t test_cli_exit_status_stdout_actual.XXXXXX
)
60 actual_stderr
=$
(mktemp
-t test_cli_exit_status_stderr_actual.XXXXXX
)
62 bt_cli
"$actual_stdout" "$actual_stderr" "${cli_args[@]}"
64 is $?
1 "Erroring graph exits with status 1"
66 bt_diff
/dev
/null
"$actual_stdout"
67 ok $?
"Erroring graph gives expected stdout"
69 like
"$(cat "${actual_stderr}")" "TypeError: Raising type error" \
70 "Erroring graph gives expected error message"
72 rm -f "${actual_stdout}"
73 rm -f "${actual_stderr}"
77 local cli_args
=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"STOP\"")
81 actual_stdout
=$
(mktemp
-t test_cli_exit_status_stdout_actual.XXXXXX
)
82 actual_stderr
=$
(mktemp
-t test_cli_exit_status_stderr_actual.XXXXXX
)
84 bt_cli
"$actual_stdout" "$actual_stderr" "${cli_args[@]}"
86 is $?
0 "Successful graph exits with status 0"
88 bt_diff
/dev
/null
"$actual_stdout"
89 ok $?
"Successful graph gives no stdout"
91 bt_diff
/dev
/null
"$actual_stderr"
92 ok $?
"Successful graph gives no stderr"
94 rm -f "${actual_stdout}"
95 rm -f "${actual_stderr}"
100 test_interrupted_graph