directory-handle: print `errno` reason on `unlinkat()` error
[lttng-tools.git] / tests / regression / kernel / test_lttng_logger
1 #!/bin/bash
2 #
3 # Copyright (C) - 2017 Julien Desfossez <jdesfossez@efficios.com>
4 #
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.
8 #
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
12 # more details.
13 #
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.
17
18 TEST_DESC="Kernel tracer - lttng-logger"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../..
22 NUM_TESTS=30
23 PAYLOAD="test_logger"
24 SESSION_NAME="kernel_event_basic"
25
26 source $TESTDIR/utils/utils.sh
27
28 function test_proc_logger()
29 {
30 diag "Test /proc/lttng-logger"
31
32 TRACE_PATH=$(mktemp -d)
33
34 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
35
36 lttng_enable_kernel_event $SESSION_NAME "lttng_logger"
37
38 start_lttng_tracing_ok
39
40 test -e /proc/lttng-logger
41 if test $? = 0; then
42 pass "/proc/lttng-logger exists"
43 echo -n "$PAYLOAD proc" > /proc/lttng-logger
44 ok $? "Write in /proc/lttng-logger"
45 else
46 fail "No /proc/lttng-logger"
47 fi
48
49 stop_lttng_tracing_ok
50
51 validate_trace_count "lttng_logger" $TRACE_PATH 1
52 validate_trace_only_exp "$PAYLOAD" $TRACE_PATH
53
54 destroy_lttng_session_ok $SESSION_NAME
55
56 rm -rf $TRACE_PATH
57 }
58
59 function test_dev_logger()
60 {
61 diag "Test /dev/lttng-logger"
62
63 TRACE_PATH=$(mktemp -d)
64
65 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
66
67 lttng_enable_kernel_event $SESSION_NAME "lttng_logger"
68
69 start_lttng_tracing_ok
70
71 test -c /dev/lttng-logger
72 if test $? = 0; then
73 pass "/dev/lttng-logger is a character device"
74 echo -n "$PAYLOAD dev" > /dev/lttng-logger
75 ok $? "Write in /dev/lttng-logger"
76 else
77 fail "No /dev/lttng-logger"
78 fi
79
80 stop_lttng_tracing_ok
81
82 validate_trace_count "lttng_logger" $TRACE_PATH 1
83 validate_trace_only_exp "$PAYLOAD" $TRACE_PATH
84
85 destroy_lttng_session_ok $SESSION_NAME
86
87 rm -rf $TRACE_PATH
88 }
89
90 function test_payload_limit()
91 {
92 diag "Test lttng-logger payload limit"
93
94 TRACE_PATH=$(mktemp -d)
95
96 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
97
98 lttng_enable_kernel_event $SESSION_NAME "lttng_logger"
99
100 start_lttng_tracing_ok
101
102 # Write 100 times "test_logger", which generates 1200 characters, we expect
103 # the tracer to write 2 events from that string because it limits the
104 # input to 1024 strings.
105 printf "%.s $PAYLOAD" {1..100} > /proc/lttng-logger
106 printf "%.s $PAYLOAD" {1..100} > /dev/lttng-logger
107
108 stop_lttng_tracing_ok
109
110 validate_trace_count "lttng_logger" $TRACE_PATH 4
111 validate_trace_only_exp "$PAYLOAD" $TRACE_PATH
112
113 destroy_lttng_session_ok $SESSION_NAME
114
115 rm -rf $TRACE_PATH
116 }
117
118 # MUST set TESTDIR before calling those functions
119 plan_tests $NUM_TESTS
120
121 print_test_banner "$TEST_DESC"
122
123 if [ "$(id -u)" == "0" ]; then
124 isroot=1
125 else
126 isroot=0
127 fi
128
129 skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
130 {
131 start_lttng_sessiond
132
133 test_proc_logger
134 test_dev_logger
135 test_payload_limit
136
137 stop_lttng_sessiond
138 }
This page took 0.03312 seconds and 4 git commands to generate.