diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-11-12 17:28:57 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-11-12 17:28:57 +0000 |
commit | 2ac6f661130322e63b8d2737145ea11d445aaa79 (patch) | |
tree | dd30179d22c09cc73898d7db6218e0d620d74ac8 /tests.as-root | |
parent | 19b16a2cc6d67871d0a4298354eb446ada136a8e (diff) | |
parent | a5b913a83db94380fc91d15571f55cbf7b5c741b (diff) | |
download | morph-2ac6f661130322e63b8d2737145ea11d445aaa79.tar.gz |
Merge branch 'samthursfield/build-without-push' of git://git.baserock.org/baserock/morph
Diffstat (limited to 'tests.as-root')
8 files changed, 111 insertions, 66 deletions
diff --git a/tests.as-root/build-with-external-strata.script b/tests.as-root/build-with-external-strata.script new file mode 100755 index 00000000..affb28f5 --- /dev/null +++ b/tests.as-root/build-with-external-strata.script @@ -0,0 +1,62 @@ +#!/bin/bash +# Copyright (C) 2012 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# "morph build" with strata outside the branch root repository. + +set -eu + +# Disable test on versions of Python before 2.7. +if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null +then + cat "$SRCDIR/tests.as-root/build-with-external-strata.stdout" + exit 0 +fi + +. "$SRCDIR/scripts/setup-3rd-party-strata" + +cd "$DATADIR/workspace" +"$SRCDIR/scripts/test-morph" branch test:morphs branch1 + +# System will fail to build unless we add linux to it -- make the change but +# don't commit it, in one of the external strata, as a challenge for +# 'morph build'. +cd "branch1" +"$SRCDIR/scripts/test-morph" edit hello-system stratum2 +cd "test:external-strata" +cat stratum2.morph | \ + head -n $(expr $(wc -l < stratum2.morph) - 3) > stratum2.morph +cat <<EOF >> stratum2.morph + }, + { + "name": "linux", + "repo": "test:kernel-repo", + "ref": "master", + "build-depends": [] + } + ] +} +EOF + +# Ignore Morph's output for now because it gives us: +# 2012-11-07 16:26:12 Overlaps in system artifact hello-system-rootfs detected +# +# This is due to having a chunk named 'hello' in more than one stratum. It's +# a bug that this generates overlaps (the chunk's .meta file needs to be called +# $stratum.$chunk.meta rather than $chunk.meta to avoid the overlap) and the +# redirection should be removed once this bug is fixed. +"$SRCDIR/scripts/test-morph" build hello-system > /dev/null + +[ $("$SRCDIR/scripts/list-tree" "$DATADIR/cache/artifacts" | wc -l) -eq 23 ] diff --git a/tests.as-root/build-with-push.script b/tests.as-root/build-with-push.script new file mode 100755 index 00000000..1c3fb3fd --- /dev/null +++ b/tests.as-root/build-with-push.script @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright (C) 2012 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Test 'morph build' when build without push is disabled, i.e. everything is +# built from the remote repositories instead of the local checkouts. + +set -eu + +# Disable test on versions of Python before 2.7. +if ! python --version 2>&1 | grep '^Python 2\.[78]' > /dev/null +then + cat "$SRCDIR/tests.as-root/build-with-push.stdout" + exit 0 +fi + +source "$SRCDIR/tests.as-root/setup-build" + +cd "$DATADIR/workspace/branch1" +"$SRCDIR/scripts/test-morph" --push-build-branches build linux-system + +# Test that the chunk was built from test:kernel-repo and not a local branch +cd "$DATADIR/cache/artifacts" +tar xf *.chunk.linux baserock/linux.meta +grep -q "\"repo\": \"file://$DATADIR/kernel-repo\"" baserock/linux.meta + + 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 ab84c431..9ccc3dee 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 @@ -32,14 +32,14 @@ source "$SRCDIR/tests.as-root/setup-build" # Build once. cd "$DATADIR/workspace" "$SRCDIR/scripts/test-morph" build linux-system -"$SRCDIR/scripts/list-tree" "$DATADIR/cache/artifacts" +ARTIFACT_COUNT="$(ls "$DATADIR/cache/artifacts" | wc -l)" # Build twice. cd "$DATADIR/workspace/branch1" "$SRCDIR/scripts/test-morph" build linux-system -"$SRCDIR/scripts/list-tree" "$DATADIR/cache/artifacts" +[ "$ARTIFACT_COUNT" -eq $(ls "$DATADIR/cache/artifacts" | wc -l) ] # Build thrice, and that should be enough. cd "$DATADIR/workspace/branch1/test:morphs" "$SRCDIR/scripts/test-morph" build linux-system -"$SRCDIR/scripts/list-tree" "$DATADIR/cache/artifacts" +[ "$ARTIFACT_COUNT" -eq $(ls "$DATADIR/cache/artifacts" | wc -l) ] diff --git a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.stdout b/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.stdout deleted file mode 100644 index a02b977c..00000000 --- a/tests.as-root/building-a-system-branch-multiple-times-doesnt-generate-new-artifacts.stdout +++ /dev/null @@ -1,30 +0,0 @@ -d . -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.meta -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum.meta -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.build-log -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.chunk.linux -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.meta -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.meta -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-kernel -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-rootfs -d . -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.meta -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum.meta -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.build-log -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.chunk.linux -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.meta -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.meta -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-kernel -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-rootfs -d . -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.meta -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum.meta -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.build-log -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.chunk.linux -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.meta -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.meta -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-kernel -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-rootfs diff --git a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script b/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script index f959bb43..642093dc 100755 --- a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script +++ b/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.script @@ -34,14 +34,10 @@ cd "$DATADIR/workspace" "$SRCDIR/scripts/test-morph" build linux-system # Print tree SHA1s of the build ref of morphs and kernel. -echo "Tree of morphs repo build branch after first build:" cd "$DATADIR/workspace/branch1/test:morphs" -git log -1 --format=%T baserock/builds/123456789/987654321 -echo "Tree of kernel repo build branch after first build:" +MORPHS_SHA1="$(git rev-parse baserock/builds/123456789/987654321)" cd "$DATADIR/workspace/branch1/test:kernel-repo" -git log -1 --format=%T baserock/builds/123456789/AABBCCDDE - -echo +KERNEL_SHA1="$(git rev-parse baserock/builds/123456789/AABBCCDDE)" # Make an uncommitted change to the linux morphology. cd "$DATADIR/workspace/branch1/test:kernel-repo" @@ -55,9 +51,7 @@ cd "$DATADIR/workspace" # This time the tree SHA1 of morphs should be the same # but that of the kernel repo should be different because we # made a change. -echo "Tree of morphs repo build branch after second build:" cd "$DATADIR/workspace/branch1/test:morphs" -git log -1 --format=%T baserock/builds/123456789/987654321 -echo "Tree of kernel repo build branch after second build:" +[ "$(git rev-parse baserock/builds/123456789/987654321)" != "$MORPHS_SHA1" ] cd "$DATADIR/workspace/branch1/test:kernel-repo" -git log -1 --format=%T baserock/builds/123456789/AABBCCDDE +[ "$(git rev-parse baserock/builds/123456789/AABBCCDDE)" != "$KERNEL_SHA1" ] diff --git a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.stdout b/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.stdout deleted file mode 100644 index d5758d78..00000000 --- a/tests.as-root/building-a-system-branch-picks-up-uncommitted-changes.stdout +++ /dev/null @@ -1,9 +0,0 @@ -Tree of morphs repo build branch after first build: -73b00844bfe028b01d2464727d703f1fcc1f8ef9 -Tree of kernel repo build branch after first build: -83d99190fa36d14f1bd24d88ba0fbe2ce674dd7c - -Tree of morphs repo build branch after second build: -73b00844bfe028b01d2464727d703f1fcc1f8ef9 -Tree of kernel repo build branch after second build: -5b015689415c96cdd290834ba105a64be28a3cfb 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 1ce59b0f..2bba83dc 100755 --- a/tests.as-root/building-a-system-branch-works-anywhere.script +++ b/tests.as-root/building-a-system-branch-works-anywhere.script @@ -52,11 +52,10 @@ cd "$DATADIR/workspace/branch1/test:kernel-repo" "$SRCDIR/scripts/list-tree" "$DATADIR/cache/artifacts" > "$DATADIR/output4" rm -rf "$DATADIR/cache/artifacts"/* -# Verify that we're always building the same and that we're building -# the right things after all. -cat "$DATADIR/output1" +# Verify that we build the right number of artifacts +[ $(wc < "$DATADIR/output1" -l) -eq 10 ] -# Print diffs of the build results, all of which should be empty. +# List of files in the artifact cache should be identical after each build diff "$DATADIR/output1" "$DATADIR/output2" diff "$DATADIR/output2" "$DATADIR/output3" diff "$DATADIR/output3" "$DATADIR/output4" diff --git a/tests.as-root/building-a-system-branch-works-anywhere.stdout b/tests.as-root/building-a-system-branch-works-anywhere.stdout deleted file mode 100644 index 3bbb820f..00000000 --- a/tests.as-root/building-a-system-branch-works-anywhere.stdout +++ /dev/null @@ -1,10 +0,0 @@ -d . -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.meta -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum -f ./2311765afd12c233a772a33d7f7e31e2450c191379a430790ea03b07938b9e14.stratum.linux-stratum.meta -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.build-log -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.chunk.linux -f ./e8d3ecb31babcb58516f1298ccc5f63b167186e6527d831af5a788309a648cd6.meta -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.meta -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-kernel -f ./f59cea90b0ea8c780c00adee730f6de993be0b744c7c92fb06b037b7879fc668.system.linux-system-rootfs |