grub_cmd_test.in 1.3 KB

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