mount: add a test for bind+rshared
[oweals/busybox.git] / testsuite / mount.tests
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
5 . ./testing.sh
6 test -f "$bindir/.config" && . "$bindir/.config"
7
8 test "`id -u`" = 0 || {
9         echo "SKIPPED: mount (must be root to test this)"
10         exit 0
11 }
12
13 if test x"$CONFIG_MKFS_MINIX" != x"y" \
14 || test x"$CONFIG_FEATURE_MINIX2" != x"y" \
15 || test x"$CONFIG_FEATURE_MOUNT_LOOP" != x"y" \
16 || test x"$CONFIG_FEATURE_MOUNT_FLAGS" != x"y" \
17 || test x"$CONFIG_FEATURE_DEVFS" = x"y" \
18 ; then
19         echo "SKIPPED: mount"
20         exit 0
21 fi
22
23 testdir="$PWD/mount.testdir"
24
25 dd if=/dev/zero of=mount.image1m count=1 bs=1M 2>/dev/null || { echo "dd error"; exit 1; }
26 mkfs.minix -v mount.image1m >/dev/null 2>&1 || { echo "mkfs.minix error"; exit 1; }
27 modprobe minix 2>/dev/null
28 mkdir "$testdir" 2>/dev/null
29 umount -d "$testdir" 2>/dev/null
30
31 # testing "test name" "command" "expected result" "file input" "stdin"
32 #   file input will be file called "input"
33 #   test can create a file "actual" instead of writing to stdout
34
35 testing "mount -o remount,mand" \
36 "mount -o loop mount.image1m $testdir "\
37 "&& grep -Fc $testdir </proc/mounts "\
38 "&& mount -o remount,mand $testdir "\
39 "&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'" \
40         "1\n""1\n" \
41         "" ""
42
43 umount -d "$testdir"
44 rmdir "$testdir"
45 rm mount.image1m
46
47
48 # Bug: mount.shared1 directory shows no files (has to show files a and b)
49 testing "mount bind+rshared" "\
50 mkdir -p mount.dir mount.shared1 mount.shared2
51 touch mount.dir/a mount.dir/b
52
53 mount --bind         mount.shared1 mount.shared1 2>&1
54 mount --make-rshared mount.shared1               2>&1
55 mount --bind         mount.shared2 mount.shared2 2>&1
56 mount --make-rshared mount.shared2               2>&1
57
58 mount --bind mount.shared2 mount.shared1         2>&1
59 mount --bind mount.dir     mount.shared2         2>&1
60
61 ls -R mount.dir mount.shared1 mount.shared2      2>&1
62
63 umount mount.dir mount.shared1 mount.shared2 2>/dev/null
64 umount mount.dir mount.shared1 mount.shared2 2>/dev/null
65 umount mount.dir mount.shared1 mount.shared2 2>/dev/null
66 rm -f mount.dir/a mount.dir/b mount.dir/c
67 rmdir mount.dir mount.shared1 mount.shared2
68 " \
69 "\
70 mount.dir:
71 a
72 b
73
74 mount.shared1:
75 a
76 b
77
78 mount.shared2:
79 a
80 b
81 " \
82         "" ""
83
84 exit $FAILCOUNT