blob: c5891be836aaea980d144e6e5049dde4e025107c [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 Vlasenkobfa1b2e2010-05-11 03:53:57 +020013if test x"$CONFIG_MKFS_MINIX" != x"y" \
14|| test x"$CONFIG_FEATURE_MINIX2" != x"y" \
Denys Vlasenkoc0211e92010-05-11 04:32:04 +020015|| test x"$CONFIG_FEATURE_MOUNT_LOOP" != x"y" \
Denys Vlasenkoda138242010-05-11 12:02:48 +020016|| test x"$CONFIG_FEATURE_MOUNT_FLAGS" != x"y" \
Denys Vlasenkobfa1b2e2010-05-11 03:53:57 +020017|| test x"$CONFIG_FEATURE_DEVFS" = x"y" \
18; then
19 echo "SKIPPED: mount"
20 exit 0
Chris Metcalf208d35d2010-04-02 09:57:27 +020021fi
22
Denys Vlasenkoc2fda862011-03-14 06:28:28 +010023testdir="$PWD/mount.testdir"
Denys Vlasenkoc1fc3d32009-07-18 17:22:03 +020024
Denys Vlasenko6ae64262009-07-18 16:22:26 +020025dd if=/dev/zero of=mount.image1m count=1 bs=1M 2>/dev/null || { echo "dd error"; exit 1; }
26mkfs.minix -v mount.image1m >/dev/null 2>&1 || { echo "mkfs.minix error"; exit 1; }
Denys Vlasenkoc1fc3d32009-07-18 17:22:03 +020027modprobe minix 2>/dev/null
28mkdir "$testdir" 2>/dev/null
29umount -d "$testdir" 2>/dev/null
Denis Vlasenko5d624622008-07-08 02:57:40 +000030
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
35testing "mount -o remount,mand" \
Denis Vlasenkoabe49fa2008-07-11 21:41:14 +000036"mount -o loop mount.image1m $testdir "\
Denis Vlasenko5d624622008-07-08 02:57:40 +000037"&& 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
Denys Vlasenkoc1fc3d32009-07-18 17:22:03 +020043umount -d "$testdir"
44rmdir "$testdir"
Denis Vlasenkoabe49fa2008-07-11 21:41:14 +000045rm mount.image1m
Denis Vlasenko5d624622008-07-08 02:57:40 +000046
Denys Vlasenkoc2fda862011-03-14 06:28:28 +010047
48# Bug: mount.shared1 directory shows no files (has to show files a and b)
Denys Vlasenko47b03362011-08-10 10:45:48 +020049optional FEATURE_LS_RECURSIVE FEATURE_LS_SORTFILES
Denys Vlasenkoc2fda862011-03-14 06:28:28 +010050testing "mount bind+rshared" "\
51mkdir -p mount.dir mount.shared1 mount.shared2
52touch mount.dir/a mount.dir/b
53
54mount --bind mount.shared1 mount.shared1 2>&1
55mount --make-rshared mount.shared1 2>&1
56mount --bind mount.shared2 mount.shared2 2>&1
57mount --make-rshared mount.shared2 2>&1
58
59mount --bind mount.shared2 mount.shared1 2>&1
60mount --bind mount.dir mount.shared2 2>&1
61
62ls -R mount.dir mount.shared1 mount.shared2 2>&1
63
64umount mount.dir mount.shared1 mount.shared2 2>/dev/null
65umount mount.dir mount.shared1 mount.shared2 2>/dev/null
66umount mount.dir mount.shared1 mount.shared2 2>/dev/null
67rm -f mount.dir/a mount.dir/b mount.dir/c
68rmdir mount.dir mount.shared1 mount.shared2
69" \
70"\
71mount.dir:
72a
73b
74
75mount.shared1:
76a
77b
78
79mount.shared2:
80a
81b
82" \
83 "" ""
Denys Vlasenkob47b3ce2011-08-10 00:51:29 +020084SKIP=
Denys Vlasenkoc2fda862011-03-14 06:28:28 +010085
Denis Vlasenko5d624622008-07-08 02:57:40 +000086exit $FAILCOUNT