#!/bin/sh

# select the program
elf="$1"
shift

done=0
while [ $# -gt 0 -a $done -eq 0 ]; do
  case "$1" in
    --stdin)
      if [ $# -lt 2 ]; then
        echo "Error: --stdin requires a quoted string"
        exit 1
      fi
      stdin="$2"
      shift 2
      ;;
    --args)
      if [ $# -lt 2 ]; then
        echo "Error: --args requires a quoted string"
        exit 1
      fi
      args="$2"
      shift 2
      ;;
    *)
      done=1
      ;;
  esac
done

lm32-unknown-elf-run $elf
ret=$?
case "$1" in
    *printf*-tests*)
        case $ret in
            2)
                echo 'printf-tests failed in the usual way, skipping'
                ret=77
                ;;
        esac
esac
exit $ret
