Skip to content

Instantly share code, notes, and snippets.

@evgeni
Created August 9, 2012 09:05
Show Gist options
  • Save evgeni/3302505 to your computer and use it in GitHub Desktop.
Save evgeni/3302505 to your computer and use it in GitHub Desktop.
#!/bin/bash
# TODO:
# * Test i386 on amd64 too?
ISO_squeeze_amd64=/home/evgeni/Downloads/debian-6.0.5-amd64-CD-1.iso
ISO_wheezy_amd64=/home/evgeni/Downloads/debian-testing-amd64-CD-1.iso
oneTimeSetUp() {
TEST_ARCH=$(dpkg --print-architecture)
TEST_ROOT=$(mktemp -d)
TEST_ISO=${TEST_ROOT}/iso
mkdir $TEST_ISO
}
_call_grml_debootstrap() {
echo "Testing ${TEST_RELEASE}/${TEST_ARCH} in ${TEST_DIR}"
CMDLINE="../grml-debootstrap -d .. --force --password grml \
--arch $TEST_ARCH --target ${TEST_DIR} \
--release $TEST_RELEASE $TEST_PARAMS"
echo "Calling $CMDLINE"
$CMDLINE
}
_test_chroot_bootstrap() {
TEST_SUFFIX='.chroot'
[ -n "$TEST_TYPE" ] && TEST_SUFFIX="${TEST_SUFFIX}.${TEST_TYPE}"
TEST_DIR="${TEST_ROOT}/${TEST_RELEASE}-${TEST_ARCH}${TEST_SUFFIX}"
_call_grml_debootstrap
assertTrue "Could not execute /bin/true in the chroot" \
"chroot ${TEST_DIR} /bin/true"
assertTrue "Could not find a working kernel" \
"[ -r ${TEST_DIR}/vmlinuz ]"
assertFalse "Did not properly unmount" \
"grep -q ${TEST_DIR} /proc/mounts"
}
_test_vmfile_bootstrap() {
TEST_SUFFIX='.img'
[ -n "$TEST_TYPE" ] && TEST_SUFFIX="${TEST_SUFFIX}.${TEST_TYPE}"
TEST_DIR="${TEST_ROOT}/${TEST_RELEASE}-${TEST_ARCH}${TEST_SUFFIX}"
TEST_PARAMS="${TEST_PARAMS} --vmfile --bootappend 0"
_call_grml_debootstrap
timeout 60 kvm -hda $TEST_DIR -m 1024 || fail "Could not properly boot the VM"
}
_test_vmfile_bootstrap_from_iso() {
TEST_TYPE='from_iso'
ISO=ISO_${TEST_RELEASE}_${TEST_ARCH}
TEST_PARAMS="--iso $TEST_ISO --mirror http://127.0.0.1/non-existant"
mount ${!ISO} $TEST_ISO
_test_vmfile_bootstrap
umount $TEST_ISO
}
_test_chroot_bootstrap_from_iso() {
TEST_TYPE='from_iso'
ISO=ISO_${TEST_RELEASE}_${TEST_ARCH}
TEST_PARAMS="--iso $TEST_ISO --mirror http://127.0.0.1/non-existant"
mount ${!ISO} $TEST_ISO
_test_chroot_bootstrap
umount $TEST_ISO
}
DISABLED_test_bootstrap_squeeze_chroot() {
TEST_RELEASE='squeeze'
_test_chroot_bootstrap
}
DISABLED_test_bootstrap_wheezy_chroot() {
TEST_RELEASE='wheezy'
_test_chroot_bootstrap
}
DISABLED_test_bootstrap_sid_chroot() {
TEST_RELEASE='sid'
_test_chroot_bootstrap
}
DISABLED_test_bootstrap_squeeze_chroot_from_iso() {
TEST_RELEASE='squeeze'
_test_chroot_bootstrap_from_iso
}
DISABLED_test_bootstrap_wheezy_chroot_from_iso() {
TEST_RELEASE='wheezy'
_test_chroot_bootstrap_from_iso
}
DISABLED_test_bootstrap_sid_chroot_from_iso() {
TEST_RELEASE='sid'
_test_chroot_bootstrap_from_iso
}
test_bootstrap_squeeze_vmfile_from_iso() {
TEST_RELEASE='squeeze'
_test_vmfile_bootstrap_from_iso
}
oneTimeTearDown() {
rm -rf $TEST_ROOT
}
SHUNIT_PARENT=$0
. /usr/share/shunit2/shunit2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment