| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Checks that a given assembyl file is decoded identically to objdump. | 6 # Checks that a given assembyl file is decoded identically to objdump. |
| 7 # | 7 # |
| 8 # Usage: | 8 # Usage: |
| 9 # decoder_test_one_file.sh GAS=... OBJDUMP=... DECODER=... ASMFILE=... | 9 # decoder_test_one_file.sh GAS=... OBJDUMP=... DECODER=... ASMFILE=... |
| 10 | 10 |
| 11 # TODO(shcherbina): fix leaking temp files on failed tests |
| 12 |
| 11 set -e | 13 set -e |
| 12 set -u | 14 set -u |
| 13 | 15 |
| 14 # Parse arguments. | 16 # Parse arguments. |
| 15 eval "$@" | 17 eval "$@" |
| 16 | 18 |
| 17 # Sanity check arguments. | 19 # Sanity check arguments. |
| 18 if [[ ! -x "${GAS% *}" || ! -x "${OBJDUMP% *}" || ! -x "${DECODER% *}" ]] ; then | 20 if [[ ! -x "${GAS% *}" || ! -x "${OBJDUMP% *}" || ! -x "${DECODER% *}" ]] ; then |
| 19 echo >&2 "error: GAS or OBJDUMP or DECODER incorrect" | 21 echo >&2 "error: GAS or OBJDUMP or DECODER incorrect" |
| 20 exit 2 | 22 exit 2 |
| 21 fi | 23 fi |
| 22 | 24 |
| 23 if [[ ! -f "$ASMFILE" ]] ; then | 25 if [[ ! -f "$ASMFILE" ]] ; then |
| 24 echo >&2 "error: ASMFILE is not a regular file: $ASMFILE" | 26 echo >&2 "error: ASMFILE is not a regular file: $ASMFILE" |
| 25 exit 3 | 27 exit 3 |
| 26 fi | 28 fi |
| 27 | 29 |
| 28 # Produce an object file, disassemble it in 2 ways and compare results. | 30 # Produce an object file, disassemble it in 2 ways and compare results. |
| 29 $GAS "$ASMFILE" -o "$ASMFILE.o" | 31 $GAS "$ASMFILE" -o "$ASMFILE.o" |
| 30 rm -f "$ASMFILE" | 32 rm -f "$ASMFILE" |
| 31 $DECODER "$ASMFILE.o" > "$ASMFILE.decoder" | 33 $DECODER "$ASMFILE.o" > "$ASMFILE.decoder" |
| 32 # Take objdump output starting at line 8 to skip the unimportant header that | 34 # Take objdump output starting at line 8 to skip the unimportant header that |
| 33 # is not emulated in the decoder test. | 35 # is not emulated in the decoder test. |
| 34 $OBJDUMP -d "$ASMFILE.o" | | 36 $OBJDUMP -d "$ASMFILE.o" | |
| 35 tail -n+8 - | | 37 tail -n+8 - | |
| 36 cmp - "$ASMFILE.decoder" | 38 cmp - "$ASMFILE.decoder" |
| 37 rm -f "$ASMFILE.o" "$ASMFILE.decoder" | 39 rm -f "$ASMFILE.o" "$ASMFILE.decoder" |
| OLD | NEW |