mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 18:11:35 +00:00
tests: Fix kernel builder tests
Some kernels are only build for some architectures. The test assumed that all kernels were build for all architectures. Now, get a list of architectures for which we have a given kernel image and then make sure the builder images pointed to by the label and the builder image tagged by convention exist and point to the same thing. Signed-off-by: Rolf Neugebauer <rn@rneugeba.io>
This commit is contained in:
parent
0e025d8fb9
commit
0d8bb78f07
@ -14,15 +14,15 @@ set -e
|
|||||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||||
|
|
||||||
if [ -z "${KERNEL}" ]; then
|
if [ -z "${KERNEL}" ]; then
|
||||||
echo "KERNEL env var must be set"
|
echo "KERNEL env var must be set"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NAME=tags
|
NAME=tags
|
||||||
|
|
||||||
clean_up() {
|
clean_up() {
|
||||||
docker rm ${ctrid}
|
docker rm ${ctrid}
|
||||||
/bin/rm -f ${BUILDERFILE}
|
/bin/rm -f ${BUILDERFILE}
|
||||||
}
|
}
|
||||||
trap clean_up EXIT
|
trap clean_up EXIT
|
||||||
|
|
||||||
@ -39,28 +39,47 @@ ctrid=$(docker create $KERNEL /bin/sh)
|
|||||||
docker cp ${ctrid}:/kernel-builder ${BUILDERFILE}
|
docker cp ${ctrid}:/kernel-builder ${BUILDERFILE}
|
||||||
FILECONTENTS=$(cat ${BUILDERFILE})
|
FILECONTENTS=$(cat ${BUILDERFILE})
|
||||||
|
|
||||||
# get the manifests for the referenced tag and for the referenced builder.
|
# Get a list of architectures for which we have this kernel
|
||||||
# these are not guaranated to be identical, since the orders can change. So we need to account for that.
|
KERNEL_ARCHES=$(docker manifest inspect ${KERNEL} | jq -r -c '.manifests[].platform.architecture')
|
||||||
sumtag=$(docker manifest inspect ${BUILDER} | jq -c '.manifests | sort_by(.digest)' | sha256sum | awk '{print $1}')
|
|
||||||
sumlabel=$(docker manifest inspect ${BUILDERLABEL} | jq -c '.manifests | sort_by(.digest)' | sha256sum | awk '{print $1}')
|
# Get builder manifest
|
||||||
|
BUILDER_MANIFEST=$(docker manifest inspect ${BUILDER} | jq -c '.manifests')
|
||||||
|
|
||||||
|
# Get the manifest of the builder pointed to by the label
|
||||||
|
BUILDER_LABEL_MANIFEST=$(docker manifest inspect ${BUILDERLABEL} | jq -c '.manifests')
|
||||||
|
|
||||||
|
|
||||||
# these two files should be identical
|
# these two files should be identical
|
||||||
echo "builder label: ${BUILDERLABEL}"
|
echo "builder label: ${BUILDERLABEL}"
|
||||||
echo "builder file: ${FILECONTENTS}"
|
echo "builder file: ${FILECONTENTS}"
|
||||||
echo "builder tag: ${BUILDER}"
|
echo "builder tag: ${BUILDER}"
|
||||||
echo "builder tag sha256: ${sumtag}"
|
|
||||||
echo "builder label sha256: ${sumlabel}"
|
|
||||||
|
|
||||||
# check that the label and file contents match
|
# check that the label and file contents match
|
||||||
if [ "${BUILDERLABEL}" != "${FILECONTENTS}" ]; then
|
if [ "${BUILDERLABEL}" != "${FILECONTENTS}" ]; then
|
||||||
echo "label vs file contents mismatch"
|
echo "label vs file contents mismatch"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
|
||||||
# check that the tag actually points to the manifest
|
|
||||||
if [ "${sumtag}" != "${sumlabel}" ]; then
|
|
||||||
echo "tag ${BUILDER} and label ${BUILDERLABEL} have mismatched contents"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check that for each architecture we have the kernel for builder and the builder label points to the same thing
|
||||||
|
for ARCH in ${KERNEL_ARCHES}; do
|
||||||
|
BUILDER_ARCH_DIGEST=$(echo ${BUILDER_MANIFEST} | jq -r --arg ARCH "$ARCH" '.[] | select (.platform.architecture == $ARCH) | .digest')
|
||||||
|
BUILDER_LABEL_ARCH_DIGEST=$(echo ${BUILDER_LABEL_MANIFEST} | jq -r --arg ARCH "$ARCH" '.[] | select (.platform.architecture == $ARCH) | .digest')
|
||||||
|
|
||||||
|
if [ -z "${BUILDER_ARCH_DIGEST}" ]; then
|
||||||
|
echo "No Builder for ${ARCH} in manifest ${BUILDER}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${BUILDER_LABEL_ARCH_DIGEST}" ]; then
|
||||||
|
echo "No Builder for ${ARCH} in manifest ${BUILDERLABEL}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${BUILDER_ARCH_DIGEST}" != "${BUILDER_LABEL_ARCH_DIGEST}" ]; then
|
||||||
|
echo "Builder digests for kernel ${KERNEL} arch ${ARCH} do not match ${BUILDER_ARCH_DIGEST} != ${BUILDER_LABEL_ARCH_DIGEST}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Builder tags/labels for kernel ${KERNEL} arch ${ARCH} match: ${BUILDER_ARCH_DIGEST} == ${BUILDER_LABEL_ARCH_DIGEST}"
|
||||||
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user