annotate tests/mount.test @ 1776:7bf68329eb3b draft default tip

Repository switched to git at https://github.com/landley/toybox
author Rob Landley <rob@landley.net>
date Thu, 09 Apr 2015 02:28:32 -0500
parents 8700cbe1cb29
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1377
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
1 #!/bin/bash
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
2
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
3 # Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
4 # Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
5
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
6 [ -f testing.sh ] && . testing.sh
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
7
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
8 #testing "name" "command" "result" "infile" "stdin"
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
9
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
10 root_fs=`df | grep "\/$" | awk '{print $1}'`
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
11 root_fs_type=`file -sL $root_fs | awk '{print $5}'`
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
12
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
13 tmp_b_fs="tmp_b_fs"
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
14 tmp_b_fs_type="ext3"
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
15
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
16 reCreateTmpFs() {
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
17 rm -rf $tmp_b_fs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
18 mknod $tmp_b_fs b 1 0
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
19 mkfs.ext3 $tmp_b_fs >/dev/null 2>&1
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
20 }
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
21 reCreateTmpFs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
22
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
23 testing "mount $root_fs /mnt" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
24 "mount $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
25 sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
26 testing "mount $tmp_b_fs /mnt" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
27 "mount $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
28 sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
29 reCreateTmpFs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
30
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
31 chmod 444 /mnt
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
32 testing "mount $root_fs /mnt (read_only dir)" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
33 "mount $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
34 sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
35 testing "mount $tmp_b_fs /mnt (read_only dir)" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
36 "mount $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
37 sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
38 reCreateTmpFs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
39 chmod 755 /mnt
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
40 testing "mount -w $root_fs /mnt (write_only mode)" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
41 "mount -w $root_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
42 sleep 1 && umount /mnt && test -e /testDir && rmdir /testDir" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
43 testing "mount -w $tmp_b_fs /mnt (write_only mode)" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
44 "mount -w $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
45 sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
46 reCreateTmpFs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
47 testing "mount -rw $tmp_b_fs /mnt (read_write mode)" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
48 'mount -rw $tmp_b_fs /mnt >/dev/null && mkdir /mnt/testDir && \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
49 sleep 1 && ! test -e /mnt/testDir && umount /mnt' "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
50 reCreateTmpFs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
51 testing "mount $tmp_b_fs /mnt -t fs_type" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
52 "mount $tmp_b_fs /mnt -t $tmp_b_fs_type >/dev/null 2>&1 &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
53 mkdir /mnt/testDir && sleep 1 && umount /mnt &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
54 ! test -e /mnt/testDir" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
55 reCreateTmpFs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
56 mkdir -p testDir1/testDir2 testDir
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
57 echo "abcdefghijklmnopqrstuvwxyz" > testDir1/testDir2/testFile
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
58 testing "mount -o bind dir1 dir2" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
59 'mount -o bind testDir1 testDir >/dev/null 2>&1 && \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
60 cat testDir/testDir2/testFile && sleep 1 && umount testDir' \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
61 "abcdefghijklmnopqrstuvwxyz\n" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
62 testing "mount -o rbind dir1 dir2" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
63 'mount -o rbind testDir1 testDir >/dev/null 2>&1 && \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
64 cat testDir/testDir2/testFile && sleep 1 && umount testDir' \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
65 "abcdefghijklmnopqrstuvwxyz\n" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
66 testing "mount -o loop $tmp_b_fs /mnt" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
67 "mount -o loop $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDirp &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
68 sleep 1 && umount -d /mnt && ! test -e /mnt/testDirp" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
69 reCreateTmpFs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
70
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
71 mkdir testDir2
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
72 testing "mount -o move mount_1 mount_2" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
73 "mount $tmp_b_fs testDir1 && mkdir testDir1/testDirr &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
74 mount -o move testDir1 testDir2 && test -r testDir2/testDirr &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
75 sleep 1 && umount testDir2" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
76 reCreateTmpFs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
77 testing "mount -o rw $tmp_b_fs /mnt" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
78 "mount -o rw $tmp_b_fs /mnt >/dev/null 2>&1 && mkdir /mnt/testDir &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
79 sleep 1 && umount /mnt && ! test -e /mnt/testDir" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
80 reCreateTmpFs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
81 testing "mount -o ro $tmp_b_fs /mnt" \
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
82 "mount -o ro $tmp_b_fs /mnt >/dev/null 2>&1 &&
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
83 mkdir /mnt/testDir 2>/dev/null || sleep 1 && umount /mnt" "" "" ""
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
84 reCreateTmpFs
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
85
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
86 umount testDir1
7a2aec0876fe I have developed few testsuites for toybox commands -
Divya Kothari <divya.s.kothari@gmail.com>
parents:
diff changeset
87 rm -f $tmp_b_fs