# Check that expected warning is printed.
# shellcheck disable=SC2016
-grep -q 'No trace was found based on input `some_other_non_opt`' "$stderr_actual_file"
+bt_grep -q 'No trace was found based on input `some_other_non_opt`' "$stderr_actual_file"
ok "$?" "warning is printed"
rm -f "$stdout_actual_file"
ok $? "$what: nothing is printed on stdout"
# Check for expected error string in stderr.
- grep --quiet --fixed-strings -e "$expected_error_str" "$tmp_stderr"
+ bt_grep --quiet --fixed-strings -e "$expected_error_str" "$tmp_stderr"
local status=$?
ok "$status" "$what: expected error message"
if [ "$status" -ne 0 ]; then
ok "$?" "exit code is 0"
# Extract the section about our custom this-is-a-plugin Python plugin.
-grep --after-context=11 '^this-is-a-plugin:$' "${stdout_file}" > "${grep_stdout_file}"
+bt_grep --after-context=11 '^this-is-a-plugin:$' "${stdout_file}" > "${grep_stdout_file}"
ok "$?" "entry for this-is-a-plugin is present"
if [ "$BT_TESTS_OS_TYPE" = "mingw" ]; then
# Ensure that a CLI error stack is printed (and that babeltrace doesn't
# abort before that).
- grep --silent "^ERROR: " "${stderr_file}"
+ bt_grep --silent "^ERROR: " "${stderr_file}"
ok $? "${test_name}: babeltrace produces an error stack"
- grep --silent "${expected_str}" "${stderr_file}"
+ bt_grep --silent "${expected_str}" "${stderr_file}"
ok "$?" "${test_name}: expect \`${expected_str}\` error message on stderr"
}
bt_cli "${stdout}" "${stderr}" help ctf
ok $? "help ctf plugin exit status"
-grep --silent 'Description: CTF input and output' "${stdout}"
+bt_grep --silent 'Description: CTF input and output' "${stdout}"
ok $? "help ctf plugin expected output"
is_empty "${stderr}"
bt_cli "${stdout}" "${stderr}" help src.ctf.fs
ok $? "help src.ctf.fs component class exit status"
-grep --silent 'Description: Read CTF traces from the file system.' "${stdout}"
+bt_grep --silent 'Description: Read CTF traces from the file system.' "${stdout}"
ok $? "help src.ctf.fs component class expected output"
is_empty "${stderr}"
bt_cli "${stdout}" "${stderr}" help
isnt $? 0 "help without parameter exit status"
-grep --silent "Missing plugin name or component class descriptor." "${stderr}"
+bt_grep --silent "Missing plugin name or component class descriptor." "${stderr}"
ok $? "help without parameter produces expected error"
is_empty "${stdout}"
bt_cli "${stdout}" "${stderr}" help ctf fs
isnt $? 0 "help with too many parameters exit status"
-grep --silent "Extraneous command-line argument specified to \`help\` command:" "${stderr}"
+bt_grep --silent "Extraneous command-line argument specified to \`help\` command:" "${stderr}"
ok $? "help with too many parameters produces expected error"
is_empty "${stdout}"
bt_cli "${stdout}" "${stderr}" help zigotos
isnt $? 0 "help with unknown plugin name"
-grep --silent 'Cannot find plugin: plugin-name="zigotos"' "${stderr}"
+bt_grep --silent 'Cannot find plugin: plugin-name="zigotos"' "${stderr}"
ok $? "help with unknown plugin name produces expected error"
is_empty "${stdout}"
bt_cli "${stdout}" "${stderr}" help src.ctf.bob
isnt $? 0 "help with unknown component class name"
-grep --silent 'Cannot find component class: plugin-name="ctf", comp-cls-name="bob", comp-cls-type=SOURCE' "${stderr}"
+bt_grep --silent 'Cannot find component class: plugin-name="ctf", comp-cls-name="bob", comp-cls-type=SOURCE' "${stderr}"
ok $? "help with unknown component class name produces expected error"
-grep --silent 'Description: CTF input and output' "${stdout}"
+bt_grep --silent 'Description: CTF input and output' "${stdout}"
ok $? "help with unknown component class name prints plugin help"
# Test with unknown component class plugin
bt_cli "${stdout}" "${stderr}" help src.bob.fs
isnt $? 0 "help with unknown component class plugin"
-grep --silent 'Cannot find plugin: plugin-name="bob"' "${stderr}"
+bt_grep --silent 'Cannot find plugin: plugin-name="bob"' "${stderr}"
ok $? "help with unknown component class plugin produces expected error"
is_empty "${stdout}"
bt_cli "${stdout}" "${stderr}" --stream-intersection "${trace}"
isnt "$?" 0 "run with --stream-intersection fails"
- grep --silent "${expected_error_message}" "${stderr}"
+ bt_grep --silent "${expected_error_message}" "${stderr}"
ok $? "stderr contains expected error message"
}
"${BT_TESTS_BT2_BIN}" "$trace" >/dev/null 2>&1
ok $? "Trace parses"
- "${BT_TESTS_BT2_BIN}" "$trace" 2>&1 >/dev/null | "${BT_TESTS_GREP_BIN}" "\[warning\] Tracer lost"
+ "${BT_TESTS_BT2_BIN}" "$trace" 2>&1 >/dev/null | bt_grep "\[warning\] Tracer lost"
if test $? = 0; then
fail 1 "Should not find any lost events"
else
# WARNING: Tracer discarded 2 trace packets between ....
# WARNING: Tracer discarded 3 trace packets between ....
# into "2,3" and make sure it matches the expected result
- "${BT_TESTS_BT2_BIN}" "$trace" 2>&1 >/dev/null | "${BT_TESTS_GREP_BIN}" "WARNING: Tracer discarded" \
+ "${BT_TESTS_BT2_BIN}" "$trace" 2>&1 >/dev/null | bt_grep "WARNING: Tracer discarded" \
| cut -d" " -f4 | tr "\n" "," | "${BT_TESTS_SED_BIN}" "s/.$//" | \
- "${BT_TESTS_GREP_BIN}" "$expectedcountstr" >/dev/null
+ bt_grep "$expectedcountstr" >/dev/null
ok $? "Lost events string matches $expectedcountstr"
}
# duplicate timestamps in the output.
# If there are, we have to sort the text output to make sure it is
# always the same.
- head -1 "${text_output1}" | "${BT_TESTS_GREP_BIN}" "^\[" >/dev/null
+ head -1 "${text_output1}" | bt_grep "^\[" >/dev/null
if test $? = 0; then
# shellcheck disable=SC2016
uniq_ts_cnt="$("${BT_TESTS_AWK_BIN}" '{ print $1 }' < "${text_output1}" | sort | uniq | wc -l)"
# even if Babeltrace aborts (e.g. hits an assert). Check that the
# Babeltrace CLI finishes gracefully by checking that the error stream
# contains an error stack printed by the CLI.
- grep --silent "^CAUSED BY " "${stderr_file}"
+ bt_grep --silent "^CAUSED BY " "${stderr_file}"
ok $? "Trace ${name}: babeltrace produces an error stack"
- grep --silent "${expected_error_msg}" "${stderr_file}"
+ bt_grep --silent "${expected_error_msg}" "${stderr_file}"
ok $? "Trace ${name}: babeltrace produces the expected error message"
}
bt_diff "/dev/null" "${stdout_file}"
ok $? "non existent trace dir: babeltrace produces the expected stdout"
- grep --silent "^CAUSED BY " "${stderr_file}"
+ bt_grep --silent "^CAUSED BY " "${stderr_file}"
ok $? "non existent trace dir: babeltrace produces an error stack"
- grep --silent "Failed to open metadata file: No such file or directory: path=\".*metadata\"" \
+ bt_grep --silent "Failed to open metadata file: No such file or directory: path=\".*metadata\"" \
"${stderr_file}"
ok $? "non existent trace dir: babeltrace produces the expected error message"
"$succeed_trace_dir/$name" "${details_comp[@]}" \
"${details_args[@]}"
- "$BT_TESTS_GREP_BIN" "Packet end" "$temp_stdout_output_file" > "$temp_greped_stdout_output_file"
+ bt_grep "Packet end" "$temp_stdout_output_file" > "$temp_greped_stdout_output_file"
bt_diff "$expected_stdout" "$temp_greped_stdout_output_file"
ret_stdout=$?
-c src.ctf.fs -p "inputs=[${inputs}]"
isnt 0 "$?" "${test_name}: exit status is not 0"
- grep --silent "^ERROR: " "${stderr_file}"
+ bt_grep --silent "^ERROR: " "${stderr_file}"
ok "$?" "${test_name}: error stack is produced"
- grep --silent "No event class with ID of event class ID to use in stream class" "${stderr_file}"
+ bt_grep --silent "No event class with ID of event class ID to use in stream class" "${stderr_file}"
ok "$?" "${test_name}: expected error message is present"
}
return $ret
}
+# Run the grep binary configured for the tests.
+bt_grep() {
+ "$BT_TESTS_GREP_BIN" "$@"
+}
### Functions ###
# existing ASAN_OPTIONS, such that we override the user's value if it
# contains detect_leaks=1.
if [ "${BT_TESTS_ENABLE_ASAN:-}" = "1" ]; then
- if ${BT_TESTS_CC_BIN} --version | head -n 1 | grep -q '^gcc'; then
+ if ${BT_TESTS_CC_BIN} --version | head -n 1 | bt_grep -q '^gcc'; then
lib_asan="$(${BT_TESTS_CC_BIN} -print-file-name=libasan.so)"
local -x LD_PRELOAD="${lib_asan}${LD_PRELOAD:+:}${LD_PRELOAD:-}"
fi