1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/android/test-shell.sh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,130 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# Copyright (c) 2012 Google Inc. 1.7 +# All rights reserved. 1.8 +# 1.9 +# Redistribution and use in source and binary forms, with or without 1.10 +# modification, are permitted provided that the following conditions are 1.11 +# met: 1.12 +# 1.13 +# * Redistributions of source code must retain the above copyright 1.14 +# notice, this list of conditions and the following disclaimer. 1.15 +# * Redistributions in binary form must reproduce the above 1.16 +# copyright notice, this list of conditions and the following disclaimer 1.17 +# in the documentation and/or other materials provided with the 1.18 +# distribution. 1.19 +# * Neither the name of Google Inc. nor the names of its 1.20 +# contributors may be used to endorse or promote products derived from 1.21 +# this software without specific prior written permission. 1.22 +# 1.23 +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.24 +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.25 +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.26 +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.27 +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.28 +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.29 +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.30 +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.31 +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.32 +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.33 +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.34 + 1.35 +# A special shell wrapper that can be used to run the Google Breakpad unit 1.36 +# tests on a connected Android device. 1.37 +# 1.38 +# This is designed to be called from the Makefile during 'make check' 1.39 +# 1.40 + 1.41 +PROGDIR=$(dirname "$0") 1.42 +PROGNAME=$(basename "$0") 1.43 +. $PROGDIR/common-functions.sh 1.44 + 1.45 +# Extract test program name first. 1.46 +TEST_PROGRAM=$1 1.47 +shift 1.48 + 1.49 +if [ -z "$TEST_PROGRAM" ]; then 1.50 + panic "No test program/script name on the command-line!" 1.51 +fi 1.52 + 1.53 +if [ ! -f "$TEST_PROGRAM" ]; then 1.54 + panic "Can't find test program/script: $TEST_PROGRAM" 1.55 +fi 1.56 + 1.57 +# Create test directory on the device 1.58 +TEST_DIR=/data/local/tmp/test-google-breakpad 1.59 +adb_shell mkdir "$TEST_DIR" || panic "Can't create test directory on device" 1.60 + 1.61 +# Ensure that it is always removed when the script exits. 1.62 +clean_test_dir () { 1.63 + # Don't care about success/failure, use '$ADB shell' directly. 1.64 + adb_shell rm -r "$TEST_DIR" 1.65 +} 1.66 + 1.67 +atexit clean_test_dir 1.68 + 1.69 +TEST_PROGRAM_NAME=$(basename "$TEST_PROGRAM") 1.70 +TEST_PROGRAM_DIR=$(dirname "$TEST_PROGRAM") 1.71 + 1.72 +# Handle special case(s) here. 1.73 +DATA_FILES= 1.74 +case $TEST_PROGRAM_NAME in 1.75 + linux_client_unittest) 1.76 + # linux_client_unittest will call another executable at runtime, ensure 1.77 + # it is installed too. 1.78 + adb_install "$TEST_PROGRAM_DIR/linux_dumper_unittest_helper" "$TEST_DIR" 1.79 + # linux_client_unittest loads a shared library at runtime, ensure it is 1.80 + # installed too. 1.81 + adb_install "$TEST_PROGRAM_DIR/linux_client_unittest_shlib" "$TEST_DIR" 1.82 + ;; 1.83 + basic_source_line_resolver_unittest) 1.84 + DATA_FILES="module1.out \ 1.85 + module2.out \ 1.86 + module3_bad.out \ 1.87 + module4_bad.out" 1.88 + ;; 1.89 + exploitability_unittest) 1.90 + DATA_FILES="scii_read_av.dmp \ 1.91 + ascii_read_av_block_write.dmp \ 1.92 + ascii_read_av_clobber_write.dmp \ 1.93 + ascii_read_av_conditional.dmp \ 1.94 + ascii_read_av_non_null.dmp \ 1.95 + ascii_read_av_then_jmp.dmp \ 1.96 + ascii_read_av_xchg_write.dmp \ 1.97 + ascii_write_av.dmp \ 1.98 + ascii_write_av_arg_to_call.dmp \ 1.99 + exec_av_on_stack.dmp \ 1.100 + null_read_av.dmp \ 1.101 + null_write_av.dmp \ 1.102 + read_av.dmp \ 1.103 + null_read_av.dmp \ 1.104 + write_av_non_null.dmp" 1.105 + ;; 1.106 + fast_source_line_resolver_unittest) 1.107 + DATA_FILES="module0.out \ 1.108 + module1.out \ 1.109 + module2.out \ 1.110 + module3_bad.out \ 1.111 + module4_bad.out" 1.112 + ;; 1.113 + minidump_processor_unittest|minidump_unittest) 1.114 + DATA_FILES="src/processor/testdata/minidump2.dmp" 1.115 + ;; 1.116 +esac 1.117 + 1.118 +# Install the data files, their path is relative to the environment 1.119 +# variable 'srcdir' 1.120 +for FILE in $DATA_FILES; do 1.121 + FILEDIR=src/processor/testdata/$(dirname "$FILE") 1.122 + adb_shell mkdir -p "$TEST_DIR/$FILEDIR" 1.123 + adb_install "${srcdir:-.}/$FILE" "$TEST_DIR"/"$FILE" 1.124 +done 1.125 + 1.126 +# Copy test program to device 1.127 +adb_install "$TEST_PROGRAM" "$TEST_DIR" 1.128 + 1.129 +# Run it 1.130 +adb_shell "cd $TEST_DIR && LD_LIBRARY_PATH=. ./$TEST_PROGRAM_NAME $@" 1.131 + 1.132 +# Note: exiting here will call cleanup_exit which will remove the temporary 1.133 +# files from the device.