From 5add18f790ef284e70f43de87f5aef97dd77121a Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Thu, 9 Nov 2017 23:58:09 -0500 Subject: [PATCH 1/2] Fix bugs for xcattest: 3411,4189,3138,4204 --- xCAT-test/xcattest | 96 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 29 deletions(-) diff --git a/xCAT-test/xcattest b/xCAT-test/xcattest index 5bb76bb13..a220f5f15 100755 --- a/xCAT-test/xcattest +++ b/xCAT-test/xcattest @@ -95,7 +95,7 @@ Options: -f : specify the configuration file. If 'System' tag is used, only [System] section in the configuration file will be used. If 'System' is not used all other sections of the configuration file will be used, like [Table], [Object], etc. -c : Comma separated list of command names to test. -t : Comma separated list of test case names to test. - -b : Comma separated list of bundle names to test. If a bundle name is specified without an absolute path, bundles under $bundledir will be searched + -b : Comma separated list of bundle names to test. If a bundle name is specified without an absolute path, such like /[$i]->{hcp} =~ /$config{var}{HCP}/i) { + if (exists ($config{var}{HCP}) && ($case_ref->[$i]->{hcp} =~ /$config{var}{HCP}/i)) { $valid = 1; } unless ($valid) { @@ -995,11 +1001,8 @@ sub load_case { $m = 0; if ($run_case_flag) { $case_ref->[$i]->{cmd}->[$j][$m] = getvar($1, \%config); - if ($case_ref->[$i]->{cmd}->[$j][$m] =~ /miss attribute/) { - my $errlog = "$case_ref->[$i]->{name} $case_ref->[$i]->{cmd}->[$j][$m]"; - if (!(grep /$errlog/, @{ $invalidcases{"missattr"} })) { - push @{ $invalidcases{"missattr"} }, $errlog; - } + if ($case_ref->[$i]->{cmd}->[$j][$m] =~ /miss attribute (.+)/) { + update_miss_attr($case_ref->[$i]->{cmd}->[$j][$m], $case_ref->[$i]->{name}, \@{$invalidcases{"missattr"}}); } } else { $case_ref->[$i]->{cmd}->[$j][$m] = $1; @@ -1010,10 +1013,7 @@ sub load_case { if ($run_case_flag) { $case_ref->[$i]->{check}->[$j][$z] = getvar($1, \%config); if ($case_ref->[$i]->{check}->[$j][$z] =~ /miss attribute/) { - my $errlog = "$case_ref->[$i]->{name} $case_ref->[$i]->{check}->[$j][$z]"; - if (!(grep /$errlog/, @{ $invalidcases{"missattr"} })) { - push @{ $invalidcases{"missattr"} }, $errlog; - } + update_miss_attr($case_ref->[$i]->{check}->[$j][$z], $case_ref->[$i]->{name}, \@{$invalidcases{"missattr"}}); } } else { $case_ref->[$i]->{check}->[$j][$z] = $1; @@ -1025,10 +1025,7 @@ sub load_case { if ($run_case_flag) { $case_ref->[$i]->{cmdcheck}->[$j][$z] = getvar($1, \%config); if ($case_ref->[$i]->{cmdcheck}->[$j][$z] =~ /miss attribute/) { - my $errlog = "$case_ref->[$i]->{name} $case_ref->[$i]->{cmdcheck}->[$j][$z]"; - if (!(grep /$errlog/, @{ $invalidcases{"missattr"} })) { - push @{ $invalidcases{"missattr"} }, $errlog; - } + update_miss_attr($case_ref->[$i]->{cmdcheck}->[$j][$z],$case_ref->[$i]->{name}, \@{$invalidcases{"missattr"}}); } } else { $case_ref->[$i]->{cmdcheck}->[$j][$z] = $1; @@ -1054,37 +1051,55 @@ sub load_case { #log_this($running_log_fd, "Case name invalid:", @{ $invalidcases{"invalidcasename"} }); $$error_ref = "Case name invalid: " . join(",", @{ $invalidcases{"invalidcasename"} }); push @wrong_cases, @{ $invalidcases{"invalidcasename"} }; - $caseerror = 1; + $caseerror = 2; } if ($run_case_flag) { if ($invalidcases{"missattr"}) { - - #log_this($running_log_fd, "Miss attribute:", @{$invalidcases{"missattr"}}); - $$error_ref = "Miss attribute: " . join(",", @{ $invalidcases{"missattr"} }); + log_this($running_log_fd, "Miss attribute:", @{$invalidcases{"missattr"}}); + #$$error_ref = "Miss attribute: " . join(",", @{ $invalidcases{"missattr"} }); foreach my $line (@{ $invalidcases{"missattr"} }) { my @name = split(" ", $line); if (!(grep /$name[0]/, @wrong_cases)) { push @wrong_cases, $name[0]; } } - $caseerror = 1; + $caseerror = 2; } if ($invalidcases{"noruncases"}) { - log_this($running_log_fd, "Not to run:", @{ $invalidcases{"noruncases"} }); + log_this($running_log_fd, "Unsuitable current environment:", @{ $invalidcases{"noruncases"} }); push @wrong_cases, @{ $invalidcases{"noruncases"} }; + $caseerror = 2; } - unless ($caseerror) { + # To filter unexisted cases + my @unexisted_cases; + foreach my $case (@{$cases_to_be_run_ref}){ + if(!(grep { /^$case$/ } @wrong_cases) && !defined ($$case_name_index_map_ref{$case})){ + push @unexisted_cases, $case; + } + } + if(@unexisted_cases){ + log_this($running_log_fd, "Not existed:", @unexisted_cases); + push @wrong_cases, @unexisted_cases; + $caseerror = 2; + } + + if($caseerror) { my @new_cases_to_be_run = (); foreach my $c (@{$cases_to_be_run_ref}) { if (!(grep { /^$c$/ } @wrong_cases)) { push @new_cases_to_be_run, $c; } } - log_this($running_log_fd, "To run:", @new_cases_to_be_run); - #@{$cases_to_be_run_ref} = @new_cases_to_be_run; + @{$cases_to_be_run_ref} = @new_cases_to_be_run; + } + + if (@{$cases_to_be_run_ref}){ + log_this($running_log_fd, "To run:", @{$cases_to_be_run_ref}); + }else{ + log_this($running_log_fd, "To run:", "There is not valid case to run"); } } return $caseerror; @@ -1734,4 +1749,27 @@ sub print_table { return 0; } +sub update_miss_attr { + my $org_str = shift; + my $case_name = shift; + my $miss_attr_arr_ref = shift; + my $insert_flag = 0; + my $index = 0; + foreach my $str (@{$miss_attr_arr_ref}){ + my @words = split(" ", $str); + my @org_words = split(" ", $org_str); + if($case_name eq "$words[0]"){ + if(!(grep { /^$org_words[2]$/} @words)){ + $miss_attr_arr_ref->[$index] .= " $org_words[2]"; + } + $insert_flag = 1; + last; + } + ++$index; + } + + unless($insert_flag){ + push @{$miss_attr_arr_ref}, "$case_name $org_str"; + } +} From 499a619577d0546ad4430b523b367d532623f028 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Fri, 10 Nov 2017 04:29:26 -0500 Subject: [PATCH 2/2] modify depending on baiyuan's comment --- xCAT-test/xcattest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/xcattest b/xCAT-test/xcattest index a220f5f15..ed1a86fda 100755 --- a/xCAT-test/xcattest +++ b/xCAT-test/xcattest @@ -1099,7 +1099,7 @@ sub load_case { if (@{$cases_to_be_run_ref}){ log_this($running_log_fd, "To run:", @{$cases_to_be_run_ref}); }else{ - log_this($running_log_fd, "To run:", "There is not valid case to run"); + log_this($running_log_fd, "To run:", "There is no valid case to run"); } } return $caseerror;