[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 03/13] BuildSupport, ts-*-build: Remove some clone-and-hack



Introduce Osstest::BuildSupport containing selectbuildhost,
builddirsprops and prepbuilddirs.  The corresponding replicated code
from the various ts-*-build scripts is abolished.

Also break out xendist, which we are going to want to reuse.

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/BuildSupport.pm |   93 +++++++++++++++++++++++++++++++++++++++++++++++
 ts-kernel-build         |   15 ++------
 ts-libvirt-build        |   22 +++--------
 ts-xen-build            |   15 ++------
 4 files changed, 106 insertions(+), 39 deletions(-)
 create mode 100644 Osstest/BuildSupport.pm

diff --git a/Osstest/BuildSupport.pm b/Osstest/BuildSupport.pm
new file mode 100644
index 0000000..1b15557
--- /dev/null
+++ b/Osstest/BuildSupport.pm
@@ -0,0 +1,93 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2009-2013 Citrix Inc.
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+package Osstest::BuildSupport;
+
+use strict;
+use warnings;
+
+use POSIX;
+use IO::File;
+
+use Osstest::TestSupport;
+
+BEGIN {
+    use Exporter ();
+    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+    $VERSION     = 1.00;
+    @ISA         = qw(Exporter);
+    @EXPORT      = qw(
+
+                      selectbuildhost
+                      $whhost $ho
+
+                      builddirsprops
+                      $builddir $makeflags
+
+                      prepbuilddirs
+
+                      xendist
+                      $xendist
+
+                      );
+    %EXPORT_TAGS = ( );
+
+    @EXPORT_OK   = qw();
+}
+
+our ($whhost,$ho);
+our ($builddir,$makeflags);
+our ($xendist);
+
+sub selectbuildhost {
+    # pass @ARGV
+    ($whhost) = @_;
+    $whhost ||= 'host';
+    $ho= selecthost($whhost);
+}
+
+sub builddirsprops {
+    my (%xbuildopts) = @_;
+
+    $xbuildopts{DefMakeFlags} ||= '-j4';
+
+    my $leaf= "build.$flight.$job";
+    my $homedir = get_host_property($ho, 'homedir', '/home/osstest');
+    $builddir= "$homedir/$leaf";
+
+    $makeflags= get_host_property($ho, 'build make flags',
+                                 $xbuildopts{DefMakeFlags});
+}
+
+sub prepbuilddirs {
+    my (@xbuilddirs) = @_;
+    my $cmd = "rm -rf $builddir && mkdir $builddir";
+    $cmd .= " && mkdir $builddir/$_" foreach @xbuilddirs;
+    target_cmd($ho,$cmd,600);
+}
+
+sub xendist () {
+    $xendist= "$builddir/xendist";
+    target_cmd($ho,"rm -rf $xendist && mkdir $xendist",60);
+
+    my $path = get_stashed("path_dist", $r{"buildjob"});
+    my $distcopy= "$builddir/dist.tar.gz";
+    target_putfile($ho, 300, $path, $distcopy);
+    target_cmd($ho, "tar -C $xendist -hzxf $distcopy", 300);
+}
+
+1;
diff --git a/ts-kernel-build b/ts-kernel-build
index 9d890a7..984a935 100755
--- a/ts-kernel-build
+++ b/ts-kernel-build
@@ -19,18 +19,11 @@ use strict qw(vars);
 use DBI;
 use Osstest;
 use Osstest::TestSupport;
+use Osstest::BuildSupport;
 
 tsreadconfig();
-
-our ($whhost) = @ARGV;
-$whhost ||= 'host';
-our $ho= selecthost($whhost);
-
-my $leaf= "build.$flight.$job";
-my $homedir = get_host_property($ho, 'homedir', '/home/osstest');
-my $builddir= "$homedir/$leaf";
-
-my $makeflags= get_host_property($ho, 'build make flags', '-j4');
+selectbuildhost(@ARGV);
+builddirsprops();
 
 my $archparms = {
     'armhf' => { DefConfig => 'multi_v7_defconfig', KernelImage => 
'arch/arm/boot/zImage' },
@@ -41,7 +34,7 @@ my $archparms = {
 sub enable_xen_config ();
 
 sub checkout () {
-    target_cmd($ho, "rm -rf $builddir && mkdir $builddir", 600);
+    prepbuilddirs();
 
     build_clone($ho, 'linux', $builddir, 'linux');
 
diff --git a/ts-libvirt-build b/ts-libvirt-build
index 9c731ce..ffef714 100755
--- a/ts-libvirt-build
+++ b/ts-libvirt-build
@@ -19,29 +19,17 @@ use strict qw(vars);
 use DBI;
 use Osstest;
 use Osstest::TestSupport;
+use Osstest::BuildSupport;
 
 tsreadconfig();
-
-our ($whhost) = @ARGV;
-$whhost ||= 'host';
-our $ho= selecthost($whhost);
-
-my $leaf= "build.$flight.$job";
-my $homedir = get_host_property($ho, 'homedir', '/home/osstest');
-my $builddir= "$homedir/$leaf";
-my $xendist= "$builddir/xendist";
+selectbuildhost(@ARGV);
+builddirsprops();
 
 sub libvirtd_init ();
 
-my $makeflags= get_host_property($ho, 'build make flags', '-j4');
-
 sub checkout () {
-    target_cmd($ho, "rm -rf $builddir && mkdir $builddir && mkdir $xendist", 
600);
-
-    my $path = get_stashed("path_dist", $r{"buildjob"});
-    my $distcopy= "$builddir/dist.tar.gz";
-    target_putfile($ho, 300, $path, $distcopy);
-    target_cmd($ho, "tar -C $xendist -hzxf $distcopy", 300);
+    prepbuilddirs();
+    xendist();
 
     build_clone($ho, 'libvirt', $builddir, 'libvirt');
     build_clone($ho, 'gnulib_libvirt', $builddir, 'gnulib-libvirt');
diff --git a/ts-xen-build b/ts-xen-build
index 7ac46ea..d251e16 100755
--- a/ts-xen-build
+++ b/ts-xen-build
@@ -21,21 +21,14 @@ use Osstest;
 use File::Path;
 use POSIX;
 use Osstest::TestSupport;
+use Osstest::BuildSupport;
 
 tsreadconfig();
-
-our ($whhost) = @ARGV;
-$whhost ||= 'host';
-our $ho= selecthost($whhost);
-
-my $leaf= "build.$flight.$job";
-my $homedir = get_host_property($ho, 'homedir', '/home/osstest');
-my $builddir= "$homedir/$leaf";
-
-my $makeflags= get_host_property($ho, 'build make flags', '-j4');
+selectbuildhost(@ARGV);
+builddirsprops();
     
 sub checkout () {
-    target_cmd($ho, "rm -rf $builddir && mkdir $builddir", 60);
+    prepbuilddirs();
 
     build_clone($ho, 'xen', $builddir, 'xen-unstable');
 
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.