1#!/bin/bash
2
3BITS=`getconf LONG_BIT`
4OS=linux
5if [ `uname -o 2>/dev/null` ]; then
6  if [ `uname -o` == "GNU/Linux" ]; then
7    OS=linux
8  elif [ `uname -o` == "Cygwin" ]; then
9    OS=win  # cygwin
10    BITS=32 # httest win is 32 bit
11  fi
12elif [ `uname -s` == "Darwin" ]; then
13  OS=mac
14elif [ `uname -s` == "SunOS" ]; then
15  OS=solaris
16fi
17export BITS
18export OS
19printf "($OS $BITS) "
20
21function run_all {
22  list=$1
23  count=$2
24
25  errors=0
26  i=1
27  for E in $list; do
28    rm -f .out.txt
29    printf "$i/$count $(date) $E "
30    CORES_PRE=`ls core* 2>/dev/null | wc -l`
31    run_single $E .out.txt
32    ret=$?
33    if [ $ret -eq 1 ]; then
34      printf "...\e[1;31mFAILED\e[0m\n\n"
35      tail .out.txt
36      mv .out.txt $E.error
37      let errors++
38      echo
39    elif [ $ret -eq 2 ]; then
40      printf "...\e[1;33mSKIP\e[0m\n"
41    else
42      printf "...\e[1;32mOK\e[0m\n"
43    fi
44    CORES_POST=`ls core* 2>/dev/null | wc -l`
45    if [ $CORES_POST -gt $CORES_PRE ]; then
46      echo Coredump detected!
47    fi
48    let i++
49  done
50
51  if [ $errors -ne 0 ]; then
52    printf "\e[1;31m$errors Errors found\e[0m\n"
53	if [ "$OS" == "win" ]; then
54	  exit $errors
55	fi
56  fi
57  errors=0
58}
59