2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 09:36:41 +00:00

enhance xcattest for better debug new case and acquire attribute not only for node:

- to support customize the testcase dir with environment variable XCATTEST_CASEDIR
 - to allow to print more debug info with environment variable XCATTEST_DEBUG
 - to add a new func to get general object attribute (__GETOBJECTATTR(...)__)
This commit is contained in:
robin2008 2018-06-20 09:13:29 +08:00
parent 18c5afc0f4
commit c6745a3dd5

View File

@ -21,6 +21,7 @@ my $program_name = basename($0);
my $rootdir = "$prpgram_path/../share/xcat/tools/autotest";
my $casedir = "$rootdir/testcase/";
$casedir = $ENV{'XCATTEST_CASEDIR'} if exists $ENV{'XCATTEST_CASEDIR'};
my $bundledir = "$rootdir/bundle/";
my $resultdir = "$rootdir/result/";
my $rst = 0;
@ -56,6 +57,8 @@ my $running_log_fd = undef
my $running_log_name = undef;
my $failed_log_name = undef;
my $performance_log_name = undef;
my $xcatdebug = 0;
$xcatdebug = 1 if exists $ENV{'XCATTEST_DEBUG'};
#--------------command line attrbutes--------------
my $needhelp = 0;
@ -177,8 +180,11 @@ if ($rst) {
to_exit(1);
}
#print "----case to be run-----------------\n";
#print Dumper \@cases_to_be_run;
if ($xcatdebug) {
print "----case to be run-----------------\n";
print Dumper \@cases_to_be_run;
}
if ($list) {
if ($list eq "caselist") {
@ -340,12 +346,14 @@ if ($rst && $rst < 2) {
to_exit(1);
}
#print "=====Dumper loaded cases=======\n";
#print Dumper \@cases;
#print "=====Dumper case_name_index_map=======================\n";
#print Dumper \%case_name_index_map;
#print "=====Dumper cases to be run=====\n";
#print Dumper \@cases_to_be_run;
if ($xcatdebug) {
print "=====Dumper loaded cases=======\n";
print Dumper \@cases;
print "=====Dumper case_name_index_map=======================\n";
print Dumper \%case_name_index_map;
print "=====Dumper cases to be run=====\n";
print Dumper \@cases_to_be_run;
}
unless (@cases_to_be_run) {
to_exit(1);
@ -1647,7 +1655,7 @@ sub runscript {
#--------------------------------------------------------
# Fuction name: getnodeattr
# Description: get the value of node attribute form current environment
# Description: get the value of node attribute from current environment
# Atrributes:
# Retrun code:
#--------------------------------------------------------
@ -1655,11 +1663,26 @@ sub getnodeattr {
my $node = shift;
my $attr = shift;
my $maxtry = 40;
return getobjectattr('node', $node, $attr, $maxtry);
}
#--------------------------------------------------------
# Fuction name: getobjectattr
# Description: get the value of object attribute from current DB
# Atrributes:
# Retrun code:
#--------------------------------------------------------
sub getobjectattr {
my $objtype = shift;
my $objname = shift;
my $attr = shift;
my $maxtry = shift;
$maxtry = 1 unless defined($maxtry) and $maxtry > 0;
foreach my $try (0 .. $maxtry) {
my @output = runcmd("lsdef -t node -o $node -i $attr");
my @output = runcmd("lsdef -t $objtype -o $objname -i $attr");
if ($::RUNCMD_RC == 0) {
foreach my $line (@output) {
if ($line =~ /$attr=(\w.+)/) {
if ($line =~ /$attr=(\S.+)/) {
return $1;
}
}
@ -1813,7 +1836,7 @@ sub getfunc
{
my $str = shift;
while ($str =~ /__(\w+)\(([\s\,\w\$]*)\)__/) {
while ($str =~ /__(\w+)\(([\s\,\w\$\-\.]*)\)__/) {
my $func = $1;
my $parameter = $2;
my $value = undef;
@ -1827,6 +1850,11 @@ sub getfunc
if ($value eq "Unknown") {
$value = '';
}
} elsif ($func eq "GETOBJECTATTR") {
$value = getobjectattr(@para);
if ($value eq "Unknown") {
$value = '';
}
} elsif ($func eq "INC") {
$value = $para[0] + 1;
} elsif ($func eq "GETTABLEVALUE") {