From f2ac7c18a775dc10c3fa502f3de5ad01faa0efea Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 6 Apr 2012 18:49:45 +0100 Subject: tests: Fix guest building so parallel 'make -jN check' works. This means renaming various temporary files (eg. fstab.tmp) that several of the scripts were using so they don't conflict (eg. fstab.tmp.$$). Also the rule: fedora-md1.img fedora-md2.img: guest-aux/make-fedora-img.pl causes the script to run twice in parallel when using 'make -jN'. Replace this with a stamp file so it runs once: fedora-md1.img fedora-md2.img: stamp-fedora-md.img stamp-fedora-md.img: guest-aux/make-fedora-img.pl --- .gitignore | 1 + tests/guests/Makefile.am | 8 ++++++-- tests/guests/guest-aux/make-debian-img.sh | 10 +++++----- tests/guests/guest-aux/make-fedora-img.pl | 26 +++++++++++++------------- tests/guests/guest-aux/make-ubuntu-img.sh | 14 +++++++------- tests/guests/guest-aux/make-windows-img.sh | 4 ++-- 6 files changed, 34 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index f70feea8..a31c6ceb 100644 --- a/.gitignore +++ b/.gitignore @@ -405,6 +405,7 @@ pod2htm?.tmp /tests/guests/fedora-md2.img /tests/guests/guest-aux/fedora-name.db /tests/guests/guest-aux/fedora-packages.db +/tests/guests/stamp-fedora-md.img /tests/guests/ubuntu.img /tests/guests/windows.img /tests/regressions/rhbz501893 diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am index 960f708a..e20d91ca 100644 --- a/tests/guests/Makefile.am +++ b/tests/guests/Makefile.am @@ -40,7 +40,7 @@ EXTRA_DIST = \ # time and we need the tools we have built in order to make it. check_DATA = debian.img fedora.img fedora-md1.img fedora-md2.img ubuntu.img windows.img -CLEANFILES = $(check_DATA) +CLEANFILES = $(check_DATA) stamp-fedora-md.img # Make a (dummy) Fedora image. fedora.img: guest-aux/make-fedora-img.pl \ @@ -52,13 +52,17 @@ fedora.img: guest-aux/make-fedora-img.pl \ ../../run $< # Make a (dummy) Fedora image using md devices -fedora-md1.img fedora-md2.img: guest-aux/make-fedora-img.pl \ +fedora-md1.img fedora-md2.img: stamp-fedora-md.img + +stamp-fedora-md.img: guest-aux/make-fedora-img.pl \ guest-aux/fedora-name.db \ guest-aux/fedora-packages.db + rm -f $@ TMPDIR=$(top_builddir) \ SRCDIR=$(srcdir) \ LAYOUT=partitions-md \ ../../run $< + touch $@ guest-aux/fedora-name.db: guest-aux/fedora-name.db.txt rm -f $@ $@-t diff --git a/tests/guests/guest-aux/make-debian-img.sh b/tests/guests/guest-aux/make-debian-img.sh index f0c1597c..659e8ec5 100755 --- a/tests/guests/guest-aux/make-debian-img.sh +++ b/tests/guests/guest-aux/make-debian-img.sh @@ -22,7 +22,7 @@ export LANG=C set -e # fstab file. -cat > fstab.tmp < fstab.tmp.$$ <', 'fstab.tmp') or die; + open(my $fstab, '>', "fstab.tmp.$$") or die; print $fstab <', 'fedora.img.tmp') or die; + open(my $img, '>', "fedora.img.tmp.$$") or die; truncate($img, 512*1024*1024) or die; close($img) or die; - $g->add_drive('fedora.img.tmp'); + $g->add_drive("fedora.img.tmp.$$"); $g->launch(); $g->part_init('/dev/sda', 'mbr'); @@ -63,9 +63,9 @@ EOF } elsif ($ENV{LAYOUT} eq 'partitions-md') { - push(@images, 'fedora-md1.img.tmp', 'fedora-md2.img.tmp'); + push(@images, "fedora-md1.img.tmp.$$", "fedora-md2.img.tmp.$$"); - open(my $fstab, '>', 'fstab.tmp') or die; + open(my $fstab, '>', "fstab.tmp.$$") or die; print $fstab <md_create('boot', ['/dev/sda1', '/dev/sdb1']); $g->md_create('root', ['/dev/sda2', '/dev/sdb2']); - open(my $mdadm, '>', 'mdadm.tmp') or die; + open(my $mdadm, '>', "mdadm.tmp.$$") or die; print $mdadm <mkdir('/etc/sysconfig'); $g->mkdir('/usr'); $g->mkdir_p('/var/lib/rpm'); -$g->upload('fstab.tmp', '/etc/fstab'); +$g->upload("fstab.tmp.$$", '/etc/fstab'); $g->write('/etc/redhat-release', 'Fedora release 14 (Phony)'); $g->write('/etc/fedora-release', 'Fedora release 14 (Phony)'); $g->write('/etc/sysconfig/network', 'HOSTNAME=fedora.invalid'); -if (-f 'mdadm.tmp') { - $g->upload('mdadm.tmp', '/etc/mdadm.conf'); - unlink('mdadm.tmp') or die; +if (-f "mdadm.tmp.$$") { + $g->upload("mdadm.tmp.$$", '/etc/mdadm.conf'); + unlink("mdadm.tmp.$$") or die; } $g->upload('guest-aux/fedora-name.db', '/var/lib/rpm/Name'); @@ -190,8 +190,8 @@ $g->mkfs_opts('ext2', '/dev/VG/LV2', blocksize => 1024); $g->mkfs_opts('ext2', '/dev/VG/LV3', blocksize => 2048); # Cleanup -unlink('fstab.tmp') or die; +unlink("fstab.tmp.$$") or die; foreach my $img (@images) { - $img =~ /^(.*)\.tmp$/ or die; + $img =~ /^(.*)\.tmp\.\d+$/ or die; rename($img, $1) or die; } diff --git a/tests/guests/guest-aux/make-ubuntu-img.sh b/tests/guests/guest-aux/make-ubuntu-img.sh index a2b4d173..62f3cc9f 100755 --- a/tests/guests/guest-aux/make-ubuntu-img.sh +++ b/tests/guests/guest-aux/make-ubuntu-img.sh @@ -22,13 +22,13 @@ export LANG=C set -e # fstab file. -cat > fstab.tmp < fstab.tmp.$$ < release.tmp <<'EOF' +cat > release.tmp.$$ <<'EOF' DISTRIB_ID=Ubuntu DISTRIB_RELEASE=10.10 DISTRIB_CODENAME=maverick @@ -37,7 +37,7 @@ EOF # Create a disk image. ../../run ../../fish/guestfish <