2019-07-15 06:37:43 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# s3fs - FUSE-based file system backed by Amazon S3
|
|
|
|
#
|
|
|
|
# Copyright 2007-2008 Randy Rizun <rrizun@gmail.com>
|
|
|
|
#
|
|
|
|
# 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; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
|
|
|
|
func_usage()
|
|
|
|
{
|
|
|
|
echo ""
|
|
|
|
echo "Usage: $1 [-h] <log file path>"
|
|
|
|
echo " -h print help"
|
|
|
|
echo " log file path path for test-suite.log"
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
|
2022-01-15 17:08:46 +00:00
|
|
|
PRGNAME=$(basename "$0")
|
|
|
|
SCRIPTDIR=$(dirname "$0")
|
|
|
|
S3FSDIR=$(cd "${SCRIPTDIR}"/.. || exit 1; pwd)
|
|
|
|
TOPDIR=$(cd "${S3FSDIR}"/test || exit 1; pwd)
|
2019-07-15 06:37:43 +00:00
|
|
|
SUITELOG="${TOPDIR}/test-suite.log"
|
|
|
|
TMP_LINENO_FILE="/tmp/.lineno.tmp"
|
|
|
|
|
|
|
|
while [ $# -ne 0 ]; do
|
|
|
|
if [ "X$1" = "X" ]; then
|
|
|
|
break
|
2022-01-15 17:08:46 +00:00
|
|
|
elif [ "X$1" = "X-h" ] || [ "X$1" = "X-H" ] || [ "X$1" = "X--help" ] || [ "X$1" = "X--HELP" ]; then
|
|
|
|
func_usage "${PRGNAME}"
|
2019-07-15 06:37:43 +00:00
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
SUITELOG=$1
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
2022-01-15 17:08:46 +00:00
|
|
|
if [ ! -f "${SUITELOG}" ]; then
|
2019-07-15 06:37:43 +00:00
|
|
|
echo "[ERROR] not found ${SUITELOG} log file."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Extract keyword line numbers and types
|
|
|
|
#
|
|
|
|
# 0 : normal line
|
|
|
|
# 1 : start line for one small test(specified in integration-test-main.sh)
|
|
|
|
# 2 : passed line of end of one small test(specified in test-utils.sh)
|
|
|
|
# 3 : failed line of end of one small test(specified in test-utils.sh)
|
|
|
|
#
|
2022-01-15 17:08:46 +00:00
|
|
|
grep -n -e 'test_.*: ".*"' -o -e 'test_.* passed' -o -e 'test_.* failed' "${SUITELOG}" 2>/dev/null | sed 's/:test_.*: ".*"/ 1/g' | sed 's/:test_.* passed/ 2/g' | sed 's/:test_.* failed/ 3/g' > "${TMP_LINENO_FILE}"
|
2019-07-15 06:37:43 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Loop for printing result
|
|
|
|
#
|
|
|
|
prev_line_type=0
|
|
|
|
prev_line_number=1
|
2022-01-15 17:08:46 +00:00
|
|
|
while read -r line; do
|
2019-07-15 06:37:43 +00:00
|
|
|
# line is "<line number> <line type>"
|
2022-01-15 17:08:46 +00:00
|
|
|
#
|
|
|
|
# shellcheck disable=SC2206
|
|
|
|
number_type=(${line})
|
2019-07-15 06:37:43 +00:00
|
|
|
|
2022-01-15 17:08:46 +00:00
|
|
|
head_line_cnt=$((number_type[0] - 1))
|
|
|
|
tail_line_cnt=$((number_type[0] - prev_line_number))
|
2019-07-15 06:37:43 +00:00
|
|
|
|
2022-01-15 17:08:46 +00:00
|
|
|
if [ "${number_type[1]}" -eq 2 ]; then
|
2019-07-15 06:37:43 +00:00
|
|
|
echo ""
|
|
|
|
fi
|
2022-01-15 17:08:46 +00:00
|
|
|
if [ "${prev_line_type}" -eq 1 ]; then
|
|
|
|
if [ "${number_type[1]}" -eq 2 ]; then
|
2019-07-15 06:37:43 +00:00
|
|
|
# if passed, cut s3fs information messages
|
2022-01-15 17:08:46 +00:00
|
|
|
head "-${head_line_cnt}" "${SUITELOG}" | tail "-${tail_line_cnt}" | grep -v -e '[0-9]\+\%' | grep -v -e '^s3fs: ' -a -e '\[INF\]'
|
|
|
|
elif [ "${number_type[1]}" -eq 3 ]; then
|
2019-07-15 06:37:43 +00:00
|
|
|
# if failed, print all
|
2022-01-15 17:08:46 +00:00
|
|
|
head "-${head_line_cnt}" "${SUITELOG}" | tail "-${tail_line_cnt}" | grep -v -e '[0-9]\+\%'
|
2019-07-15 06:37:43 +00:00
|
|
|
else
|
|
|
|
# there is start keyword but not end keyword, so print all
|
2022-01-15 17:08:46 +00:00
|
|
|
head "-${head_line_cnt}" "${SUITELOG}" | tail "-${tail_line_cnt}" | grep -v -e '[0-9]\+\%'
|
2019-07-15 06:37:43 +00:00
|
|
|
fi
|
2022-01-15 17:08:46 +00:00
|
|
|
elif [ "${prev_line_type}" -eq 2 ] || [ "${prev_line_type}" -eq 3 ]; then
|
|
|
|
if [ "${number_type[1]}" -eq 2 ] || [ "${number_type[1]}" -eq 3 ]; then
|
2019-07-15 06:37:43 +00:00
|
|
|
# previous is end of chmpx, but this type is end of chmpx without start keyword. then print all
|
2022-01-15 17:08:46 +00:00
|
|
|
head "-${head_line_cnt}" "${SUITELOG}" | tail "-${tail_line_cnt}" | grep -v -e '[0-9]\+\%'
|
2019-07-15 06:37:43 +00:00
|
|
|
else
|
|
|
|
# this area is not from start to end, cut s3fs information messages
|
2022-01-15 17:08:46 +00:00
|
|
|
head "-${head_line_cnt}" "${SUITELOG}" | tail "-${tail_line_cnt}" | grep -v -e '[0-9]\+\%' | grep -v -e '^s3fs: ' -a -e '\[INF\]'
|
2019-07-15 06:37:43 +00:00
|
|
|
fi
|
|
|
|
else
|
2022-01-15 17:08:46 +00:00
|
|
|
if [ "${number_type[1]}" -eq 2 ] || [ "${number_type[1]}" -eq 3 ]; then
|
2019-07-15 06:37:43 +00:00
|
|
|
# previous is normal, but this type is end of chmpx without start keyword. then print all
|
2022-01-15 17:08:46 +00:00
|
|
|
head "-${head_line_cnt}" "${SUITELOG}" | tail "-${tail_line_cnt}" | grep -v -e '[0-9]\+\%'
|
2019-07-15 06:37:43 +00:00
|
|
|
else
|
|
|
|
# this area is normal, cut s3fs information messages
|
2022-01-15 17:08:46 +00:00
|
|
|
head "-${head_line_cnt}" "${SUITELOG}" | tail "-${tail_line_cnt}" | grep -v -e '[0-9]\+\%' | grep -v -e '^s3fs: ' -a -e '\[INF\]'
|
2019-07-15 06:37:43 +00:00
|
|
|
fi
|
|
|
|
fi
|
2022-01-15 17:08:46 +00:00
|
|
|
if [ "${number_type[1]}" -eq 3 ]; then
|
2019-07-15 06:37:43 +00:00
|
|
|
echo ""
|
|
|
|
fi
|
2022-01-15 17:08:46 +00:00
|
|
|
prev_line_type="${number_type[1]}"
|
|
|
|
prev_line_number="${number_type[0]}"
|
2019-07-15 06:37:43 +00:00
|
|
|
|
2022-01-15 17:08:46 +00:00
|
|
|
done < "${TMP_LINENO_FILE}"
|
2019-07-15 06:37:43 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Print rest lines
|
|
|
|
#
|
2022-01-15 17:08:46 +00:00
|
|
|
file_line_cnt=$(wc -l "${SUITELOG}" | awk '{print $1}')
|
|
|
|
tail_line_cnt=$((file_line_cnt - prev_line_number))
|
2019-07-15 06:37:43 +00:00
|
|
|
|
2022-01-15 17:08:46 +00:00
|
|
|
if [ "${prev_line_type}" -eq 1 ]; then
|
|
|
|
tail "-${tail_line_cnt}" "${SUITELOG}" | grep -v -e '[0-9]\+\%'
|
2019-07-15 06:37:43 +00:00
|
|
|
else
|
2022-01-15 17:08:46 +00:00
|
|
|
tail "-${tail_line_cnt}" "${SUITELOG}" | grep -v -e '[0-9]\+\%' | grep -v -e '^s3fs: ' -a -e '\[INF\]'
|
2019-07-15 06:37:43 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Remove temp file
|
|
|
|
#
|
2022-01-15 17:08:46 +00:00
|
|
|
rm -f "${TMP_LINENO_FILE}"
|
2019-07-15 06:37:43 +00:00
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
#
|
|
|
|
# Local variables:
|
|
|
|
# tab-width: 4
|
|
|
|
# c-basic-offset: 4
|
|
|
|
# End:
|
2020-09-15 13:11:14 +00:00
|
|
|
# vim600: expandtab sw=4 ts=4 fdm=marker
|
|
|
|
# vim<600: expandtab sw=4 ts=4
|
2019-07-15 06:37:43 +00:00
|
|
|
#
|