#!/bin/sh
#
# This file is supposed to run in directory where all the test data files exist.
#
# test_socket may need network card configured. If not, unmark TEST_INET
#
#
NAME=chk_errmsg
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_ret
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi


NAME=chk_except
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi


NAME=chk_num
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_mutex
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_time
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_cond
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_str
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_ptr
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_once
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_pathname
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_date
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_thread1
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_thread2
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_filestat
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_dirent
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_regfile
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_fifofile
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_sockaddrlocal
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_sockaddrinet
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_sockfile
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_termios
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_terminal
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_dirfile
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_lnkfile
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_chrfile
if [ -x $NAME ]; then
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_stdin
if [ -x $NAME ]; then
   ./$NAME < testfile.regf.LF2
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_stdout
if [ -x $NAME ]; then
   echo "test data redirect to regular file t"
   ./$NAME > t
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

NAME=chk_stderr
if [ -x $NAME ]; then
   echo "test data redirect to regular file t"
   ./$NAME 2> t
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
   ./$NAME
   if [ $? -ne 0 ]; then
     echo "Test Failed: $NAME"
     exit -1
   fi
else
  echo "File not found: $NAME"
  exit -1
fi

echo "--- All check files reported OK (for me). Check messages  ---"
exit 0
