mount.tests 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/bin/sh
  2. # Copyright 2007 by Denys Vlasenko <vda.linux@googlemail.com>
  3. # Licensed under GPLv2, see file LICENSE in this source tree.
  4. . ./testing.sh
  5. test -f "$bindir/.config" && . "$bindir/.config"
  6. test "`id -u`" = 0 || {
  7. echo "SKIPPED: mount (must be root to test this)"
  8. exit 0
  9. }
  10. if test x"$CONFIG_MKFS_MINIX" != x"y" \
  11. || test x"$CONFIG_FEATURE_MINIX2" != x"y" \
  12. || test x"$CONFIG_FEATURE_MOUNT_LOOP" != x"y" \
  13. || test x"$CONFIG_FEATURE_MOUNT_FLAGS" != x"y" \
  14. || test x"$CONFIG_FEATURE_DEVFS" = x"y" \
  15. ; then
  16. echo "SKIPPED: mount"
  17. exit 0
  18. fi
  19. testdir="$PWD/mount.testdir"
  20. dd if=/dev/zero of=mount.image1m count=1 bs=1M 2>/dev/null || { echo "dd error"; exit 1; }
  21. mkfs.minix -v mount.image1m >/dev/null 2>&1 || { echo "mkfs.minix error"; exit 1; }
  22. modprobe minix 2>/dev/null
  23. mkdir "$testdir" 2>/dev/null
  24. umount -d "$testdir" 2>/dev/null
  25. # testing "test name" "command" "expected result" "file input" "stdin"
  26. # file input will be file called "input"
  27. # test can create a file "actual" instead of writing to stdout
  28. testing "mount -o remount,mand" \
  29. "mount -o loop mount.image1m $testdir "\
  30. "&& grep -Fc $testdir </proc/mounts "\
  31. "&& mount -o remount,mand $testdir "\
  32. "&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'"\
  33. "|| grep -F $testdir </proc/mounts" \
  34. "1\n""1\n" \
  35. "" ""
  36. umount -d "$testdir"
  37. rmdir "$testdir"
  38. rm mount.image1m
  39. # Bug: mount.shared1 directory shows no files (has to show files a and b)
  40. optional FEATURE_LS_RECURSIVE FEATURE_LS_SORTFILES
  41. testing "mount bind+rshared" "\
  42. mkdir -p mount.dir mount.shared1 mount.shared2
  43. touch mount.dir/a mount.dir/b
  44. mount --bind mount.shared1 mount.shared1 2>&1
  45. mount --make-rshared mount.shared1 2>&1
  46. mount --bind mount.shared2 mount.shared2 2>&1
  47. mount --make-rshared mount.shared2 2>&1
  48. mount --bind mount.shared2 mount.shared1 2>&1
  49. mount --bind mount.dir mount.shared2 2>&1
  50. ls -R mount.dir mount.shared1 mount.shared2 2>&1
  51. umount mount.dir mount.shared1 mount.shared2 2>/dev/null
  52. umount mount.dir mount.shared1 mount.shared2 2>/dev/null
  53. umount mount.dir mount.shared1 mount.shared2 2>/dev/null
  54. rm -f mount.dir/a mount.dir/b mount.dir/c
  55. rmdir mount.dir mount.shared1 mount.shared2
  56. " \
  57. "\
  58. mount.dir:
  59. a
  60. b
  61. mount.shared1:
  62. a
  63. b
  64. mount.shared2:
  65. a
  66. b
  67. " \
  68. "" ""
  69. SKIP=
  70. testing "mount RO loop" "\
  71. exec 2>&1
  72. umount -d mount.dir 2>/dev/null
  73. rmdir mount.dir 2>/dev/null
  74. mkdir -p mount.dir
  75. (
  76. cd mount.dir || { echo 'cd error'; exit 1; }
  77. mkdir z1 z2 || { echo 'mkdir error'; exit 1; }
  78. mount -t tmpfs tmpfs z1 || { echo 'mount tmpfs error'; exit 1; }
  79. dd if=/dev/zero of=z1/e2img count=10 bs=1M 2>/dev/null || { echo 'dd error'; exit 1; }
  80. mke2fs -F z1/e2img 2>/dev/null >&2 || { echo 'mke2fs error'; exit 1; }
  81. mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; exit 1; }
  82. mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; }
  83. )
  84. umount -d mount.dir/z2
  85. ##losetup -d /dev/loop*
  86. umount -d mount.dir/z1
  87. rm -rf mount.dir
  88. echo DONE
  89. " \
  90. "DONE\n" "" ""
  91. exit $FAILCOUNT