blob: f5d8cd65ac994d99abe420a5b63bdf6fbda2d0a0 [file] [log] [blame]
Aart Bik69ae54a2015-07-01 14:52:26 -07001#!/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.
19prog="$0"
20while [ -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
29done
30oldwd=`pwd`
31progdir=`dirname "${prog}"`
32cd "${progdir}"
33progdir=`pwd`
34prog="${progdir}"/`basename "${prog}"`
35
36# Set up a temp directory for output.
37tmpdir=/tmp/test-$$
38mkdir ${tmpdir}
39
40# Set up binary and flags to test.
41DEXD="${ANDROID_HOST_OUT}/bin/dexdump2"
42FLAGS1="-dfh"
43FLAGS2="-l xml"
44
45# Run the tests.
46passed=0
47failed=0
48for i in *.dex; do
49 echo $i
50 basenm=`basename "${i}" .dex`
51 txtfile=${basenm}.txt
52 xmlfile=${basenm}.xml
53 genfile1=${tmpdir}/${txtfile}
54 genfile2=${tmpdir}/${xmlfile}
55 ${DEXD} ${FLAGS1} ${i} > ${genfile1}
56 cmp ${txtfile} ${genfile1}
57 if [ "$?" = "0" ]; then
58 ((passed += 1))
59 else
60 ((failed += 1))
61 echo failed: ${i}
62 fi
63 ${DEXD} ${FLAGS2} ${i} > ${genfile2}
64 cmp ${xmlfile} ${genfile2}
65 if [ "$?" = "0" ]; then
66 ((passed += 1))
67 else
68 ((failed += 1))
69 echo failed: ${i}
70 fi
71done
72
73# Report results.
74echo
75echo "passed: ${passed} test(s)"
76echo "failed: ${failed} test(s)"
77echo
78
79# Clean up, cd back to original dir.
80#rm -rf ${tmpdir}
81cd ${oldwd}
82
83# Return status.
84if [ "${failed}" != "0" ]; then
85 echo failed
86 exit 1
87fi
88exit 0
89