lttng add-trigger: replace domain options with single --domain
[lttng-tools.git] / tests / regression / tools / trigger / test_remove_trigger_cli
CommitLineData
b61776fb
SM
1#!/bin/bash
2#
3# Copyright (C) - 2020 EfficiOS, inc
4#
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.
8#
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
12# details.
13#
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
17
18# Test the `lttng remove-trigger` command line interface.
19
20CURDIR="$(dirname "$0")"
21TESTDIR="$CURDIR/../../.."
22
23# shellcheck source=../../../utils/utils.sh
24source "$TESTDIR/utils/utils.sh"
25
26plan_tests 17
27
28FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}"
29
30tmp_stdout=$(mktemp -t test_list_triggers_cli_stdout.XXXXXX)
31tmp_stderr=$(mktemp -t test_list_triggers_cli_stderr.XXXXXX)
32tmp_expected_stdout=$(mktemp -t test_list_triggers_cli_expected_stdout.XXXXXX)
33
34uid=$(id --user)
35gid=$(id --group)
36
b61776fb
SM
37function list_triggers ()
38{
39 local test_name="$1"
40 local expected_stdout_file="$2"
41
42 "${FULL_LTTNG_BIN}" list-triggers > "${tmp_stdout}" 2> "${tmp_stderr}"
43 ok $? "${test_name}: exit code is 0"
44
45 diff -u "${expected_stdout_file}" "${tmp_stdout}"
46 ok $? "${test_name}: expected stdout"
47
48 diff -u /dev/null "${tmp_stderr}"
49 ok $? "${test_name}: expected stderr"
50}
51
52function remove_trigger ()
53{
1d4b59f2
SM
54 local name="$1"
55 local test_name="remove trigger ${name}"
b61776fb 56
1d4b59f2 57 "${FULL_LTTNG_BIN}" remove-trigger "${name}" > "${tmp_stdout}" 2> "${tmp_stderr}"
b61776fb
SM
58 ok $? "${test_name}: exit code is 0"
59
1d4b59f2 60 diff -u <(echo "Removed trigger \`${name}\`.") "${tmp_stdout}"
b61776fb
SM
61 ok $? "${test_name}: expected stdout"
62
63 diff -u /dev/null "${tmp_stderr}"
64 ok $? "${test_name}: expected stderr"
65}
66
67# shellcheck disable=SC2119
68start_lttng_sessiond_notap
69
70# Add a few triggers
64c34630
SM
71lttng_add_trigger_ok "ABC" --condition event-rule-matches --name=aaa --domain=user --filter 'p == 2' --action notify
72lttng_add_trigger_ok "DEF" --condition event-rule-matches --domain=user --action notify
b61776fb
SM
73
74cat > "${tmp_expected_stdout}" <<- EOF
1d4b59f2 75- name: ABC
b61776fb
SM
76 user id: ${uid}
77 condition: event rule hit
78 rule: aaa (type: tracepoint, domain: ust, filter: p == 2)
79 actions:
80 notify
709fb83f
JG
81 errors: none
82 errors: none
1d4b59f2 83- name: DEF
b61776fb
SM
84 user id: ${uid}
85 condition: event rule hit
86 rule: * (type: tracepoint, domain: ust)
87 actions:
88 notify
709fb83f
JG
89 errors: none
90 errors: none
b61776fb
SM
91EOF
92list_triggers "two triggers left" "${tmp_expected_stdout}"
93
94remove_trigger "ABC"
95
96cat > "${tmp_expected_stdout}" <<- EOF
1d4b59f2 97- name: DEF
b61776fb
SM
98 user id: ${uid}
99 condition: event rule hit
100 rule: * (type: tracepoint, domain: ust)
101 actions:
102 notify
709fb83f
JG
103 errors: none
104 errors: none
b61776fb
SM
105EOF
106list_triggers "one trigger left" "${tmp_expected_stdout}"
107
70c766ac 108remove_trigger "DEF"
b61776fb
SM
109
110list_triggers "no triggers left" "/dev/null"
111
112# Cleanup
113stop_lttng_sessiond_notap
114rm -f "${tmp_stdout}"
115rm -f "${tmp_stderr}"
116rm -f "${tmp_expected_stdout}"
This page took 0.039615 seconds and 4 git commands to generate.