summaryrefslogtreecommitdiff
path: root/tests.as-root
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-11-14 17:52:38 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-11-14 17:58:39 +0000
commite8a342e61989f06172457fc25311abc02e5dfee6 (patch)
tree1cb80924d7cd49b495a4844419fd1669ce7eeafd /tests.as-root
parent70564c6457b732e1dd35384971da5df3c5a1665b (diff)
downloadmorph-e8a342e61989f06172457fc25311abc02e5dfee6.tar.gz
Update as-root tests to use their setup infrastructure
Code to generate system images was being duplicated in each test needlessly.
Diffstat (limited to 'tests.as-root')
-rwxr-xr-xtests.as-root/archless-system-fails.script5
-rwxr-xr-xtests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script1
-rwxr-xr-xtests.as-root/building-a-system-branch-works-anywhere.script3
-rwxr-xr-xtests.as-root/building-creates-correct-temporary-refs.script1
-rwxr-xr-xtests.as-root/disk-builds-rootfs-and-kernel.script72
-rw-r--r--tests.as-root/disk-builds-rootfs-and-kernel.stdout14
-rw-r--r--tests.as-root/lib3
-rwxr-xr-xtests.as-root/make-patch.script32
-rwxr-xr-xtests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script62
-rwxr-xr-xtests.as-root/setup37
-rw-r--r--tests.as-root/setup-build4
-rwxr-xr-xtests.as-root/syslinux-disk-builds-rootfs-and-kernel.script72
-rw-r--r--tests.as-root/syslinux-disk-builds-rootfs-and-kernel.stdout12
-rwxr-xr-xtests.as-root/syslinux-fails-if-no-mbr-found.script66
14 files changed, 77 insertions, 307 deletions
diff --git a/tests.as-root/archless-system-fails.script b/tests.as-root/archless-system-fails.script
index 074ff46f..eda797f1 100755
--- a/tests.as-root/archless-system-fails.script
+++ b/tests.as-root/archless-system-fails.script
@@ -20,10 +20,7 @@
set -eu
-cache="$DATADIR/cache/artifacts"
-morphsrepo="$DATADIR/morphs"
-
-cd "$morphsrepo"
+cd "$DATADIR/morphs"
git checkout --quiet -b archless master
cat <<EOF >archless-system.morph
{
diff --git a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script b/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script
index 6c8f5c28..7b26e84e 100755
--- a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script
+++ b/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.script
@@ -1,4 +1,5 @@
#!/bin/bash
+#
# Copyright (C) 2012 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
diff --git a/tests.as-root/building-a-system-branch-works-anywhere.script b/tests.as-root/building-a-system-branch-works-anywhere.script
index 11fc6850..3f96e00e 100755
--- a/tests.as-root/building-a-system-branch-works-anywhere.script
+++ b/tests.as-root/building-a-system-branch-works-anywhere.script
@@ -1,4 +1,5 @@
#!/bin/bash
+#
# Copyright (C) 2012 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
@@ -50,7 +51,7 @@ cd "$DATADIR/workspace/branch1/test:kernel-repo"
rm -rf "$DATADIR/cache/artifacts"/*
# Verify that we build the right number of artifacts
-[ $(wc < "$DATADIR/output1" -l) -eq 10 ]
+[ $(wc < "$DATADIR/output1" -l) -eq 16 ]
# List of files in the artifact cache should be identical after each build
diff "$DATADIR/output1" "$DATADIR/output2"
diff --git a/tests.as-root/building-creates-correct-temporary-refs.script b/tests.as-root/building-creates-correct-temporary-refs.script
index be067f71..300f563e 100755
--- a/tests.as-root/building-creates-correct-temporary-refs.script
+++ b/tests.as-root/building-creates-correct-temporary-refs.script
@@ -1,4 +1,5 @@
#!/bin/bash
+#
# Copyright (C) 2012 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
diff --git a/tests.as-root/disk-builds-rootfs-and-kernel.script b/tests.as-root/disk-builds-rootfs-and-kernel.script
index 3c1b903c..c11c246f 100755
--- a/tests.as-root/disk-builds-rootfs-and-kernel.script
+++ b/tests.as-root/disk-builds-rootfs-and-kernel.script
@@ -23,77 +23,21 @@ set -eu
. "$SRCDIR/tests.as-root/lib"
cache="$DATADIR/cache/artifacts"
-kernelrepo="$DATADIR/kernel-repo"
-morphsrepo="$DATADIR/morphs"
-arch=$(uname -m)
-
-cd "$morphsrepo"
-git checkout --quiet -b custom master
-cat <<EOF >system.morph
-{
- "name": "system",
- "kind": "system",
- "system-kind": "disk",
- "arch": "$arch",
- "disk-size": "1G",
- "strata": [
- {
- "morph": "stratum",
- "repo": "test:morphs",
- "ref": "custom"
- }
- ]
-}
-EOF
-cat <<EOF >stratum.morph
-{
- "name": "stratum",
- "kind": "stratum",
- "chunks": [
- {
- "name": "hello",
- "repo": "test:chunk-repo",
- "ref": "farrokh",
- "build-depends": []
- },
- {
- "name": "linux",
- "repo": "test:kernel-repo",
- "ref": "custom",
- "build-depends": ["hello"]
- }
- ]
-}
-EOF
-git add system.morph stratum.morph
-git commit --quiet -m "foo"
-
-cd "$kernelrepo"
-git checkout --quiet -b custom master
-cat <<EOF >linux.morph
-{
- "name": "linux",
- "kind": "chunk",
- "install-commands": [
- "mkdir -p \"\$DESTDIR/boot\"",
- "touch \"\$DESTDIR\"/boot/vmlinuz",
- "touch \"\$DESTDIR\"/boot/System.map"
- ]
-}
-EOF
-git add linux.morph
-
-git commit --quiet -m 'Make the kernel create a dummy zImage'
+cd "$DATADIR/morphs"
+sed -e 's/"system-kind": "syslinux-disk"/"system-kind": "disk"/' \
+ -i linux-system.morph
+git add linux-system.morph
+git commit --quiet -m "Build rootfs tarball system"
rootfs=$("$SRCDIR/scripts/test-morph" --find-system-artifact \
- build-morphology test:morphs custom system)
+ build-morphology test:morphs master linux-system)
for suffix in kernel rootfs
do
- if [ ! -e "$cache"/*system.system-"$suffix" ];
+ if [ ! -e "$cache"/*system.linux-system-"$suffix" ];
then
- echo "No .system.system-$suffix" 1>&2
+ echo "No .system.linux-system-$suffix" 1>&2
find "$cache" 1>&2
exit 1
fi
diff --git a/tests.as-root/disk-builds-rootfs-and-kernel.stdout b/tests.as-root/disk-builds-rootfs-and-kernel.stdout
index 7600c167..af3a936b 100644
--- a/tests.as-root/disk-builds-rootfs-and-kernel.stdout
+++ b/tests.as-root/disk-builds-rootfs-and-kernel.stdout
@@ -5,10 +5,11 @@
./factory
./factory-run
./factory-run/baserock
+./factory-run/baserock/hello-stratum.meta
./factory-run/baserock/hello.meta
+./factory-run/baserock/linux-stratum.meta
+./factory-run/baserock/linux-system-rootfs.meta
./factory-run/baserock/linux.meta
-./factory-run/baserock/stratum.meta
-./factory-run/baserock/system-rootfs.meta
./factory-run/bin
./factory-run/bin/hello
./factory-run/boot
@@ -17,11 +18,13 @@
./factory-run/etc
./factory-run/etc/fstab
./factory-run/etc/os-release
+./factory-run/extlinux.conf
./factory/baserock
+./factory/baserock/hello-stratum.meta
./factory/baserock/hello.meta
+./factory/baserock/linux-stratum.meta
+./factory/baserock/linux-system-rootfs.meta
./factory/baserock/linux.meta
-./factory/baserock/stratum.meta
-./factory/baserock/system-rootfs.meta
./factory/bin
./factory/bin/hello
./factory/boot
@@ -30,4 +33,5 @@
./factory/etc
./factory/etc/fstab
./factory/etc/os-release
-Baserock system, built from ref custom
+./factory/extlinux.conf
+Baserock linux-system, built from ref master
diff --git a/tests.as-root/lib b/tests.as-root/lib
index 2492bb53..d17d8e32 100644
--- a/tests.as-root/lib
+++ b/tests.as-root/lib
@@ -15,7 +15,8 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-# Helper functions for as-root tests
+
+## Helper functions for as-root tests
loopback_rootfs() {
# Find offset partition offset in a rootfs and mount it
diff --git a/tests.as-root/make-patch.script b/tests.as-root/make-patch.script
index 43b0b26a..f8cdcb88 100755
--- a/tests.as-root/make-patch.script
+++ b/tests.as-root/make-patch.script
@@ -22,33 +22,9 @@ set -eu
. "$SRCDIR/tests.as-root/lib"
-# Make a stratum that include hello and kernel chunks.
-cat <<EOF > "$DATADIR/morphs/hello-stratum.morph"
-{
- "name": "hello-stratum",
- "kind": "stratum",
- "chunks": [
- {
- "name": "hello",
- "repo": "test:chunk-repo",
- "ref": "farrokh",
- "build-depends": []
- },
- {
- "name": "linux",
- "repo": "test:kernel-repo",
- "ref": "master",
- "build-depends": ["hello"]
- }
- ]
-}
-EOF
-"$SRCDIR/scripts/run-git-in" "$DATADIR/morphs" commit --quiet -am foo \
- > /dev/null
-
# Build first image. Remember the stratum.
"$SRCDIR/scripts/test-morph" build-morphology \
- test:morphs master hello-system
+ test:morphs master linux-system
img1=$(find "$DATADIR/cache/artifacts" -maxdepth 1 -name '*.system.*-rootfs')
# Modify the chunk, in a new branch.
@@ -68,15 +44,15 @@ sed -i 's/master/alfred/' "$DATADIR/morphs/hello-system.morph"
# Build second image.
"$SRCDIR/scripts/test-morph" build-morphology \
- test:morphs alfred hello-system
+ test:morphs alfred linux-system
img2=$(find "$DATADIR/cache/artifacts" -maxdepth 1 -name '*.system.*' \
! -name $(basename "$img1"))
# Make the patch.
patch="$DATADIR/patch"
"$SRCDIR/scripts/test-morph" make-patch "$patch" \
- test:morphs master hello-system.morph \
- test:morphs alfred hello-system.morph
+ test:morphs master linux-system.morph \
+ test:morphs alfred linux-system.morph
# Big Scary WARNING: The test from here-on down is disabled
# Not because of bugs in Morph but because the images are compressed
diff --git a/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script b/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script
index f1aa674a..8bf25dee 100755
--- a/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script
+++ b/tests.as-root/rootfs-tarball-builds-rootfs-and-kernel.script
@@ -16,63 +16,24 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-# A system-kind of rootfs-tarball should build both kernel image and
-# a tarball with the root filesystem.
+## A system-kind of rootfs-tarball should build both kernel image and
+## a tarball with the root filesystem.
set -eu
. "$SRCDIR/scripts/python-check"
cache="$DATADIR/cache/artifacts"
-kernelrepo="$DATADIR/kernel-repo"
-morphsrepo="$DATADIR/morphs"
-log="$DATADIR/morph.log"
arch=$(uname -m)
-cd "$morphsrepo"
-git checkout --quiet -b custom master
-cat <<EOF >system.morph
-{
- "name": "system",
- "kind": "system",
- "system-kind": "rootfs-tarball",
- "arch": "$arch",
- "disk-size": "1G",
- "strata": [
- {
- "morph": "stratum",
- "repo": "test:morphs",
- "ref": "custom"
- }
- ]
-}
-EOF
-cat <<EOF >stratum.morph
-{
- "name": "stratum",
- "kind": "stratum",
- "chunks": [
- {
- "name": "hello",
- "repo": "test:chunk-repo",
- "ref": "farrokh",
- "build-depends": []
- },
- {
- "name": "linux",
- "repo": "test:kernel-repo",
- "ref": "custom",
- "build-depends": ["hello"]
- }
- ]
-}
-EOF
-git add system.morph stratum.morph
-git commit --quiet -m "add custom system"
+cd "$DATADIR/morphs"
+sed -e 's/"system-kind": "syslinux-disk"/"system-kind": "rootfs-tarball"/' \
+ -i linux-system.morph
+git add linux-system.morph
+git commit --quiet -m "Build rootfs tarball system"
-cd "$kernelrepo"
-git checkout --quiet -b custom master
+cd "$DATADIR/kernel-repo"
cat <<EOF >linux.morph
{
"name": "linux",
@@ -84,17 +45,16 @@ cat <<EOF >linux.morph
}
EOF
git add linux.morph
-
git commit --quiet -m 'Make the kernel create a dummy zImage'
"$SRCDIR/scripts/test-morph" \
- build-morphology test:morphs custom system > /dev/null
+ build-morphology test:morphs master linux-system > /dev/null
for suffix in kernel rootfs
do
- if [ ! -e "$cache"/*system.system-$suffix ]
+ if [ ! -e "$cache"/*system.linux-system-$suffix ]
then
- echo "can't find $cache/*system.system-$suffix" 1>&2
+ echo "can't find $cache/*system.linux-system-$suffix" 1>&2
find "$cache" 1>&2
exit 1
fi
diff --git a/tests.as-root/setup b/tests.as-root/setup
index b7a273da..a69dd94e 100755
--- a/tests.as-root/setup
+++ b/tests.as-root/setup
@@ -125,6 +125,22 @@ cat <<EOF > hello-system.morph
EOF
git add hello-system.morph
+cat <<EOF > linux-stratum.morph
+{
+ "name": "linux-stratum",
+ "kind": "stratum",
+ "chunks": [
+ {
+ "name": "linux",
+ "repo": "test:kernel-repo",
+ "ref": "master",
+ "build-depends": []
+ }
+ ]
+}
+EOF
+git add linux-stratum.morph
+
cat <<EOF > linux-system.morph
{
"name": "linux-system",
@@ -134,6 +150,11 @@ cat <<EOF > linux-system.morph
"disk-size": "1G",
"strata": [
{
+ "morph": "hello-stratum",
+ "repo": "test:morphs",
+ "ref": "master"
+ },
+ {
"morph": "linux-stratum",
"repo": "test:morphs",
"ref": "master"
@@ -143,22 +164,6 @@ cat <<EOF > linux-system.morph
EOF
git add linux-system.morph
-cat <<EOF > linux-stratum.morph
-{
- "name": "linux-stratum",
- "kind": "stratum",
- "chunks": [
- {
- "name": "linux",
- "repo": "test:kernel-repo",
- "ref": "master",
- "build-depends": []
- }
- ]
-}
-EOF
-git add linux-stratum.morph
-
git commit --quiet -m "add morphs"
# Make a dummy kernel chunk.
diff --git a/tests.as-root/setup-build b/tests.as-root/setup-build
index 8d6e6612..1f6f1c39 100644
--- a/tests.as-root/setup-build
+++ b/tests.as-root/setup-build
@@ -1,4 +1,5 @@
#!/bin/bash
+#
# Copyright (C) 2012 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
@@ -14,7 +15,8 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-# Fixture for tests involving 'morph build'
+
+## Fixture for tests involving 'morph build'
source "$SRCDIR/scripts/fix-committer-info"
diff --git a/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.script b/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.script
index 4a55cd5b..cfadc452 100755
--- a/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.script
+++ b/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.script
@@ -16,8 +16,8 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-# A system kind of syslinux-disk should create the disk image, plus a kernel
-# file.
+## A system kind of syslinux-disk should create the disk image, plus a kernel
+## file.
set -eu
@@ -31,77 +31,15 @@ case "$arch" in
esac
cache="$DATADIR/cache/artifacts"
-kernelrepo="$DATADIR/kernel-repo"
-morphsrepo="$DATADIR/morphs"
-log="$DATADIR/morph.log"
-
-cd "$morphsrepo"
-git checkout --quiet -b custom master
-cat <<EOF >system.morph
-{
- "name": "system",
- "kind": "system",
- "system-kind": "syslinux-disk",
- "arch": "$arch",
- "disk-size": "1G",
- "strata": [
- {
- "morph": "stratum",
- "repo": "test:morphs",
- "ref": "custom"
- }
- ]
-}
-EOF
-cat <<EOF >stratum.morph
-{
- "name": "stratum",
- "kind": "stratum",
- "chunks": [
- {
- "name": "hello",
- "repo": "test:chunk-repo",
- "ref": "farrokh",
- "build-depends": []
- },
- {
- "name": "linux",
- "repo": "test:kernel-repo",
- "ref": "custom",
- "build-depends": ["hello"]
- }
- ]
-}
-EOF
-git add system.morph stratum.morph
-git commit --quiet -m "foo"
-
-cd "$kernelrepo"
-git checkout --quiet -b custom master
-cat <<EOF >linux.morph
-{
- "name": "linux",
- "kind": "chunk",
- "install-commands": [
- "mkdir -p \"\$DESTDIR/boot\"",
- "touch \"\$DESTDIR\"/boot/vmlinuz",
- "touch \"\$DESTDIR\"/boot/System.map"
- ]
-}
-EOF
-git add linux.morph
-
-git commit --quiet -m 'Make the kernel create a dummy zImage'
-
rootfs=$("$SRCDIR/scripts/test-morph" --find-system-artifact \
- build-morphology test:morphs custom system)
+ build-morphology test:morphs master linux-system)
for suffix in kernel rootfs
do
- if [ ! -e "$cache"/*system.system-"$suffix" ];
+ if [ ! -e "$cache"/*system.linux-system-"$suffix" ];
then
- echo "No .system.system-$suffix" 1>&2
+ echo "No .system.linux-system-$suffix" 1>&2
find "$cache" 1>&2
exit 1
fi
diff --git a/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.stdout b/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.stdout
index c5fe4661..dfa7d9d3 100644
--- a/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.stdout
+++ b/tests.as-root/syslinux-disk-builds-rootfs-and-kernel.stdout
@@ -6,10 +6,11 @@
./factory
./factory-run
./factory-run/baserock
+./factory-run/baserock/hello-stratum.meta
./factory-run/baserock/hello.meta
+./factory-run/baserock/linux-stratum.meta
+./factory-run/baserock/linux-system-rootfs.meta
./factory-run/baserock/linux.meta
-./factory-run/baserock/stratum.meta
-./factory-run/baserock/system-rootfs.meta
./factory-run/bin
./factory-run/bin/hello
./factory-run/boot
@@ -20,10 +21,11 @@
./factory-run/etc/os-release
./factory-run/extlinux.conf
./factory/baserock
+./factory/baserock/hello-stratum.meta
./factory/baserock/hello.meta
+./factory/baserock/linux-stratum.meta
+./factory/baserock/linux-system-rootfs.meta
./factory/baserock/linux.meta
-./factory/baserock/stratum.meta
-./factory/baserock/system-rootfs.meta
./factory/bin
./factory/bin/hello
./factory/boot
@@ -33,4 +35,4 @@
./factory/etc/fstab
./factory/etc/os-release
./factory/extlinux.conf
-Baserock system, built from ref custom
+Baserock linux-system, built from ref master
diff --git a/tests.as-root/syslinux-fails-if-no-mbr-found.script b/tests.as-root/syslinux-fails-if-no-mbr-found.script
index fbf675dc..b0d5b9bd 100755
--- a/tests.as-root/syslinux-fails-if-no-mbr-found.script
+++ b/tests.as-root/syslinux-fails-if-no-mbr-found.script
@@ -16,8 +16,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-# A system kind of syslinux-disk should create the disk image, plus a kernel
-# file.
+# Handle invalid syslinux MBR parameters.
set -eu
@@ -29,67 +28,6 @@ case "$arch" in
esac
cache="$DATADIR/cache/artifacts"
-kernelrepo="$DATADIR/kernel-repo"
-morphsrepo="$DATADIR/morphs"
-log="$DATADIR/morph.log"
-
-cd "$morphsrepo"
-git checkout --quiet -b custom master
-cat <<EOF >system.morph
-{
- "name": "system",
- "kind": "system",
- "system-kind": "syslinux-disk",
- "arch": "$arch",
- "disk-size": "1G",
- "strata": [
- {
- "morph": "stratum",
- "repo": "test:morphs",
- "ref": "custom"
- }
- ]
-}
-EOF
-cat <<EOF >stratum.morph
-{
- "name": "stratum",
- "kind": "stratum",
- "chunks": [
- {
- "name": "hello",
- "repo": "test:chunk-repo",
- "ref": "farrokh",
- "build-depends": []
- },
- {
- "name": "linux",
- "repo": "test:kernel-repo",
- "ref": "custom",
- "build-depends": ["hello"]
- }
- ]
-}
-EOF
-git add system.morph stratum.morph
-git commit --quiet -m "foo"
-
-cd "$kernelrepo"
-git checkout --quiet -b custom master
-cat <<EOF >linux.morph
-{
- "name": "linux",
- "kind": "chunk",
- "install-commands": [
- "mkdir -p \"\$DESTDIR/boot\"",
- "touch \"\$DESTDIR\"/boot/vmlinuz",
- "touch \"\$DESTDIR\"/boot/System.map"
- ]
-}
-EOF
-git add linux.morph
-
-git commit --quiet -m 'Make the kernel create a dummy zImage'
"$SRCDIR/scripts/test-morph" --syslinux-mbr-search-path=nosuchfile.bin \
- build-morphology test:morphs custom system > /dev/null
+ build-morphology test:morphs master linux-system > /dev/null