Skip to content

Commit

Permalink
Merge pull request #2450 from gaweinbergi/check-log-empty
Browse files Browse the repository at this point in the history
  • Loading branch information
krzycz committed Dec 15, 2017
2 parents 04deff9 + 5faa89b commit ce679b8
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/test/unittest/unittest.sh
Expand Up @@ -2241,6 +2241,17 @@ function setup() {
fi
}

#
# check_log_empty -- if match file does not exist, assume log should be empty
#
function check_log_empty() {
if [ ! -f ${1}.match ] && [ $(get_size $1) -ne 0 ]; then
echo "unexpected output in $1"
dump_last_n_lines $1
exit 1
fi
}

#
# check_local -- check local test results (using .match files)
#
Expand All @@ -2249,15 +2260,7 @@ function check_local() {
option=-q
fi

# If errX.log.match does not exist, assume errX.log should be empty
ERR_LOG_LEN=0
[ -f $ERR_LOG_FILE ] && ERR_LOG_LEN=$(stat -c %b $ERR_LOG_FILE)

if [ ! -f ${ERR_LOG_FILE}.match ] && [ $ERR_LOG_LEN -ne 0 ]; then
echo "unexpected output in $ERR_LOG_FILE"
dump_last_n_lines $ERR_LOG_FILE
exit 1
fi
check_log_empty $ERR_LOG_FILE

FILES=$(get_files "[^0-9w]*${UNITTEST_NUM}\.log\.match")
if [ -n "$FILES" ]; then
Expand Down Expand Up @@ -2296,16 +2299,8 @@ function check() {
option=-q
fi

# If errX.log.match does not exist, assume errX.log should be empty
for N in $NODES_SEQ; do
ERR_LOG_LEN=0
[ -f node_${N}_${ERR_LOG_FILE} ] && ERR_LOG_LEN=$(stat -c %b node_${N}_${ERR_LOG_FILE})

if [ ! -f node_${N}_${ERR_LOG_FILE}.match ] && [ $ERR_LOG_LEN -ne 0 ]; then
echo "unexpected output in node_${N}_${ERR_LOG_FILE}"
dump_last_n_lines node_${N}_${ERR_LOG_FILE}
exit 1
fi
check_log_empty node_${N}_${ERR_LOG_FILE}
done

if [ -n "$FILES" ]; then
Expand Down Expand Up @@ -2408,11 +2403,15 @@ check_no_files()
}

#
# get_size -- return size of file
# get_size -- return size of file (0 if file does not exist)
#
get_size()
{
stat $STAT_SIZE $1
if [ ! -f $1 ]; then
echo "0"
else
stat $STAT_SIZE $1
fi
}

#
Expand Down

0 comments on commit ce679b8

Please sign in to comment.