michael@0: #!/bin/sh michael@0: # michael@0: # Copyright (c) 2012 Google Inc. michael@0: # All rights reserved. michael@0: # michael@0: # Redistribution and use in source and binary forms, with or without michael@0: # modification, are permitted provided that the following conditions are michael@0: # met: michael@0: # michael@0: # * Redistributions of source code must retain the above copyright michael@0: # notice, this list of conditions and the following disclaimer. michael@0: # * Redistributions in binary form must reproduce the above michael@0: # copyright notice, this list of conditions and the following disclaimer michael@0: # in the documentation and/or other materials provided with the michael@0: # distribution. michael@0: # * Neither the name of Google Inc. nor the names of its michael@0: # contributors may be used to endorse or promote products derived from michael@0: # this software without specific prior written permission. michael@0: # michael@0: # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT michael@0: # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@0: # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@0: # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, michael@0: # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY michael@0: # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE michael@0: # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: michael@0: # A special shell wrapper that can be used to run the Google Breakpad unit michael@0: # tests on a connected Android device. michael@0: # michael@0: # This is designed to be called from the Makefile during 'make check' michael@0: # michael@0: michael@0: PROGDIR=$(dirname "$0") michael@0: PROGNAME=$(basename "$0") michael@0: . $PROGDIR/common-functions.sh michael@0: michael@0: # Extract test program name first. michael@0: TEST_PROGRAM=$1 michael@0: shift michael@0: michael@0: if [ -z "$TEST_PROGRAM" ]; then michael@0: panic "No test program/script name on the command-line!" michael@0: fi michael@0: michael@0: if [ ! -f "$TEST_PROGRAM" ]; then michael@0: panic "Can't find test program/script: $TEST_PROGRAM" michael@0: fi michael@0: michael@0: # Create test directory on the device michael@0: TEST_DIR=/data/local/tmp/test-google-breakpad michael@0: adb_shell mkdir "$TEST_DIR" || panic "Can't create test directory on device" michael@0: michael@0: # Ensure that it is always removed when the script exits. michael@0: clean_test_dir () { michael@0: # Don't care about success/failure, use '$ADB shell' directly. michael@0: adb_shell rm -r "$TEST_DIR" michael@0: } michael@0: michael@0: atexit clean_test_dir michael@0: michael@0: TEST_PROGRAM_NAME=$(basename "$TEST_PROGRAM") michael@0: TEST_PROGRAM_DIR=$(dirname "$TEST_PROGRAM") michael@0: michael@0: # Handle special case(s) here. michael@0: DATA_FILES= michael@0: case $TEST_PROGRAM_NAME in michael@0: linux_client_unittest) michael@0: # linux_client_unittest will call another executable at runtime, ensure michael@0: # it is installed too. michael@0: adb_install "$TEST_PROGRAM_DIR/linux_dumper_unittest_helper" "$TEST_DIR" michael@0: # linux_client_unittest loads a shared library at runtime, ensure it is michael@0: # installed too. michael@0: adb_install "$TEST_PROGRAM_DIR/linux_client_unittest_shlib" "$TEST_DIR" michael@0: ;; michael@0: basic_source_line_resolver_unittest) michael@0: DATA_FILES="module1.out \ michael@0: module2.out \ michael@0: module3_bad.out \ michael@0: module4_bad.out" michael@0: ;; michael@0: exploitability_unittest) michael@0: DATA_FILES="scii_read_av.dmp \ michael@0: ascii_read_av_block_write.dmp \ michael@0: ascii_read_av_clobber_write.dmp \ michael@0: ascii_read_av_conditional.dmp \ michael@0: ascii_read_av_non_null.dmp \ michael@0: ascii_read_av_then_jmp.dmp \ michael@0: ascii_read_av_xchg_write.dmp \ michael@0: ascii_write_av.dmp \ michael@0: ascii_write_av_arg_to_call.dmp \ michael@0: exec_av_on_stack.dmp \ michael@0: null_read_av.dmp \ michael@0: null_write_av.dmp \ michael@0: read_av.dmp \ michael@0: null_read_av.dmp \ michael@0: write_av_non_null.dmp" michael@0: ;; michael@0: fast_source_line_resolver_unittest) michael@0: DATA_FILES="module0.out \ michael@0: module1.out \ michael@0: module2.out \ michael@0: module3_bad.out \ michael@0: module4_bad.out" michael@0: ;; michael@0: minidump_processor_unittest|minidump_unittest) michael@0: DATA_FILES="src/processor/testdata/minidump2.dmp" michael@0: ;; michael@0: esac michael@0: michael@0: # Install the data files, their path is relative to the environment michael@0: # variable 'srcdir' michael@0: for FILE in $DATA_FILES; do michael@0: FILEDIR=src/processor/testdata/$(dirname "$FILE") michael@0: adb_shell mkdir -p "$TEST_DIR/$FILEDIR" michael@0: adb_install "${srcdir:-.}/$FILE" "$TEST_DIR"/"$FILE" michael@0: done michael@0: michael@0: # Copy test program to device michael@0: adb_install "$TEST_PROGRAM" "$TEST_DIR" michael@0: michael@0: # Run it michael@0: adb_shell "cd $TEST_DIR && LD_LIBRARY_PATH=. ./$TEST_PROGRAM_NAME $@" michael@0: michael@0: # Note: exiting here will call cleanup_exit which will remove the temporary michael@0: # files from the device.