tests: adjust src.ctf.fs succeed tests to read CTF 2 traces
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 2 Aug 2022 19:10:50 +0000 (15:10 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 16:06:16 +0000 (12:06 -0400)
Change-Id: I3a78fb1641c3c1bae98be74b741ce2f4b8089ec0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8509
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
tests/plugins/src.ctf.fs/succeed/test_succeed

index a986a6be91db4707668641f3d232530bbd9a24d6..d1063b662215b39f4f98e89d68c0f27011831052 100755 (executable)
@@ -24,11 +24,17 @@ source "$UTILSSH"
 
 this_dir_relative="plugins/src.ctf.fs/succeed"
 this_dir_build="$BT_TESTS_BUILDDIR/$this_dir_relative"
-succeed_trace_dir="$BT_CTF_TRACES_PATH/1/succeed"
 expect_dir="$BT_TESTS_DATADIR/$this_dir_relative"
 
 test_ctf_common_details_args=("-p" "with-trace-name=no,with-stream-name=no")
 
+succeed_trace_path() {
+       name="$1"
+       ctf_version="$2"
+
+       echo "$BT_CTF_TRACES_PATH/$ctf_version/succeed/$name"
+}
+
 test_ctf_gen_single() {
        name="$1"
 
@@ -40,47 +46,57 @@ test_ctf_gen_single() {
 }
 
 test_ctf_single() {
-       name="$1"
-
-       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"
-}
-
-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)"
+       for ctf_version in 1 2; do
+               local trace_path
 
-       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=$?
+               trace_path=$(succeed_trace_path "$name" "$ctf_version")
 
-       bt_diff /dev/null "$temp_stderr_output_file"
-       ret_stderr=$?
+               bt_diff_details_ctf_single "$expect_dir/trace-$name.expect" \
+                       "$trace_path" "${test_ctf_common_details_args[@]}"
+               ok $? "Trace '$name' gives the expected output - CTF $ctf_version"
+       done
+}
 
-       if ((ret_stdout != 0 || ret_stderr != 0)); then
-               ret=1
-       fi
+test_packet_end() {
+       local name="$1"
 
-       ok $ret "Trace '$name' gives the expected output"
-       rm -f "$temp_stdout_output_file" "$temp_stderr_output_file" "$temp_greped_stdout_output_file"
+       for ctf_version in 1 2; do
+               local expected_stdout="$expect_dir/trace-$name.expect"
+               local trace_path
+               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
+
+               trace_path="$(succeed_trace_path "$name" "$ctf_version")"
+               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" \
+                 "$trace_path" "${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 - CTF $ctf_version"
+               rm -f "$temp_stdout_output_file" "$temp_stderr_output_file" "$temp_greped_stdout_output_file"
+       done
 }
 
 test_force_origin_unix_epoch() {
@@ -100,8 +116,8 @@ test_force_origin_unix_epoch() {
        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[@]}" \
+               "$(succeed_trace_path "$name1" 1)" "${src_ctf_fs_args[@]}" \
+               "$(succeed_trace_path "$name2" 1)" "${src_ctf_fs_args[@]}" \
                "${details_comp[@]}" "${details_args[@]}"
 
        bt_diff "$expected_stdout" "$temp_stdout_output_file"
@@ -125,7 +141,7 @@ test_force_origin_unix_epoch() {
        rm -f "$temp_stdout_output_file" "$temp_stderr_output_file"
 }
 
-plan_tests 13
+plan_tests 23
 
 test_force_origin_unix_epoch 2packets barectf-event-before-packet
 test_ctf_gen_single simple
This page took 0.028165 seconds and 5 git commands to generate.