run-test
author Paul Crowley <paul@lshift.net>
Fri, 17 Dec 2010 14:31:50 +0000
changeset 271 c1ceab337505
parent 269 a09f1bc9a6cf
permissions -rwxr-xr-x
Improve automated tests
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     1
#!/bin/sh
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     2
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     3
# Must be root to run this
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     4
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     5
set -e
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
     6
267
4f24892b33fe Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents: 266
diff changeset
     7
DEBVERSION=sid
4f24892b33fe Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents: 266
diff changeset
     8
4f24892b33fe Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents: 266
diff changeset
     9
PRISTINE=/var/local/cache/pristine/$DEBVERSION
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    10
271
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    11
if [ ! -e $PRISTINE ] ; then
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    12
    echo "Debian pristine image not found, try running create-source-image"
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    13
    echo $PRISTINE
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    14
    exit -1
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    15
fi
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    16
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    17
TOPDIR=`pwd`
271
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    18
mkdir -p $TOPDIR/build/env
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    19
BACKING=$TOPDIR/build/env/backing
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    20
MOUNT=$TOPDIR/build/env/mount
271
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    21
if [ -e $MOUNT ] ; then
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    22
    echo "Removing old filesystem"
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    23
    # FIXME: evil hack!
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    24
    chroot $MOUNT /etc/init.d/ssh stop || true
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    25
    umount $MOUNT/proc || true
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    26
    umount $MOUNT || true
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    27
    rm -rf $MOUNT
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    28
fi
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    29
if [ -e $BACKING ] ; then
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    30
    echo "Copying deb files into cache"
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    31
    cp $BACKING/var/cache/apt/archives/* build/aptcache/$DEBVERSION || true
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    32
    echo "Deleting old filesystem backing store"
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    33
    rm -rf $BACKING
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    34
fi
267
4f24892b33fe Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents: 266
diff changeset
    35
mkdir $BACKING $MOUNT
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    36
265
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    37
touch $BACKING/please-trash-this-system
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    38
mkdir -p $BACKING/etc
266
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    39
echo "pristine" > $BACKING/etc/debian_chroot
265
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    40
cp -v policy-rc.d $BACKING/etc/policy-rc.d
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    41
266
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    42
mkdir -p $BACKING/var/cache/apt/archives
271
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    43
echo "Copying deb files out of cache"
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    44
cp build/aptcache/$DEBVERSION/* $BACKING/var/cache/apt/archives || true
266
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    45
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    46
cp -av action $BACKING
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    47
#hg -R ../mercurial-server archive -r default $BACKING/action/mercurial-server
269
a09f1bc9a6cf Change back to non-Debian testing, fix test to work around NULL problem
Paul Crowley <paul@lshift.net>
parents: 267
diff changeset
    48
( cd ../mercurial-server && \
a09f1bc9a6cf Change back to non-Debian testing, fix test to work around NULL problem
Paul Crowley <paul@lshift.net>
parents: 267
diff changeset
    49
    hg st -mac0n | cpio -p -0 -d $BACKING/action/mercurial-server )
267
4f24892b33fe Evil hack: make it so it instead uses the Debian package.
Paul Crowley <paul@lshift.net>
parents: 266
diff changeset
    50
269
a09f1bc9a6cf Change back to non-Debian testing, fix test to work around NULL problem
Paul Crowley <paul@lshift.net>
parents: 267
diff changeset
    51
#cp ../mercurial-server/build/debian/mercurial-server_1.0-1_all.deb $BACKING/action
266
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    52
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    53
unionfs-fuse -o cow -o allow_other,suid,dev $BACKING=RW:$PRISTINE=RO $MOUNT
265
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    54
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    55
#mount --bind /dev "$MOUNT/dev"
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    56
#mount --bind /dev/pts "$MOUNT/dev/pts"
6629144cf111 More complete test - inhibit daemons, mount proc, add safety guard
Paul Crowley <paul@lshift.net>
parents: 264
diff changeset
    57
mount -t proc proc $MOUNT/proc
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    58
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    59
chroot $MOUNT ./action/go
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    60
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    61
266
7cc208cbf2be Runs a real live test of mercurial-server from beginning to end
Paul Crowley <paul@lshift.net>
parents: 265
diff changeset
    62
#cat $BACKING/action/results
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    63
271
c1ceab337505 Improve automated tests
Paul Crowley <paul@lshift.net>
parents: 269
diff changeset
    64
#rm -rf build/env
264
cd7f901d3902 Do something with unionfs - it works
Paul Crowley <paul@lshift.net>
parents:
diff changeset
    65