#
# Common code for checking map init by OS description
#

mkdir -p out || exit 99

name=$( basename "$0" )
resultfile="out/${name}.result"
expectfile="$srcdir/$name.expect"
symfile="$srcdir/$name.sym"
datafile="$srcdir/$name.data"

optspec=
test -n "$opts" && optspec="opts=$opts"
symspec=
test -f "$symfile" && symspec="SYM=$symfile"
dataspec=
test -f "$datafile" && dataspec="DATA=$datafile"
test -n "$data_as" && dataspec="data_as=$data_as
$dataspec"

echo -n "Checking... "
./xlat-os >"$resultfile" <<EOF
ostype=$ostype
osver=$osver
arch=$arch
$optspec
$symspec
$dataspec
EOF
rc=$?
if [ $rc -gt 1 ]; then
    echo ERROR
    echo "Cannot set $input" >&2
    exit $rc
elif [ $rc -ne 0 ]; then
    echo FAILED
    exit $rc
elif ! diff "$expectfile" "$resultfile"; then
    echo FAILED
    echo "Result does not match" >&2
    exit 1
else
    echo OK
fi

exit 0
