|
Packit Service |
9ccfef |
#!/bin/sh
|
|
Packit Service |
9ccfef |
#
|
|
Packit Service |
9ccfef |
# smidump-FORMAT.test --
|
|
Packit Service |
9ccfef |
#
|
|
Packit Service |
9ccfef |
# smidump test for various output formats and conversions.
|
|
Packit Service |
9ccfef |
#
|
|
Packit Service |
9ccfef |
# FORMAT=xxx :
|
|
Packit Service |
9ccfef |
# Check `smidump -f xxx' output for all TESTMIBS read from the libsmi MIB
|
|
Packit Service |
9ccfef |
# repository against nominal dumps/xxx/ files.
|
|
Packit Service |
9ccfef |
#
|
|
Packit Service |
9ccfef |
# FORMAT=xxx-yyy :
|
|
Packit Service |
9ccfef |
# Check `smidump -f yyy' output for all TESTMIBS read from dumps/xxx/
|
|
Packit Service |
9ccfef |
# against nominal dumps/yyy-xxx/ files.
|
|
Packit Service |
9ccfef |
#
|
|
Packit Service |
9ccfef |
# FORMAT=orig-yyy :
|
|
Packit Service |
9ccfef |
# Check `smidump -f yyy' output for all TESTMIBS read from the libsmi MIB
|
|
Packit Service |
9ccfef |
# repository against the original files from the repository. This is done
|
|
Packit Service |
9ccfef |
# by extracting unified characteristics of both files of each check
|
|
Packit Service |
9ccfef |
# (see the filter shell function) and comparing the diff with the nominal
|
|
Packit Service |
9ccfef |
# diff in dumps/orig-yyy/.
|
|
Packit Service |
9ccfef |
#
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
FORMAT=`echo $0 | sed -e 's/^.*smidump-\(.*\).test/\1/'`
|
|
Packit Service |
9ccfef |
ACTUALDIR=smidump-${FORMAT}.out
|
|
Packit Service |
9ccfef |
NOMINALDIR=dumps/${FORMAT}
|
|
Packit Service |
9ccfef |
INFORMAT=`echo -$FORMAT | sed -e 's/-[^-]*$//' -e 's/-//'`
|
|
Packit Service |
9ccfef |
OUTFORMAT=`echo $FORMAT | sed -e 's/[a-z0-9]*-//'`
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
filter() {
|
|
Packit Service |
9ccfef |
# 1. strip off comments
|
|
Packit Service |
9ccfef |
# 2. condens white space
|
|
Packit Service |
9ccfef |
# 3. remove ambigious white space
|
|
Packit Service |
9ccfef |
# 4. strip off texts enclosed in double qoutes
|
|
Packit Service |
9ccfef |
# 5. convert blanks back to nl, and finally
|
|
Packit Service |
9ccfef |
# 6. sort
|
|
Packit Service |
9ccfef |
sed -e 's/\"[a-z]*\"//g' | \
|
|
Packit Service |
9ccfef |
sed -e 's/--[^\"-]*--//g' -e 's/--[^\"]*$//' | \
|
|
Packit Service |
9ccfef |
tr '\t\n' ' ' | \
|
|
Packit Service |
9ccfef |
sed -e 's/ */ /g' | \
|
|
Packit Service |
9ccfef |
sed -e 's/SIZE (/SIZE(/g' -e 's/ }/}/g' | \
|
|
Packit Service |
9ccfef |
sed -e 's/\"[^\"]*\"/\"\"/g' | \
|
|
Packit Service |
9ccfef |
tr ' ' '\n' | \
|
|
Packit Service |
9ccfef |
sort
|
|
Packit Service |
9ccfef |
}
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
rm -rf ${ACTUALDIR}
|
|
Packit Service |
9ccfef |
mkdir ${ACTUALDIR}
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
RC=0
|
|
Packit Service |
9ccfef |
FAILED=""
|
|
Packit Service |
9ccfef |
for mib in ${TESTMIBS} ; do
|
|
Packit Service |
9ccfef |
if [ "$INFORMAT" -a "$INFORMAT" != "orig" ] ; then
|
|
Packit Service |
9ccfef |
input=../dumps/${INFORMAT}/$mib
|
|
Packit Service |
9ccfef |
else
|
|
Packit Service |
9ccfef |
input=$mib
|
|
Packit Service |
9ccfef |
fi
|
|
Packit Service |
9ccfef |
echo "comparing \`smidump -f ${OUTFORMAT} $input' output with ${NOMINALDIR}/*."
|
|
Packit Service |
9ccfef |
cd ${ACTUALDIR}
|
|
Packit Service |
9ccfef |
../../tools/smidump -c/dev/null -f ${OUTFORMAT} $input > $mib 2>/dev/null
|
|
Packit Service |
9ccfef |
if [ ! -s $mib ] ; then
|
|
Packit Service |
9ccfef |
rm $mib
|
|
Packit Service |
9ccfef |
FILES=""
|
|
Packit Service |
9ccfef |
else
|
|
Packit Service |
9ccfef |
FILES="$mib"
|
|
Packit Service |
9ccfef |
fi
|
|
Packit Service |
9ccfef |
FILES="$FILES "`ls -1 | grep -v '\.diff' | grep '\.'`
|
|
Packit Service |
9ccfef |
cd ..
|
|
Packit Service |
9ccfef |
for file in $FILES ; do
|
|
Packit Service |
9ccfef |
if [ "$INFORMAT" != "orig" ] ; then
|
|
Packit Service |
9ccfef |
@DIFF@ ${ACTUALDIR}/$file ${NOMINALDIR}/$file >> ${ACTUALDIR}/$file.diff
|
|
Packit Service |
9ccfef |
else
|
|
Packit Service |
9ccfef |
filter < ../mibs/ietf/$mib > ${ACTUALDIR}/$file.orig
|
|
Packit Service |
9ccfef |
filter < ${ACTUALDIR}/$mib > ${ACTUALDIR}/$file.out
|
|
Packit Service |
9ccfef |
@DIFF@ ${ACTUALDIR}/$file.orig ${ACTUALDIR}/$file.out > ${ACTUALDIR}/$file
|
|
Packit Service |
9ccfef |
@DIFF@ ${ACTUALDIR}/$file ${NOMINALDIR}/$file > ${ACTUALDIR}/$file.diff
|
|
Packit Service |
9ccfef |
fi
|
|
Packit Service |
9ccfef |
if [ ! -s ${ACTUALDIR}/$file.diff ] ; then
|
|
Packit Service |
9ccfef |
rm ${ACTUALDIR}/$file.diff
|
|
Packit Service |
9ccfef |
else
|
|
Packit Service |
9ccfef |
FAILED=1
|
|
Packit Service |
9ccfef |
fi
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
echo "cmp -s ${ACTUALDIR}/$file ${NOMINALDIR}/$file || \$CMDPREFIX cp -v ${ACTUALDIR}/$file ${NOMINALDIR}/$file" >> sync-dumps
|
|
Packit Service |
9ccfef |
done
|
|
Packit Service |
9ccfef |
rm -f ${ACTUALDIR}/*.orig ${ACTUALDIR}/*.out
|
|
Packit Service |
9ccfef |
done
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
if [ "$FAILED" ] ; then
|
|
Packit Service |
9ccfef |
echo "*** smidump output differs, see ${ACTUALDIR}/*.diff"
|
|
Packit Service |
9ccfef |
RC=1
|
|
Packit Service |
9ccfef |
fi
|
|
Packit Service |
9ccfef |
|
|
Packit Service |
9ccfef |
exit ${RC}
|