summaryrefslogtreecommitdiff
path: root/tests.as-root
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-01-30 16:24:51 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-02-11 17:36:51 +0000
commit2bc4e93f6c29ebdc7c63c1388dc579b0e1d1b081 (patch)
tree10b06f8ee93c89d9afab415d74b2ff65f92772d7 /tests.as-root
parent720cf3275d70340a707cb8794af218a713e201b5 (diff)
downloadmorph-2bc4e93f6c29ebdc7c63c1388dc579b0e1d1b081.tar.gz
Add a black-box test for branch-from-image
The test builds a system, makes a commit to mainline, then branches from the system and checks whether it is petrified to the exact commits that the system was built from by checking the morphology contents and rebuilding the system.
Diffstat (limited to 'tests.as-root')
-rwxr-xr-xtests.as-root/branch-from-image-works.script57
l---------tests.as-root/branch-from-image-works.setup1
-rw-r--r--tests.as-root/branch-from-image-works.stdout1
3 files changed, 59 insertions, 0 deletions
diff --git a/tests.as-root/branch-from-image-works.script b/tests.as-root/branch-from-image-works.script
new file mode 100755
index 00000000..1d694e9b
--- /dev/null
+++ b/tests.as-root/branch-from-image-works.script
@@ -0,0 +1,57 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 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.
+
+
+# A branch created with branch-from-image has the right commits specified
+
+set -eu
+
+# Disable test on versions of Python before 2.7.
+. "$SRCDIR/scripts/python-check"
+
+. "$SRCDIR/scripts/fix-committer-info"
+
+tar=$("$SRCDIR/scripts/test-morph" --find-system-artifact \
+ build-morphology test:morphs tarball hello-tarball)
+
+extracted="$DATADIR/extracted"
+mkdir -p "$extracted"
+tar -xf "$tar" -C "$extracted"
+get_sha1(){
+ sed -nre '/sha1/s/^.*([0-9a-f]{40}).*$/\1/p' "$1"
+}
+hello_chunk_commit=$(get_sha1 "$extracted/baserock/hello.meta")
+
+# Make a commit so that petrifying from HEAD is detectable
+chunkrepo="$DATADIR/chunk-repo"
+cd "$chunkrepo"
+git checkout --quiet farrokh
+sed -i -e 's/hello, world/goodbye, world/g' hello.c
+git add hello.c
+git commit --quiet -m 'Make hello say goodbye'
+
+
+workspace="$DATADIR/workspace"
+"$SRCDIR/scripts/test-morph" init "$workspace"
+cd "$workspace"
+"$SRCDIR/scripts/test-morph" branch-from-image \
+ test:morphs mybranch "$extracted/baserock"
+cd mybranch/test:morphs
+grep -qFe "$hello_chunk_commit" hello-stratum.morph
+tar=$("$SRCDIR/scripts/test-morph" --find-system-artifact build hello-tarball)
+tar -xf "$tar" bin/hello
+bin/hello
diff --git a/tests.as-root/branch-from-image-works.setup b/tests.as-root/branch-from-image-works.setup
new file mode 120000
index 00000000..aac6926a
--- /dev/null
+++ b/tests.as-root/branch-from-image-works.setup
@@ -0,0 +1 @@
+metadata-includes-morph-version.setup \ No newline at end of file
diff --git a/tests.as-root/branch-from-image-works.stdout b/tests.as-root/branch-from-image-works.stdout
new file mode 100644
index 00000000..4b5fa637
--- /dev/null
+++ b/tests.as-root/branch-from-image-works.stdout
@@ -0,0 +1 @@
+hello, world