aboutsummaryrefslogtreecommitdiff
path: root/scripts/test/mount.test
diff options
context:
space:
mode:
authorDivya Kothari <divya.s.kothari@gmail.com>2014-07-04 21:20:02 -0500
committerDivya Kothari <divya.s.kothari@gmail.com>2014-07-04 21:20:02 -0500
commitef0ed68d5ba5794c1352e64273d4c5039e62476b (patch)
treece65d458c8f5e0b51eaf8f0be4caa07c07792d7d /scripts/test/mount.test
parent4a855d6cf62cebe40fa9fe97c7e6b9ca49f79b5b (diff)
downloadtoybox-ef0ed68d5ba5794c1352e64273d4c5039e62476b.tar.gz
I have developed few testsuites for toybox commands -
1. lsattr/chattr 2. mount 3. chmod 4. pgrep/pkill 5. groupadd 6. groupdel 7. useradd
Diffstat (limited to 'scripts/test/mount.test')
-rw-r--r--scripts/test/mount.test87
1 files changed, 87 insertions, 0 deletions
diff --git a/scripts/test/mount.test b/scripts/test/mount.test
new file mode 100644
index 00000000..1fdc00f7
--- /dev/null
+++ b/scripts/test/mount.test
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+# Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
+# Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+root_fs=`df | grep "\/$" | awk '{print $1}'`
+root_fs_type=`file -sL $root_fs | awk '{print $5}'`
+
+tmp_b_fs="tmp_b_fs"
+tmp_b_fs_type="ext3"
+
+reCreateTmpFs() {
+ rm -rf $tmp_b_fs
+ mknod $tmp_b_fs b 1 0
+ mkfs.ext3 $tmp_b_fs >/dev/null 2>&1
+}
+reCreateTmpFs
+
+testing "mount $root_fs /mnt" \
+ "mount $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
+ sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" ""
+testing "mount $tmp_b_fs /mnt" \
+ "mount $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
+ sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
+reCreateTmpFs
+
+chmod 444 /mnt
+testing "mount $root_fs /mnt (read_only dir)" \
+ "mount $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
+ sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" ""
+testing "mount $tmp_b_fs /mnt (read_only dir)" \
+ "mount $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
+ sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
+reCreateTmpFs
+chmod 755 /mnt
+testing "mount -w $root_fs /mnt (write_only mode)" \
+ "mount -w $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
+ sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" ""
+testing "mount -w $tmp_b_fs /mnt (write_only mode)" \
+ "mount -w $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
+ sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
+reCreateTmpFs
+testing "mount -rw $tmp_b_fs /mnt (read_write mode)" \
+ 'mount -rw $tmp_b_fs /mnt >/dev/null && mkdir /mnt/testDir && \
+ sleep 1 && ! test -e /mnt/testDir && umount /mnt' "" "" ""
+reCreateTmpFs
+testing "mount $tmp_b_fs /mnt -t fs_type" \
+ "mount $tmp_b_fs /mnt -t $tmp_b_fs_type >/dev/null 2>&1 &&
+ mkdir /mnt/testDir && sleep 1 && umount /mnt &&
+ ! test -e /mnt/testDir" "" "" ""
+reCreateTmpFs
+mkdir -p testDir1/testDir2 testDir
+echo "abcdefghijklmnopqrstuvwxyz" > testDir1/testDir2/testFile
+testing "mount -o bind dir1 dir2" \
+ 'mount -o bind testDir1 testDir >/dev/null 2>&1 && \
+ cat testDir/testDir2/testFile && sleep 1 && umount testDir' \
+ "abcdefghijklmnopqrstuvwxyz\n" "" ""
+testing "mount -o rbind dir1 dir2" \
+ 'mount -o rbind testDir1 testDir >/dev/null 2>&1 && \
+ cat testDir/testDir2/testFile && sleep 1 && umount testDir' \
+ "abcdefghijklmnopqrstuvwxyz\n" "" ""
+testing "mount -o loop $tmp_b_fs /mnt" \
+ "mount -o loop $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDirp &&
+ sleep 1 && umount -d /mnt && ! test -e /mnt/testDirp" "" "" ""
+reCreateTmpFs
+
+mkdir testDir2
+testing "mount -o move mount_1 mount_2" \
+ "mount $tmp_b_fs testDir1 && mkdir testDir1/testDirr &&
+ mount -o move testDir1 testDir2 && test -r testDir2/testDirr &&
+ sleep 1 && umount testDir2" "" "" ""
+reCreateTmpFs
+testing "mount -o rw $tmp_b_fs /mnt" \
+ "mount -o rw $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
+ sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
+reCreateTmpFs
+testing "mount -o ro $tmp_b_fs /mnt" \
+ "mount -o ro $tmp_b_fs /mnt >/dev/null 2>&1 &&
+ mkdir /mnt/testDir 2>/dev/null || sleep 1 && umount /mnt" "" "" ""
+reCreateTmpFs
+
+umount testDir1
+rm -f $tmp_b_fs