diff --git a/tests/test_images.sh b/tests/test_images.sh index 00498517..7601d56b 100755 --- a/tests/test_images.sh +++ b/tests/test_images.sh @@ -33,6 +33,10 @@ readonly docker_build_runtime="runc" test_images_only="false" test_initrds_only="false" +# Hashes used to keep track of image sizes +typeset -A built_images +typeset -A built_initrds + usage() { cat <> "$tmpfile" + done + + # initrds + for name in "${!built_initrds[@]}" + do + size=${built_initrds[$name]} + sizeMB=$(bc <<< "scale=2; ${size} / 2^20") + + printf '%12.12s\t-8.8%s\t-8.8%s\t%-20.20s\n' \ + "${size}" \ + "${sizeMB}" \ + 'initrd' \ + "${name}" >> "$tmpfile" + done + + info "Image sizes (bytes) and types (small [better] to large)" + echo + + printf '%12.12s\t-8.8%s\t-8.8%s\t%-20.20s\n\n' "Bytes" "MB" "Type" "Name" + sort -k1,1n "$tmpfile" | cat -n + + rm -f "${tmpfile}" +} + exit_handler() { if [ "$?" -eq 0 ] @@ -278,12 +327,16 @@ handle_options() local image_path="${images_dir}/${type}-${distro}-agent-init-${AGENT_INIT}.img" build_image "${image_path}" "${rootfs}" + built_images["${distro}"]=$(stat -c "%s" "${image_path}") + install_image_create_container "${image_path}" elif [ "$type" = "initrd" ] then local initrd_path="${images_dir}/${type}-${distro}-agent-init-${AGENT_INIT}.img" build_initrd "${initrd_path}" "${rootfs}" + built_initrds["${distro}"]=$(stat -c "%s" "${initrd_path}") + install_initrd_create_container "${initrd_path}" else die "invalid type: '$type' for distro $distro option $opt" @@ -459,6 +512,8 @@ test_all_distros() # previous tests. test_distro_euleros fi + + show_stats } main()