test_sha512sum.in 846 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #! @BUILD_SHEBANG@
  2. set -e
  3. # create a randome file
  4. file="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
  5. cat >$file <<EOF
  6. hello world!
  7. EOF
  8. . "@builddir@/grub-core/modinfo.sh"
  9. if [ x"${grub_modinfo_platform}" = xemu ]; then
  10. grub_file="(host)$file"
  11. else
  12. grub_file="/boot/grub/file"
  13. fi
  14. outfile1="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
  15. @builddir@/grub-shell --files=/boot/grub/file=$file >$outfile1 <<EOF
  16. sha512sum $grub_file
  17. EOF
  18. outfile2="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
  19. sha512sum $file >$outfile2
  20. SHA1=`cat $outfile1 | tr -d '\n' | cut -f1 -d\ `
  21. SHA2=`cat $outfile2 | cut -f1 -d\ `
  22. if test "$SHA1" = "$SHA2"; then
  23. rm -f ${outfile1} ${outfile2}
  24. exit 0
  25. else
  26. echo "GRUB sha512sum output did not match sha512sum output."
  27. echo "See diff -u ${outfile1} ${outfile2}"
  28. exit 1
  29. fi