3
0

mount.tests 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. testing "mount -o remount,mand" \
  31. "mount -o loop mount.image1m $testdir "\
  32. "&& grep -Fc $testdir </proc/mounts "\
  33. "&& mount -o remount,mand $testdir "\
  34. "&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'"\
  35. "|| grep -F $testdir </proc/mounts" \
  36. "1\n""1\n" \
  37. "" ""
  38. umount -d "$testdir"
  39. rmdir "$testdir"
  40. rm mount.image1m
  41. # Bug: mount.shared1 directory shows no files (has to show files a and b)
  42. optional FEATURE_LS_RECURSIVE FEATURE_LS_SORTFILES
  43. testing "mount bind+rshared" "\
  44. mkdir -p mount.dir mount.shared1 mount.shared2
  45. touch mount.dir/a mount.dir/b
  46. mount --bind mount.shared1 mount.shared1 2>&1
  47. mount --make-rshared mount.shared1 2>&1
  48. mount --bind mount.shared2 mount.shared2 2>&1
  49. mount --make-rshared mount.shared2 2>&1
  50. mount --bind mount.shared2 mount.shared1 2>&1
  51. mount --bind mount.dir mount.shared2 2>&1
  52. ls -R mount.dir mount.shared1 mount.shared2 2>&1
  53. umount mount.dir mount.shared1 mount.shared2 2>/dev/null
  54. umount mount.dir mount.shared1 mount.shared2 2>/dev/null
  55. umount mount.dir mount.shared1 mount.shared2 2>/dev/null
  56. rm -f mount.dir/a mount.dir/b mount.dir/c
  57. rmdir mount.dir mount.shared1 mount.shared2
  58. " \
  59. "\
  60. mount.dir:
  61. a
  62. b
  63. mount.shared1:
  64. a
  65. b
  66. mount.shared2:
  67. a
  68. b
  69. " \
  70. "" ""
  71. SKIP=
  72. testing "mount RO loop" "\
  73. exec 2>&1
  74. umount -d mount.dir 2>/dev/null
  75. rmdir mount.dir 2>/dev/null
  76. mkdir -p mount.dir
  77. (
  78. cd mount.dir || { echo 'cd error'; exit 1; }
  79. mkdir z1 z2 || { echo 'mkdir error'; exit 1; }
  80. mount -t tmpfs tmpfs z1 || { echo 'mount tmpfs error'; exit 1; }
  81. dd if=/dev/zero of=z1/e2img count=10 bs=1M 2>/dev/null || { echo 'dd error'; exit 1; }
  82. mke2fs -F z1/e2img 2>/dev/null >&2 || { echo 'mke2fs error'; exit 1; }
  83. mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; exit 1; }
  84. mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; }
  85. )
  86. umount -d mount.dir/z2
  87. ##losetup -d /dev/loop*
  88. umount -d mount.dir/z1
  89. rm -rf mount.dir
  90. echo DONE
  91. " \
  92. "DONE\n" "" ""
  93. exit $FAILCOUNT