summaryrefslogtreecommitdiff
path: root/tests.as-root/branch-from-image-works.script
blob: fb0b09c966c7cb4bfa59f518e4feaf216f0ed22d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
#
# Copyright (C) 2013-2014  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-bins.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  mybranch \
                             --metadata-dir="$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