mirror of
https://github.com/containers/skopeo.git
synced 2026-02-03 07:48:30 +00:00
Add a test helper for examining image metadata and checking their types, and add tests that use it to verify that after writing either Docker v2 or OCI v1 images, that the manifest and configuration blobs that we stored for them successfully decode as the correct data types. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> Closes: #118 Approved by: rhatdan
53 lines
1.3 KiB
Bash
53 lines
1.3 KiB
Bash
#!/bin/bash
|
|
|
|
BUILDAH_BINARY=${BUILDAH_BINARY:-$(dirname ${BASH_SOURCE})/../buildah}
|
|
TESTSDIR=${TESTSDIR:-$(dirname ${BASH_SOURCE})}
|
|
|
|
function setup() {
|
|
suffix=$(dd if=/dev/urandom bs=12 count=1 status=none | base64 | tr +/ _.)
|
|
TESTDIR=${BATS_TMPDIR}/tmp.${suffix}
|
|
rm -fr ${TESTDIR}
|
|
mkdir -p ${TESTDIR}/{root,runroot}
|
|
REPO=${TESTDIR}/root
|
|
}
|
|
|
|
function buildimgtype() {
|
|
go build -tags "$(${TESTSDIR}/../btrfs_tag.sh; ${TESTSDIR}/../libdm_tag.sh)" -o imgtype ${TESTSDIR}/imgtype.go
|
|
}
|
|
|
|
function starthttpd() {
|
|
pushd ${2:-${TESTDIR}} > /dev/null
|
|
cp ${TESTSDIR}/serve.go .
|
|
go build serve.go
|
|
HTTP_SERVER_PORT=$((RANDOM+32768))
|
|
./serve ${HTTP_SERVER_PORT} ${1:-${BATS_TMPDIR}} &
|
|
HTTP_SERVER_PID=$!
|
|
popd > /dev/null
|
|
}
|
|
|
|
function stophttpd() {
|
|
if test -n "$HTTP_SERVER_PID" ; then
|
|
kill -HUP ${HTTP_SERVER_PID}
|
|
unset HTTP_SERVER_PID
|
|
unset HTTP_SERVER_PORT
|
|
fi
|
|
true
|
|
}
|
|
|
|
function teardown() {
|
|
stophttpd
|
|
rm -fr ${TESTDIR}
|
|
}
|
|
|
|
function createrandom() {
|
|
dd if=/dev/urandom bs=1 count=${2:-256} of=${1:-${BATS_TMPDIR}/randomfile} status=none
|
|
}
|
|
|
|
function buildah() {
|
|
${BUILDAH_BINARY} --debug --root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver vfs "$@"
|
|
}
|
|
|
|
function imgtype() {
|
|
./imgtype -root ${TESTDIR}/root -runroot ${TESTDIR}/runroot -storage-driver vfs "$@"
|
|
}
|