summaryrefslogtreecommitdiff
path: root/lib/sbin/RunTest.pl
blob: 8e5b814ce31036882dc6f29b1de04be08ad5f819 (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
#!/bin/perl -s
#
# Test Suite tool
# Version: $Header$

require "lib/sbin/RunTestUtils.pl";

# Read options from command line
$prompt = shift;   
$prompt =~ tr/A-Z/a-z/;
$home_dir = shift;
$config = shift;;

&PrintHeader;

# Set up RunTest configuration
%config_data = &Configure($config,$home_dir);

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

%runconfig = &InitialiseRunData();

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

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

# Print database
#&PrintDataBase(%testdata);

while ($choice !~ /^Q/i)
{
  undef($thorn);
  undef($test);
  undef($choice);
  
  while (!($choice =~ /^Q/i) )
  {
      
    print "------------------------------------------------------------------------\n\n";
    print "  --- Menu ---\n\n";
    
    print "  Run entire set of tests [E]\n";
    print "  Run entire set of tests interactively [I]\n";
    print "  Choose test from [T]horn or [A]rrangement\n";
    print "  Rerun previous test [R]\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: ","E");
    print "\n";
    
    if ($choice =~ /^[EIO]/i) 
    {

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

      # Run all parameter files
      foreach $thorn (split(" ",$testdata{"RUNNABLETHORNS"}))
      {
	foreach $test (split(" ",$testdata{"$thorn RUNNABLE"}))
	{
	  print "------------------------------------------------------------------------\n\n";
	  print "  Test $thorn: $test \n";
	  print "    \"$testdata{\"$thorn $test DESC\"}\"\n";
	  if ($choice !~ /^O/i)
	  {
	    %testdata = &RunTest($test,$thorn,\%config_data,%testdata);
	  }
	  %rundata = &CompareTestFiles($test,$thorn,\%runconfig,\%rundata,\%config_data,%testdata);
	  %rundata = &ReportOnTest($test,$thorn,\%rundata,%testdata);
	  if ($choice =~ /^I/i)
	  {
	    &ViewResults($test,$thorn,\%runconfig,\%rundata,%testdata);
	  }
	}
      }

      # Write results of all tests
      &WriteFullResults(\%rundata,%testdata);
    } 
    elsif ($choice =~ /^[AT]/i)
    {
      ($ntests,@tests) = &ChooseTests($choice,%testdata);
      for ($i=0;$i<$ntests;$i++)
      {
	$test  = $tests[2*$i];
	$thorn = $tests[2*$i+1];
	print "------------------------------------------------------------------------\n\n";
	print "  Test $thorn: $test\n";
	print "    \"$testdata{\"$thorn $test DESC\"}\"\n";
	%testdata = &RunTest($tests[2*$i],$tests[2*$i+1],\%config_data,%testdata);
	%rundata = &CompareTestFiles($tests[2*$i],$tests[2*$i+1],\%runconfig,\%rundata,\%config_data,%testdata);
	%rundata = &ReportOnTest($tests[2*$i],$tests[2*$i+1],\%rundata,%testdata);
	&ViewResults($tests[2*$i],$tests[2*$i+1],\%runconfig,\%rundata,%testdata);
      }
    }
    elsif ($choice =~ /^R/i)
    {
      if ($thorn && $test)
      {
	print "------------------------------------------------------------------------\n\n";
	print "  Test $thorn: $test \n";
	print "    \"$testdata{\"$thorn $test DESC\"}\"\n";
	%testdata = &RunTest($test,$thorn,\%config_data,%testdata);
	%rundata = &CompareTestFiles($test,$thorn,\%runconfig,\%rundata,\%config_data,%testdata);
	%rundata = &ReportOnTest($test,$thorn,,\%rundata,%testdata);
	&ViewResults($test,$thorn,\%runconfig,\%rundata,%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 $rundata->{\"TOLERANCE\"} for all further runs [T]\n";
      $choice = &defprompt("  Select choice: ","");
      if ($choice =~ /T/i)
      {
	$rundata->{"TOLERANCE"} = &defprompt("  New tolerance: ","$rundata->{\"TOLERANCE\"}");
      }
    }
    elsif ($choice =~ /^Q/i)
    {
      $loop = 0;
    }
    else
    {
      print "  Choice not recognized, try again!\n";
    }
  }
  print "\n";
}