3
0

mount.tests 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. # Without MOUNT_LOOP_CREATE, the test will fail if /dev/loopN's do not exist
  11. if test x"$CONFIG_MKFS_MINIX" != x"y" \
  12. || test x"$CONFIG_FEATURE_MINIX2" != x"y" \
  13. || test x"$CONFIG_FEATURE_MOUNT_LOOP" != x"y" \
  14. || test x"$CONFIG_FEATURE_MOUNT_LOOP_CREATE" != x"y" \
  15. || test x"$CONFIG_FEATURE_MOUNT_FLAGS" != x"y" \
  16. || test x"$CONFIG_FEATURE_DEVFS" = x"y" \
  17. ; then
  18. echo "SKIPPED: mount"
  19. exit 0
  20. fi
  21. testdir="$PWD/mount.testdir"
  22. dd if=/dev/zero of=mount.image1m count=1 bs=1M 2>/dev/null || { echo "dd error"; exit 1; }
  23. mkfs.minix -v mount.image1m >/dev/null 2>&1 || { echo "mkfs.minix error"; exit 1; }
  24. modprobe minix 2>/dev/null
  25. mkdir "$testdir" 2>/dev/null
  26. umount -d "$testdir" 2>/dev/null
  27. # testing "test name" "command" "expected result" "file input" "stdin"
  28. # file input will be file called "input"
  29. # test can create a file "actual" instead of writing to stdout
  30. # This will always fail on !CONFIG_MANDATORY_FILE_LOCKING kernels
  31. test "$SKIP_MOUNT_MAND_TESTS" = "1" || \
  32. testing "mount -o remount,mand" \
  33. "mount -o loop mount.image1m $testdir "\
  34. "&& grep -Fc $testdir </proc/mounts "\
  35. "&& mount -o remount,mand $testdir "\
  36. "&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'"\
  37. "|| grep -F $testdir </proc/mounts" \
  38. "1\n""1\n" \
  39. "" ""
  40. umount -d "$testdir"
  41. rmdir "$testdir"
  42. rm mount.image1m
  43. # Bug: mount.shared1 directory shows no files (has to show files a and b)
  44. optional FEATURE_LS_RECURSIVE FEATURE_LS_SORTFILES
  45. testing "mount bind+rshared" "\
  46. mkdir -p mount.dir mount.shared1 mount.shared2
  47. touch mount.dir/a mount.dir/b
  48. mount --bind mount.shared1 mount.shared1 2>&1
  49. mount --make-rshared mount.shared1 2>&1
  50. mount --bind mount.shared2 mount.shared2 2>&1
  51. mount --make-rshared mount.shared2 2>&1
  52. mount --bind mount.shared2 mount.shared1 2>&1
  53. mount --bind mount.dir mount.shared2 2>&1
  54. ls -R mount.dir mount.shared1 mount.shared2 2>&1
  55. umount mount.dir mount.shared1 mount.shared2 2>/dev/null
  56. umount mount.dir mount.shared1 mount.shared2 2>/dev/null
  57. umount mount.dir mount.shared1 mount.shared2 2>/dev/null
  58. rm -f mount.dir/a mount.dir/b mount.dir/c
  59. rmdir mount.dir mount.shared1 mount.shared2
  60. " \
  61. "\
  62. mount.dir:
  63. a
  64. b
  65. mount.shared1:
  66. a
  67. b
  68. mount.shared2:
  69. a
  70. b
  71. " \
  72. "" ""
  73. SKIP=
  74. testing "mount RO loop" "\
  75. exec 2>&1
  76. umount -d mount.dir 2>/dev/null
  77. rmdir mount.dir 2>/dev/null
  78. mkdir -p mount.dir
  79. (
  80. cd mount.dir || { echo 'cd error'; exit 1; }
  81. mkdir z1 z2 || { echo 'mkdir error'; exit 1; }
  82. mount -t tmpfs tmpfs z1 || { echo 'mount tmpfs error'; exit 1; }
  83. dd if=/dev/zero of=z1/e2img count=10 bs=1M 2>/dev/null || { echo 'dd error'; exit 1; }
  84. mke2fs -F z1/e2img 2>/dev/null >&2 || { echo 'mke2fs error'; exit 1; }
  85. mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; exit 1; }
  86. mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; }
  87. )
  88. umount -d mount.dir/z2
  89. ##losetup -d /dev/loop*
  90. umount -d mount.dir/z1
  91. rm -rf mount.dir
  92. echo DONE
  93. " \
  94. "DONE\n" "" ""
  95. exit $FAILCOUNT