tests/lib/test_trace_ir_ref.c: rename user structure
[babeltrace.git] / tests / cli / test_exit_status
1 #!/bin/bash
2 #
3 # SPDX-License-Identifier: GPL-2.0-only
4 #
5 # Copyright (C) 2019 EfficiOS Inc.
6 #
7
8 SH_TAP=1
9
10 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
11 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
12 else
13 UTILSSH="$(dirname "$0")/../utils/utils.sh"
14 fi
15
16 # shellcheck source=../utils/utils.sh
17 source "$UTILSSH"
18
19 data_dir="$BT_TESTS_DATADIR/cli/exit_status"
20 source_name="src.test_exit_status.StatusSrc"
21
22 test_interrupted_graph() {
23 local cli_args=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"INTERRUPTED\"")
24 local actual_stdout
25 local actual_stderr
26
27 actual_stdout=$(mktemp -t test_cli_exit_status_stdout_actual.XXXXXX)
28 actual_stderr=$(mktemp -t test_cli_exit_status_stderr_actual.XXXXXX)
29
30 bt_cli "$actual_stdout" "$actual_stderr" "${cli_args[@]}"
31
32 is $? 2 "Interrupted graph exits with status 2"
33
34 bt_diff /dev/null "$actual_stdout"
35 ok $? "Interrupted graph gives no stdout"
36
37 bt_diff /dev/null "$actual_stderr"
38 ok $? "Interrupted graph gives no stderr"
39
40 rm -f "${actual_stdout}"
41 rm -f "${actual_stderr}"
42 }
43
44 test_error_graph() {
45 local cli_args=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"ERROR\"")
46 local actual_stdout
47 local actual_stderr
48
49 actual_stdout=$(mktemp -t test_cli_exit_status_stdout_actual.XXXXXX)
50 actual_stderr=$(mktemp -t test_cli_exit_status_stderr_actual.XXXXXX)
51
52 bt_cli "$actual_stdout" "$actual_stderr" "${cli_args[@]}"
53
54 is $? 1 "Erroring graph exits with status 1"
55
56 bt_diff /dev/null "$actual_stdout"
57 ok $? "Erroring graph gives expected stdout"
58
59 like "$(cat "${actual_stderr}")" "TypeError: Raising type error" \
60 "Erroring graph gives expected error message"
61
62 rm -f "${actual_stdout}"
63 rm -f "${actual_stderr}"
64 }
65
66 test_stop_graph() {
67 local cli_args=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"STOP\"")
68 local actual_stdout
69 local actual_stderr
70
71 actual_stdout=$(mktemp -t test_cli_exit_status_stdout_actual.XXXXXX)
72 actual_stderr=$(mktemp -t test_cli_exit_status_stderr_actual.XXXXXX)
73
74 bt_cli "$actual_stdout" "$actual_stderr" "${cli_args[@]}"
75
76 is $? 0 "Successful graph exits with status 0"
77
78 bt_diff /dev/null "$actual_stdout"
79 ok $? "Successful graph gives no stdout"
80
81 bt_diff /dev/null "$actual_stderr"
82 ok $? "Successful graph gives no stderr"
83
84 rm -f "${actual_stdout}"
85 rm -f "${actual_stderr}"
86 }
87
88 plan_tests 9
89
90 test_interrupted_graph
91 test_error_graph
92 test_stop_graph
This page took 0.032808 seconds and 4 git commands to generate.