The 'wc' command on macOS prefixes the count it returns with spaces, if
we quote the output it won't be properly converted to integer for the
comparison.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
"${BT_BIN}" --no-delta "${path}" 2>/dev/null >"${text_output1}"
ret=$?
cnt="$(wc -l < "${text_output1}")"
"${BT_BIN}" --no-delta "${path}" 2>/dev/null >"${text_output1}"
ret=$?
cnt="$(wc -l < "${text_output1}")"
- if test "$ret" == 0 && test "$cnt" == 0; then
+ if test "$ret" == 0 && test $cnt == 0; then
pass "Empty trace ${trace}, nothing to copy"
clean_tmp
continue
pass "Empty trace ${trace}, nothing to copy"
clean_tmp
continue
# Extract only the timestamp columns and compare the number of
# unique lines with the total number of lines to see if there
# are duplicate timestamps.
# Extract only the timestamp columns and compare the number of
# unique lines with the total number of lines to see if there
# are duplicate timestamps.
- if test "$cnt" != "$uniq_ts_cnt"; then
+ if test $cnt != $uniq_ts_cnt; then
diag "Trace with non unique timestamps, sorting the output"
sort_cmd="sort"
tmp="$(mktemp)"
diag "Trace with non unique timestamps, sorting the output"
sort_cmd="sort"
tmp="$(mktemp)"
"${BT_BIN}" --no-delta "${out_path}" 2>/dev/null | $sort_cmd >"${text_output2}"
cnt=$(diff "${text_output1}" "${text_output2}" | wc -l)
"${BT_BIN}" --no-delta "${out_path}" 2>/dev/null | $sort_cmd >"${text_output2}"
cnt=$(diff "${text_output1}" "${text_output2}" | wc -l)
ok $? "Exact same content between the two traces"
clean_tmp
ok $? "Exact same content between the two traces"
clean_tmp
2>/dev/null >"${tmp_out}"
ok $? "Running with --begin"
cnt=$(wc -l < "${tmp_out}")
2>/dev/null >"${tmp_out}"
ok $? "Running with --begin"
cnt=$(wc -l < "${tmp_out}")
ok $? "Expected number of events after trimming begin and end"
"${BT_BIN}" --clock-gmt --end 17:48:17.588680018 "${TRACE_PATH}" \
2>/dev/null >"${tmp_out}"
ok $? "Running with --end"
cnt=$(wc -l < "${tmp_out}")
ok $? "Expected number of events after trimming begin and end"
"${BT_BIN}" --clock-gmt --end 17:48:17.588680018 "${TRACE_PATH}" \
2>/dev/null >"${tmp_out}"
ok $? "Running with --end"
cnt=$(wc -l < "${tmp_out}")
ok $? "Expected number of events after trimming end"
"${BT_BIN}" --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \
"${TRACE_PATH}" 2>/dev/null >"${tmp_out}"
ok $? "Running with --begin and --end"
cnt=$(wc -l < "${tmp_out}")
ok $? "Expected number of events after trimming end"
"${BT_BIN}" --clock-gmt --begin 17:48:17.587029529 --end 17:48:17.588680018 \
"${TRACE_PATH}" 2>/dev/null >"${tmp_out}"
ok $? "Running with --begin and --end"
cnt=$(wc -l < "${tmp_out}")
ok $? "Expected number of events after trimming begin and end"
"${BT_BIN}" --clock-gmt --begin 18:48:17.587029529 "${TRACE_PATH}" \
2>/dev/null >"${tmp_out}"
ok $? "Running with --begin out of range"
cnt=$(wc -l < "${tmp_out}")
ok $? "Expected number of events after trimming begin and end"
"${BT_BIN}" --clock-gmt --begin 18:48:17.587029529 "${TRACE_PATH}" \
2>/dev/null >"${tmp_out}"
ok $? "Running with --begin out of range"
cnt=$(wc -l < "${tmp_out}")
ok $? "No event output when begin is after the end of the trace"
"${BT_BIN}" --clock-gmt --end 16:48:17.588680018 "${TRACE_PATH}" \
2>/dev/null >"${tmp_out}"
cnt=$(wc -l < "${tmp_out}")
ok $? "No event output when begin is after the end of the trace"
"${BT_BIN}" --clock-gmt --end 16:48:17.588680018 "${TRACE_PATH}" \
2>/dev/null >"${tmp_out}"
cnt=$(wc -l < "${tmp_out}")
ok $? "No event output when end is before the beginning of the trace"
rm "${tmp_out}"
ok $? "No event output when end is before the beginning of the trace"
rm "${tmp_out}"