#!/usr/bin/perl -w
use strict;
use strict 'refs';
# ************************************************************************
# 
#                 Anasazi:  Block Eigensolver Package
#                 Copyright (2004) Sandia Corporation
# 
# Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
# license for use of this work by or on behalf of the U.S. Government.
# 
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#  
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#  
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
# USA
# Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
# 
# ************************************************************************
#
printf
  "\n*****************************************************".
  "\n*** Running Anasazi tests (no news is good news) ****".
  "\n*****************************************************\n";

my $success = 1;  # Boolean (false=0,true=nonzero)
my $result;       # success=0, failure=nonzero

#************************************
# Modal solver utilties test
#************************************

$result = system ('./ModalSolverUtils/ModalSolverUtils_test.exe');
if ($result != 0) {
  # If we failed run it again in verbose mode.
  $success = 0;
  printf
    "\n\n*****************************************".
    "\n*** Running ModalSolverUtils test ****".
    "\n*****************************************\n\n";
  system ('./ModalSolverUtils/ModalSolverUtils_test.exe -v');
} else {
  printf
    "\n ****** ModalSolverUtils test PASSED ****** \n";
}

#************************************
# MVOPTester utilties test
#************************************

$result = system ('./MVOPTester/MVOPTester_test.exe');
if ($result != 0) {
  # If we failed run it again in verbose mode.
  $success = 0;
  printf
    "\n\n*****************************************".
    "\n*** Running MVOPTester test ****".
    "\n*****************************************\n\n";
  system ('./MVOPTester/MVOPTester_test.exe -v');
} else {
  printf
    "\n ****** MVOPTester test PASSED ****** \n";
}

#************************************
# Block Krylov-Schur test
#************************************

$result = system ('./BlockKrylovSchur/BlockKrylovSchur_test.exe');
if ($result != 0) {
  # If we failed run it again in verbose mode.
  $success = 0;
  printf
    "\n\n*****************************************".
    "\n*** Running BlockKrylovSchur test ****".
    "\n*****************************************\n\n";
  system ('./BlockKrylovSchur/BlockKrylovSchur_test.exe -v');
} else {
  printf
    "\n ****** BlockKrylovSchur test PASSED ****** \n";
}

#************************************
# Block Davidson test
#************************************

$result = system ('./BlockDavidson/BlockDavidson_test.exe');
if ($result != 0) {
  # If we failed run it again in verbose mode.
  $success = 0;
  printf
    "\n\n*****************************************".
    "\n*** Running BlockDavidson test ****".
    "\n*****************************************\n\n";
  system ('./BlockDavidson/BlockDavidson_test.exe -v');
} else {
  printf
    "\n ****** BlockDavidson test PASSED ****** \n";
}

#************************************
# LOBPCG test
#************************************

$result = system ('./LOBPCG/LOBPCG_test.exe');
if ($result != 0) {
  # If we failed run it again in verbose mode.
  $success = 0;
  printf
    "\n\n*****************************************".
    "\n*** Running LOBPCG test ****".
    "\n*****************************************\n\n";
  system ('./LOBPCG/LOBPCG_test.exe -v');
} else {
  printf
    "\n ****** LOBPCG test PASSED ****** \n";
}

# Return 0 if all the tests were successful, else return -1.
exit ($success ? 0 : -1 );

