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
This commit is contained in:
Richard W.M. Jones
2012-04-06 18:49:45 +01:00
parent 418a048215
commit f2ac7c18a7
6 changed files with 34 additions and 29 deletions

1
.gitignore vendored
View File

@@ -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

View File

@@ -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

View File

@@ -22,7 +22,7 @@ export LANG=C
set -e
# fstab file.
cat > fstab.tmp <<EOF
cat > fstab.tmp.$$ <<EOF
LABEL=BOOT /boot ext2 default 0 0
/dev/debian/root / ext2 default 0 0
/dev/debian/usr /usr ext2 default 1 2
@@ -32,7 +32,7 @@ EOF
# Create a disk image.
../../run ../../fish/guestfish <<EOF
sparse debian.img.tmp 512M
sparse debian.img.tmp.$$ 512M
run
# Format the disk.
@@ -76,7 +76,7 @@ mkdir /bin
mkdir /etc
mkdir-p /var/lib/dpkg
upload fstab.tmp /etc/fstab
upload fstab.tmp.$$ /etc/fstab
write /etc/debian_version "5.0.1"
write /etc/hostname "debian.invalid"
@@ -88,5 +88,5 @@ mkdir /boot/grub
touch /boot/grub/grub.conf
EOF
rm fstab.tmp
mv debian.img.tmp debian.img
rm fstab.tmp.$$
mv debian.img.tmp.$$ debian.img

View File

@@ -38,9 +38,9 @@ foreach ('LAYOUT', 'SRCDIR') {
}
if ($ENV{LAYOUT} eq 'partitions') {
push (@images, 'fedora.img.tmp');
push (@images, "fedora.img.tmp.$$");
open(my $fstab, '>', 'fstab.tmp') or die;
open(my $fstab, '>', "fstab.tmp.$$") or die;
print $fstab <<EOF;
LABEL=BOOT /boot ext2 default 0 0
LABEL=ROOT / ext2 default 0 0
@@ -50,11 +50,11 @@ EOF
$bootdev = '/dev/sda1';
$rootdev = '/dev/sda2';
open(my $img, '>', '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 <<EOF;
/dev/md0 /boot ext2 default 0 0
LABEL=ROOT / ext2 default 0 0
@@ -95,7 +95,7 @@ EOF
$g->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 <<EOF;
MAILADDR root
AUTO +imsm +1.x -all
@@ -144,14 +144,14 @@ $g->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;
}

View File

@@ -22,13 +22,13 @@ export LANG=C
set -e
# fstab file.
cat > fstab.tmp <<EOF
cat > fstab.tmp.$$ <<EOF
LABEL=BOOT /boot ext2 default 0 0
/dev/sda2 / ext2 default 1 2
EOF
# lsb-release file.
cat > 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 <<EOF
sparse ubuntu.img.tmp 512M
sparse ubuntu.img.tmp.$$ 512M
run
# Format the disk.
@@ -64,9 +64,9 @@ mkdir /home
mkdir /usr
mkdir-p /var/lib/dpkg
upload fstab.tmp /etc/fstab
upload fstab.tmp.$$ /etc/fstab
write /etc/debian_version "5.0.1"
upload release.tmp /etc/lsb-release
upload release.tmp.$$ /etc/lsb-release
write /etc/hostname "ubuntu.invalid"
upload $SRCDIR/guest-aux/debian-packages /var/lib/dpkg/status
@@ -77,5 +77,5 @@ mkdir /boot/grub
touch /boot/grub/grub.conf
EOF
rm fstab.tmp release.tmp
mv ubuntu.img.tmp ubuntu.img
rm fstab.tmp.$$ release.tmp.$$
mv ubuntu.img.tmp.$$ ubuntu.img

View File

@@ -37,7 +37,7 @@ fi
# Create a disk image.
../../run ../../fish/guestfish <<EOF
sparse windows.img.tmp 512M
sparse windows.img.tmp.$$ 512M
run
# Format the disk.
@@ -68,4 +68,4 @@ touch /autoexec.bat
EOF
mv windows.img.tmp windows.img
mv windows.img.tmp.$$ windows.img