Merge "Fix disk usage report"

This commit is contained in:
Jenkins 2016-04-18 19:36:40 +00:00 committed by Gerrit Code Review
commit 05382d10b9
2 changed files with 9 additions and 5 deletions

View File

@ -331,6 +331,7 @@ if [ -n "$DIB_IMAGE_SIZE" ]; then
du_size=$(echo "$DIB_IMAGE_SIZE" | awk '{printf("%d\n",$1 * 1024 *1024)}') du_size=$(echo "$DIB_IMAGE_SIZE" | awk '{printf("%d\n",$1 * 1024 *1024)}')
else else
set +o xtrace set +o xtrace
echo "Calculating image size (this may take a minute)..."
du_output=$(sudo du -a -c -x ${TMP_BUILD_DIR}/built) du_output=$(sudo du -a -c -x ${TMP_BUILD_DIR}/built)
# the last line is the total size from "-c". # the last line is the total size from "-c".
# scale this by 0.6 to create a slightly bigger image # scale this by 0.6 to create a slightly bigger image
@ -345,25 +346,27 @@ if [[ "${DIB_SHOW_IMAGE_USAGE:-0}" != 0 ]]; then
du_output=$(sudo du -a -c -x ${TMP_BUILD_DIR}/built) du_output=$(sudo du -a -c -x ${TMP_BUILD_DIR}/built)
fi fi
du_output_show="sort -nr |
numfmt --to=iec-i --padding=7
--suffix=B --field=1 --from-unit=1024"
# by default show the 10MiB and greater files & directories -- a # by default show the 10MiB and greater files & directories -- a
# dir with lots of little files will still show up, but this helps # dir with lots of little files will still show up, but this helps
# signal:noise ratio # signal:noise ratio
if [[ ${DIB_SHOW_IMAGE_USAGE_FULL:-0} == 0 ]]; then if [[ ${DIB_SHOW_IMAGE_USAGE_FULL:-0} == 0 ]]; then
# numfmt will start giving a decimal place when < 10MiB # numfmt will start giving a decimal place when < 10MiB
du_output_limit="| egrep 'MiB|GiB|TiB|PiB' | grep -v '\..MiB'" du_output_show+="| egrep 'MiB|GiB|TiB|PiB' | grep -v '\..MiB'"
echo "=================================" echo "================================="
echo "Image size report (files > 10MiB)" echo "Image size report (files > 10MiB)"
echo "=================================" echo "================================="
else else
du_output_limit=""
echo "=================" echo "================="
echo "Image size report" echo "Image size report"
echo "=================" echo "================="
fi fi
echo "$du_output" | sort -nr | \ eval ${du_output_show} <<< "$du_output"
numfmt --to=iec-i --padding=7 --suffix=B --field=1 --from-unit=1024 \
$du_output_limit
echo echo
echo "===== end image size report =====" echo "===== end image size report ====="
echo echo

View File

@ -32,6 +32,7 @@ function run_disk_element_test() {
if break="after-error" break_outside_target=1 \ if break="after-error" break_outside_target=1 \
break_cmd="cp \$TMP_MOUNT_PATH/tmp/dib-test-should-fail /tmp/ 2>&1 > /dev/null || true" \ break_cmd="cp \$TMP_MOUNT_PATH/tmp/dib-test-should-fail /tmp/ 2>&1 > /dev/null || true" \
DIB_SHOW_IMAGE_USAGE=1 \
ELEMENTS_PATH=$DIB_ELEMENTS:$DIB_ELEMENTS/$element/test-elements \ ELEMENTS_PATH=$DIB_ELEMENTS:$DIB_ELEMENTS/$element/test-elements \
$DIB_CMD -x -t tar,qcow2 -o $dest_dir/image -n $element $test_element; then $DIB_CMD -x -t tar,qcow2 -o $dest_dir/image -n $element $test_element; then