Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright 2008 by Denys Vlasenko |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 3 | # Licensed under GPLv2, see file LICENSE in this source tree. |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 4 | |
Mike Frysinger | caa7940 | 2009-11-04 18:41:22 -0500 | [diff] [blame] | 5 | . ./testing.sh |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 6 | |
| 7 | # ls -ln is showing date. Need to remove that, it's variable |
| 8 | # sed: (1) "maj, min" -> "maj,min" (2) coalesce spaces |
Denis Vlasenko | 4461564 | 2008-03-29 13:10:57 +0000 | [diff] [blame] | 9 | # cut: remove date |
Denys Vlasenko | 307b24c | 2010-01-25 02:00:16 +0100 | [diff] [blame] | 10 | FILTER_LS="grep -v '^total ' | sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-5,9-" |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 11 | # cut: remove size+date |
Denys Vlasenko | 307b24c | 2010-01-25 02:00:16 +0100 | [diff] [blame] | 12 | FILTER_LS2="grep -v '^total ' | sed -e 's/, */,/g' -e 's/ */ /g' | cut -d' ' -f 1-4,9-" |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 13 | |
| 14 | # testing "test name" "options" "expected result" "file input" "stdin" |
| 15 | |
| 16 | rm -rf mdev.testdir |
| 17 | mkdir mdev.testdir |
| 18 | # We need mdev executable to be in chroot jail! |
| 19 | # (will still fail with dynamically linked one, though...) |
| 20 | cp ../busybox mdev.testdir/mdev |
Denis Vlasenko | 32dcc53 | 2008-05-02 13:21:24 +0000 | [diff] [blame] | 21 | mkdir mdev.testdir/bin |
| 22 | cp ../busybox mdev.testdir/bin/sh 2>/dev/null # for testing cmd feature |
Denis Vlasenko | 4461564 | 2008-03-29 13:10:57 +0000 | [diff] [blame] | 23 | mkdir mdev.testdir/etc |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 24 | mkdir mdev.testdir/dev |
| 25 | mkdir -p mdev.testdir/sys/block/sda |
| 26 | echo "8:0" >mdev.testdir/sys/block/sda/dev |
| 27 | |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 28 | # env - PATH=$PATH: on some systems chroot binary won't otherwise be found |
| 29 | |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 30 | optional STATIC FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 31 | testing "mdev add /block/sda" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 32 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 33 | ls -ln mdev.testdir/dev | $FILTER_LS" \ |
| 34 | "\ |
Denis Vlasenko | 4461564 | 2008-03-29 13:10:57 +0000 | [diff] [blame] | 35 | brw-rw---- 1 0 0 8,0 sda |
| 36 | " \ |
| 37 | "" "" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 38 | SKIP= |
Denis Vlasenko | 4461564 | 2008-03-29 13:10:57 +0000 | [diff] [blame] | 39 | |
| 40 | # continuing to use directory structure from prev test |
Denys Vlasenko | f2860bf | 2010-08-16 14:26:15 +0200 | [diff] [blame] | 41 | optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
| 42 | testing "mdev deletes /block/sda" \ |
| 43 | "env - PATH=$PATH ACTION=remove DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
| 44 | ls -ln mdev.testdir/dev | $FILTER_LS" \ |
| 45 | "\ |
| 46 | " \ |
| 47 | "" "" |
| 48 | SKIP= |
| 49 | |
| 50 | # continuing to use directory structure from prev test |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 51 | rm -rf mdev.testdir/dev/* |
Denis Vlasenko | 4461564 | 2008-03-29 13:10:57 +0000 | [diff] [blame] | 52 | echo ".* 1:1 666" >mdev.testdir/etc/mdev.conf |
| 53 | echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 54 | optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
Denis Vlasenko | 4461564 | 2008-03-29 13:10:57 +0000 | [diff] [blame] | 55 | testing "mdev stops on first rule" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 56 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
Denis Vlasenko | 4461564 | 2008-03-29 13:10:57 +0000 | [diff] [blame] | 57 | ls -ln mdev.testdir/dev | $FILTER_LS" \ |
| 58 | "\ |
| 59 | brw-rw-rw- 1 1 1 8,0 sda |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 60 | " \ |
| 61 | "" "" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 62 | SKIP= |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 63 | |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 64 | # continuing to use directory structure from prev test |
| 65 | rm -rf mdev.testdir/dev/* |
Denis Vlasenko | 3161b61 | 2009-04-16 22:42:01 +0000 | [diff] [blame] | 66 | echo "-.* 1:1 666" >mdev.testdir/etc/mdev.conf |
| 67 | echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 68 | optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
Denis Vlasenko | 3161b61 | 2009-04-16 22:42:01 +0000 | [diff] [blame] | 69 | testing "mdev does not stop on dash-rule" \ |
| 70 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
| 71 | ls -ln mdev.testdir/dev | $FILTER_LS" \ |
| 72 | "\ |
| 73 | br--r--r-- 1 2 2 8,0 sda |
| 74 | " \ |
| 75 | "" "" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 76 | SKIP= |
Denis Vlasenko | 3161b61 | 2009-04-16 22:42:01 +0000 | [diff] [blame] | 77 | |
| 78 | # continuing to use directory structure from prev test |
| 79 | rm -rf mdev.testdir/dev/* |
Denis Vlasenko | 3798db5 | 2009-04-19 21:37:07 +0000 | [diff] [blame] | 80 | echo "\$MODALIAS=qw 1:1 666" >mdev.testdir/etc/mdev.conf |
| 81 | echo "\$MODALIAS=qw. 2:2 444" >>mdev.testdir/etc/mdev.conf |
| 82 | echo "\$MODALIAS=qw. 3:3 400" >>mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 83 | optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
Denis Vlasenko | 3798db5 | 2009-04-19 21:37:07 +0000 | [diff] [blame] | 84 | testing "mdev \$ENVVAR=regex match" \ |
| 85 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda MODALIAS=qwe chroot mdev.testdir /mdev 2>&1; |
| 86 | ls -ln mdev.testdir/dev | $FILTER_LS" \ |
| 87 | "\ |
| 88 | br--r--r-- 1 2 2 8,0 sda |
| 89 | " \ |
| 90 | "" "" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 91 | SKIP= |
Denis Vlasenko | 3798db5 | 2009-04-19 21:37:07 +0000 | [diff] [blame] | 92 | |
| 93 | # continuing to use directory structure from prev test |
| 94 | rm -rf mdev.testdir/dev/* |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 95 | echo "sda 0:0 444 >disk/scsiA" >mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 96 | optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 97 | testing "mdev move/symlink rule '>bar/baz'" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 98 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 99 | ls -lnR mdev.testdir/dev | $FILTER_LS2" \ |
| 100 | "\ |
| 101 | mdev.testdir/dev: |
| 102 | drwxr-xr-x 2 0 0 disk |
| 103 | lrwxrwxrwx 1 0 0 sda -> disk/scsiA |
| 104 | |
| 105 | mdev.testdir/dev/disk: |
| 106 | br--r--r-- 1 0 0 scsiA |
| 107 | " \ |
| 108 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 109 | SKIP= |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 110 | |
| 111 | # continuing to use directory structure from prev test |
| 112 | rm -rf mdev.testdir/dev/* |
| 113 | echo "sda 0:0 444 >disk/" >mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 114 | optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 115 | testing "mdev move/symlink rule '>bar/'" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 116 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 117 | ls -lnR mdev.testdir/dev | $FILTER_LS2" \ |
| 118 | "\ |
| 119 | mdev.testdir/dev: |
| 120 | drwxr-xr-x 2 0 0 disk |
| 121 | lrwxrwxrwx 1 0 0 sda -> disk/sda |
| 122 | |
| 123 | mdev.testdir/dev/disk: |
| 124 | br--r--r-- 1 0 0 sda |
| 125 | " \ |
| 126 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 127 | SKIP= |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 128 | |
Denis Vlasenko | f2f3868 | 2008-03-29 17:26:10 +0000 | [diff] [blame] | 129 | # continuing to use directory structure from prev test |
| 130 | rm -rf mdev.testdir/dev/* |
| 131 | # here we complicate things by having non-matching group 1 and using %0 |
| 132 | echo "s([0-9])*d([a-z]+) 0:0 644 >sd/%2_%0" >mdev.testdir/etc/mdev.conf |
Denys Vlasenko | da13824 | 2010-05-11 12:02:48 +0200 | [diff] [blame] | 133 | optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_RENAME_REGEXP FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_LS_SORTFILES |
Denis Vlasenko | f2f3868 | 2008-03-29 17:26:10 +0000 | [diff] [blame] | 134 | testing "mdev regexp substring match + replace" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 135 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
Denis Vlasenko | f2f3868 | 2008-03-29 17:26:10 +0000 | [diff] [blame] | 136 | ls -lnR mdev.testdir/dev | $FILTER_LS2" \ |
| 137 | "\ |
| 138 | mdev.testdir/dev: |
| 139 | drwxr-xr-x 2 0 0 sd |
| 140 | lrwxrwxrwx 1 0 0 sda -> sd/a_sda |
| 141 | |
| 142 | mdev.testdir/dev/sd: |
| 143 | brw-r--r-- 1 0 0 a_sda |
| 144 | " \ |
| 145 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 146 | SKIP= |
Denis Vlasenko | f2f3868 | 2008-03-29 17:26:10 +0000 | [diff] [blame] | 147 | |
Denis Vlasenko | 32dcc53 | 2008-05-02 13:21:24 +0000 | [diff] [blame] | 148 | # continuing to use directory structure from prev test |
| 149 | rm -rf mdev.testdir/dev/* |
Denis Vlasenko | 32dcc53 | 2008-05-02 13:21:24 +0000 | [diff] [blame] | 150 | echo "sda 0:0 644 @echo @echo TEST" >mdev.testdir/etc/mdev.conf |
Denys Vlasenko | c0211e9 | 2010-05-11 04:32:04 +0200 | [diff] [blame] | 151 | optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_EXEC FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_SH_IS_ASH |
Denis Vlasenko | 32dcc53 | 2008-05-02 13:21:24 +0000 | [diff] [blame] | 152 | testing "mdev command" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 153 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
Denis Vlasenko | 32dcc53 | 2008-05-02 13:21:24 +0000 | [diff] [blame] | 154 | ls -lnR mdev.testdir/dev | $FILTER_LS" \ |
| 155 | "\ |
| 156 | @echo TEST |
| 157 | mdev.testdir/dev: |
| 158 | brw-r--r-- 1 0 0 8,0 sda |
| 159 | " \ |
| 160 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 161 | SKIP= |
Denis Vlasenko | 32dcc53 | 2008-05-02 13:21:24 +0000 | [diff] [blame] | 162 | |
Denis Vlasenko | 8d89bed | 2008-09-07 23:22:08 +0000 | [diff] [blame] | 163 | # continuing to use directory structure from prev test |
| 164 | rm -rf mdev.testdir/dev/* |
Denys Vlasenko | 90db359 | 2009-07-02 13:07:11 +0200 | [diff] [blame] | 165 | echo "sda 0:0 644 =block/ @echo @echo TEST:\$MDEV" >mdev.testdir/etc/mdev.conf |
Denys Vlasenko | c0211e9 | 2010-05-11 04:32:04 +0200 | [diff] [blame] | 166 | optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_EXEC FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_SH_IS_ASH |
Denis Vlasenko | 319fe12 | 2009-01-12 07:57:52 +0000 | [diff] [blame] | 167 | testing "mdev move and command" \ |
| 168 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
| 169 | ls -lnR mdev.testdir/dev | $FILTER_LS2" \ |
| 170 | "\ |
Denys Vlasenko | 90db359 | 2009-07-02 13:07:11 +0200 | [diff] [blame] | 171 | @echo TEST:block/sda |
Denis Vlasenko | 319fe12 | 2009-01-12 07:57:52 +0000 | [diff] [blame] | 172 | mdev.testdir/dev: |
| 173 | drwxr-xr-x 2 0 0 block |
| 174 | |
| 175 | mdev.testdir/dev/block: |
| 176 | brw-r--r-- 1 0 0 sda |
| 177 | " \ |
| 178 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 179 | SKIP= |
Denis Vlasenko | 319fe12 | 2009-01-12 07:57:52 +0000 | [diff] [blame] | 180 | |
| 181 | # continuing to use directory structure from prev test |
| 182 | rm -rf mdev.testdir/dev/* |
Denys Vlasenko | 2441060 | 2009-06-13 23:41:57 +0200 | [diff] [blame] | 183 | echo "@8,0 0:1 644" >mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 184 | optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_RENAME_REGEXP FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
Denis Vlasenko | 8d89bed | 2008-09-07 23:22:08 +0000 | [diff] [blame] | 185 | testing "mdev #maj,min and no explicit uid" \ |
| 186 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
| 187 | ls -lnR mdev.testdir/dev | $FILTER_LS" \ |
| 188 | "\ |
| 189 | mdev.testdir/dev: |
| 190 | brw-r--r-- 1 0 1 8,0 sda |
| 191 | " \ |
| 192 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 193 | SKIP= |
Denis Vlasenko | 8d89bed | 2008-09-07 23:22:08 +0000 | [diff] [blame] | 194 | |
Denys Vlasenko | 2f86ca1 | 2009-06-22 01:31:12 +0200 | [diff] [blame] | 195 | # continuing to use directory structure from prev test |
| 196 | rm -rf mdev.testdir/dev/* |
| 197 | mkdir -p mdev.testdir/sys/class/tty/capi |
| 198 | echo "191:0" >mdev.testdir/sys/class/tty/capi/dev |
| 199 | mkdir -p mdev.testdir/sys/class/tty/capi1 |
| 200 | echo "191:1" >mdev.testdir/sys/class/tty/capi1/dev |
| 201 | mkdir -p mdev.testdir/sys/class/tty/capi20 |
| 202 | echo "191:20" >mdev.testdir/sys/class/tty/capi20/dev |
| 203 | echo "capi 0:0 0660 =capi20" >mdev.testdir/etc/mdev.conf |
| 204 | echo "capi([0-9]) 0:0 0660 =capi20.0%1" >>mdev.testdir/etc/mdev.conf |
| 205 | echo "capi([0-9]*) 0:0 0660 =capi20.%1" >>mdev.testdir/etc/mdev.conf |
| 206 | # mdev invocation with DEVPATH=/class/tty/capi20 was deleting /dev/capi20 |
Denys Vlasenko | da13824 | 2010-05-11 12:02:48 +0200 | [diff] [blame] | 207 | optional STATIC FEATURE_MDEV_CONF FEATURE_MDEV_RENAME FEATURE_MDEV_RENAME_REGEXP FEATURE_LS_RECURSIVE FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME FEATURE_LS_SORTFILES |
Denys Vlasenko | 2f86ca1 | 2009-06-22 01:31:12 +0200 | [diff] [blame] | 208 | testing "move rule does not delete node with name == device_name" \ |
| 209 | "\ |
| 210 | env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi chroot mdev.testdir /mdev 2>&1; |
| 211 | env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi1 chroot mdev.testdir /mdev 2>&1; |
| 212 | env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi20 chroot mdev.testdir /mdev 2>&1; |
| 213 | ls -lnR mdev.testdir/dev | $FILTER_LS" \ |
| 214 | "\ |
| 215 | mdev.testdir/dev: |
| 216 | crw-rw---- 1 0 0 191,0 capi20 |
| 217 | crw-rw---- 1 0 0 191,1 capi20.01 |
| 218 | crw-rw---- 1 0 0 191,20 capi20.20 |
| 219 | " \ |
| 220 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 221 | SKIP= |
Denys Vlasenko | 2f86ca1 | 2009-06-22 01:31:12 +0200 | [diff] [blame] | 222 | |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 223 | # clean up |
| 224 | rm -rf mdev.testdir |
| 225 | |
| 226 | exit $FAILCOUNT |