#!/bin/bash
#
# This file performs a test of the autojudge system. It can run whatever you feel important to test the autojudge
# and the script files that are included in the problem package

mkdir -p testdir
cd testdir

cat > test.cpp <<EOF
#include<stdio.h>

using namespace std;
int main() {
  char s[100];
  scanf("%s", s);
  printf("%s\n",s);
  return 0;
}
EOF
cat > test.in <<EOF
inputdata
EOF

TL=2
REP=10
chmod 755 ../../compile/cpp
../../compile/cpp test.cpp test.exe $TL
chmod 755 ../../run/cpp
../../run/cpp test.exe test.in $TL $REP
if [ -r stdout0 ]; then
  output=`cat stdout0`
  if [ "$output" != "inputdata" ]; then
    echo "ERROR"
    exit 1
  fi
else
  echo "ERROR"
  exit 1
fi
echo "TEST PASSED"
cd ..
exit 0
