Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 1 | #!/bin/sh |
Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 2 | # Copyright 2007 by Denys Vlasenko <vda.linux@googlemail.com> |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 3 | # Licensed under GPLv2, see file LICENSE in this source tree. |
Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 4 | |
Mike Frysinger | caa7940 | 2009-11-04 18:41:22 -0500 | [diff] [blame] | 5 | . ./testing.sh |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 6 | test -f "$bindir/.config" && . "$bindir/.config" |
| 7 | |
Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 8 | test "`id -u`" = 0 || { |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 9 | echo "SKIPPED: mount (must be root to test this)" |
Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 10 | exit 0 |
| 11 | } |
| 12 | |
Denys Vlasenko | 3357666 | 2018-06-28 14:10:00 +0200 | [diff] [blame] | 13 | # Without MOUNT_LOOP_CREATE, the test will fail if /dev/loopN's do not exist |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 14 | if test x"$CONFIG_MKFS_MINIX" != x"y" \ |
| 15 | || test x"$CONFIG_FEATURE_MINIX2" != x"y" \ |
Denys Vlasenko | c0211e9 | 2010-05-11 04:32:04 +0200 | [diff] [blame] | 16 | || test x"$CONFIG_FEATURE_MOUNT_LOOP" != x"y" \ |
Denys Vlasenko | 3357666 | 2018-06-28 14:10:00 +0200 | [diff] [blame] | 17 | || test x"$CONFIG_FEATURE_MOUNT_LOOP_CREATE" != x"y" \ |
Denys Vlasenko | da13824 | 2010-05-11 12:02:48 +0200 | [diff] [blame] | 18 | || test x"$CONFIG_FEATURE_MOUNT_FLAGS" != x"y" \ |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 19 | || test x"$CONFIG_FEATURE_DEVFS" = x"y" \ |
| 20 | ; then |
| 21 | echo "SKIPPED: mount" |
| 22 | exit 0 |
Chris Metcalf | 208d35d | 2010-04-02 09:57:27 +0200 | [diff] [blame] | 23 | fi |
| 24 | |
Denys Vlasenko | c2fda86 | 2011-03-14 06:28:28 +0100 | [diff] [blame] | 25 | testdir="$PWD/mount.testdir" |
Denys Vlasenko | c1fc3d3 | 2009-07-18 17:22:03 +0200 | [diff] [blame] | 26 | |
Denys Vlasenko | 6ae6426 | 2009-07-18 16:22:26 +0200 | [diff] [blame] | 27 | dd if=/dev/zero of=mount.image1m count=1 bs=1M 2>/dev/null || { echo "dd error"; exit 1; } |
| 28 | mkfs.minix -v mount.image1m >/dev/null 2>&1 || { echo "mkfs.minix error"; exit 1; } |
Denys Vlasenko | c1fc3d3 | 2009-07-18 17:22:03 +0200 | [diff] [blame] | 29 | modprobe minix 2>/dev/null |
| 30 | mkdir "$testdir" 2>/dev/null |
| 31 | umount -d "$testdir" 2>/dev/null |
Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 32 | |
| 33 | # testing "test name" "command" "expected result" "file input" "stdin" |
| 34 | # file input will be file called "input" |
| 35 | # test can create a file "actual" instead of writing to stdout |
| 36 | |
Denys Vlasenko | 77a51a2 | 2020-12-29 16:53:11 +0100 | [diff] [blame] | 37 | # This will always fail on !CONFIG_MANDATORY_FILE_LOCKING kernels |
| 38 | test "$SKIP_MOUNT_MAND_TESTS" = "1" || \ |
Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 39 | testing "mount -o remount,mand" \ |
Denis Vlasenko | abe49fa | 2008-07-11 21:41:14 +0000 | [diff] [blame] | 40 | "mount -o loop mount.image1m $testdir "\ |
Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 41 | "&& grep -Fc $testdir </proc/mounts "\ |
| 42 | "&& mount -o remount,mand $testdir "\ |
Denys Vlasenko | c9a1311 | 2012-06-21 16:50:46 +0200 | [diff] [blame] | 43 | "&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'"\ |
| 44 | "|| grep -F $testdir </proc/mounts" \ |
Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 45 | "1\n""1\n" \ |
| 46 | "" "" |
| 47 | |
Denys Vlasenko | c1fc3d3 | 2009-07-18 17:22:03 +0200 | [diff] [blame] | 48 | umount -d "$testdir" |
| 49 | rmdir "$testdir" |
Denis Vlasenko | abe49fa | 2008-07-11 21:41:14 +0000 | [diff] [blame] | 50 | rm mount.image1m |
Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 51 | |
Denys Vlasenko | c2fda86 | 2011-03-14 06:28:28 +0100 | [diff] [blame] | 52 | |
| 53 | # Bug: mount.shared1 directory shows no files (has to show files a and b) |
Denys Vlasenko | 47b0336 | 2011-08-10 10:45:48 +0200 | [diff] [blame] | 54 | optional FEATURE_LS_RECURSIVE FEATURE_LS_SORTFILES |
Denys Vlasenko | c2fda86 | 2011-03-14 06:28:28 +0100 | [diff] [blame] | 55 | testing "mount bind+rshared" "\ |
| 56 | mkdir -p mount.dir mount.shared1 mount.shared2 |
| 57 | touch mount.dir/a mount.dir/b |
| 58 | |
| 59 | mount --bind mount.shared1 mount.shared1 2>&1 |
| 60 | mount --make-rshared mount.shared1 2>&1 |
| 61 | mount --bind mount.shared2 mount.shared2 2>&1 |
| 62 | mount --make-rshared mount.shared2 2>&1 |
| 63 | |
| 64 | mount --bind mount.shared2 mount.shared1 2>&1 |
| 65 | mount --bind mount.dir mount.shared2 2>&1 |
| 66 | |
| 67 | ls -R mount.dir mount.shared1 mount.shared2 2>&1 |
| 68 | |
| 69 | umount mount.dir mount.shared1 mount.shared2 2>/dev/null |
| 70 | umount mount.dir mount.shared1 mount.shared2 2>/dev/null |
| 71 | umount mount.dir mount.shared1 mount.shared2 2>/dev/null |
| 72 | rm -f mount.dir/a mount.dir/b mount.dir/c |
| 73 | rmdir mount.dir mount.shared1 mount.shared2 |
| 74 | " \ |
| 75 | "\ |
| 76 | mount.dir: |
| 77 | a |
| 78 | b |
| 79 | |
| 80 | mount.shared1: |
| 81 | a |
| 82 | b |
| 83 | |
| 84 | mount.shared2: |
| 85 | a |
| 86 | b |
| 87 | " \ |
| 88 | "" "" |
Denys Vlasenko | b47b3ce | 2011-08-10 00:51:29 +0200 | [diff] [blame] | 89 | SKIP= |
Denys Vlasenko | c2fda86 | 2011-03-14 06:28:28 +0100 | [diff] [blame] | 90 | |
Denys Vlasenko | c9a1311 | 2012-06-21 16:50:46 +0200 | [diff] [blame] | 91 | |
| 92 | testing "mount RO loop" "\ |
| 93 | exec 2>&1 |
| 94 | umount -d mount.dir 2>/dev/null |
| 95 | rmdir mount.dir 2>/dev/null |
| 96 | mkdir -p mount.dir |
| 97 | ( |
| 98 | cd mount.dir || { echo 'cd error'; exit 1; } |
| 99 | mkdir z1 z2 || { echo 'mkdir error'; exit 1; } |
| 100 | mount -t tmpfs tmpfs z1 || { echo 'mount tmpfs error'; exit 1; } |
| 101 | dd if=/dev/zero of=z1/e2img count=10 bs=1M 2>/dev/null || { echo 'dd error'; exit 1; } |
| 102 | mke2fs -F z1/e2img 2>/dev/null >&2 || { echo 'mke2fs error'; exit 1; } |
| 103 | mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; exit 1; } |
| 104 | mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; } |
| 105 | ) |
| 106 | umount -d mount.dir/z2 |
| 107 | ##losetup -d /dev/loop* |
| 108 | umount -d mount.dir/z1 |
| 109 | rm -rf mount.dir |
| 110 | echo DONE |
| 111 | " \ |
| 112 | "DONE\n" "" "" |
| 113 | |
| 114 | |
Denis Vlasenko | 5d62462 | 2008-07-08 02:57:40 +0000 | [diff] [blame] | 115 | exit $FAILCOUNT |