grub_cmd_test.in 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #! @BUILD_SHEBANG@
  2. set -e
  3. # create a randome file
  4. empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
  5. non_empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
  6. cat >$non_empty <<EOF
  7. hello world!
  8. EOF
  9. . "@builddir@/grub-core/modinfo.sh"
  10. if [ x"${grub_modinfo_platform}" = xemu ]; then
  11. grub_empty="(host)$empty"
  12. grub_non_empty="(host)$non_empty"
  13. grub_dir="(host)${TMPDIR:-/tmp}"
  14. else
  15. grub_empty="/boot/empty"
  16. grub_non_empty="/boot/non_empty"
  17. grub_dir="/boot/grub"
  18. fi
  19. outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 99
  20. @builddir@/grub-shell --files=$grub_empty=$empty --files=$grub_non_empty=$non_empty>$outfile <<EOF
  21. if ! test -f $grub_empty; then
  22. echo FAIL1
  23. fi
  24. if ! test -e $grub_empty; then
  25. echo FAIL2
  26. fi
  27. if test -d $grub_empty; then
  28. echo FAIL3
  29. fi
  30. if ! test -d $grub_dir; then
  31. echo FAIL4
  32. fi
  33. if test -s $grub_empty; then
  34. echo FAIL5
  35. fi
  36. if ! test -s $grub_non_empty; then
  37. echo FAIL6
  38. fi
  39. if test -f $grub_empty -a foo = bar; then
  40. echo FAIL7
  41. fi
  42. if test -e $grub_empty -a foo = bar; then
  43. echo FAIL8
  44. fi
  45. if test -s $grub_non_empty -a foo = bar; then
  46. echo FAIL9
  47. fi
  48. if test -d $grub_dir -a foo = bar; then
  49. echo FAIL10
  50. fi
  51. EOF
  52. rm -f "$empty" "$non_empty"
  53. if grep FAIL "$outfile" > /dev/null 2>&1; then
  54. echo "GRUB test command file tests failed."
  55. cat "$outfile"
  56. exit 1
  57. else
  58. rm -f "${outfile}"
  59. exit 0
  60. fi