blob: b6d5ebe0863653c5679bf4675f51d999a0cc3baa [file] [log] [blame]
Denis Vlasenko5d624622008-07-08 02:57:40 +00001#!/bin/sh
Denis Vlasenko5d624622008-07-08 02:57:40 +00002# Copyright 2007 by Denys Vlasenko <vda.linux@googlemail.com>
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02003# Licensed under GPLv2, see file LICENSE in this source tree.
Denis Vlasenko5d624622008-07-08 02:57:40 +00004
Mike Frysingercaa79402009-11-04 18:41:22 -05005. ./testing.sh
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +02006test -f "$bindir/.config" && . "$bindir/.config"
7
Denis Vlasenko5d624622008-07-08 02:57:40 +00008test "`id -u`" = 0 || {
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +02009 echo "SKIPPED: mount (must be root to test this)"
Denis Vlasenko5d624622008-07-08 02:57:40 +000010 exit 0
11}
12
Denys Vlasenko33576662018-06-28 14:10:00 +020013# Without MOUNT_LOOP_CREATE, the test will fail if /dev/loopN's do not exist
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +020014if test x"$CONFIG_MKFS_MINIX" != x"y" \
15|| test x"$CONFIG_FEATURE_MINIX2" != x"y" \
Denys Vlasenkoc0211e92010-05-11 04:32:04 +020016|| test x"$CONFIG_FEATURE_MOUNT_LOOP" != x"y" \
Denys Vlasenko33576662018-06-28 14:10:00 +020017|| test x"$CONFIG_FEATURE_MOUNT_LOOP_CREATE" != x"y" \
Denys Vlasenkoda138242010-05-11 12:02:48 +020018|| test x"$CONFIG_FEATURE_MOUNT_FLAGS" != x"y" \
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +020019|| test x"$CONFIG_FEATURE_DEVFS" = x"y" \
20; then
21 echo "SKIPPED: mount"
22 exit 0
Chris Metcalf208d35d2010-04-02 09:57:27 +020023fi
24
Denys Vlasenkoc2fda862011-03-14 06:28:28 +010025testdir="$PWD/mount.testdir"
Denys Vlasenkoc1fc3d32009-07-18 17:22:03 +020026
Denys Vlasenko6ae64262009-07-18 16:22:26 +020027dd if=/dev/zero of=mount.image1m count=1 bs=1M 2>/dev/null || { echo "dd error"; exit 1; }
28mkfs.minix -v mount.image1m >/dev/null 2>&1 || { echo "mkfs.minix error"; exit 1; }
Denys Vlasenkoc1fc3d32009-07-18 17:22:03 +020029modprobe minix 2>/dev/null
30mkdir "$testdir" 2>/dev/null
31umount -d "$testdir" 2>/dev/null
Denis Vlasenko5d624622008-07-08 02:57:40 +000032
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 Vlasenko77a51a22020-12-29 16:53:11 +010037# This will always fail on !CONFIG_MANDATORY_FILE_LOCKING kernels
38test "$SKIP_MOUNT_MAND_TESTS" = "1" || \
Denis Vlasenko5d624622008-07-08 02:57:40 +000039testing "mount -o remount,mand" \
Denis Vlasenkoabe49fa2008-07-11 21:41:14 +000040"mount -o loop mount.image1m $testdir "\
Denis Vlasenko5d624622008-07-08 02:57:40 +000041"&& grep -Fc $testdir </proc/mounts "\
42"&& mount -o remount,mand $testdir "\
Denys Vlasenkoc9a13112012-06-21 16:50:46 +020043"&& grep -F $testdir </proc/mounts | grep -c '[, ]mand[, ]'"\
44"|| grep -F $testdir </proc/mounts" \
Denis Vlasenko5d624622008-07-08 02:57:40 +000045 "1\n""1\n" \
46 "" ""
47
Denys Vlasenkoc1fc3d32009-07-18 17:22:03 +020048umount -d "$testdir"
49rmdir "$testdir"
Denis Vlasenkoabe49fa2008-07-11 21:41:14 +000050rm mount.image1m
Denis Vlasenko5d624622008-07-08 02:57:40 +000051
Denys Vlasenkoc2fda862011-03-14 06:28:28 +010052
53# Bug: mount.shared1 directory shows no files (has to show files a and b)
Denys Vlasenko47b03362011-08-10 10:45:48 +020054optional FEATURE_LS_RECURSIVE FEATURE_LS_SORTFILES
Denys Vlasenkoc2fda862011-03-14 06:28:28 +010055testing "mount bind+rshared" "\
56mkdir -p mount.dir mount.shared1 mount.shared2
57touch mount.dir/a mount.dir/b
58
59mount --bind mount.shared1 mount.shared1 2>&1
60mount --make-rshared mount.shared1 2>&1
61mount --bind mount.shared2 mount.shared2 2>&1
62mount --make-rshared mount.shared2 2>&1
63
64mount --bind mount.shared2 mount.shared1 2>&1
65mount --bind mount.dir mount.shared2 2>&1
66
67ls -R mount.dir mount.shared1 mount.shared2 2>&1
68
69umount mount.dir mount.shared1 mount.shared2 2>/dev/null
70umount mount.dir mount.shared1 mount.shared2 2>/dev/null
71umount mount.dir mount.shared1 mount.shared2 2>/dev/null
72rm -f mount.dir/a mount.dir/b mount.dir/c
73rmdir mount.dir mount.shared1 mount.shared2
74" \
75"\
76mount.dir:
77a
78b
79
80mount.shared1:
81a
82b
83
84mount.shared2:
85a
86b
87" \
88 "" ""
Denys Vlasenkob47b3ce2011-08-10 00:51:29 +020089SKIP=
Denys Vlasenkoc2fda862011-03-14 06:28:28 +010090
Denys Vlasenkoc9a13112012-06-21 16:50:46 +020091
92testing "mount RO loop" "\
93exec 2>&1
94umount -d mount.dir 2>/dev/null
95rmdir mount.dir 2>/dev/null
96mkdir -p mount.dir
97(
98cd mount.dir || { echo 'cd error'; exit 1; }
99mkdir z1 z2 || { echo 'mkdir error'; exit 1; }
100mount -t tmpfs tmpfs z1 || { echo 'mount tmpfs error'; exit 1; }
101dd if=/dev/zero of=z1/e2img count=10 bs=1M 2>/dev/null || { echo 'dd error'; exit 1; }
102mke2fs -F z1/e2img 2>/dev/null >&2 || { echo 'mke2fs error'; exit 1; }
103mount -r -o loop -t ext2 z1/e2img z2 || { echo 'mount -r -o loop error'; exit 1; }
104mount -o remount,ro z1 || { echo 'mount -o remount,ro error'; exit 1; }
105)
106umount -d mount.dir/z2
107##losetup -d /dev/loop*
108umount -d mount.dir/z1
109rm -rf mount.dir
110echo DONE
111" \
112"DONE\n" "" ""
113
114
Denis Vlasenko5d624622008-07-08 02:57:40 +0000115exit $FAILCOUNT