diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-04-23 15:42:35 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-04-23 15:47:50 +0100 |
commit | a75d85b12480770716eef81a531d7fac0f02e47d (patch) | |
tree | b8007e20199004c3b325ba8a7e37dc70c9821964 /tests.as-root | |
parent | c353664cdfe3ad1e926ed9a3f00c76955c5cae36 (diff) | |
download | morph-a75d85b12480770716eef81a531d7fac0f02e47d.tar.gz |
Fix make-patch to use new builder stuff, and its cmdtest test
Diffstat (limited to 'tests.as-root')
-rw-r--r-- | tests.as-root/hello-chunk.tar.gz | bin | 12596 -> 0 bytes | |||
-rw-r--r-- | tests.as-root/hello-stratum.morph | 10 | ||||
-rwxr-xr-x | tests.as-root/make-patch.script | 113 | ||||
-rw-r--r-- | tests.as-root/make-patch.stderr | 0 | ||||
-rw-r--r-- | tests.as-root/make-patch.stdout | 4 | ||||
-rwxr-xr-x | tests.as-root/morph | 29 |
6 files changed, 71 insertions, 85 deletions
diff --git a/tests.as-root/hello-chunk.tar.gz b/tests.as-root/hello-chunk.tar.gz Binary files differdeleted file mode 100644 index 91e27347..00000000 --- a/tests.as-root/hello-chunk.tar.gz +++ /dev/null diff --git a/tests.as-root/hello-stratum.morph b/tests.as-root/hello-stratum.morph deleted file mode 100644 index 11ac4e1c..00000000 --- a/tests.as-root/hello-stratum.morph +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "hello", - "kind": "stratum", - "sources": { - "hello": { - "repo": "hello", - "ref": "master" - } - } -} diff --git a/tests.as-root/make-patch.script b/tests.as-root/make-patch.script index f6793aae..2ffb58cf 100755 --- a/tests.as-root/make-patch.script +++ b/tests.as-root/make-patch.script @@ -19,13 +19,11 @@ set -eu -( # make the dummy stratum contain a chunk for a fake kernel - mkdir -p "$DATADIR/dummykernel" - cd "$DATADIR/dummykernel" - git init --quiet - cat <<EOF >dummykernel.morph +# Make a dummy kernel chunk. +mkdir "$DATADIR/kernel-repo" +cat <<EOF > "$DATADIR/kernel-repo/linux.morph" { - "name": "dummykernel", + "name": "linux", "kind": "chunk", "install-commands": [ "mkdir -p \"\$DESTDIR/boot\"", @@ -35,52 +33,75 @@ set -eu ] } EOF - - - git add . - git commit --quiet -m "Make dummy boot files" +"$SRCDIR/scripts/run-git-in" "$DATADIR/kernel-repo" init --quiet +"$SRCDIR/scripts/run-git-in" "$DATADIR/kernel-repo" add . +"$SRCDIR/scripts/run-git-in" "$DATADIR/kernel-repo" commit --quiet -m foo \ + > /dev/null - cd "$DATADIR/morphs-repo" - git checkout --quiet master - sed -i -e 's/^.*sources.*$/&\ - {\ - "name": "dummykernel",\ - "ref": "master"\ - },\ -/' hello-stratum.morph +# Make a stratum that include hello and kernel chunks. +cat <<EOF > "$DATADIR/morphs-repo/hello-stratum.morph" +{ + "name": "hello-stratum", + "kind": "stratum", + "sources": [ + { + "name": "hello", + "repo": "chunk-repo", + "ref": "farrokh" + }, + { + "name": "linux", + "repo": "kernel-repo", + "ref": "master" + } + ] +} +EOF +"$SRCDIR/scripts/run-git-in" "$DATADIR/morphs-repo" commit --quiet -am foo \ + > /dev/null - git commit --quiet -m "add dummy kernel" hello-stratum.morph -) +# Build first image. Remember the stratum. +"$SRCDIR/scripts/test-morph" build morphs-repo master hello-system.morph +img1=$(find "$DATADIR/cache" -maxdepth 1 -name '*.system.*') +stratum1=$(find "$DATADIR/cache" -maxdepth 1 -name '*.stratum.*') -tests.as-root/morph build morphs-repo master hello-system.morph +# Modify the chunk, in a new branch. +"$SRCDIR/scripts/run-git-in" "$DATADIR/chunk-repo" checkout --quiet farrokh +"$SRCDIR/scripts/run-git-in" "$DATADIR/chunk-repo" checkout --quiet -b alfred +sed -i s/hello/goodbye/ "$DATADIR/chunk-repo/hello.c" +"$SRCDIR/scripts/run-git-in" "$DATADIR/chunk-repo" commit -am goodbye \ + > /dev/null + +# Modify the morphs repo to use the new chunk branch, creating a new +# branch for the morphs repo. +"$SRCDIR/scripts/run-git-in" "$DATADIR/morphs-repo" checkout --quiet -b alfred +sed -i 's/farrokh/alfred/' "$DATADIR/morphs-repo/hello-stratum.morph" +"$SRCDIR/scripts/run-git-in" "$DATADIR/morphs-repo" commit -am goodbye \ + > /dev/null -# save the stratum as we will apply the patch on top of this later -cp "$DATADIR/cache/"*stratum* "$DATADIR"/farrokh-stratum +# Build second image. +"$SRCDIR/scripts/test-morph" build morphs-repo alfred hello-system.morph +img2=$(find "$DATADIR/cache" -maxdepth 1 -name '*.system.*' \ + ! -name $(basename "$img1")) - -( # make an evil stratum - cd "$DATADIR/chunk-repo" - git checkout --quiet -b evil farrokh - sed -i -e 's/hello/goodbye/g' hello.c - git add hello.c - git commit --quiet -m "Make the program evil" +# Make the patch. +patch="$DATADIR/patch" +"$SRCDIR/scripts/test-morph" make-patch "$patch" \ + morphs-repo master hello-system.morph \ + morphs-repo alfred hello-system.morph --log=/home/liw/foo.log - cd "$DATADIR/morphs-repo" - git checkout --quiet -b evil master - sed -i -e 's/farrokh/evil/g' hello-stratum.morph - git add hello-stratum.morph - git commit --quiet -m "Build evil systems" -) +# Unpack the original stratum and run the program. +mkdir "$DATADIR/unpacked" +cd "$DATADIR/unpacked" +tar -xf "$stratum1" +echo "old version:" +./bin/hello -tests.as-root/morph build morphs-repo evil hello-system.morph +# Apply patch, run program again. We should get updated output. +tbdiff-deploy "$patch" 2>/dev/null +echo "new version:" +./bin/hello -# make a patch to make the system evil -PATCH="$DATADIR"/patchfile -tests.as-root/morph make-patch "$PATCH" morphs-repo master hello-system.morph \ - morphs-repo evil hello-system.morph +# Done. +echo "Done." -UNPACKED="$DATADIR"/unpacked -mkdir -p "$UNPACKED" -tar -C "$UNPACKED" -xf "$DATADIR"/farrokh-stratum -(cd "$UNPACKED" && tbdiff-deploy "$PATCH") 2>/dev/null -"$UNPACKED"/bin/hello diff --git a/tests.as-root/make-patch.stderr b/tests.as-root/make-patch.stderr deleted file mode 100644 index e69de29b..00000000 --- a/tests.as-root/make-patch.stderr +++ /dev/null diff --git a/tests.as-root/make-patch.stdout b/tests.as-root/make-patch.stdout index 8b9743b2..b52a681e 100644 --- a/tests.as-root/make-patch.stdout +++ b/tests.as-root/make-patch.stdout @@ -1 +1,5 @@ +old version: +hello, world +new version: goodbye, world +Done. diff --git a/tests.as-root/morph b/tests.as-root/morph deleted file mode 100755 index 8ba3ae78..00000000 --- a/tests.as-root/morph +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -# -# Run morph in a way suitable for tests. -# -# 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. - -set -eu - -fatalcat(){ - cat "$1" 1>&2 - return 1 -} - -PATH="$(pwd):$PATH" -./morph --no-default-config --config="$DATADIR/morph.conf" "$@" || \ - fatalcat "$DATADIR/morph.log" |