Skip to content

Commit

Permalink
add e2e tests for --platform usage
Browse files Browse the repository at this point in the history
  • Loading branch information
coopernetes committed Oct 14, 2023
1 parent a34a657 commit 3f4712a
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions tests/structure_test_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

#End to end tests to make sure the structure tests do what we expect them
#to do on a known quantity, the latest debian docker image.
if [[ -n "$DEBUG" ]];
then
set -x
fi
failures=0

# Get the architecture to load the right configurations
Expand Down Expand Up @@ -230,7 +234,7 @@ then
echo "$res"
echo "$code"
failures=$((failures +1))
else
else
echo "PASS: oci failing test case"
fi

Expand All @@ -242,10 +246,50 @@ then
echo "$res"
echo "$code"
failures=$((failures +1))
else
else
echo "PASS: oci success test case"
fi

HEADER "Platform test cases"

docker run --rm --privileged tonistiigi/binfmt --install all > /dev/null
res=$(./out/container-structure-test test --image "$test_image" --platform="linux/$go_architecture" --config "${test_config_dir}/ubuntu_20_04_test.yaml" 2>&1)
code=$?
if ! [[ ("$res" =~ "PASS" && "$code" == "0") ]];
then
echo "FAIL: current host platform test case"
echo "$res"
echo "$code"
failures=$((failures +1))
else
echo "PASS: current host platform test case"
fi

res=$(./out/container-structure-test test --image "$test_image" --platform="linux/riscv64" --config "${test_config_dir}/ubuntu_20_04_test.yaml" 2>&1)
code=$?
if ! [[ ("$res" =~ image\ with\ reference.+was\ found\ but\ does\ not\ match\ the\ specified\ platform:\ wanted\ linux\/\riscv64,\ actual:\ linux\/$go_architecture && "$code" == "1") ]];
then
echo "FAIL: platform failing test case"
echo "$res"
echo "$code"
failures=$((failures +1))
else
echo "PASS: platform failing test case"
fi

res=$(./out/container-structure-test test --image "$test_image" --platform="linux/s390x" --pull --config "${test_config_dir}/ubuntu_20_04_test.yaml" 2>&1)
code=$?
if ! [[ ("$res" =~ "PASS" && "$code" == "0") ]];
then
echo "FAIL: platform w/ --pull test case"
echo "$res"
echo "$code"
failures=$((failures +1))
else
echo "PASS: platform w/ --pull test case"
fi


if [ $failures -gt 0 ]; then
echo "Some tests did not pass. $failures"
exit 1
Expand Down

0 comments on commit 3f4712a

Please sign in to comment.