toolkit/crashreporter/google-breakpad/android/test-shell.sh

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rwxr-xr-x

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 #!/bin/sh
michael@0 2 #
michael@0 3 # Copyright (c) 2012 Google Inc.
michael@0 4 # All rights reserved.
michael@0 5 #
michael@0 6 # Redistribution and use in source and binary forms, with or without
michael@0 7 # modification, are permitted provided that the following conditions are
michael@0 8 # met:
michael@0 9 #
michael@0 10 # * Redistributions of source code must retain the above copyright
michael@0 11 # notice, this list of conditions and the following disclaimer.
michael@0 12 # * Redistributions in binary form must reproduce the above
michael@0 13 # copyright notice, this list of conditions and the following disclaimer
michael@0 14 # in the documentation and/or other materials provided with the
michael@0 15 # distribution.
michael@0 16 # * Neither the name of Google Inc. nor the names of its
michael@0 17 # contributors may be used to endorse or promote products derived from
michael@0 18 # this software without specific prior written permission.
michael@0 19 #
michael@0 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 31
michael@0 32 # A special shell wrapper that can be used to run the Google Breakpad unit
michael@0 33 # tests on a connected Android device.
michael@0 34 #
michael@0 35 # This is designed to be called from the Makefile during 'make check'
michael@0 36 #
michael@0 37
michael@0 38 PROGDIR=$(dirname "$0")
michael@0 39 PROGNAME=$(basename "$0")
michael@0 40 . $PROGDIR/common-functions.sh
michael@0 41
michael@0 42 # Extract test program name first.
michael@0 43 TEST_PROGRAM=$1
michael@0 44 shift
michael@0 45
michael@0 46 if [ -z "$TEST_PROGRAM" ]; then
michael@0 47 panic "No test program/script name on the command-line!"
michael@0 48 fi
michael@0 49
michael@0 50 if [ ! -f "$TEST_PROGRAM" ]; then
michael@0 51 panic "Can't find test program/script: $TEST_PROGRAM"
michael@0 52 fi
michael@0 53
michael@0 54 # Create test directory on the device
michael@0 55 TEST_DIR=/data/local/tmp/test-google-breakpad
michael@0 56 adb_shell mkdir "$TEST_DIR" || panic "Can't create test directory on device"
michael@0 57
michael@0 58 # Ensure that it is always removed when the script exits.
michael@0 59 clean_test_dir () {
michael@0 60 # Don't care about success/failure, use '$ADB shell' directly.
michael@0 61 adb_shell rm -r "$TEST_DIR"
michael@0 62 }
michael@0 63
michael@0 64 atexit clean_test_dir
michael@0 65
michael@0 66 TEST_PROGRAM_NAME=$(basename "$TEST_PROGRAM")
michael@0 67 TEST_PROGRAM_DIR=$(dirname "$TEST_PROGRAM")
michael@0 68
michael@0 69 # Handle special case(s) here.
michael@0 70 DATA_FILES=
michael@0 71 case $TEST_PROGRAM_NAME in
michael@0 72 linux_client_unittest)
michael@0 73 # linux_client_unittest will call another executable at runtime, ensure
michael@0 74 # it is installed too.
michael@0 75 adb_install "$TEST_PROGRAM_DIR/linux_dumper_unittest_helper" "$TEST_DIR"
michael@0 76 # linux_client_unittest loads a shared library at runtime, ensure it is
michael@0 77 # installed too.
michael@0 78 adb_install "$TEST_PROGRAM_DIR/linux_client_unittest_shlib" "$TEST_DIR"
michael@0 79 ;;
michael@0 80 basic_source_line_resolver_unittest)
michael@0 81 DATA_FILES="module1.out \
michael@0 82 module2.out \
michael@0 83 module3_bad.out \
michael@0 84 module4_bad.out"
michael@0 85 ;;
michael@0 86 exploitability_unittest)
michael@0 87 DATA_FILES="scii_read_av.dmp \
michael@0 88 ascii_read_av_block_write.dmp \
michael@0 89 ascii_read_av_clobber_write.dmp \
michael@0 90 ascii_read_av_conditional.dmp \
michael@0 91 ascii_read_av_non_null.dmp \
michael@0 92 ascii_read_av_then_jmp.dmp \
michael@0 93 ascii_read_av_xchg_write.dmp \
michael@0 94 ascii_write_av.dmp \
michael@0 95 ascii_write_av_arg_to_call.dmp \
michael@0 96 exec_av_on_stack.dmp \
michael@0 97 null_read_av.dmp \
michael@0 98 null_write_av.dmp \
michael@0 99 read_av.dmp \
michael@0 100 null_read_av.dmp \
michael@0 101 write_av_non_null.dmp"
michael@0 102 ;;
michael@0 103 fast_source_line_resolver_unittest)
michael@0 104 DATA_FILES="module0.out \
michael@0 105 module1.out \
michael@0 106 module2.out \
michael@0 107 module3_bad.out \
michael@0 108 module4_bad.out"
michael@0 109 ;;
michael@0 110 minidump_processor_unittest|minidump_unittest)
michael@0 111 DATA_FILES="src/processor/testdata/minidump2.dmp"
michael@0 112 ;;
michael@0 113 esac
michael@0 114
michael@0 115 # Install the data files, their path is relative to the environment
michael@0 116 # variable 'srcdir'
michael@0 117 for FILE in $DATA_FILES; do
michael@0 118 FILEDIR=src/processor/testdata/$(dirname "$FILE")
michael@0 119 adb_shell mkdir -p "$TEST_DIR/$FILEDIR"
michael@0 120 adb_install "${srcdir:-.}/$FILE" "$TEST_DIR"/"$FILE"
michael@0 121 done
michael@0 122
michael@0 123 # Copy test program to device
michael@0 124 adb_install "$TEST_PROGRAM" "$TEST_DIR"
michael@0 125
michael@0 126 # Run it
michael@0 127 adb_shell "cd $TEST_DIR && LD_LIBRARY_PATH=. ./$TEST_PROGRAM_NAME $@"
michael@0 128
michael@0 129 # Note: exiting here will call cleanup_exit which will remove the temporary
michael@0 130 # files from the device.

mercurial