Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright 2008 by Denys Vlasenko |
| 3 | # Licensed under GPL v2, see file LICENSE for details. |
| 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 |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 41 | rm -rf mdev.testdir/dev/* |
Denis Vlasenko | 4461564 | 2008-03-29 13:10:57 +0000 | [diff] [blame] | 42 | echo ".* 1:1 666" >mdev.testdir/etc/mdev.conf |
| 43 | echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 44 | optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
Denis Vlasenko | 4461564 | 2008-03-29 13:10:57 +0000 | [diff] [blame] | 45 | testing "mdev stops on first rule" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 46 | "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] | 47 | ls -ln mdev.testdir/dev | $FILTER_LS" \ |
| 48 | "\ |
| 49 | brw-rw-rw- 1 1 1 8,0 sda |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 50 | " \ |
| 51 | "" "" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 52 | SKIP= |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 53 | |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 54 | # continuing to use directory structure from prev test |
| 55 | rm -rf mdev.testdir/dev/* |
Denis Vlasenko | 3161b61 | 2009-04-16 22:42:01 +0000 | [diff] [blame] | 56 | echo "-.* 1:1 666" >mdev.testdir/etc/mdev.conf |
| 57 | echo "sda 2:2 444" >>mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 58 | optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
Denis Vlasenko | 3161b61 | 2009-04-16 22:42:01 +0000 | [diff] [blame] | 59 | testing "mdev does not stop on dash-rule" \ |
| 60 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
| 61 | ls -ln mdev.testdir/dev | $FILTER_LS" \ |
| 62 | "\ |
| 63 | br--r--r-- 1 2 2 8,0 sda |
| 64 | " \ |
| 65 | "" "" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 66 | SKIP= |
Denis Vlasenko | 3161b61 | 2009-04-16 22:42:01 +0000 | [diff] [blame] | 67 | |
| 68 | # continuing to use directory structure from prev test |
| 69 | rm -rf mdev.testdir/dev/* |
Denis Vlasenko | 3798db5 | 2009-04-19 21:37:07 +0000 | [diff] [blame] | 70 | echo "\$MODALIAS=qw 1:1 666" >mdev.testdir/etc/mdev.conf |
| 71 | echo "\$MODALIAS=qw. 2:2 444" >>mdev.testdir/etc/mdev.conf |
| 72 | echo "\$MODALIAS=qw. 3:3 400" >>mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 73 | optional STATIC FEATURE_MDEV_CONF FEATURE_LS_TIMESTAMPS FEATURE_LS_USERNAME |
Denis Vlasenko | 3798db5 | 2009-04-19 21:37:07 +0000 | [diff] [blame] | 74 | testing "mdev \$ENVVAR=regex match" \ |
| 75 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda MODALIAS=qwe chroot mdev.testdir /mdev 2>&1; |
| 76 | ls -ln mdev.testdir/dev | $FILTER_LS" \ |
| 77 | "\ |
| 78 | br--r--r-- 1 2 2 8,0 sda |
| 79 | " \ |
| 80 | "" "" |
Denys Vlasenko | 8e3aff0 | 2010-05-10 11:00:11 +0200 | [diff] [blame] | 81 | SKIP= |
Denis Vlasenko | 3798db5 | 2009-04-19 21:37:07 +0000 | [diff] [blame] | 82 | |
| 83 | # continuing to use directory structure from prev test |
| 84 | rm -rf mdev.testdir/dev/* |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 85 | echo "sda 0:0 444 >disk/scsiA" >mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 86 | 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] | 87 | testing "mdev move/symlink rule '>bar/baz'" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 88 | "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] | 89 | ls -lnR mdev.testdir/dev | $FILTER_LS2" \ |
| 90 | "\ |
| 91 | mdev.testdir/dev: |
| 92 | drwxr-xr-x 2 0 0 disk |
| 93 | lrwxrwxrwx 1 0 0 sda -> disk/scsiA |
| 94 | |
| 95 | mdev.testdir/dev/disk: |
| 96 | br--r--r-- 1 0 0 scsiA |
| 97 | " \ |
| 98 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 99 | SKIP= |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 100 | |
| 101 | # continuing to use directory structure from prev test |
| 102 | rm -rf mdev.testdir/dev/* |
| 103 | echo "sda 0:0 444 >disk/" >mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 104 | 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] | 105 | testing "mdev move/symlink rule '>bar/'" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 106 | "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] | 107 | ls -lnR mdev.testdir/dev | $FILTER_LS2" \ |
| 108 | "\ |
| 109 | mdev.testdir/dev: |
| 110 | drwxr-xr-x 2 0 0 disk |
| 111 | lrwxrwxrwx 1 0 0 sda -> disk/sda |
| 112 | |
| 113 | mdev.testdir/dev/disk: |
| 114 | br--r--r-- 1 0 0 sda |
| 115 | " \ |
| 116 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 117 | SKIP= |
Denis Vlasenko | cae11b5 | 2008-03-29 15:11:07 +0000 | [diff] [blame] | 118 | |
Denis Vlasenko | f2f3868 | 2008-03-29 17:26:10 +0000 | [diff] [blame] | 119 | # continuing to use directory structure from prev test |
| 120 | rm -rf mdev.testdir/dev/* |
| 121 | # here we complicate things by having non-matching group 1 and using %0 |
| 122 | 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] | 123 | 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] | 124 | testing "mdev regexp substring match + replace" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 125 | "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] | 126 | ls -lnR mdev.testdir/dev | $FILTER_LS2" \ |
| 127 | "\ |
| 128 | mdev.testdir/dev: |
| 129 | drwxr-xr-x 2 0 0 sd |
| 130 | lrwxrwxrwx 1 0 0 sda -> sd/a_sda |
| 131 | |
| 132 | mdev.testdir/dev/sd: |
| 133 | brw-r--r-- 1 0 0 a_sda |
| 134 | " \ |
| 135 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 136 | SKIP= |
Denis Vlasenko | f2f3868 | 2008-03-29 17:26:10 +0000 | [diff] [blame] | 137 | |
Denis Vlasenko | 32dcc53 | 2008-05-02 13:21:24 +0000 | [diff] [blame] | 138 | # continuing to use directory structure from prev test |
| 139 | rm -rf mdev.testdir/dev/* |
Denis Vlasenko | 32dcc53 | 2008-05-02 13:21:24 +0000 | [diff] [blame] | 140 | 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] | 141 | 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] | 142 | testing "mdev command" \ |
Denis Vlasenko | 5db861a | 2008-08-04 14:40:58 +0000 | [diff] [blame] | 143 | "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] | 144 | ls -lnR mdev.testdir/dev | $FILTER_LS" \ |
| 145 | "\ |
| 146 | @echo TEST |
| 147 | mdev.testdir/dev: |
| 148 | brw-r--r-- 1 0 0 8,0 sda |
| 149 | " \ |
| 150 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 151 | SKIP= |
Denis Vlasenko | 32dcc53 | 2008-05-02 13:21:24 +0000 | [diff] [blame] | 152 | |
Denis Vlasenko | 8d89bed | 2008-09-07 23:22:08 +0000 | [diff] [blame] | 153 | # continuing to use directory structure from prev test |
| 154 | rm -rf mdev.testdir/dev/* |
Denys Vlasenko | 90db359 | 2009-07-02 13:07:11 +0200 | [diff] [blame] | 155 | 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] | 156 | 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] | 157 | testing "mdev move and command" \ |
| 158 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
| 159 | ls -lnR mdev.testdir/dev | $FILTER_LS2" \ |
| 160 | "\ |
Denys Vlasenko | 90db359 | 2009-07-02 13:07:11 +0200 | [diff] [blame] | 161 | @echo TEST:block/sda |
Denis Vlasenko | 319fe12 | 2009-01-12 07:57:52 +0000 | [diff] [blame] | 162 | mdev.testdir/dev: |
| 163 | drwxr-xr-x 2 0 0 block |
| 164 | |
| 165 | mdev.testdir/dev/block: |
| 166 | brw-r--r-- 1 0 0 sda |
| 167 | " \ |
| 168 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 169 | SKIP= |
Denis Vlasenko | 319fe12 | 2009-01-12 07:57:52 +0000 | [diff] [blame] | 170 | |
| 171 | # continuing to use directory structure from prev test |
| 172 | rm -rf mdev.testdir/dev/* |
Denys Vlasenko | 2441060 | 2009-06-13 23:41:57 +0200 | [diff] [blame] | 173 | echo "@8,0 0:1 644" >mdev.testdir/etc/mdev.conf |
Denys Vlasenko | bfa1b2e | 2010-05-11 03:53:57 +0200 | [diff] [blame] | 174 | 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] | 175 | testing "mdev #maj,min and no explicit uid" \ |
| 176 | "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; |
| 177 | ls -lnR mdev.testdir/dev | $FILTER_LS" \ |
| 178 | "\ |
| 179 | mdev.testdir/dev: |
| 180 | brw-r--r-- 1 0 1 8,0 sda |
| 181 | " \ |
| 182 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 183 | SKIP= |
Denis Vlasenko | 8d89bed | 2008-09-07 23:22:08 +0000 | [diff] [blame] | 184 | |
Denys Vlasenko | 2f86ca1 | 2009-06-22 01:31:12 +0200 | [diff] [blame] | 185 | # continuing to use directory structure from prev test |
| 186 | rm -rf mdev.testdir/dev/* |
| 187 | mkdir -p mdev.testdir/sys/class/tty/capi |
| 188 | echo "191:0" >mdev.testdir/sys/class/tty/capi/dev |
| 189 | mkdir -p mdev.testdir/sys/class/tty/capi1 |
| 190 | echo "191:1" >mdev.testdir/sys/class/tty/capi1/dev |
| 191 | mkdir -p mdev.testdir/sys/class/tty/capi20 |
| 192 | echo "191:20" >mdev.testdir/sys/class/tty/capi20/dev |
| 193 | echo "capi 0:0 0660 =capi20" >mdev.testdir/etc/mdev.conf |
| 194 | echo "capi([0-9]) 0:0 0660 =capi20.0%1" >>mdev.testdir/etc/mdev.conf |
| 195 | echo "capi([0-9]*) 0:0 0660 =capi20.%1" >>mdev.testdir/etc/mdev.conf |
| 196 | # mdev invocation with DEVPATH=/class/tty/capi20 was deleting /dev/capi20 |
Denys Vlasenko | da13824 | 2010-05-11 12:02:48 +0200 | [diff] [blame] | 197 | 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] | 198 | testing "move rule does not delete node with name == device_name" \ |
| 199 | "\ |
| 200 | env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi chroot mdev.testdir /mdev 2>&1; |
| 201 | env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi1 chroot mdev.testdir /mdev 2>&1; |
| 202 | env - PATH=$PATH ACTION=add DEVPATH=/class/tty/capi20 chroot mdev.testdir /mdev 2>&1; |
| 203 | ls -lnR mdev.testdir/dev | $FILTER_LS" \ |
| 204 | "\ |
| 205 | mdev.testdir/dev: |
| 206 | crw-rw---- 1 0 0 191,0 capi20 |
| 207 | crw-rw---- 1 0 0 191,1 capi20.01 |
| 208 | crw-rw---- 1 0 0 191,20 capi20.20 |
| 209 | " \ |
| 210 | "" "" |
Denys Vlasenko | e3d90a9 | 2010-05-10 05:53:16 +0200 | [diff] [blame] | 211 | SKIP= |
Denys Vlasenko | 2f86ca1 | 2009-06-22 01:31:12 +0200 | [diff] [blame] | 212 | |
Denis Vlasenko | e1caabb | 2008-03-27 20:49:26 +0000 | [diff] [blame] | 213 | # clean up |
| 214 | rm -rf mdev.testdir |
| 215 | |
| 216 | exit $FAILCOUNT |