2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-31 10:06:39 +00:00

add package test case

This commit is contained in:
junxiawang 2016-06-20 06:14:42 -04:00
parent 9677507e35
commit f926e81c1c
2 changed files with 272 additions and 43 deletions

View File

@ -1,69 +1,111 @@
start:del_ospkg
descreption:del ospkg
cmd:if cat /etc/*-release | grep SUSE >/dev/null; then ver=`echo "$$os" |awk -F "." '{print $1}'`; cp /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist.bak; `cat /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist |sed 's/ntp/-ntp/g' >> /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist.1`;`yes | cp -f /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist.1 /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist` ;updatenode $$CN -S;elif cat /etc/*release |grep "Red Hat" >/dev/null;then ver=`echo "$$os" |awk -F "." '{print $1}'`;cp /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist.bak;`cat /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist |sed 's/ntp/-ntp/g' >>/opt/xcat/share/xcat/install/rh/compute.$ver.pkglist.1`;`yes |cp -f /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist.1 /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist` ;updatenode $$CN -S;fi
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s $$osimage pkglist __GETNODEATTR($$CN,os)__
check:rc==0
cmd:rm -rf /opt/xcat/share/xcat/install/rh/compute.*.pkglist.1
cmd:xdsh $$CN rpm -qa |grep ntp-4.2
check:rc!=0
cmd:if cat /etc/*-release | grep SUSE >/dev/null; then ver=`echo "$$os" |awk -F "." '{print $1}'`; `yes| cp -f /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist.bak /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist`;elif cat /etc/*release |grep "Red Hat" >/dev/null;then ver=`echo "$$os" |awk -F "." '{print $1}'`;`yes |cp -f /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist.bak /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist`;fi
#cmd:rm -rf /opt/xcat/share/xcat/install/rh/compute.*.pkglist.1
cmd:rm -rf /opt/xcat/share/xcat/install/rh/compute.*.pkglist.bak
end
start:add_ospkg
descreption:add ospkg
cmd:if cat /etc/*-release | grep SUSE >/dev/null; then ver=`echo "$$os" |awk -F "." '{print $1}'`; cp /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist.bak; `cat /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist |sed 's/ntp/-ntp/g' >> /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist.1`;`yes | cp -f /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist.1 /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist` ;updatenode $$CN -S;elif cat /etc/*release |grep "Red Hat" >/dev/null;then ver=`echo "$$os" |awk -F "." '{print $1}'`;cp /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist.bak;`cat /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist |sed 's/ntp/-ntp/g' >>/opt/xcat/share/xcat/install/rh/compute.$ver.pkglist.1`;`yes |cp -f /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist.1 /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist` ;updatenode $$CN -S;fi
cmd:rm -rf /opt/xcat/share/xcat/install/rh/compute.*.pkglist.1
check:rc==0
cmd:xdsh $$CN rpm -qa |grep ntp-4.2
check:rc!=0
cmd:if cat /etc/*-release | grep SUSE >/dev/null; then ver=`echo "$$os" |awk -F "." '{print $1}'`; `yes| cp -f /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist.bak /opt/xcat/share/xcat/install/sles/compute.$ver.pkglist`;elif cat /etc/*release |grep "Red Hat" >/dev/null;then ver=`echo "$$os" |awk -F "." '{print $1}'`;`yes |cp -f /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist.bak /opt/xcat/share/xcat/install/rh/compute.$ver.pkglist`;fi
#cmd:rm -rf /opt/xcat/share/xcat/install/rh/compute.*.pkglist.1
cmd:updatenode $$CN -S
check:rc==0
cmd:xdsh $$CN rpm -qa |grep ntp-4.2
check:output=~ntp-4.2
cmd:rm -rf /opt/xcat/share/xcat/install/rh/compute.*.pkglist.bak
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep "ii rpm"|grep "package manager for RPM" ;else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc==0
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c $$osimage pkglist __GETNODEATTR($$CN,os)__
check:rc==0
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -r $$osimage pkglist __GETNODEATTR($$CN,os)__
check:rc==0
cmd:updatenode $$CN -S
check:rc==0
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c $$osimage pkglist __GETNODEATTR($$CN,os)__
cmd:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep "ii rpm" |grep "package manager for RPM";else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc!=0
cmd:copycds $$ISO
check:rc==0
end
start:add_ospkg_updatenode
descreption:add ospkg
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s $$osimage pkglist __GETNODEATTR($$CN,os)__
check:rc==0
cmd:updatenode $$CN -S
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep "ii rpm"|grep "package manager for RPM";else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc==0
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c $$osimage pkglist __GETNODEATTR($$CN,os)__
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -r rpm; else xdsh $$CN rpm -e xCAT-test; fi
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep "ii rpm"|grep "package manager for RPM" ;else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc!=0
cmd:copycds $$ISO
check:rc==0
end
start:add_includeospkg_updatenode
descreption:add include ospkg list
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -i $$osimage pkglist __GETNODEATTR($$CN,os)__
check:rc==0
cmd:updatenode $$CN -S
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep "ii rpm"|grep "package manager for RPM" ;else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc==0
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c $$osimage pkglist __GETNODEATTR($$CN,os)__
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -r rpm; else xdsh $$CN rpm -e xCAT-test; fi
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep "ii rpm"|grep "package manager for RPM" ;else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc!=0
cmd:copycds $$ISO
check:rc==0
end
start:add_other_pkg
descreption:add other pkg
cmd:if echo "$$os" |grep "sles11"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;`mkdir -p /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat/xcat-core`;cp -r /xcat-core/build/* /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat/xcat-core ;`cp -r /xcat-dep /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat ` ;`cd /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat && createrepo .`;`echo "xcat/xcat-core/xCAT" >> /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist`;`echo "xcat/xcat-dep/$ver/__GETNODEATTR($$CN,arch)__/conserver-xcat" >> /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist `;`echo "xcat/xcat-dep/$ver/__GETNODEATTR($$CN,arch)__/perl-Net-Telnet" >> /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist`;`echo "xcat/xcat-dep/sles/__GETNODEATTR($$CN,arch)__/perl-Expect" >> /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist` ;chdef -t osimage -o $ver-__GETNODEATTR($$CN,arch)__-install-compute otherpkglist=/opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist;elif echo "$$os" |grep "rhels7" >/dev/null;then ver=`echo "$$os" |awk -F "." '{print $1}'`;`mkdir -p /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat/xcat-core`;cp -r /xcat-core/build/* /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat/xcat-core ;`cp -r /xcat-dep /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat ` ;`cd /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat && createrepo .`;`echo "xcat/xcat-core/xCAT" >> /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;`echo "xcat/xcat-dep/rh7/ppc64/conserver-xcat" >> /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist `;`echo "xcat/xcat-dep/rh7/ppc64/perl-Net-Telnet" >> /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;`echo "xcat/xcat-dep/rh7/ppc64/perl-Expect" >> /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;chdef -t osimage -o $ver-__GETNODEATTR($$CN,arch)__-install-compute otherpkglist=opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist;elif echo "$$os" |grep "rhels6" >/dev/null;then ver=`echo "$$os" |awk -F "." '{print $1}'`;`mkdir -p /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat/xcat-core`;`cp -r /xcat-core/build/* /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat/xcat-core `;`cp -r /xcat-dep /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat ` ;`cd /install/post/otherpkgs/$$ver/__GETNODEATTR($$CN,arch)__/xcat && createrepo .`;`echo "xcat/xcat-core/xCAT" >> /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;`echo "xcat/xcat-dep/rh6/__GETNODEATTR($$CN,arch)__/conserver-xcat" >> /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist `;`echo "xcat/xcat-dep/rh6/__GETNODEATTR($$CN,arch)__/perl-Net-Telnet" >> /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;`echo "xcat/xcat-dep/rh6/__GETNODEATTR($$CN,arch)__/perl-Expect" >> /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;chdef -t osimage -o $ver-__GETNODEATTR($$CN,arch)__-install-compute otherpkglist=/opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist;fi
check:rc==0
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__
cmd:updatenode $$CN -S
check:rc==0
cmd:xdsh $$CN lsdef
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep xcat ;else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc==0
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o $$osimage __GETNODEATTR($$CN,os)__
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -r xcat-test; else xdsh $$CN rpm -e xCAT-test; fi
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep xcat ;else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc!=0
cmd:copycds $$ISO
check:rc==0
end
start:del_other_pkg
descreption:del other pkg
cmd:if echo "$$os" |grep "sles11"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;`cp /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist.bak`;elif echo "$$os" |grep "rhels"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;`cp /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist.bak`;fi
cmd:if echo "$$os" |grep "sles11"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;`echo "xcat/xcat-core/xCAT-test" >> /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist`;elif echo "$$os" |grep "rhels";then ver=`echo "$$os" |awk -F "." '{print $1}'`;`echo "xcat/xcat-core/xCAT-test" >> /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;fi
cmd:cd /install/post/otherpkgs/rhels7/__GETNODEATTR($$CN,arch)__/xcat && createrepo .
cmd:updatenode $$CN -S
check:rc==0
cmd:xdsh $$CN yum repolist all
cmd:xdsh $$CN rpm -qa |grep xCAT-test
cmd:if echo "$$os" |grep "sles11"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;`yes |cp -f /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist.bak /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist`;elif echo "$$os" |grep "rhels"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;`yes |cp -f /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist.bak /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;fi
cmd:if echo "$$os" |grep "sles11"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;echo "-xCAT-test" >>/opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist.1;`yes | cp -f /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist.1 /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist`;elif echo "$$os" |grep "rhels"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;echo "-xCAT-test" >>/opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist.1;`yes | cp -f /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist.1 /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;fi
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -s -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__
check:rc==0
cmd:updatenode $$CN -S
check:rc==0
cmd:xdsh $$CN rpm -qa |grep xCAT-test
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep xcat ;else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc==0
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__
check:rc==0
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -r -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__
check:rc==0
cmd:updatenode $$CN -S
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep xcat ;else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc!=0
cmd:if echo "$$os" |grep "sles11"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;`yes |cp -f /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist.bak /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist`;rm -rf /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist.bak;rm -rf /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist.1;elif echo "$$os" |grep "rhels"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;`yes |cp -f /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist.bak /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;rm -rf /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist.bak;rm -rf /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist.1;fi
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__
check:rc==0
cmd:copycds $$ISO
check:rc==0
end
start:add_other_pkg_afterinstall
descreption:add other pkg after install
cmd:if echo "$$os" |grep "sles11"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;`echo "xcat/xcat-core/xCAT-test" >> /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist`;elif echo "$$os" |grep "rhels";then ver=`echo "$$os" |awk -F "." '{print $1}'`;`echo "xcat/xcat-core/xCAT-test" >> /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;fi
cmd:updatenode $$CN -S
check:rc==0
cmd:if echo "$$os" |grep "sles11"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;cat /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist |sed 's/xCAT-test/--xCAT-test/g' >>/opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist.1;`yes | cp -f /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist.1 /opt/xcat/share/xcat/install/sles/compute.$ver.otherpkg.pkglist`;elif echo "$$os" |grep "rhels"; then ver=`echo "$$os" |awk -F "." '{print $1}'`;cat /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist |sed 's/xCAT-test/--xCAT-test/g' >>/opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist.1;`yes | cp -f /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist.1 /opt/xcat/share/xcat/install/rh/compute.$ver.otherpkg.pkglist`;fi
start:add_other_pkg_include
descreption:add other pkg include other list
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -i -o $$osimage otherpkgdir __GETNODEATTR($$CN,os)__
check:rc==0
cmd:updatenode $$CN -S
check:rc==0
cmd:xdsh $$CN rpm -qa |grep xCAT-test
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep xcat ;else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc==0
cmd:xdsh $$CN lsdef
cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/pkg/pkgtest.pl -c -o $$osimage __GETNODEATTR($$CN,os)__
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -r xcat-test; else xdsh $$CN rpm -e xCAT-test; fi
check:rc==0
cmd:if echo "__GETNODEATTR($$CN,os)__" | grep ubuntu >/dev/null; then xdsh $$CN dpkg -l |grep xcat ;else xdsh $$CN rpm -qa |grep xCAT-test; fi
check:rc!=0
cmd:copycds $$ISO
check:rc==0
end

View File

@ -0,0 +1,187 @@
#!/usr/bin/env perl
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
use strict;
use warnings;
use Getopt::Long;
use Data::Dumper;
use Term::ANSIColor;
use Time::Local;
BEGIN
{
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
}
use lib "$::XCATROOT/lib/perl";
my $osver;
my $log="/tmp/pkg.log";
my $needhelp = 0;
my $setupenv = 0;
my $clearenv = 0;
my $setupenvinclude = 0;
my $removerpm = 0;
my $ospkg = 0;
my $int;
if (
!GetOptions("h|?" => \$needhelp,
"s" => \$setupenv,
"c"=>\$clearenv,
"i"=>\$setupenvinclude,
"r"=>\$removerpm,
"o"=>\$ospkg)
)
{
&usage;
exit 1;
}
sub usage
{
print "Usage:pkg - Run xcat pkg test cases.\n";
print " pkg [-?|-h]\n";
print " pkgtest [-s] [osimage] [attribute] [os] set up package test environment \n";
print " pkgtest [-i] [osimage] [attribute] [os] set up package test environment using include package list\n";
print " pkgtest [-r] [osimage] [attribute] [os] remove package \n";
print " pkgtest [-c] [osimage] [attribute] [os] clear package test environment \n";
print " pkgtest [-o] [osimage] [attribute] [os] other package test \n";
print "\n";
return;
}
sub getimgattr
{
my @output = `lsdef -t osimage -o $ARGV[0] -i $ARGV[1]`;
my $pkglistvalue;
print " output is @output \n";
if($?){
print "unkonw";
return "Unknown";
}
if($? == 0){
foreach my $output1 (@output){
if($output1 =~ /$ARGV[1]=(.*)/){
print "output1 is $output1 ,attrs is $ARGV[1] value is $1 \n";
$pkglistvalue = $1 ;
}
} }
return $pkglistvalue;
}
sub setupenv
{
my $int = shift;
if ($ospkg){
`mkdir -p $int`;
`cp -rf /xcat-core $int`;
}else{
`cp $int /tmp/pkgtest.bak`;
}
if (($ARGV[2] =~ /ubuntu/)&&($ospkg ==0)){
`echo "rpm" >>/tmp/pkgtest.bak `;
}else{
`echo "xCAT-test" >>/tmp/pkgtest.bak `;
}
}
sub clearenv
{
my $int = shift;
if ($ospkg ==0){
`rm -rf /tmp/pkgtest.* `;
`rm -rf /install/pkgtest`;
}else{
`rm -rf /tmp/pkgtest.* `;
`rm -rf $int`;
}
}
sub setupenvinclude
{
my $int = shift;
if ($ospkg){
`mkdir -p $int`;
`cp -rf /xcat-core $int`;
}else{
` cp $int /tmp/pkgtest.bak`;
}
if (($ARGV[2] =~ /ubuntu/)&&($ospkg ==0)){
`echo "rpm" >>/tmp/pkgtest.bak `;
}else{
`echo "xCAT-test" >> /tmp/pkgtest.includelist `;
}
`echo "#INCLUDE:/tmp/pkgtest.includelist#">>/tmp/pkgtest.bak `;
}
sub removerpm
{
my $int = shift;
if ($ospkg){
`mkdir -p $int`;
`cp -rf /xcat-core $int`;
}else{
` cp $int /tmp/pkgtest.bak`;
}
if (($ARGV[2] =~ /ubuntu/)&&($ospkg ==0)){
`echo "-rpm" >>/tmp/pkgtest.bak `;
}elsif(($ARGV[2] =~ /ubuntu/)&&($ospkg !=0)){
`echo "-xcat-test">>/tmp/pkgtest.bak`;
}else{
`echo "-xCAT-test" >>/tmp/pkgtest.bak`;
}
}
if ($needhelp)
{
&usage;
exit 0;
}
$int = getimgattr;
if ( ($setupenv) || ($setupenvinclude) ||($removerpm))
{
if (! -f "/tmp/int"){
`echo $int >> /tmp/int`;
}else{
print "please clear the pkg test environment first \n";
exit 1;
}
}
if ($setupenv)
{
&setupenv($int);
}
if ($setupenvinclude)
{
&setupenvinclude($int);
}
if ($removerpm)
{
&removerpm($int);
}
if ($clearenv)
{
if (-f "/tmp/int"){
my $int=`cat /tmp/int`;
&clearenv($int);
`rm -rf /tmp/int`;
exit 0;
}else{
print "please set the pkg test environment first \n";
exit 1;
}
}
if (($setupenv) || ($setupenvinclude) ||($removerpm))
{
`mkdir -p /install/pkgtest`;
`cp -rf /xcat-core/* /install/pkgtest`;
if (($ARGV[2] !~ /ubuntu/)&&($ospkg ==0)){
`chdef -t osimage -o $ARGV[0] pkgdir=/install/pkgtest pkglist=/tmp/pkgtest.bak `;
}elsif (($ARGV[2] !~ /ubuntu/)&&($ospkg !=0)){
`chdef -t osimage -o $ARGV[0] otherpkglist=/tmp/pkgtest.bak`;
}elsif(($ARGV[2] =~ /ubuntu/)&&($ospkg !=0)){
`chdef -t osimage -o $ARGV[0] otherpkglist="/tmp/pkgtest.bak" otherpkgdir="http://xcat.org/files/xcat/repos/apt/2.12/xcat-core trusty main"`;
}elsif(($ARGV[2] =~ /ubuntu/)&&($ospkg ==0)){
`chdef -t osimage -o $ARGV[0] pkglist=/tmp/pkgtest.bak`;
}
}
if ($?)
{
return 0;
}