#!/bin/sh
# test an mst binary

if [ "$1" = "" ]; then
  echo "usage: $0 ./mst.exe"
  exit
fi

# all of mst's output is to stderr
echo "running: $1 2048 1 2>output"
if ! $1 2048 1 2>output; then
  echo "$1 failed directly"
  exit 2
fi

# mst prints sizes of its structures, which increase after boxing
if ! sed 's/size = [0-9][0-9]/size = xx/' <output | diff out.orig - >out.diff; then
    if test -s out.diff; then 
      echo "$1 got the wrong answer. See out.diff"
      exit 4
    fi
fi
echo "$1 seems to work"
rm -f out.diff
 