Commit 5fe29f76 authored by rsesek's avatar rsesek Committed by Commit bot

Fix chrome/test/data/safe_browsing/dmg/generate_test_data.sh to not silently fail.

generate_test_data.sh uses `hdiutil create` and `hdiutil convert`. The former
can overwrite an existing output file, but the latter cannot. This led to the
following error:

  hdiutil: convert failed - File exists

But this message was getting swallowed because the script 1) did not do `set -e`
to stop on errors, and 2) redirect all output to /dev/null. This also fixes both
of those issues.

BUG=696529
R=thakis@chromium.org

Review-Url: https://codereview.chromium.org/2748453002
Cr-Commit-Position: refs/heads/master@{#456141}
parent 3c309fdb
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
set -eu
THIS_DIR=$(dirname "$0") THIS_DIR=$(dirname "$0")
OUT_DIR="$1" OUT_DIR="$1"
...@@ -22,6 +24,10 @@ if [[ ! -d "$1" ]]; then ...@@ -22,6 +24,10 @@ if [[ ! -d "$1" ]]; then
fi fi
generate_test_data() { generate_test_data() {
# `hdiutil convert` cannot overwrite files, so remove items in the output
# directory.
rm -f "${OUT_DIR}"/*
# HFS Raw Images ############################################################# # HFS Raw Images #############################################################
MAKE_HFS="${THIS_DIR}/make_hfs.sh" MAKE_HFS="${THIS_DIR}/make_hfs.sh"
...@@ -34,7 +40,7 @@ generate_test_data() { ...@@ -34,7 +40,7 @@ generate_test_data() {
echo "This is a test DMG file. It has been generated from " \ echo "This is a test DMG file. It has been generated from " \
"chrome/test/data/safe_browsing/dmg/generate_test_data.sh" \ "chrome/test/data/safe_browsing/dmg/generate_test_data.sh" \
> "${DMG_SOURCE}/README.txt" > "${DMG_SOURCE}/README.txt"
dd if=/dev/urandom of="${DMG_SOURCE}/random" bs=512 count=4 dd if=/dev/urandom of="${DMG_SOURCE}/random" bs=512 count=4 &> /dev/null
DMG_TEMPLATE_FORMAT="UDRO" DMG_TEMPLATE_FORMAT="UDRO"
DMG_FORMATS="UDRW UDCO UDZO UDBZ UFBI UDTO UDSP" DMG_FORMATS="UDRW UDCO UDZO UDBZ UFBI UDTO UDSP"
...@@ -46,7 +52,7 @@ generate_test_data() { ...@@ -46,7 +52,7 @@ generate_test_data() {
hdiutil create -srcfolder "${DMG_SOURCE}" \ hdiutil create -srcfolder "${DMG_SOURCE}" \
-format "${DMG_TEMPLATE_FORMAT}" -layout "${layout}" \ -format "${DMG_TEMPLATE_FORMAT}" -layout "${layout}" \
-volname "${DMG_NAME}" \ -volname "${DMG_NAME}" \
-ov "${OUT_DIR}/${DMG_NAME}" "${OUT_DIR}/${DMG_NAME}"
done done
# Convert each template into the different compression format. # Convert each template into the different compression format.
...@@ -80,5 +86,5 @@ generate_test_data() { ...@@ -80,5 +86,5 @@ generate_test_data() {
rm -rf "${DMG_SOURCE}" rm -rf "${DMG_SOURCE}"
} }
# Silence any log output. # Silence any stdout, but keep stderr.
generate_test_data &> /dev/null generate_test_data > /dev/null
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# This script is used to generate an HFS file system with several types of # This script is used to generate an HFS file system with several types of
# files of different sizes. # files of different sizes.
set -e set -eu
FILESYSTEM_TYPE="$1" FILESYSTEM_TYPE="$1"
RAMDISK_SIZE="$2" RAMDISK_SIZE="$2"
...@@ -46,7 +46,7 @@ pushd third ...@@ -46,7 +46,7 @@ pushd third
pushd fourth pushd fourth
pushd fifth pushd fifth
dd if=/dev/random of=random bs=1 count=768 dd if=/dev/random of=random bs=1 count=768 &> /dev/null
popd # fourth popd # fourth
...@@ -75,5 +75,5 @@ popd # Original PWD ...@@ -75,5 +75,5 @@ popd # Original PWD
# Unmount the volume, copy the raw device to a file, and then destroy it. # Unmount the volume, copy the raw device to a file, and then destroy it.
diskutil unmount ${RAMDISK_VOLUME} diskutil unmount ${RAMDISK_VOLUME}
dd if=${RAMDISK_VOLUME} of="${OUT_FILE}" dd if=${RAMDISK_VOLUME} of="${OUT_FILE}" &> /dev/null
diskutil eject ${RAMDISK_VOLUME} diskutil eject ${RAMDISK_VOLUME}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment