# @@@ START COPYRIGHT @@@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
# @@@ END COPYRIGHT @@@

# If running test from a regress directory and SQLMX_REGRESS is not set, 
# assume SQLMX_REGRESS is 1.
if [ "$SQLMX_REGRESS" = "" ]; then
  export SQLMX_REGRESS=0
  pwd=`echo $PWD | tr A-Z a-z`
  if [   `expr match "$pwd" ".*/regress/"` -gt 0 ]; then
    SQLMX_REGRESS=1
  elif [ `expr match "$pwd" ".*/regress$"` -gt 0 ]; then
    SQLMX_REGRESS=1
  fi
fi

# Set these if not already set OR if we're in a run* script.
#
if [   "$SQL_ERROR_MSGBOX" = ""	-o $SQLMX_REGRESS -ne 0 ]; then
  export SQL_ERROR_MSGBOX=0				# no popup!
fi
if [   "$SQL_ERROR_SLEEP" = ""	-o $SQLMX_REGRESS -ne 0 ]; then
  export SQL_ERROR_SLEEP=0				# no sleeping!
fi
if [   "$YYERROR_QUIET" = ""	-o $SQLMX_REGRESS -ne 0 ]; then
  export YYERROR_QUIET=1				# quiet yacc!
fi

# Set these ONLY if we're in a run* script.
#
if [ $SQLMX_REGRESS -ne 0 ]; then

  export DEBUG_QUIET=1					# quiet other debugging!
  export SQLMX_EVENT_LOGGING_OFF=1			# no logging fail popup!
  export SQL_MXCI_CASE_INSENSITIVE_LOG='U'		# force Uppercase LOG ..
  export SQL_MXCI_CASE_INSENSITIVE_OBEY='U'		# ..and OBEY file names

  test "$scriptsdir" = "" && export scriptsdir=$TRAF_HOME/../sql/regress
  test "$rundir"     = "" && export rundir=$TRAF_HOME/../sql/regress/rundir

  dbgvars=`env | grep -i -e _DEBUG -e SQLMX_REGRESS_JAVA`
  if [ "$dbgvars" != "" ]; then
    echo
    echo "**********************************************************************"
    echo "Warning: you have env var settings that may affect regression results!"
    echo
    echo "$dbgvars"
    echo "**********************************************************************"
    echo
  fi

fi
