3 # smidump-FORMAT.test --
5 # smidump test for various output formats and conversions.
8 # Check `smidump -f xxx' output for all TESTMIBS read from the libsmi MIB
9 # repository against nominal dumps/xxx/ files.
12 # Check `smidump -f yyy' output for all TESTMIBS read from dumps/xxx/
13 # against nominal dumps/yyy-xxx/ files.
16 # Check `smidump -f yyy' output for all TESTMIBS read from the libsmi MIB
17 # repository against the original files from the repository. This is done
18 # by extracting unified characteristics of both files of each check
19 # (see the filter shell function) and comparing the diff with the nominal
20 # diff in dumps/orig-yyy/.
23 FORMAT=`echo $0 | sed -e 's/^.*smidump-\(.*\).test/\1/'`
24 ACTUALDIR=smidump-${FORMAT}.out
25 NOMINALDIR=dumps/${FORMAT}
26 INFORMAT=`echo -$FORMAT | sed -e 's/-[^-]*$//' -e 's/-//'`
27 OUTFORMAT=`echo $FORMAT | sed -e 's/[a-z0-9]*-//'`
32 # 1. strip off comments
33 # 2. condens white space
34 # 3. remove ambigious white space
35 # 4. strip off texts enclosed in double qoutes
36 # 5. convert blanks back to nl, and finally
38 sed -e 's/\"[a-z]*\"//g' | \
39 sed -e 's/--[^\"-]*--//g' -e 's/--[^\"]*$//' | \
42 sed -e 's/SIZE (/SIZE(/g' -e 's/ }/}/g' | \
43 sed -e 's/\"[^\"]*\"/\"\"/g' | \
55 for mib in ${TESTMIBS} ; do
56 if [ "$INFORMAT" -a "$INFORMAT" != "orig" ] ; then
57 input=../dumps/${INFORMAT}/$mib
61 echo "comparing \`smidump -f ${OUTFORMAT} $input' output with ${NOMINALDIR}/*."
63 ../../tools/smidump -c/dev/null -f ${OUTFORMAT} $input > $mib 2>/dev/null
64 if [ ! -s $mib ] ; then
70 FILES="$FILES "`ls -1 | grep -v '\.diff' | grep '\.'`
72 for file in $FILES ; do
73 if [ "$INFORMAT" != "orig" ] ; then
74 /usr/bin/diff --ignore-matching-lines='generated by smidump' --ignore-matching-lines='$Id.*$' --ignore-matching-lines='@author.*smidump' ${ACTUALDIR}/$file ${NOMINALDIR}/$file >> ${ACTUALDIR}/$file.diff
76 filter < ../mibs/ietf/$mib > ${ACTUALDIR}/$file.orig
77 filter < ${ACTUALDIR}/$mib > ${ACTUALDIR}/$file.out
78 /usr/bin/diff --ignore-matching-lines='generated by smidump' --ignore-matching-lines='$Id.*$' --ignore-matching-lines='@author.*smidump' ${ACTUALDIR}/$file.orig ${ACTUALDIR}/$file.out > ${ACTUALDIR}/$file
79 /usr/bin/diff --ignore-matching-lines='generated by smidump' --ignore-matching-lines='$Id.*$' --ignore-matching-lines='@author.*smidump' ${ACTUALDIR}/$file ${NOMINALDIR}/$file > ${ACTUALDIR}/$file.diff
81 if [ ! -s ${ACTUALDIR}/$file.diff ] ; then
82 rm ${ACTUALDIR}/$file.diff
87 echo "cmp -s ${ACTUALDIR}/$file ${NOMINALDIR}/$file || \$CMDPREFIX cp -v ${ACTUALDIR}/$file ${NOMINALDIR}/$file" >> sync-dumps
89 rm -f ${ACTUALDIR}/*.orig ${ACTUALDIR}/*.out
92 if [ "$FAILED" ] ; then
93 echo "*** smidump output differs, see ${ACTUALDIR}/*.diff"