Imported Upstream version 0.4.8
[platform/upstream/libsmi.git] / test / smilint-smiv2.test
1 #!/bin/sh
2 #
3 # smilint-FORMAT.test --
4 #
5 #       smilint test for various input formats.
6 #
7 # FORMAT=xxx : 
8 #   Check `smilint -l9' output for all TESTMIBS read from dumps/xxx/
9 #   against nominal dumps/smilint-xxx/ output files.
10 #
11
12 FORMAT=`echo $0 | sed -e 's/^.*smilint-\(.*\).test/\1/'`
13 ACTUALDIR=smilint-${FORMAT}.out
14 NOMINALDIR=dumps/smilint-${FORMAT}
15
16 rm -rf ${ACTUALDIR}
17 mkdir ${ACTUALDIR}
18
19 RC=0
20 FAILED=""
21 for mib in ${TESTMIBS} ; do
22     echo "comparing \`smilint -l9 dumps/${FORMAT}/$mib' output with ${NOMINALDIR}/*."
23     cd ${ACTUALDIR}
24     ../../tools/smilint -c/dev/null -l9 ../dumps/${FORMAT}/$mib > $mib 2>&1
25     cd ..
26     /usr/bin/diff --ignore-matching-lines='generated by smidump' --ignore-matching-lines='$Id.*$' --ignore-matching-lines='@author.*smidump' ${ACTUALDIR}/$mib ${NOMINALDIR}/$mib > ${ACTUALDIR}/$mib.diff
27     if [ ! -s ${ACTUALDIR}/$mib.diff ] ; then
28         rm ${ACTUALDIR}/$mib.diff
29     else
30         FAILED=1
31     fi
32 done
33
34 if [ "$FAILED" ] ; then
35     echo "*** smilint output differs, see ${ACTUALDIR}/*.diff"
36     RC=1
37 fi
38
39 rm -f sync-dumps
40 cat > sync-dumps <<EOF
41 #
42 # sync-dumps
43 #
44 # This script copies test output files to the nominal files in the
45 # dumps/ directory. It MUST ONLY be executed after carefully ensuring
46 # that the current output files are valid. Otherwise the sense of
47 # this test suite would be dubious.
48 #
49
50 CMDPREFIX=echo
51 if [ "\$1" == "-f" ] ; then CMDPREFIX="" ; fi
52
53 EOF
54 chmod a+x sync-dumps
55
56 exit ${RC}