PageRenderTime 1058ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/test/compare_transform.sh

https://gitlab.com/0072016/Facebook-Sdk
Shell | 62 lines | 58 code | 3 blank | 1 comment | 7 complexity | 712c5337a4ea872a60fc3221c30ab107 MD5 | raw file
  1. #!/bin/bash
  2. set -o pipefail
  3. INPUT=$1
  4. REDEXOUT=$2
  5. TEMPDIR=`mktemp -d 2>/dev/null || mktemp -d -t 'extractdexdump'`
  6. OUTA=$TEMPDIR/alpha.filt.dexdump
  7. OUTB=$TEMPDIR/beta.filt.dexdump
  8. OUTDIFF=$TEMPDIR/diff
  9. if [ ! -f $INPUT ]; then
  10. echo "No such file $INPUT, bailing"
  11. exit 1;
  12. fi
  13. DEXDUMP=
  14. if [[ "$INPUT" =~ dex$ ]]; then
  15. DEXDUMP="dexdump -d"
  16. elif [[ "$INPUT" =~ apk$ ]]; then
  17. ROOT=$((git rev-parse --show-toplevel || hg root) 2>/dev/null)
  18. DEXDUMP="$ROOT/fbandroid/scripts/ordering/extractdexdump"
  19. if [ ! -f $DEXDUMP ]; then
  20. DEXDUMP="$ROOT/scripts/ordering/extractdexdump"
  21. fi
  22. else
  23. echo "You must specify a dex or apk file as input\"$INPUT\"."
  24. exit 2;
  25. fi
  26. export LC_ALL=C
  27. $DEXDUMP $INPUT | \
  28. sed 's/^Processing .*dex//' | \
  29. sed 's/^Opened .*dex//' | \
  30. sed 's/^ source_file_idx : [0-9]* / source_file_idx : /' | \
  31. sed 's/^.*|/|/' | \
  32. sed 's/|\[[0-9a-f]*\]/|\[\]/' | \
  33. sed 's/type@[0-9a-f]*/type@/' | \
  34. sed 's/string@[0-9a-f]*/string@/' | \
  35. sed 's/method@[0-9a-f]*/method@/' | \
  36. sed 's/field@[0-9a-f]*/field@/' | \
  37. sed 's/^|[0-9a-f]*:/|:/' \
  38. > $OUTA
  39. $DEXDUMP $REDEXOUT | \
  40. sed 's/^Processing .*dex//' | \
  41. sed 's/^Opened .*dex//' | \
  42. sed 's/^ source_file_idx : [0-9]* / source_file_idx : /' | \
  43. sed 's/^.*|/|/' | \
  44. sed 's/|\[[0-9a-f]*\]/|\[\]/' | \
  45. sed 's/type@[0-9a-f]*/type@/' | \
  46. sed 's/string@[0-9a-f]*/string@/' | \
  47. sed 's/method@[0-9a-f]*/method@/' | \
  48. sed 's/field@[0-9a-f]*/field@/' | \
  49. sed 's/^|[0-9a-f]*:/|:/' \
  50. > $OUTB
  51. diff --speed-large-files -u $OUTA $OUTB | tee $OUTDIFF
  52. if [ $? == 0 ]; then
  53. echo "The dexes are equivalent"
  54. exit 0;
  55. else
  56. echo "FAILURE, the dexes have a significant difference"
  57. echo "The differences are recorded in $OUTDIFF"
  58. exit 1;
  59. fi