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