test_load_fmap.sh 909 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash -eux
  2. # Copyright 2014 The Chromium OS Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. me=${0##*/}
  6. TMP="$me.tmp"
  7. # Work in scratch directory
  8. cd "$OUTDIR"
  9. IN=${SCRIPTDIR}/data/bios_link_mp.bin
  10. BIOS=${TMP}.bios.bin
  11. cp ${IN} ${BIOS}
  12. AREAS="RW_SECTION_A VBLOCK_B BOOT_STUB"
  13. # Extract good blobs first
  14. ${FUTILITY} dump_fmap -x ${BIOS} ${AREAS}
  15. # Save the good blobs, make same-size random blobs, create command
  16. CMDS=""
  17. for a in ${AREAS}; do
  18. size=$(stat -c '%s' $a)
  19. mv $a $a.good
  20. dd if=/dev/urandom of=$a.rand bs=$size count=1
  21. CMDS="$CMDS $a:$a.rand"
  22. done
  23. # Poke the new blobs in
  24. ${FUTILITY} load_fmap ${BIOS} ${CMDS}
  25. # Pull them back out and see if they match
  26. ${FUTILITY} dump_fmap -x ${BIOS} ${AREAS}
  27. for a in ${AREAS}; do
  28. cmp $a $a.rand
  29. done
  30. # cleanup
  31. rm -f ${TMP}* ${AREAS} *.rand *.good
  32. exit 0