#!/usr/bin/perl -w
use strict;
use strict 'refs';

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 );

