Dmitriy Ivanov | 775f1e8 | 2014-04-03 16:51:24 -0700 | [diff] [blame] | 1 | # Copyright (C) 2014 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the 'License'); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an 'AS IS' BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Dmitriy Ivanov | b743db5 | 2014-06-04 17:05:54 -0700 | [diff] [blame] | 15 | source $ANDROID_BUILD_TOP/build/envsetup.sh >/dev/null |
Dmitriy Ivanov | 03dc4f2 | 2014-05-27 17:08:20 -0700 | [diff] [blame] | 16 | |
Dmitriy Ivanov | 775f1e8 | 2014-04-03 16:51:24 -0700 | [diff] [blame] | 17 | root_dir=`realpath \`dirname $0\`/../../` |
| 18 | |
| 19 | if [ -z "$ANDROID_SERIAL" ]; then |
| 20 | echo "Please set up ANDORID_SERAL enviroment variable" |
| 21 | exit -1 |
| 22 | fi |
| 23 | |
Dmitriy Ivanov | c891ee6 | 2014-05-23 18:17:26 -0700 | [diff] [blame] | 24 | if [ -z "$1" ]; then |
Dmitriy Ivanov | ddf341e | 2014-10-16 12:31:50 -0700 | [diff] [blame] | 25 | echo "Usage runtest.sh test-name [64]" |
Dmitriy Ivanov | c891ee6 | 2014-05-23 18:17:26 -0700 | [diff] [blame] | 26 | exit -1; |
| 27 | fi |
| 28 | |
| 29 | test_name=$1 |
Dmitriy Ivanov | 03dc4f2 | 2014-05-27 17:08:20 -0700 | [diff] [blame] | 30 | product_out=$(cd $ANDROID_BUILD_TOP;get_build_var PRODUCT_OUT 2>/dev/null) |
Dmitriy Ivanov | ddf341e | 2014-10-16 12:31:50 -0700 | [diff] [blame] | 31 | test_local=$product_out/data/nativetest$2/$test_name/$test_name |
| 32 | test_target=/data/nativetest$2/$test_name/$test_name |
Dmitriy Ivanov | 775f1e8 | 2014-04-03 16:51:24 -0700 | [diff] [blame] | 33 | |
| 34 | cd $root_dir |
| 35 | adb push $test_local $test_target |
| 36 | |
| 37 | logfile_native=$test_name.stdout.log |
| 38 | logfile_valgrind=$test_name.stdout.vlog |
| 39 | |
| 40 | # reference point |
| 41 | echo "Creating reference point log (run without valgrind)..." |
| 42 | adb shell $test_target > $logfile_native |
| 43 | # valgrind run |
| 44 | echo "Running test under valgrind..." |
| 45 | adb shell valgrind $test_target > $logfile_valgrind |
| 46 | |
| 47 | echo "Checking results..." |
Dmitriy Ivanov | ddf341e | 2014-10-16 12:31:50 -0700 | [diff] [blame] | 48 | dos2unix $logfile_native |
| 49 | dos2unix $logfile_valgrind |
| 50 | # TODO: remove last 3 grep -v; they are added to work around linker warning about unsupported DT_FLAGS_1 |
| 51 | diff $logfile_native $logfile_valgrind | grep -v "^> ==" | grep -v -e "^[0-9]" | grep -v "WARNING: linker: Unsupported flags" | grep -v "^> $" | grep -v "^> 0x421==" > $test_name.diff.log |
Dmitriy Ivanov | 775f1e8 | 2014-04-03 16:51:24 -0700 | [diff] [blame] | 52 | |
| 53 | if [ -s $test_name.diff.log ]; then |
| 54 | echo "Test $test_name FAILED, please check the diff below" |
| 55 | cat $test_name.diff.log | sed "s/^< /expected: /" | sed "s/^> /actual : /" |
| 56 | exit -2 |
| 57 | fi |
| 58 | |
| 59 | echo "Test $test_name PASSED" |
| 60 | |