diff options
Diffstat (limited to 'chrome/test/data')
-rwxr-xr-x | chrome/test/data/safe_browsing/dmg/generate_test_data.sh | 33 | ||||
-rwxr-xr-x | chrome/test/data/safe_browsing/dmg/make_hfs.sh | 79 |
2 files changed, 112 insertions, 0 deletions
diff --git a/chrome/test/data/safe_browsing/dmg/generate_test_data.sh b/chrome/test/data/safe_browsing/dmg/generate_test_data.sh new file mode 100755 index 0000000..f538c62 --- /dev/null +++ b/chrome/test/data/safe_browsing/dmg/generate_test_data.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +THIS_DIR=$(dirname "$0") + +OUT_DIR="$1" + +if [[ ! "$1" ]]; then + echo "Usage: $(basename "$0") [output_dir]" + exit 1 +fi + +if [[ -e "$1" && ! -d "$1" ]]; then + echo "Output directory \`$1' exists but is not a directory." + exit 1 +fi +if [[ ! -d "$1" ]]; then + mkdir -p "$1" +fi + +generate_test_data() { + # HFS Raw Images ############################################################# + + MAKE_HFS="${THIS_DIR}/make_hfs.sh" + "${MAKE_HFS}" HFS+ 1024 "${OUT_DIR}/hfs_plus.img" + "${MAKE_HFS}" hfsx $((8 * 1024)) "${OUT_DIR}/hfsx_case_sensitive.img" +} + +# Silence any log output. +generate_test_data &> /dev/null diff --git a/chrome/test/data/safe_browsing/dmg/make_hfs.sh b/chrome/test/data/safe_browsing/dmg/make_hfs.sh new file mode 100755 index 0000000..df08184 --- /dev/null +++ b/chrome/test/data/safe_browsing/dmg/make_hfs.sh @@ -0,0 +1,79 @@ +#!/bin/sh + +# Copyright 2015 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This script is used to generate an HFS file system with several types of +# files of different sizes. + +set -e + +FILESYSTEM_TYPE="$1" +RAMDISK_SIZE="$2" +OUT_FILE="$3" + +VOLUME_NAME="SafeBrowsingDMG" +UNICODE_FILENAME="Tĕsẗ 🐐 " + +if [[ ! $FILESYSTEM_TYPE ]]; then + echo "Need to specify a filesystem type. See \`diskutil listfilesystems'." + exit 1 +fi + +if [[ ! $RAMDISK_SIZE ]]; then + echo "Need to specify a volume size in bytes." + exit 1 +fi + +if [[ ! $OUT_FILE ]]; then + echo "Need to specify a destination filename." + exit 1 +fi + +RAMDISK_VOLUME=$(hdiutil attach -nomount ram://$RAMDISK_SIZE) +diskutil erasevolume "${FILESYSTEM_TYPE}" "${VOLUME_NAME}" ${RAMDISK_VOLUME} + +pushd "/Volumes/${VOLUME_NAME}" + +touch .metadata_never_index + +mkdir -p first/second/third/fourth/fifth + +pushd first +pushd second +pushd third +pushd fourth +pushd fifth + +dd if=/dev/random of=random bs=1 count=768 + +popd # fourth + +touch "Hello World" +touch "hEllo wOrld" # No-op on case-insensitive filesystem. + +popd # third + +ln -s fourth/fifth/random symlink-random + +popd # second + +echo "Poop" > "${UNICODE_FILENAME}" +ditto --hfsCompression "${UNICODE_FILENAME}" goat-output.txt + +popd # first + +ln "second/${UNICODE_FILENAME}" unicode_name + +popd # volume root + +echo "This is a test HFS+ filesystem generated by" \ + "chrome/test/data/safe_browsing/dmg/make_hfs.sh." > README.txt + +popd # Original PWD + +# Unmount the volume, copy the raw device to a file, and then destroy it. +diskutil unmount ${RAMDISK_VOLUME} +dd if=${RAMDISK_VOLUME} of="${OUT_FILE}" +diskutil eject ${RAMDISK_VOLUME} |