3 # Copyright (C) - 2020 EfficiOS, inc
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this library; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 # Test the `lttng remove-trigger` command line interface.
20 CURDIR
="$(dirname "$0")"
21 TESTDIR
="$CURDIR/../../.."
23 # shellcheck source=../../../utils/utils.sh
24 source "$TESTDIR/utils/utils.sh"
28 FULL_LTTNG_BIN
="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}"
30 tmp_stdout
=$
(mktemp
-t test_list_triggers_cli_stdout.XXXXXX
)
31 tmp_stderr
=$
(mktemp
-t test_list_triggers_cli_stderr.XXXXXX
)
32 tmp_expected_stdout
=$
(mktemp
-t test_list_triggers_cli_expected_stdout.XXXXXX
)
37 function list_triggers
()
40 local expected_stdout_file
="$2"
42 "${FULL_LTTNG_BIN}" list-triggers > "${tmp_stdout}" 2> "${tmp_stderr}"
43 ok $?
"${test_name}: exit code is 0"
45 diff -u "${expected_stdout_file}" "${tmp_stdout}"
46 ok $?
"${test_name}: expected stdout"
48 diff -u /dev
/null
"${tmp_stderr}"
49 ok $?
"${test_name}: expected stderr"
52 function remove_trigger
()
55 local test_name
="remove trigger ${id}"
57 "${FULL_LTTNG_BIN}" remove-trigger "${id}" > "${tmp_stdout}" 2> "${tmp_stderr}"
58 ok $?
"${test_name}: exit code is 0"
60 diff -u <(echo "Removed trigger \`${id}\`.") "${tmp_stdout}"
61 ok $?
"${test_name}: expected stdout"
63 diff -u /dev
/null
"${tmp_stderr}"
64 ok $?
"${test_name}: expected stderr"
67 # shellcheck disable=SC2119
68 start_lttng_sessiond_notap
71 lttng_add_trigger_ok
"ABC" --condition on-event aaa
-u --filter 'p == 2' --action notify
72 lttng_add_trigger_ok
"DEF" --condition on-event
-u -a --action notify
74 cat > "${tmp_expected_stdout}" <<- EOF
77 condition: event rule hit
78 rule: aaa (type: tracepoint, domain: ust, filter: p == 2)
79 tracer notifications discarded: 0
84 condition: event rule hit
85 rule: * (type: tracepoint, domain: ust)
86 tracer notifications discarded: 0
90 list_triggers
"two triggers left" "${tmp_expected_stdout}"
94 cat > "${tmp_expected_stdout}" <<- EOF
97 condition: event rule hit
98 rule: * (type: tracepoint, domain: ust)
99 tracer notifications discarded: 0
103 list_triggers
"one trigger left" "${tmp_expected_stdout}"
107 list_triggers
"no triggers left" "/dev/null"
110 stop_lttng_sessiond_notap
111 rm -f "${tmp_stdout}"
112 rm -f "${tmp_stderr}"
113 rm -f "${tmp_expected_stdout}"