Commit 8d4d7db0 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

Tests.pm: grow test pattern map to the number of specified FIUs

Else some hash key/value pairs are not initialized at all.
This causes for example:
"Use of uninitialized value" warnings in FIJITestsViewer.pm line 1137

With this change we also set the defaults unconditionally when loaded
by the GUI. This also requires $global_settings_ref to be passed to
_set_defaults() which was using an inexistent $self->{'settings'} so far.
parent 17b74bb4
......@@ -88,7 +88,7 @@ sub new {
# create a default instance
$self->{'design'} = {};
$self->_set_defaults(TESTCONSTMAP, $self->{'design'}, $phase);
$self->_set_defaults(TESTCONSTMAP, $self->{'design'}, $phase, $global_settings_ref);
$self->{'design'}->{'NUM_TESTS'} = $num_tests;
my $tkm_ref = TESTCONSTMAP;
......@@ -268,7 +268,7 @@ sub _read_settingsfile {
$logger->error($msg);
push(@$msg_ref, $msg);
}
$self->_set_defaults(TESTCONSTMAP, $design_ref, $phase);
$self->_set_defaults(TESTCONSTMAP, $design_ref, $phase, $global_settings_ref);
$design_ref = _rename_import(TESTCONSTMAP, $design_ref);
if (!defined($design_ref)) {
......@@ -318,7 +318,7 @@ sub _read_settingsfile {
}
my $tmp_test = {};
$self->_set_defaults($self->{'TESTPATMAP'}, $tmp_test, $phase);
$self->_set_defaults($self->{'TESTPATMAP'}, $tmp_test, $phase, $global_settings_ref);
# overwrite default entries
foreach my $k (keys(%{$test_ref})) {
......@@ -352,8 +352,14 @@ sub _read_settingsfile {
$design_ref->{'NUM_TESTS'} = $test_num; # assume the best if TEST_NUM constant is not given
}
splice(@{$self->{'tests'}}, $test_num);
my $i = $test_num;
for (; $i < $global_settings_ref->{'design'}->{'FIU_NUM'}; $i++) {
my $tmp_test = {};
$self->_set_defaults($self->{'TESTPATMAP'}, $tmp_test, $phase, $global_settings_ref);
$self->{'tests'}->[$i] = $tmp_test;
}
$logger->info("Successfully read in design constants and $test_num TEST definitions from FIJI Tests file \"$fiji_ini_file\".");
splice(@{$self->{'tests'}}, $i);
return ($self, $msg_ref);
}
......@@ -404,12 +410,13 @@ sub set_test_defaults {
# @brief Set defaults according to FIJI.pm.
sub _set_defaults {
my $logger = get_logger("");
my ($self, $map_ref, $consts_ref, $phase) = @_;
my ($self, $map_ref, $consts_ref, $phase, $global_settings_ref) = @_;
foreach my $k (keys(%{$map_ref})) {
if (exists($map_ref->{$k}->{'default'})) {
# Set default only if it is not mandatory in the given phase.
if (defined($phase) && scalar(grep { $_ eq $phase } @{$map_ref->{$k}->{'phases_opt'}}) == 0) {
# In GUI mode everything is optional... the user can modify it before starting any test.
if (defined($phase) && (scalar(grep { $_ eq $phase } @{$map_ref->{$k}->{'phases_opt'}}) == 0 && $phase ne "GUI")) {
next;
}
......@@ -420,7 +427,7 @@ sub _set_defaults {
my $def;
if (ref($map_ref->{$k}->{default}) eq 'CODE') {
$def = $map_ref->{$k}->{'default'}->($self->{'settings'});
$def = $map_ref->{$k}->{'default'}->($global_settings_ref);
} else {
$def = $map_ref->{$k}->{'default'};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment