summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Firth <dan.firth@codethink.co.uk>2013-10-28 17:56:23 +0000
committerDaniel Firth <dan.firth@codethink.co.uk>2013-10-30 12:20:00 +0000
commit6a315135ac6273c90f7dc35b7d4c49da158be487 (patch)
treec014c050030311112f32e97fe58197a7c7c062d1
parent9f22da771ebfec1901d0fe90f87b1960aa578748 (diff)
downloadmorph-6a315135ac6273c90f7dc35b7d4c49da158be487.tar.gz
Added scenario test for preventing cross-building
-rw-r--r--morphlib/__init__.py2
-rw-r--r--morphlib/buildcommand.py12
-rw-r--r--yarns/architecture.yarn11
-rw-r--r--yarns/implementations.yarn25
-rw-r--r--yarns/morph.shell-lib4
5 files changed, 52 insertions, 2 deletions
diff --git a/morphlib/__init__.py b/morphlib/__init__.py
index 7eb3f975..4954f812 100644
--- a/morphlib/__init__.py
+++ b/morphlib/__init__.py
@@ -38,7 +38,7 @@ __version__ = gitversion.version
# List of architectures that Morph supports
-valid_archs = ['armv7l', 'armv7b', 'x86_32', 'x86_64']
+valid_archs = ['armv7l', 'armv7b', 'testarch', 'x86_32', 'x86_64']
class Error(cliapp.AppException):
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index cbcc39fd..7b7612a4 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -50,6 +50,7 @@ class BuildCommand(object):
self.app.status(msg='Deciding on task order')
srcpool = self.create_source_pool(repo_name, ref, filename)
root_artifact = self.resolve_artifacts(srcpool)
+ self._validate_architecture(root_artifact)
self.build_in_order(root_artifact)
self.app.status(msg='Build ends successfully')
@@ -88,6 +89,17 @@ class BuildCommand(object):
return srcpool
+ def _validate_architecture(self, root_artifact):
+ '''Perform the validation between root and target architectures.'''
+
+ root_arch = root_artifact.source.morphology['arch']
+ host_arch = morphlib.util.get_host_architecture()
+ if root_arch != host_arch:
+ raise morphlib.Error(
+ 'Are you trying to cross-build? '
+ 'Host architecture is %s but target is %s'
+ % (host_arch, root_arch))
+
def resolve_artifacts(self, srcpool):
'''Resolve the artifacts that will be built for a set of sources'''
diff --git a/yarns/architecture.yarn b/yarns/architecture.yarn
new file mode 100644
index 00000000..66329c81
--- /dev/null
+++ b/yarns/architecture.yarn
@@ -0,0 +1,11 @@
+Morph Cross-Building Tests
+==========================
+
+ SCENARIO building a system for a different architecture
+ GIVEN a workspace
+ AND a git server
+ AND a system called base-system-testarch for architecture testarch in the git server
+ WHEN checking out the master system branch
+ AND attempting to build the system base-system-testarch in branch master
+ THEN morph failed
+ AND the build error message includes the string "Are you trying to cross-build?"
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index d03e7ae0..7efff54e 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -128,6 +128,18 @@ another to hold a chunk.
mkdir "$DATADIR/cache"
mkdir "$DATADIR/tmp"
+ IMPLEMENTS GIVEN a system called (\S+) for architecture (\S+) in the git server
+ cat << EOF > "$DATADIR/gits/morphs/$MATCH_1.morph"
+ arch: $MATCH_2
+ configuration-extensions: []
+ description: A system called $MATCH_1 for architectures $MATCH_2
+ kind: system
+ name: $MATCH_1
+ strata: []
+ EOF
+ run_in "$DATADIR/gits/morphs" git add "$MATCH_1.morph"
+ run_in "$DATADIR/gits/morphs" git commit -m "Added $MATCH_1 morphology."
+
Morphologies need to support having a null ref, which means look for the
stratum in the same repository and ref. Testing this requires different
morphologies.
@@ -434,6 +446,19 @@ Generating a manifest.
die "Output isn't what we expect"
fi
+Implementation sections for building
+====================================
+
+ IMPLEMENTS WHEN attempting to build the system (\S+) in branch (\S+)
+ cd "$DATADIR/workspace/$MATCH_2"
+ attempt_morph build "$MATCH_1"
+
+Implementations sections for reading error messages
+===================================================
+
+ IMPLEMENTS THEN the (init|build|checkout|branch) error message includes the string "(.*)"
+ grep "$MATCH_2" "$DATADIR/result-$MATCH_1"
+
IMPLEMENTS for test file and directory handling
===============================================
diff --git a/yarns/morph.shell-lib b/yarns/morph.shell-lib
index 448c60ce..58521ee8 100644
--- a/yarns/morph.shell-lib
+++ b/yarns/morph.shell-lib
@@ -31,7 +31,9 @@
run_morph()
{
"${SRCDIR:-.}"/morph \
- --no-default-config --config "$DATADIR/morph.conf" "$@"
+ --cachedir-min-space=0 --tempdir-min-space=0 \
+ --no-default-config --config "$DATADIR/morph.conf" "$@" \
+ 2> "$DATADIR/result-$1"
}