From 9101b1839abe305545f487b10939b498e1c09280 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 14 Jun 2012 12:50:56 +0000 Subject: stratum-overlap-warns: make test more loose the exact format of the logging may change, so just check that the artifact, the chunks and the files are mentioned --- tests/stratum-overlap-warns.script | 12 +++++++++++- tests/stratum-overlap-warns.stdout | 5 ----- 2 files changed, 11 insertions(+), 6 deletions(-) delete mode 100644 tests/stratum-overlap-warns.stdout (limited to 'tests') diff --git a/tests/stratum-overlap-warns.script b/tests/stratum-overlap-warns.script index edb1d855..2e9965fe 100755 --- a/tests/stratum-overlap-warns.script +++ b/tests/stratum-overlap-warns.script @@ -21,8 +21,18 @@ set -eu log="$DATADIR/morph.log" +warnings="$DATADIR/warnings" cache="$DATADIR/cache/artifacts" +warning_mentions(){ + grep -F "$1" <"$warnings" >/dev/null 2>/dev/null +} + "$SRCDIR/scripts/test-morph" \ build --log=$log test:morphs-repo overlap overlap-stratum.morph -grep WARNING $log | sed 's/^.*WARNING/WARNING/' +grep WARNING "$log" >"$warnings" +for str in overlap-stratum \ + overlap-foo-baz overlap-foobar bin/bar \ + overlap-fooqux bin/foo; do + warning_mentions 'overlap-stratum' || exit $? +done diff --git a/tests/stratum-overlap-warns.stdout b/tests/stratum-overlap-warns.stdout deleted file mode 100644 index eaddf9c1..00000000 --- a/tests/stratum-overlap-warns.stdout +++ /dev/null @@ -1,5 +0,0 @@ -WARNING Overlaps in artifact overlap-stratum detected -WARNING Artifacts overlap-foo-baz, overlap-foobar overlap with files: -WARNING bin/bar -WARNING Artifacts overlap-foo-baz, overlap-foobar, overlap-fooqux overlap with files: -WARNING bin/foo -- cgit v1.2.1 From f7790e2ec52b3cc3f8b58f3e447da37361ff9580 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 14 Jun 2012 13:03:04 +0000 Subject: tests: verify overlaps are written to the cache This adds a new script called list-overlaps, which when given a json dump of the overlap can be used to query what is overlapping The tests use this script to check that the overlaps are detected --- tests/stratum-overlap-writes-overlap.script | 34 +++++++++++++++++++++++++++++ tests/stratum-overlap-writes-overlap.setup | 1 + tests/stratum-overlap-writes-overlap.stdout | 4 ++++ 3 files changed, 39 insertions(+) create mode 100755 tests/stratum-overlap-writes-overlap.script create mode 120000 tests/stratum-overlap-writes-overlap.setup create mode 100644 tests/stratum-overlap-writes-overlap.stdout (limited to 'tests') diff --git a/tests/stratum-overlap-writes-overlap.script b/tests/stratum-overlap-writes-overlap.script new file mode 100755 index 00000000..28d3d044 --- /dev/null +++ b/tests/stratum-overlap-writes-overlap.script @@ -0,0 +1,34 @@ +#!/bin/sh +# +# If a stratum has multiple chunks that have the same files in them, +# then the overlaps must be written to the cache +# +# Copyright (C) 2011, 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 + +cache="$DATADIR/cache/artifacts" + + +"$SRCDIR/scripts/test-morph" \ + build test:morphs-repo overlap overlap-stratum.morph +"$SRCDIR/scripts/list-overlaps" groups \ + "$cache"/*.stratum.overlap-stratum.overlaps | +while IFS='\n' read overlaps; do + echo $overlaps + "$SRCDIR/scripts/list-overlaps" list-files \ + "$cache"/*.stratum.overlap-stratum.overlaps $overlaps +done diff --git a/tests/stratum-overlap-writes-overlap.setup b/tests/stratum-overlap-writes-overlap.setup new file mode 120000 index 00000000..255e9a74 --- /dev/null +++ b/tests/stratum-overlap-writes-overlap.setup @@ -0,0 +1 @@ +stratum-overlap-warns.setup \ No newline at end of file diff --git a/tests/stratum-overlap-writes-overlap.stdout b/tests/stratum-overlap-writes-overlap.stdout new file mode 100644 index 00000000..40485659 --- /dev/null +++ b/tests/stratum-overlap-writes-overlap.stdout @@ -0,0 +1,4 @@ +overlap-foo-baz overlap-foobar overlap-fooqux +bin/foo +overlap-foo-baz overlap-foobar +bin/bar -- cgit v1.2.1 From dfd9cae3248b36d489f638c5b1c3c3aa6c54c050 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 14 Jun 2012 14:25:49 +0000 Subject: tests: fix some that expected tarball strata This required functionality to create a tarball from a json file. This should probably be rewritten as a morph plugin and refactor it to consolidate the creation logic, so e.g. the stratum metadata is kept. --- tests/build-stratum-with-submodules.script | 6 ++++-- tests/build-stratum.script | 6 ++++-- tests/name-clash.script | 5 ++++- tests/stratum-overlap-keeps-directory-links.script | 4 +++- tests/stratum-overlap-stomps-file-links.script | 4 +++- 5 files changed, 18 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/build-stratum-with-submodules.script b/tests/build-stratum-with-submodules.script index 9f226068..6dd424b2 100755 --- a/tests/build-stratum-with-submodules.script +++ b/tests/build-stratum-with-submodules.script @@ -65,6 +65,8 @@ EOF # No build and verify we got a stratum. "$SRCDIR/scripts/test-morph" build test:morphs-repo master submod-stratum.morph -tar -tf "$DATADIR/cache/artifacts/"*.stratum.* | LC_ALL=C sort \ - | sed '/^\.\/./s:^\./::' +"$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ + "$DATADIR/cache/artifacts/"*.stratum.* \ + "$DATADIR/stratum.tar" +tar -tf "$DATADIR/stratum.tar" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' diff --git a/tests/build-stratum.script b/tests/build-stratum.script index 994c4077..d1f790ca 100755 --- a/tests/build-stratum.script +++ b/tests/build-stratum.script @@ -20,6 +20,8 @@ set -eu "$SRCDIR/scripts/test-morph" build test:morphs-repo master hello-stratum.morph -tar -tf "$DATADIR/cache/artifacts/"*.stratum.* | LC_ALL=C sort \ - | sed '/^\.\/./s:^\./::' +"$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ + "$DATADIR/cache/artifacts/"*.stratum.* \ + "$DATADIR/stratum.tar" +tar -tf "$DATADIR/stratum.tar" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' diff --git a/tests/name-clash.script b/tests/name-clash.script index 669949ed..f1c866f9 100755 --- a/tests/name-clash.script +++ b/tests/name-clash.script @@ -56,5 +56,8 @@ EOF # unpack it and check the contents INSTDIR="$DATADIR"/unpack mkdir -p "$INSTDIR" -tar -C "$INSTDIR" -xhf "$DATADIR/cache/artifacts/"*hello-stratum* +"$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ + "$DATADIR/cache/artifacts/"*hello-stratum* \ + "$DATADIR/stratum.tar" +tar -C "$INSTDIR" -xhf "$DATADIR/stratum.tar" test "$("$INSTDIR"/bin/hello)" = "hello, world" diff --git a/tests/stratum-overlap-keeps-directory-links.script b/tests/stratum-overlap-keeps-directory-links.script index a995194f..b0a8522b 100755 --- a/tests/stratum-overlap-keeps-directory-links.script +++ b/tests/stratum-overlap-keeps-directory-links.script @@ -27,6 +27,8 @@ mkdir -p "$extracted" "$SRCDIR/scripts/test-morph" \ build test:morphs-repo overlap overlap-stratum.morph for f in "$cache"/*.stratum.overlap-stratum; do - tar -xf "$f" -C "$extracted" + "$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ + "$f" "$DATADIR/stratum.tar" + tar -xf "$DATADIR/stratum.tar" -C "$extracted" done test -h "$extracted/usr" diff --git a/tests/stratum-overlap-stomps-file-links.script b/tests/stratum-overlap-stomps-file-links.script index 0d429bbf..22271c2e 100755 --- a/tests/stratum-overlap-stomps-file-links.script +++ b/tests/stratum-overlap-stomps-file-links.script @@ -27,6 +27,8 @@ mkdir -p "$extracted" "$SRCDIR/scripts/test-morph" \ build test:morphs-repo overlap overlap-stratum.morph for f in "$cache"/*.stratum.overlap-stratum; do - tar -xf "$f" -C "$extracted" + "$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ + "$f" "$DATADIR/stratum.tar" + tar -xf "$DATADIR/stratum.tar" -C "$extracted" done test -f "$extracted/bin/foo" -- cgit v1.2.1 From bfad258d85d25c4eb5b3232d464ab6634492b17d Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 14 Jun 2012 15:17:33 +0000 Subject: tests: amend to not consider stratum metadata These tests were failing because the stratum metadata was added to the cache. --- tests/build-stratum-with-submodules.script | 2 +- tests/build-stratum.script | 2 +- tests/name-clash.script | 2 +- tests/rebuild-cached-stratum.script | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/build-stratum-with-submodules.script b/tests/build-stratum-with-submodules.script index 6dd424b2..c67aa97e 100755 --- a/tests/build-stratum-with-submodules.script +++ b/tests/build-stratum-with-submodules.script @@ -66,7 +66,7 @@ EOF "$SRCDIR/scripts/test-morph" build test:morphs-repo master submod-stratum.morph "$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ - "$DATADIR/cache/artifacts/"*.stratum.* \ + "$DATADIR/cache/artifacts/"*submod-stratum \ "$DATADIR/stratum.tar" tar -tf "$DATADIR/stratum.tar" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' diff --git a/tests/build-stratum.script b/tests/build-stratum.script index d1f790ca..8e16423e 100755 --- a/tests/build-stratum.script +++ b/tests/build-stratum.script @@ -21,7 +21,7 @@ set -eu "$SRCDIR/scripts/test-morph" build test:morphs-repo master hello-stratum.morph "$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ - "$DATADIR/cache/artifacts/"*.stratum.* \ + "$DATADIR/cache/artifacts/"*.hello-stratum \ "$DATADIR/stratum.tar" tar -tf "$DATADIR/stratum.tar" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' diff --git a/tests/name-clash.script b/tests/name-clash.script index f1c866f9..8187c813 100755 --- a/tests/name-clash.script +++ b/tests/name-clash.script @@ -57,7 +57,7 @@ EOF INSTDIR="$DATADIR"/unpack mkdir -p "$INSTDIR" "$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ - "$DATADIR/cache/artifacts/"*hello-stratum* \ + "$DATADIR/cache/artifacts/"*hello-stratum \ "$DATADIR/stratum.tar" tar -C "$INSTDIR" -xhf "$DATADIR/stratum.tar" test "$("$INSTDIR"/bin/hello)" = "hello, world" diff --git a/tests/rebuild-cached-stratum.script b/tests/rebuild-cached-stratum.script index c0022ba6..1bea1ae6 100755 --- a/tests/rebuild-cached-stratum.script +++ b/tests/rebuild-cached-stratum.script @@ -40,7 +40,7 @@ cache="$DATADIR/cache/artifacts" "$SRCDIR/scripts/test-morph" \ build test:morphs-repo rebuild-cached-stratum hello-stratum.morph echo "first build:" -(cd "$cache" && ls *.chunk.* *.stratum.* | sed 's/^[^.]*\./ /' | +(cd "$cache" && ls *.chunk.* *hello-stratum | sed 's/^[^.]*\./ /' | LC_ALL=C sort) # Change the chunk. @@ -52,6 +52,6 @@ echo "first build:" "$SRCDIR/scripts/test-morph" \ build test:morphs-repo rebuild-cached-stratum hello-stratum.morph echo "second build:" -(cd "$cache" && ls *.chunk.* *.stratum.* | sed 's/^[^.]*\./ /' | +(cd "$cache" && ls *.chunk.* *hello-stratum | sed 's/^[^.]*\./ /' | LC_ALL=C sort) -- cgit v1.2.1 From f33553534538be564461d57f81a63ffa4ca6fd54 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Thu, 14 Jun 2012 15:50:03 +0000 Subject: tests: fix missing baserock meta files This adds the ability to do this to the script, and fixes use of the script to add the new parameter. --- tests/build-stratum-with-submodules.script | 2 +- tests/build-stratum.script | 2 +- tests/name-clash.script | 2 +- tests/stratum-overlap-keeps-directory-links.script | 2 +- tests/stratum-overlap-stomps-file-links.script | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/build-stratum-with-submodules.script b/tests/build-stratum-with-submodules.script index c67aa97e..7d44caf6 100755 --- a/tests/build-stratum-with-submodules.script +++ b/tests/build-stratum-with-submodules.script @@ -67,6 +67,6 @@ EOF "$SRCDIR/scripts/test-morph" build test:morphs-repo master submod-stratum.morph "$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ "$DATADIR/cache/artifacts/"*submod-stratum \ - "$DATADIR/stratum.tar" + "$DATADIR/stratum.tar" submod-stratum tar -tf "$DATADIR/stratum.tar" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' diff --git a/tests/build-stratum.script b/tests/build-stratum.script index 8e16423e..f4fa15a1 100755 --- a/tests/build-stratum.script +++ b/tests/build-stratum.script @@ -22,6 +22,6 @@ set -eu "$SRCDIR/scripts/test-morph" build test:morphs-repo master hello-stratum.morph "$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ "$DATADIR/cache/artifacts/"*.hello-stratum \ - "$DATADIR/stratum.tar" + "$DATADIR/stratum.tar" hello-stratum tar -tf "$DATADIR/stratum.tar" | LC_ALL=C sort | sed '/^\.\/./s:^\./::' diff --git a/tests/name-clash.script b/tests/name-clash.script index 8187c813..dcc04a8a 100755 --- a/tests/name-clash.script +++ b/tests/name-clash.script @@ -58,6 +58,6 @@ INSTDIR="$DATADIR"/unpack mkdir -p "$INSTDIR" "$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ "$DATADIR/cache/artifacts/"*hello-stratum \ - "$DATADIR/stratum.tar" + "$DATADIR/stratum.tar" hello-stratum tar -C "$INSTDIR" -xhf "$DATADIR/stratum.tar" test "$("$INSTDIR"/bin/hello)" = "hello, world" diff --git a/tests/stratum-overlap-keeps-directory-links.script b/tests/stratum-overlap-keeps-directory-links.script index b0a8522b..2c5916aa 100755 --- a/tests/stratum-overlap-keeps-directory-links.script +++ b/tests/stratum-overlap-keeps-directory-links.script @@ -28,7 +28,7 @@ mkdir -p "$extracted" build test:morphs-repo overlap overlap-stratum.morph for f in "$cache"/*.stratum.overlap-stratum; do "$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ - "$f" "$DATADIR/stratum.tar" + "$f" "$DATADIR/stratum.tar" overlap-stratum tar -xf "$DATADIR/stratum.tar" -C "$extracted" done test -h "$extracted/usr" diff --git a/tests/stratum-overlap-stomps-file-links.script b/tests/stratum-overlap-stomps-file-links.script index 22271c2e..202e1f09 100755 --- a/tests/stratum-overlap-stomps-file-links.script +++ b/tests/stratum-overlap-stomps-file-links.script @@ -28,7 +28,7 @@ mkdir -p "$extracted" build test:morphs-repo overlap overlap-stratum.morph for f in "$cache"/*.stratum.overlap-stratum; do "$SRCDIR/scripts/assemble-stratum" --cachedir "$DATADIR/cache" \ - "$f" "$DATADIR/stratum.tar" + "$f" "$DATADIR/stratum.tar" overlap-stratum tar -xf "$DATADIR/stratum.tar" -C "$extracted" done test -f "$extracted/bin/foo" -- cgit v1.2.1