3 # Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
4 # Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
6 [ -f testing.sh ] && . testing.sh
8 #testing "name" "command" "result" "infile" "stdin"
10 root_fs=`df | grep "\/$" | cut -d' ' -f1`
11 root_fs_type=`blkid -o value $root_fs | tail -1`
19 mkfs.ext3 $tmp_b_fs >/dev/null 2>&1
23 # TODO: replace /mnt with a directory we know exists. (Android has no /mnt.)
25 testing "$root_fs /mnt" \
26 "mount $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
27 sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" ""
28 testing "$tmp_b_fs /mnt" \
29 "mount $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
30 sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
34 testing "$root_fs /mnt (read_only dir)" \
35 "mount $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
36 sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" ""
37 testing "$tmp_b_fs /mnt (read_only dir)" \
38 "mount $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
39 sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
42 testing "-w $root_fs /mnt (write_only mode)" \
43 "mount -w $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
44 sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" ""
45 testing "-w $tmp_b_fs /mnt (write_only mode)" \
46 "mount -w $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
47 sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
49 testing "-rw $tmp_b_fs /mnt (read_write mode)" \
50 'mount -rw $tmp_b_fs /mnt >/dev/null && mkdir /mnt/testDir && \
51 sleep 1 && ! test -e /mnt/testDir && umount /mnt' "" "" ""
53 testing "$tmp_b_fs /mnt -t fs_type" \
54 "mount $tmp_b_fs /mnt -t $tmp_b_fs_type >/dev/null 2>&1 &&
55 mkdir /mnt/testDir && sleep 1 && umount /mnt &&
56 ! test -e /mnt/testDir" "" "" ""
58 mkdir -p testDir1/testDir2 testDir
59 echo "abcdefghijklmnopqrstuvwxyz" > testDir1/testDir2/testFile
60 testing "-o bind dir1 dir2" \
61 'mount -o bind testDir1 testDir >/dev/null 2>&1 && \
62 cat testDir/testDir2/testFile && sleep 1 && umount testDir' \
63 "abcdefghijklmnopqrstuvwxyz\n" "" ""
64 testing "-o rbind dir1 dir2" \
65 'mount -o rbind testDir1 testDir >/dev/null 2>&1 && \
66 cat testDir/testDir2/testFile && sleep 1 && umount testDir' \
67 "abcdefghijklmnopqrstuvwxyz\n" "" ""
68 testing "-o loop $tmp_b_fs /mnt" \
69 "mount -o loop $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDirp &&
70 sleep 1 && umount -d /mnt && ! test -e /mnt/testDirp" "" "" ""
74 testing "-o move mount_1 mount_2" \
75 "mount $tmp_b_fs testDir1 && mkdir testDir1/testDirr &&
76 mount -o move testDir1 testDir2 && test -r testDir2/testDirr &&
77 sleep 1 && umount testDir2" "" "" ""
79 testing "-o rw $tmp_b_fs /mnt" \
80 "mount -o rw $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
81 sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
83 testing "-o ro $tmp_b_fs /mnt" \
84 "mount -o ro $tmp_b_fs /mnt >/dev/null 2>&1 &&
85 mkdir /mnt/testDir 2>/dev/null || sleep 1 && umount /mnt" "" "" ""
87 testing "-o ro,remount $tmp_b_fs /mnt" \
88 "mount -o ro $tmp_b_fs /mnt >/dev/null 2>&1 &&
89 mkdir /mnt/testDir 2>/dev/null || sleep 1 && umount /mnt" "" "" ""