summaryrefslogtreecommitdiff
path: root/lib/sbin/RunTest.pl
blob: d936672d5549ef2d1550a703ca36e8a81b2f998f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/perl -s
#
# Test Suite tool
# Version: $Header$

require "lib/sbin/RunTestUtils.pl";

$prompt = shift;
$prompt =~ tr/A-Z/a-z/;

$config = shift;;

# Set up RunTest configuration
%config_data = &Configure($config);
$sep= "/";

&PrintHeader;

# Look to see if MPI is dfined
$mpi = ParseExtras(%config_data);

# Get the executable
$executable = ParseExecutable(%config_data);

if ($mpi)
{
  $numprocs = &defprompt("  Enter number of processors","2");
  $command = &defprompt("  Enter command to run executable","mpirun -np $numprocs ");
}
else
{
  $command = &defprompt("  Enter command to run executable"," ");
}

# Initialise testdata database
%testdata = &InitialiseTestData();

# Find test parameter files
%testdata = &ParseTests(%config_data);

# Parse test parameter files
%testdata = &ParseAllParameterFiles(%testdata);

# Reset/Initialise Test Statistics
%testdata = &ResetTestStatistics(%testdata);

# Print database
#&PrintDataBase(%testdata);
$loop = 1;
$run = 1;

$tests = &defprompt("  Run All tests or go to Menu","All");

while ($loop == 1)
{
  if ($tests =~ /^A/i) 
  {
    # Run all parameter files
    foreach $thorn (split(" ",$testdata{"RUNNABLETHORNS"}))
    {
      foreach $test (split(" ",$testdata{"$thorn RUNNABLE"}))
      {
	print "  Test $thorn: $test \n";
	print "    \"$testdata{\"$thorn $test DESC\"}\"\n";
	if ($run)
	{
	  %testdata = &RunTest($test,$thorn,%testdata);
	}
	%testdata = &CompareTestFiles($test,$thorn,%testdata);
      }
    }

    # Write results of all tests
    &WriteFullResults(%testdata);

    $loop = 0;
  } 
  elsif ($tests =~ /^M/i)
  {
    undef($thorn);
    undef($test);
    undef($choice);

    while (!($choice =~ /^[EOQ]/i) )
    {

      print "\n  --- Menu ---\n\n";
      
      print "  Choose test from [T]horn or [A]rrangement\n";
      print "  Rerun previous test [R]\n";
      print "  Run entire set of tests [E]\n";
      print "  Compare all files in the test output directories [O]\n";
      print "  Customize testsuite checking [C]\n";
      print "  Quit [Q]\n\n";
      $choice = &defprompt("  Select choice: ","T");

      if ($choice =~ /^[ATC]/i)
      {
	($test,$thorn) = &ChooseTest($choice,%testdata);
	%testdata = &RunTest($test,$thorn,%testdata);
	%testdata = &CompareTestFiles($test,$thorn,%testdata);
      }
      elsif ($choice =~ /^R/i)
      {
	if ($thorn && $test)
	{
	  print "  Running $thorn: $test \n";
	  print "    \"$testdata{\"$thorn $test DESC\"}\"\n";
	  %testdata = &RunTest($test,$thorn,%testdata);
	  %testdata = &CompareTestFiles($test,$thorn,%testdata);
	}
	else
	{
	  print "  No previous test has been run\n";
	}
      }
      elsif ($choice =~ /^C/i)
      {
	print "  Options for customization\n";
	if ($test)
	{
	  print "    Change tolerance for this run ($test) [R]\n";
	}
	print "    Change tolerance from $testdata{\"TOLERANCE\"} for all further runs [T]\n";
	$choice = &defprompt("  Select choice: ","");
	if ($choice =~ /T/i)
	{
	  $testdata{"TOLERANCE"} = &defprompt("  New tolerance: ","$testdata{\"TOLERANCE\"}");
	}
      }
      elsif ($choice =~ /^Q/i)
      {
	$loop = 0;
      }
      elsif ($choice =~ /^E/i)
      {
	$tests = "A";
      }
      elsif ($choice =~ /^O/i)
      {
	$tests = "A";
	$run = 0;
      }
      else
      {
	print "  Choice not recognized, try again!\n";
      }
    }
  }
  elsif ($tests =~ /^Q/i)
  {
    $loop = 0;
  }
  else
  {
    print "  Choice not recognized, try again!\n";
  }

  print "\n";
}