tests: Move to kernel style SPDX license identifiers
[lttng-tools.git] / tests / regression / tools / tracefile-limits / test_tracefile_count
CommitLineData
d946d662
CB
1#!/bin/bash
2#
9d16b343 3# Copyright (C) 2013 Christian Babeux <christian.babeux@efficios.com>
d946d662 4#
9d16b343 5# SPDX-License-Identifier: LGPL-2.1-only
d946d662
CB
6
7TEST_DESC="Tracefile count limits"
8
9CURDIR=$(dirname $0)/
10TESTDIR=$CURDIR/../../..
11
12TESTAPP_PATH="$TESTDIR/utils/testapp"
13TESTAPP_NAME="gen-ust-events"
14TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
15
16STATS_BIN="$TESTDIR/utils/babelstats.pl"
d7ee608c 17NUM_TESTS=74
d40d4ff6
CB
18
19NUM_CPUS=`nproc`
3b0246b4 20PAGE_SIZE=$(getconf PAGE_SIZE)
d946d662
CB
21
22source $TESTDIR/utils/utils.sh
23
24if [ ! -x "$TESTAPP_BIN" ]; then
25 BAIL_OUT "No UST events binary detected."
26fi
27
d946d662
CB
28function enable_lttng_channel_count_limit ()
29{
30 sess_name="$1"
31 channel_name="$2"
32 tracefile_count_limit="$3"
33
34 test_name="Enable channel $channel_name "
35 test_name+="for session $sess_name: "
36 test_name+="$tracefile_count_limit tracefiles"
37
38 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel \
39 -u $channel_name -s $sess_name \
3b0246b4 40 -C $(($PAGE_SIZE*3)) -W $tracefile_count_limit \
d946d662
CB
41 --overwrite >/dev/null 2>&1
42
43 ok $? "$test_name"
44}
45
46function enable_ust_lttng_event_per_channel ()
47{
48 sess_name="$1"
49 event_name="$2"
50 channel_name="$3"
51
52 test_name="Enable event $event_name "
53 test_name+="for session $sess_name "
54 test_name+="in channel $channel_name"
55
56 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" \
57 -s $sess_name -u -c $channel_name >/dev/null 2>&1
58
59 ok $? "$test_name"
60}
61
62function validate_min_max
63{
64 stats="$1"
65 field="$2"
66 expected_min="$3"
67 expected_max="$4"
68
69 echo $stats | grep -q -E "$field $expected_min $expected_max"
70 return $?
71}
72
73function validate_file_count
74{
75 path="$1"
76 file_pattern="$2"
77 expected_max_count="$3"
78
d3e2ba59 79 count=`find $path -name "$file_pattern" -type f \( ! -iname "*.idx" \) | wc -l`
d946d662
CB
80
81 if [ "$count" -gt "$expected_max_count" ]; then
82 fail "Validate file count: $file_pattern"
83 diag "File count: $count expected: $expected_max_count"
84 else
85 pass "Validate file count: $file_pattern"
86 fi
87}
88
89function test_tracefile_count_limit ()
90{
91 count_limit="$1"
92 trace_path=$(mktemp -d)
93 session_name=$(randstring 16 0)
94 channel_name="channel"
95 event_name="tp:tptest"
3b0246b4 96 num_iter=100000
d946d662
CB
97 expected_max=$(($num_iter - 1))
98
99 diag "Test tracefile count limit : $count_limit tracefiles"
100
bf6ae429 101 create_lttng_session_ok $session_name $trace_path
d946d662
CB
102
103 enable_lttng_channel_count_limit \
104 $session_name $channel_name $count_limit
105
106 enable_ust_lttng_event_per_channel \
107 $session_name $event_name $channel_name
108
e563bbdb 109 start_lttng_tracing_ok $session_name
d946d662 110
6c4a91d6 111 $TESTAPP_BIN -i $num_iter >/dev/null 2>&1
d946d662 112
96340a01 113 stop_lttng_tracing_ok $session_name
d946d662 114
67b4c664 115 destroy_lttng_session_ok $session_name
d946d662
CB
116
117 # Validate tracing dir
118
d40d4ff6 119 for cpuno in $(seq 0 $(($NUM_CPUS - 1)))
d946d662
CB
120 do
121 validate_file_count \
122 $trace_path "${channel_name}_${cpuno}_*" $count_limit
123 done
124
125 # Validate tracing data
126
127 stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $event_name`
128
129 validate_min_max "$stats" "intfield" "[0-9]+" "$expected_max"
130 ok $? "Trace validation - intfield"
131
132 validate_min_max "$stats" "netintfield" "[0-9]+" "$expected_max"
133 ok $? "Trace validation - netintfield"
134
135 validate_min_max "$stats" "longfield" "[0-9]+" "$expected_max"
136 ok $? "Trace validation - longfield"
137
138 rm -rf $trace_path
139}
140
d40d4ff6
CB
141LIMITS=("1" "2" "4" "8" "10" "16" "32" "64")
142
143# The file count validation depends on the number of streams (1 per cpu)
144TOTAL_TESTS=$(($NUM_TESTS + (${#LIMITS[@]} * $NUM_CPUS)))
145
146plan_tests $TOTAL_TESTS
d946d662
CB
147
148print_test_banner "$TEST_DESC"
149
150start_lttng_sessiond
151
d946d662
CB
152for limit in ${LIMITS[@]};
153do
154 test_tracefile_count_limit $limit
155done
156
157stop_lttng_sessiond
This page took 0.058335 seconds and 5 git commands to generate.