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