test_sha512sum.in 836 B

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