#!/bin/bash

## It is always a good idea to test an error handling mechanism before it is really needed.
## mcelog includes a test suite.
## The test suite relies on mce-inject which needs to be installed and in $PATH.

shopt -s nullglob

. $LKP_SRC/lib/debug.sh
. $LKP_SRC/lib/reproduce-log.sh

cd $BENCHMARK_ROOT/mce-log || die "can not find mce-log dir"

# workaround this error: '.depend: No such file or directory'
touch .depend

# fix the error: ./mcaerr_test: line 57: mcelog: command not found
ln -s $BENCHMARK_ROOT/mce-log/mcelog /usr/sbin/mcelog

make test

files=($BENCHMARK_ROOT/mce-log/tests/*/results)
if [[ $files ]]; then
    for file in "${files[@]}"
    do
        item=`dirname $file`
        echo "mce-log-item:${item##*/}"
        cat $file
    done
else
    echo "WARNING: mcelog test results is not exist."
fi

exit 0
