#!/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_reply
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_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_atdestroy
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_strnum_integers
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_strnum_float
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_strnum_double
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_strnum_timespec
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_ntoa_integers
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_ntoa_double
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_ntoa_timespec
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_mf
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_array
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_cseg
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_seg
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_timespec
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_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_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_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_fh
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_sockaddrinet4
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_sockaddrinet6
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_math
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_fdset
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_poly
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_iconv
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_cin
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_cout
if [ -x $NAME ]; then
   echo "test data redirect to regular file tmp.tmp.tmp"
   ./$NAME > tmp.tmp.tmp
   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_cerr
if [ -x $NAME ]; then
   echo "test data redirect to regular file tmp.tmp.tmp"
   ./$NAME 2> tmp.tmp.tmp
   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_uty
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_athread
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

rm tmp.tmp.tmp

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

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