X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Fplugins%2Fsrc.ctf.fs%2Fsucceed%2Ftest_succeed;h=81d87593e3ee7e824c736644e121205b79ec5937;hb=75e396f6b20bdf52c76a3c7312e7fb815ac1e5e9;hp=9cd77ba9d2ab76f28428c5c2db983e2d129ce381;hpb=644e036445497ef69ccf946f0700da20a5bae84f;p=babeltrace.git diff --git a/tests/plugins/src.ctf.fs/succeed/test_succeed b/tests/plugins/src.ctf.fs/succeed/test_succeed index 9cd77ba9..81d87593 100755 --- a/tests/plugins/src.ctf.fs/succeed/test_succeed +++ b/tests/plugins/src.ctf.fs/succeed/test_succeed @@ -1,20 +1,9 @@ #!/bin/bash # -# Copyright (C) 2019 Philippe Proulx -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. +# SPDX-License-Identifier: GPL-2.0-only # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# Copyright (C) 2019 Philippe Proulx # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # This test validates that a `src.ctf.fs` component successfully reads # specific CTF traces and creates the expected messages. @@ -24,7 +13,7 @@ SH_TAP=1 -if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then +if [ -n "${BT_TESTS_SRCDIR:-}" ]; then UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh" else UTILSSH="$(dirname "$0")/../../../utils/utils.sh" @@ -38,7 +27,7 @@ this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative" succeed_trace_dir="$BT_CTF_TRACES_PATH/succeed" expect_dir="$BT_TESTS_DATADIR/$this_dir_relative" -test_ctf_common_details_args="-p with-trace-name=no,with-stream-name=no" +test_ctf_common_details_args=("-p" "with-trace-name=no,with-stream-name=no") test_ctf_gen_single() { name="$1" @@ -46,19 +35,107 @@ test_ctf_gen_single() { diag "Generating trace '$name'" bt_diff_details_ctf_gen_single "$this_dir_build/gen-trace-$name" \ "$expect_dir/trace-$name.expect" \ - "$test_ctf_common_details_args -p with-uuid=no" + "${test_ctf_common_details_args[@]}" "-p" "with-uuid=no" ok $? "Generated trace '$name' gives the expected output" } test_ctf_single() { name="$1" - bt_diff_details_ctf_single "$succeed_trace_dir/$name" \ - "$expect_dir/trace-$name.expect" "$test_ctf_common_details_args" + bt_diff_details_ctf_single "$expect_dir/trace-$name.expect" \ + "$succeed_trace_dir/$name" "${test_ctf_common_details_args[@]}" ok $? "Trace '$name' gives the expected output" } -plan_tests 2 +test_packet_end() { + local name="$1" + local expected_stdout="$expect_dir/trace-$name.expect" + local ret=0 + local ret_stdout + local ret_stderr + local details_comp=("-c" "sink.text.details") + local details_args=("-p" "with-trace-name=no,with-stream-name=no,with-metadata=no,compact=yes") + local temp_stdout_output_file + local temp_greped_stdout_output_file + local temp_stderr_output_file + + temp_stdout_output_file="$(mktemp -t actual_stdout.XXXXXX)" + temp_greped_stdout_output_file="$(mktemp -t greped_stdout.XXXXXX)" + temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)" + + bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" \ + "$succeed_trace_dir/$name" "${details_comp[@]}" \ + "${details_args[@]}" + + "$BT_TESTS_GREP_BIN" "Packet end" "$temp_stdout_output_file" > "$temp_greped_stdout_output_file" + + bt_diff "$expected_stdout" "$temp_greped_stdout_output_file" + ret_stdout=$? + + bt_diff /dev/null "$temp_stderr_output_file" + ret_stderr=$? + + if ((ret_stdout != 0 || ret_stderr != 0)); then + ret=1 + fi + + ok $ret "Trace '$name' gives the expected output" + rm -f "$temp_stdout_output_file" "$temp_stderr_output_file" "$temp_greped_stdout_output_file" +} + +test_force_origin_unix_epoch() { + local name1="$1" + local name2="$2" + local expected_stdout="$expect_dir/trace-$name1-$name2.expect" + local ret=0 + local ret_stdout + local ret_stderr + local src_ctf_fs_args=("-p" "force-clock-class-origin-unix-epoch=true") + local details_comp=("-c" "sink.text.details") + local details_args=("-p" "with-trace-name=no,with-stream-name=no,with-metadata=yes,compact=yes") + local temp_stdout_output_file + local temp_stderr_output_file + + temp_stdout_output_file="$(mktemp -t actual_stdout.XXXXXX)" + temp_stderr_output_file="$(mktemp -t actual_stderr.XXXXXX)" + + bt_cli "$temp_stdout_output_file" "$temp_stderr_output_file" \ + "$succeed_trace_dir/$name1" "${src_ctf_fs_args[@]}" \ + "$succeed_trace_dir/$name2" "${src_ctf_fs_args[@]}" \ + "${details_comp[@]}" "${details_args[@]}" + + bt_diff "$expected_stdout" "$temp_stdout_output_file" + ret_stdout=$? + + if ((ret_stdout != 0)); then + ret=1 + fi + + ok $ret "Trace '$name1' and '$name2' give the expected stdout" + + bt_diff /dev/null "$temp_stderr_output_file" + ret_stderr=$? + + if ((ret_stderr != 0)); then + ret=1 + fi + + ok $ret "Trace '$name1' and '$name2' give the expected stderr" + + rm -f "$temp_stdout_output_file" "$temp_stderr_output_file" +} + +plan_tests 13 +test_force_origin_unix_epoch 2packets barectf-event-before-packet test_ctf_gen_single simple test_ctf_single smalltrace +test_ctf_single 2packets +test_ctf_single barectf-event-before-packet +test_ctf_single session-rotation +test_ctf_single lttng-tracefile-rotation +test_ctf_single array-align-elem +test_ctf_single struct-array-align-elem +test_ctf_single meta-ctx-sequence +test_packet_end lttng-event-after-packet +test_packet_end lttng-crash