Move to kernel style SPDX license identifiers
[babeltrace.git] / tests / cli / test_exit_status
CommitLineData
b5cd7d65
FD
1#!/bin/bash
2#
0235b0db 3# SPDX-License-Identifier: GPL-2.0-only
b5cd7d65 4#
0235b0db 5# Copyright (C) 2019 EfficiOS Inc.
b5cd7d65 6#
b5cd7d65
FD
7
8SH_TAP=1
9
10if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
11 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
12else
13 UTILSSH="$(dirname "$0")/../utils/utils.sh"
14fi
15
16# shellcheck source=../utils/utils.sh
17source "$UTILSSH"
18
19data_dir="$BT_TESTS_DATADIR/cli/exit_status"
20source_name="src.test_exit_status.StatusSrc"
21
22test_interrupted_graph() {
23 local cli_args=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"INTERRUPTED\"")
9bff3593
SM
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)
b5cd7d65
FD
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
44test_error_graph() {
45 local cli_args=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"ERROR\"")
9bff3593
SM
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)
b5cd7d65
FD
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
66test_stop_graph() {
67 local cli_args=("--plugin-path=$data_dir" "-c" "$source_name" "-p" "case=\"STOP\"")
9bff3593
SM
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)
b5cd7d65
FD
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
88plan_tests 9
89
90test_interrupted_graph
91test_error_graph
92test_stop_graph
This page took 0.031243 seconds and 4 git commands to generate.