Import CStringView from the Babeltrace tree
[lttng-tools.git] / tests / regression / ust / blocking / test_blocking
index 751b3453b50d7e264e6dd411b96407389931bf1c..51e2130908c78758af7b2d63ef3e6aa46d87a7a5 100755 (executable)
@@ -30,6 +30,19 @@ function run_app()
        ok $? "Application done"
 }
 
+function check_disk_space()
+{
+       local path
+
+       path="${1:?}"
+       kb_free=$(df -k -P "${path}" | tail -n 1 | awk '{ print $4 }')
+       if [ "${kb_free}" -lt "1048576" ] ; then
+               return 1
+       fi
+
+       return 0
+}
+
 function test_ust_implicit_no_blocking()
 {
        NUM_EVENT=5000000
@@ -121,13 +134,12 @@ function test_ust_blocking_no_discard()
        start_lttng_tracing_ok $SESSION_NAME
        LTTNG_UST_ALLOW_BLOCKING=1 run_app
        stop_lttng_tracing_ok $SESSION_NAME
+       discarded=$("${XML_EXTRACT}" <("${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}" --mi=xml list --channel="${CHANNEL_NAME}" "${SESSION_NAME}") '//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel/lttng:attributes/lttng:discarded_events')
        destroy_lttng_session_ok $SESSION_NAME
        stop_lttng_sessiond
 
-       nr_events=$("$BABELTRACE_BIN" $TRACE_PATH 2>/dev/null | wc -l)
-
-       test $nr_events -eq $NUM_EVENT
-       ok $? "No event lost with UST blocking mode: found $nr_events expect $NUM_EVENT"
+       test "$(echo "${discarded}" | grep -Eo '[0-9]+')" = "0"
+       ok $? "No event lost with UST blocking mode: ${discarded}"
 }
 
 plan_tests $NUM_TESTS
@@ -136,6 +148,10 @@ print_test_banner "$TEST_DESC"
 
 bail_out_if_no_babeltrace
 
+if ! check_disk_space "${TMPDIR:-/tmp}"; then
+       BAIL_OUT "Not enough free space to run blocking tests"
+fi
+
 TESTS=(
        "test_ust_implicit_no_blocking"
        "test_ust_implicit_no_blocking_with_channel_blocking"
This page took 0.024825 seconds and 4 git commands to generate.