Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / data / safe_browsing / dmg / generate_test_data.sh
blob8bf21d5e02eee40f720a4f5d6e01c601f3db8f2f
1 #!/bin/sh
3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 THIS_DIR=$(dirname "$0")
9 OUT_DIR="$1"
11 if [[ ! "$1" ]]; then
12 echo "Usage: $(basename "$0") [output_dir]"
13 exit 1
16 if [[ -e "$1" && ! -d "$1" ]]; then
17 echo "Output directory \`$1' exists but is not a directory."
18 exit 1
20 if [[ ! -d "$1" ]]; then
21 mkdir -p "$1"
24 generate_test_data() {
25 # HFS Raw Images #############################################################
27 MAKE_HFS="${THIS_DIR}/make_hfs.sh"
28 "${MAKE_HFS}" HFS+ 1024 "${OUT_DIR}/hfs_plus.img"
29 "${MAKE_HFS}" hfsx $((8 * 1024)) "${OUT_DIR}/hfsx_case_sensitive.img"
31 # DMG Files ##################################################################
33 DMG_SOURCE=$(mktemp -d -t dmg_generate_test_data.XXXXXX)
34 echo "This is a test DMG file. It has been generated from " \
35 "chrome/test/data/safe_browsing/dmg/generate_test_data.sh" \
36 > "${DMG_SOURCE}/README.txt"
37 dd if=/dev/urandom of="${DMG_SOURCE}/random" bs=512 count=4
39 DMG_FORMATS="UDRW UDRO UDCO UDZO UDBZ UFBI UDRo UDCo UDTO UDSP"
40 DMG_LAYOUTS="SPUD GPTSPUD NONE"
41 for format in ${DMG_FORMATS}; do
42 for layout in ${DMG_LAYOUTS}; do
43 DMG_NAME="dmg_${format}_${layout}"
44 hdiutil create -srcfolder "${DMG_SOURCE}" \
45 -format "${format}" -layout "${layout}" \
46 -volname "${DMG_NAME}" \
47 -ov \
48 "${OUT_DIR}/${DMG_NAME}"
49 done
50 done
52 rm -rf "${DMG_SOURCE}"
54 # DMG With Mach-O ############################################################
56 mkdir "${DMG_SOURCE}"
58 FAKE_APP="${DMG_SOURCE}/Foo.app/Contents/MacOS/"
59 mkdir -p "${FAKE_APP}"
60 cp "${THIS_DIR}/../mach_o/executablefat" "${FAKE_APP}"
61 touch "${FAKE_APP}/../Info.plist"
63 mkdir "${DMG_SOURCE}/.hidden"
64 cp "${THIS_DIR}/../mach_o/lib64.dylib" "${DMG_SOURCE}/.hidden/"
66 hdiutil create -srcfolder "${DMG_SOURCE}" \
67 -format UDZO -layout SPUD -volname "Mach-O in DMG" -ov \
68 "${OUT_DIR}/mach_o_in_dmg"
70 rm -rf "${DMG_SOURCE}"
73 # Silence any log output.
74 generate_test_data &> /dev/null