tests: Replace babelstats.pl with bt2 plugins
[lttng-tools.git] / tests / regression / tools / tracefile-limits / test_tracefile_count
index eb5d1a5f13c146aa78771414112d139f2c141bc9..9253d3ec2fcc0afdb2b6abe7320bb6f086b51ed7 100755 (executable)
@@ -9,15 +9,14 @@ TEST_DESC="Tracefile count limits"
 
 CURDIR=$(dirname "$0")/
 TESTDIR=$CURDIR/../../..
+BT2_PLUGINS_DIR="${TESTDIR}/utils/bt2_plugins"
 
 TESTAPP_PATH="$TESTDIR/utils/testapp"
 TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 
-STATS_BIN="$TESTDIR/utils/babelstats.pl"
 NUM_TESTS=74
 
-NUM_CPUS=$(nproc)
 PAGE_SIZE=$(getconf PAGE_SIZE)
 TRACEFILE_SIZE=$PAGE_SIZE
 
@@ -27,6 +26,13 @@ if [ ! -x "$TESTAPP_BIN" ]; then
        BAIL_OUT "No UST events binary detected."
 fi
 
+function pick_random_cpuid ()
+{
+       local cpuids
+       read -r -a cpuids <<< "$(get_online_cpus)"
+       echo "${cpuids[ $RANDOM % ${#cpuids[@]} ]}"
+}
+
 function enable_lttng_channel_count_limit ()
 {
        sess_name="$1"
@@ -82,7 +88,7 @@ function test_tracefile_count_limit ()
        local count_limit="$1"
 
        local channel_name="channel"
-       local cpuno=$((RANDOM % NUM_CPUS))
+       local cpuno=$(pick_random_cpuid)
        local event_name="tp:tptest"
        local expected_size=$((count_limit * TRACEFILE_SIZE))
        local num_iter=100000
@@ -90,10 +96,9 @@ function test_tracefile_count_limit ()
        local session_name
        local stream_pattern=".*${channel_name}_${cpuno}_[0-9]*"
        local stream_size=0
-       local trace_path
+       local trace_path=$(mktemp -d -t "tmp.${FUNCNAME[0]}_trace_path.XXXXXX")
 
        session_name=$(randstring 16 0)
-       trace_path=$(mktemp -d)
 
        diag "Test tracefile count limit : CPU $cpuno, $count_limit tracefiles, expecting a maximum of $expected_size bytes per CPU"
 
@@ -135,7 +140,7 @@ function test_tracefile_count_limit ()
        [ "$(get_stream_file_count "$trace_path" "$stream_pattern")" -eq "$count_limit" ]
        ok $? "Stream meets the trace file limit of $count_limit"
 
-       stats=`babeltrace $trace_path | $STATS_BIN --tracepoint $event_name`
+       stats=$("$BABELTRACE_BIN" --plugin-path "${BT2_PLUGINS_DIR}" convert $trace_path -c filter.lttngtest.event_name -p "names=[\"${event_name}\"]" -c sink.lttngtest.field_stats)
 
        validate_min_max "$stats" "intfield" "[0-9]+" "$expected_max"
        ok $? "Trace validation - intfield"
@@ -155,6 +160,8 @@ plan_tests $NUM_TESTS
 
 print_test_banner "$TEST_DESC"
 
+bail_out_if_no_babeltrace
+
 start_lttng_sessiond
 
 for limit in "${LIMITS[@]}";
This page took 0.025706 seconds and 4 git commands to generate.