Aart Bik | 69ae54a | 2015-07-01 14:52:26 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2015 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Set up prog to be the path of this script, including following symlinks, |
| 18 | # and set up progdir to be the fully-qualified pathname of its directory. |
| 19 | prog="$0" |
| 20 | while [ -h "${prog}" ]; do |
| 21 | newProg=`/bin/ls -ld "${prog}"` |
| 22 | newProg=`expr "${newProg}" : ".* -> \(.*\)$"` |
| 23 | if expr "x${newProg}" : 'x/' >/dev/null; then |
| 24 | prog="${newProg}" |
| 25 | else |
| 26 | progdir=`dirname "${prog}"` |
| 27 | prog="${progdir}/${newProg}" |
| 28 | fi |
| 29 | done |
| 30 | oldwd=`pwd` |
| 31 | progdir=`dirname "${prog}"` |
| 32 | cd "${progdir}" |
| 33 | progdir=`pwd` |
| 34 | prog="${progdir}"/`basename "${prog}"` |
| 35 | |
| 36 | # Set up a temp directory for output. |
| 37 | tmpdir=/tmp/test-$$ |
| 38 | mkdir ${tmpdir} |
| 39 | |
Aart Bik | 3e40f4a | 2015-07-07 17:09:41 -0700 | [diff] [blame] | 40 | # Set up dexdump binary and flags to test. |
Aart Bik | 22c26f5 | 2015-07-08 21:20:13 +0000 | [diff] [blame] | 41 | DEXD="${ANDROID_HOST_OUT}/bin/dexdump2" |
Aart Bik | dce5086 | 2016-06-10 16:04:03 -0700 | [diff] [blame] | 42 | DEXDFLAGS1="-adfh" |
Aart Bik | 3f382ae | 2015-11-13 10:06:01 -0800 | [diff] [blame] | 43 | DEXDFLAGS2="-e -l xml" |
Aart Bik | 3e40f4a | 2015-07-07 17:09:41 -0700 | [diff] [blame] | 44 | |
| 45 | # Set up dexlist binary and flags to test. |
Aart Bik | b1b45be | 2015-08-28 11:09:29 -0700 | [diff] [blame] | 46 | DEXL="${ANDROID_HOST_OUT}/bin/dexlist" |
Aart Bik | 3e40f4a | 2015-07-07 17:09:41 -0700 | [diff] [blame] | 47 | DEXLFLAGS="" |
Aart Bik | 69ae54a | 2015-07-01 14:52:26 -0700 | [diff] [blame] | 48 | |
| 49 | # Run the tests. |
| 50 | passed=0 |
| 51 | failed=0 |
| 52 | for i in *.dex; do |
| 53 | echo $i |
| 54 | basenm=`basename "${i}" .dex` |
| 55 | txtfile=${basenm}.txt |
| 56 | xmlfile=${basenm}.xml |
Aart Bik | 3e40f4a | 2015-07-07 17:09:41 -0700 | [diff] [blame] | 57 | lstfile=${basenm}.lst |
| 58 | gentxtfile=${tmpdir}/${txtfile} |
| 59 | genxmlfile=${tmpdir}/${xmlfile} |
| 60 | genlstfile=${tmpdir}/${lstfile} |
| 61 | ${DEXD} ${DEXDFLAGS1} ${i} > ${gentxtfile} |
| 62 | cmp ${txtfile} ${gentxtfile} |
Aart Bik | 69ae54a | 2015-07-01 14:52:26 -0700 | [diff] [blame] | 63 | if [ "$?" = "0" ]; then |
| 64 | ((passed += 1)) |
| 65 | else |
| 66 | ((failed += 1)) |
| 67 | echo failed: ${i} |
| 68 | fi |
Aart Bik | 3e40f4a | 2015-07-07 17:09:41 -0700 | [diff] [blame] | 69 | ${DEXD} ${DEXDFLAGS2} ${i} > ${genxmlfile} |
| 70 | cmp ${xmlfile} ${genxmlfile} |
| 71 | if [ "$?" = "0" ]; then |
| 72 | ((passed += 1)) |
| 73 | else |
| 74 | ((failed += 1)) |
| 75 | echo failed: ${i} |
| 76 | fi |
| 77 | ${DEXL} ${DEXLFLAGS} ${i} > ${genlstfile} |
| 78 | cmp ${lstfile} ${genlstfile} |
Aart Bik | 69ae54a | 2015-07-01 14:52:26 -0700 | [diff] [blame] | 79 | if [ "$?" = "0" ]; then |
| 80 | ((passed += 1)) |
| 81 | else |
| 82 | ((failed += 1)) |
| 83 | echo failed: ${i} |
| 84 | fi |
| 85 | done |
| 86 | |
| 87 | # Report results. |
| 88 | echo |
| 89 | echo "passed: ${passed} test(s)" |
| 90 | echo "failed: ${failed} test(s)" |
| 91 | echo |
| 92 | |
| 93 | # Clean up, cd back to original dir. |
Aart Bik | 3e40f4a | 2015-07-07 17:09:41 -0700 | [diff] [blame] | 94 | rm -rf ${tmpdir} |
Aart Bik | 69ae54a | 2015-07-01 14:52:26 -0700 | [diff] [blame] | 95 | cd ${oldwd} |
| 96 | |
| 97 | # Return status. |
| 98 | if [ "${failed}" != "0" ]; then |
| 99 | echo failed |
| 100 | exit 1 |
| 101 | fi |
| 102 | exit 0 |
| 103 | |