]>
Commit | Line | Data |
---|---|---|
a367f04e GKH |
1 | #!/usr/bin/perl |
2 | ||
438d4c3c | 3 | # udev test |
a367f04e GKH |
4 | # |
5 | # Provides automated testing of the udev binary. | |
6 | # The whole test is self contained in this file, except the matching sysfs tree. | |
7 | # Simply extend the @tests array, to add a new test variant. | |
8 | # | |
9 | # Every test is driven by its own temporary config file. | |
10 | # This program prepares the environment, creates the config and calls udev. | |
11 | # | |
65005a7f | 12 | # udev parses the rules, looks at the provided sysfs and |
a367f04e GKH |
13 | # first creates and then removes the device node. |
14 | # After creation and removal the result is checked against the | |
15 | # expected value and the result is printed. | |
16 | # | |
438d4c3c | 17 | # Copyright (C) 2004-2008 Kay Sievers <kay.sievers@vrfy.org> |
c4edd0ad | 18 | # Copyright (C) 2004 Leann Ogasawara <ogasawara@osdl.org> |
a367f04e GKH |
19 | |
20 | use warnings; | |
21 | use strict; | |
22 | ||
e08109cb | 23 | my $PWD = $ENV{PWD}; |
10283186 | 24 | my $sysfs = "test/sys/"; |
405e606f | 25 | my $udev_bin = "udev/test-udev"; |
e08109cb KS |
26 | my $valgrind = 0; |
27 | my $udev_bin_valgrind = "valgrind --tool=memcheck --leak-check=yes --quiet $udev_bin"; | |
28 | my $udev_root = "udev-root/"; | |
29 | my $udev_conf = "udev-test.conf"; | |
30 | my $udev_rules = "udev-test.rules"; | |
a367f04e | 31 | |
a367f04e | 32 | my @tests = ( |
bcf44d55 KS |
33 | { |
34 | desc => "no rules", | |
35 | subsys => "block", | |
36 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", | |
37 | exp_name => "sda" , | |
38 | rules => <<EOF | |
39 | EOF | |
40 | }, | |
c4edd0ad | 41 | { |
f49a6b22 | 42 | desc => "label test of scsi disc", |
c4edd0ad | 43 | subsys => "block", |
c7fcba1b | 44 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
c4edd0ad KS |
45 | exp_name => "boot_disk" , |
46 | rules => <<EOF | |
c6243a41 | 47 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", NAME="boot_disk%n", RUN+="socket:@/org/kernel/udev/monitor" |
c7fcba1b | 48 | KERNEL=="ttyACM0", NAME="modem" |
c4edd0ad KS |
49 | EOF |
50 | }, | |
51 | { | |
f49a6b22 | 52 | desc => "label test of scsi disc", |
c4edd0ad | 53 | subsys => "block", |
c7fcba1b | 54 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
c4edd0ad KS |
55 | exp_name => "boot_disk" , |
56 | rules => <<EOF | |
c7fcba1b KS |
57 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", NAME="boot_disk%n" |
58 | KERNEL=="ttyACM0", NAME="modem" | |
c4edd0ad KS |
59 | EOF |
60 | }, | |
a367f04e | 61 | { |
fa19f181 KS |
62 | desc => "label test of scsi disc", |
63 | subsys => "block", | |
c7fcba1b | 64 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
c013b034 | 65 | exp_name => "boot_disk" , |
65005a7f | 66 | rules => <<EOF |
c7fcba1b KS |
67 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", NAME="boot_disk%n" |
68 | KERNEL=="ttyACM0", NAME="modem" | |
a367f04e GKH |
69 | EOF |
70 | }, | |
71 | { | |
fa19f181 KS |
72 | desc => "label test of scsi partition", |
73 | subsys => "block", | |
c7fcba1b | 74 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
c013b034 | 75 | exp_name => "boot_disk1" , |
65005a7f | 76 | rules => <<EOF |
c7fcba1b | 77 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", NAME="boot_disk%n" |
83be97ba KS |
78 | EOF |
79 | }, | |
80 | { | |
fa19f181 KS |
81 | desc => "label test of pattern match", |
82 | subsys => "block", | |
c7fcba1b | 83 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
c013b034 | 84 | exp_name => "boot_disk1" , |
65005a7f | 85 | rules => <<EOF |
c7fcba1b KS |
86 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="?ATA", NAME="boot_disk%n-1" |
87 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA?", NAME="boot_disk%n-2" | |
88 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="A??", NAME="boot_disk%n" | |
89 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATAS", NAME="boot_disk%n-3" | |
358c8c20 GKH |
90 | EOF |
91 | }, | |
92 | { | |
fa19f181 KS |
93 | desc => "label test of multiple sysfs files", |
94 | subsys => "block", | |
c7fcba1b | 95 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
fa19f181 | 96 | exp_name => "boot_disk1" , |
65005a7f | 97 | rules => <<EOF |
c7fcba1b KS |
98 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS X ", NAME="boot_diskX%n" |
99 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", NAME="boot_disk%n" | |
358c8c20 GKH |
100 | EOF |
101 | }, | |
102 | { | |
d960ad15 | 103 | desc => "label test of max sysfs files (skip invalid rule)", |
fa19f181 | 104 | subsys => "block", |
c7fcba1b | 105 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
fa19f181 | 106 | exp_name => "boot_disk1" , |
65005a7f | 107 | rules => <<EOF |
c7fcba1b KS |
108 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", ATTRS{queue_depth}=="32", NAME="boot_diskXX%n" |
109 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", NAME="boot_disk%n" | |
0db6d4cc KS |
110 | EOF |
111 | }, | |
112 | { | |
fa19f181 KS |
113 | desc => "catch device by *", |
114 | subsys => "tty", | |
f2041f01 | 115 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 116 | exp_name => "modem/0" , |
65005a7f | 117 | rules => <<EOF |
c7fcba1b | 118 | KERNEL=="ttyACM*", NAME="modem/%n" |
2e317184 GKH |
119 | EOF |
120 | }, | |
121 | { | |
fa19f181 KS |
122 | desc => "catch device by * - take 2", |
123 | subsys => "tty", | |
f2041f01 | 124 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 125 | exp_name => "modem/0" , |
65005a7f | 126 | rules => <<EOF |
c7fcba1b KS |
127 | KERNEL=="*ACM1", NAME="bad" |
128 | KERNEL=="*ACM0", NAME="modem/%n" | |
9f1da361 KS |
129 | EOF |
130 | }, | |
131 | { | |
fa19f181 KS |
132 | desc => "catch device by ?", |
133 | subsys => "tty", | |
f2041f01 | 134 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 135 | exp_name => "modem/0" , |
65005a7f | 136 | rules => <<EOF |
c7fcba1b KS |
137 | KERNEL=="ttyACM??*", NAME="modem/%n-1" |
138 | KERNEL=="ttyACM??", NAME="modem/%n-2" | |
139 | KERNEL=="ttyACM?", NAME="modem/%n" | |
9f1da361 KS |
140 | EOF |
141 | }, | |
142 | { | |
fa19f181 KS |
143 | desc => "catch device by character class", |
144 | subsys => "tty", | |
f2041f01 | 145 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 146 | exp_name => "modem/0" , |
65005a7f | 147 | rules => <<EOF |
c7fcba1b KS |
148 | KERNEL=="ttyACM[A-Z]*", NAME="modem/%n-1" |
149 | KERNEL=="ttyACM?[0-9]", NAME="modem/%n-2" | |
150 | KERNEL=="ttyACM[0-9]*", NAME="modem/%n" | |
a367f04e GKH |
151 | EOF |
152 | }, | |
153 | { | |
fa19f181 KS |
154 | desc => "replace kernel name", |
155 | subsys => "tty", | |
f2041f01 | 156 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 157 | exp_name => "modem" , |
65005a7f | 158 | rules => <<EOF |
c7fcba1b | 159 | KERNEL=="ttyACM0", NAME="modem" |
281ff00a GKH |
160 | EOF |
161 | }, | |
162 | { | |
fa19f181 KS |
163 | desc => "Handle comment lines in config file (and replace kernel name)", |
164 | subsys => "tty", | |
f2041f01 | 165 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 166 | exp_name => "modem" , |
65005a7f | 167 | rules => <<EOF |
281ff00a | 168 | # this is a comment |
c7fcba1b | 169 | KERNEL=="ttyACM0", NAME="modem" |
281ff00a GKH |
170 | |
171 | EOF | |
172 | }, | |
173 | { | |
fa19f181 KS |
174 | desc => "Handle comment lines in config file with whitespace (and replace kernel name)", |
175 | subsys => "tty", | |
f2041f01 | 176 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 177 | exp_name => "modem" , |
65005a7f | 178 | rules => <<EOF |
281ff00a | 179 | # this is a comment with whitespace before the comment |
c7fcba1b | 180 | KERNEL=="ttyACM0", NAME="modem" |
281ff00a | 181 | |
3db7fa27 KS |
182 | EOF |
183 | }, | |
184 | { | |
185 | desc => "Handle whitespace only lines (and replace kernel name)", | |
186 | subsys => "tty", | |
f2041f01 | 187 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
3db7fa27 | 188 | exp_name => "whitespace" , |
65005a7f | 189 | rules => <<EOF |
3db7fa27 KS |
190 | |
191 | ||
192 | ||
193 | # this is a comment with whitespace before the comment | |
c7fcba1b | 194 | KERNEL=="ttyACM0", NAME="whitespace" |
3db7fa27 KS |
195 | |
196 | ||
197 | ||
281ff00a GKH |
198 | EOF |
199 | }, | |
200 | { | |
fa19f181 KS |
201 | desc => "Handle empty lines in config file (and replace kernel name)", |
202 | subsys => "tty", | |
f2041f01 | 203 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 204 | exp_name => "modem" , |
65005a7f | 205 | rules => <<EOF |
281ff00a | 206 | |
c7fcba1b | 207 | KERNEL=="ttyACM0", NAME="modem" |
281ff00a | 208 | |
9f8dfa19 KS |
209 | EOF |
210 | }, | |
211 | { | |
212 | desc => "Handle backslashed multi lines in config file (and replace kernel name)", | |
213 | subsys => "tty", | |
f2041f01 | 214 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 215 | exp_name => "modem" , |
65005a7f | 216 | rules => <<EOF |
c7fcba1b KS |
217 | KERNEL=="ttyACM0", \\ |
218 | NAME="modem" | |
9f8dfa19 | 219 | |
77313cd0 KS |
220 | EOF |
221 | }, | |
222 | { | |
223 | desc => "preserve backslashes, if they are not for a newline", | |
224 | subsys => "tty", | |
f2041f01 | 225 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
77313cd0 | 226 | exp_name => "aaa", |
65005a7f | 227 | rules => <<EOF |
c7fcba1b | 228 | KERNEL=="ttyACM0", PROGRAM=="/bin/echo -e \\101", RESULT=="A", NAME="aaa" |
9f8dfa19 KS |
229 | EOF |
230 | }, | |
231 | { | |
232 | desc => "Handle stupid backslashed multi lines in config file (and replace kernel name)", | |
233 | subsys => "tty", | |
f2041f01 | 234 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 235 | exp_name => "modem" , |
65005a7f | 236 | rules => <<EOF |
9f8dfa19 KS |
237 | |
238 | # | |
239 | \\ | |
240 | ||
d960ad15 | 241 | \\ |
9f8dfa19 KS |
242 | |
243 | #\\ | |
244 | ||
c7fcba1b KS |
245 | KERNEL=="ttyACM0", \\ |
246 | NAME="modem" | |
9f8dfa19 | 247 | |
5499d319 KS |
248 | EOF |
249 | }, | |
250 | { | |
fa19f181 KS |
251 | desc => "subdirectory handling", |
252 | subsys => "tty", | |
f2041f01 | 253 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 254 | exp_name => "sub/direct/ory/modem" , |
65005a7f | 255 | rules => <<EOF |
c7fcba1b | 256 | KERNEL=="ttyACM0", NAME="sub/direct/ory/modem" |
a367f04e GKH |
257 | EOF |
258 | }, | |
259 | { | |
03b24b71 | 260 | desc => "parent device name match of scsi partition", |
fa19f181 | 261 | subsys => "block", |
c7fcba1b KS |
262 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
263 | exp_name => "first_disk5" , | |
65005a7f | 264 | rules => <<EOF |
c4edd0ad | 265 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", NAME="first_disk%n" |
c4edd0ad KS |
266 | EOF |
267 | }, | |
268 | { | |
269 | desc => "test substitution chars", | |
270 | subsys => "block", | |
c7fcba1b KS |
271 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
272 | exp_name => "Major:8:minor:5:kernelnumber:5:id:0:0:0:0" , | |
c4edd0ad KS |
273 | rules => <<EOF |
274 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", NAME="Major:%M:minor:%m:kernelnumber:%n:id:%b" | |
bd0ed2ff KS |
275 | EOF |
276 | }, | |
277 | { | |
319c6700 | 278 | desc => "import of shell-value file", |
bd0ed2ff | 279 | subsys => "block", |
c7fcba1b | 280 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
37a123a9 | 281 | exp_name => "subdir/err/node" , |
bd0ed2ff | 282 | rules => <<EOF |
c4edd0ad | 283 | SUBSYSTEMS=="scsi", IMPORT{file}="udev-test.conf", NAME="subdir/%E{udev_log}/node" |
c7fcba1b | 284 | KERNEL=="ttyACM0", NAME="modem" |
319c6700 KS |
285 | EOF |
286 | }, | |
287 | { | |
288 | desc => "import of shell-value returned from program", | |
289 | subsys => "block", | |
c7fcba1b | 290 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
319c6700 KS |
291 | exp_name => "node12345678", |
292 | rules => <<EOF | |
c1987051 | 293 | SUBSYSTEMS=="scsi", IMPORT="/bin/echo -e \' TEST_KEY=12345678\\n TEST_key2=98765\'", NAME="node\$env{TEST_KEY}" |
c7fcba1b | 294 | KERNEL=="ttyACM0", NAME="modem" |
a27cd06c KS |
295 | EOF |
296 | }, | |
297 | { | |
fa19f181 KS |
298 | desc => "sustitution of sysfs value (%s{file})", |
299 | subsys => "block", | |
c7fcba1b KS |
300 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
301 | exp_name => "disk-ATA-sda" , | |
65005a7f | 302 | rules => <<EOF |
c7fcba1b KS |
303 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", NAME="disk-%s{vendor}-%k" |
304 | KERNEL=="ttyACM0", NAME="modem" | |
a367f04e GKH |
305 | EOF |
306 | }, | |
307 | { | |
fa19f181 KS |
308 | desc => "program result substitution", |
309 | subsys => "block", | |
c7fcba1b KS |
310 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
311 | exp_name => "special-device-5" , | |
65005a7f | 312 | rules => <<EOF |
c4edd0ad KS |
313 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="-special-*", NAME="%c-1-%n" |
314 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special--*", NAME="%c-2-%n" | |
315 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special-device-", NAME="%c-3-%n" | |
316 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special-devic", NAME="%c-4-%n" | |
317 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special-*", NAME="%c-%n" | |
bbbe503e KS |
318 | EOF |
319 | }, | |
320 | { | |
321 | desc => "program result substitution (newline removal)", | |
322 | subsys => "block", | |
c7fcba1b | 323 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
bbbe503e | 324 | exp_name => "newline_removed" , |
65005a7f | 325 | rules => <<EOF |
c4edd0ad | 326 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo test", RESULT=="test", NAME="newline_removed" |
f3b04a2e GKH |
327 | EOF |
328 | }, | |
329 | { | |
fa19f181 KS |
330 | desc => "program result substitution", |
331 | subsys => "block", | |
c7fcba1b | 332 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
03b24b71 | 333 | exp_name => "test-0:0:0:0" , |
65005a7f | 334 | rules => <<EOF |
c4edd0ad | 335 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n test-%b", RESULT=="test-0:0*", NAME="%c" |
dde05ccb GKH |
336 | EOF |
337 | }, | |
338 | { | |
fa19f181 KS |
339 | desc => "program with lots of arguments", |
340 | subsys => "block", | |
c7fcba1b | 341 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
fa19f181 | 342 | exp_name => "foo9" , |
65005a7f | 343 | rules => <<EOF |
c7fcba1b | 344 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", NAME="%c{7}" |
35b38379 KS |
345 | EOF |
346 | }, | |
347 | { | |
fa19f181 KS |
348 | desc => "program with subshell", |
349 | subsys => "block", | |
c7fcba1b | 350 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
fa19f181 | 351 | exp_name => "bar9" , |
65005a7f | 352 | rules => <<EOF |
c7fcba1b | 353 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c 'echo foo3 foo4 foo5 foo6 foo7 foo8 foo9 | sed s/foo9/bar9/'", KERNEL=="sda5", NAME="%c{7}" |
35b38379 KS |
354 | EOF |
355 | }, | |
356 | { | |
fa19f181 KS |
357 | desc => "program arguments combined with apostrophes", |
358 | subsys => "block", | |
c7fcba1b | 359 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
fa19f181 | 360 | exp_name => "foo7" , |
65005a7f | 361 | rules => <<EOF |
c7fcba1b | 362 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n 'foo3 foo4' 'foo5 foo6 foo7 foo8'", KERNEL=="sda5", NAME="%c{5}" |
56c963dc PM |
363 | EOF |
364 | }, | |
365 | { | |
fa19f181 KS |
366 | desc => "characters before the %c{N} substitution", |
367 | subsys => "block", | |
c7fcba1b | 368 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
fa19f181 | 369 | exp_name => "my-foo9" , |
65005a7f | 370 | rules => <<EOF |
c7fcba1b | 371 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", NAME="my-%c{7}" |
56c963dc PM |
372 | EOF |
373 | }, | |
374 | { | |
fa19f181 KS |
375 | desc => "substitute the second to last argument", |
376 | subsys => "block", | |
c7fcba1b | 377 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
fa19f181 | 378 | exp_name => "my-foo8" , |
65005a7f | 379 | rules => <<EOF |
c7fcba1b | 380 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", NAME="my-%c{6}" |
bf5d2964 KS |
381 | EOF |
382 | }, | |
383 | { | |
384 | desc => "test substitution by variable name", | |
385 | subsys => "block", | |
c7fcba1b KS |
386 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
387 | exp_name => "Major:8-minor:5-kernelnumber:5-id:0:0:0:0", | |
bf5d2964 | 388 | rules => <<EOF |
c4edd0ad | 389 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", NAME="Major:\$major-minor:\$minor-kernelnumber:\$number-id:\$id" |
bf5d2964 KS |
390 | EOF |
391 | }, | |
392 | { | |
393 | desc => "test substitution by variable name 2", | |
394 | subsys => "block", | |
c7fcba1b KS |
395 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
396 | exp_name => "Major:8-minor:5-kernelnumber:5-id:0:0:0:0", | |
bf5d2964 | 397 | rules => <<EOF |
c4edd0ad | 398 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", NAME="Major:\$major-minor:%m-kernelnumber:\$number-id:\$id" |
bf5d2964 KS |
399 | EOF |
400 | }, | |
401 | { | |
402 | desc => "test substitution by variable name 3", | |
403 | subsys => "block", | |
c7fcba1b KS |
404 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
405 | exp_name => "850:0:0:05" , | |
bf5d2964 | 406 | rules => <<EOF |
c4edd0ad | 407 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", NAME="%M%m%b%n" |
bf5d2964 KS |
408 | EOF |
409 | }, | |
410 | { | |
411 | desc => "test substitution by variable name 4", | |
412 | subsys => "block", | |
c7fcba1b KS |
413 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
414 | exp_name => "855" , | |
bf5d2964 | 415 | rules => <<EOF |
c4edd0ad | 416 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", NAME="\$major\$minor\$number" |
bf5d2964 KS |
417 | EOF |
418 | }, | |
419 | { | |
420 | desc => "test substitution by variable name 5", | |
421 | subsys => "block", | |
c7fcba1b KS |
422 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
423 | exp_name => "8550:0:0:0" , | |
bf5d2964 | 424 | rules => <<EOF |
c4edd0ad | 425 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", NAME="\$major%m%n\$id" |
8ff8bbba GKH |
426 | EOF |
427 | }, | |
428 | { | |
c4edd0ad | 429 | desc => "non matching SUBSYSTEMS for device with no parent", |
fa19f181 | 430 | subsys => "tty", |
c7fcba1b | 431 | devpath => "/devices/virtual/tty/console", |
03b24b71 | 432 | exp_name => "TTY", |
65005a7f | 433 | rules => <<EOF |
c4edd0ad | 434 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo", RESULT=="foo", NAME="foo" |
28ce66de | 435 | KERNEL=="console", NAME="TTY" |
1d936fbc GKH |
436 | EOF |
437 | }, | |
438 | { | |
c4edd0ad | 439 | desc => "non matching SUBSYSTEMS", |
fa19f181 | 440 | subsys => "tty", |
c7fcba1b | 441 | devpath => "/devices/virtual/tty/console", |
fa19f181 | 442 | exp_name => "TTY" , |
65005a7f | 443 | rules => <<EOF |
c4edd0ad | 444 | SUBSYSTEMS=="foo", ATTRS{dev}=="5:1", NAME="foo" |
28ce66de | 445 | KERNEL=="console", NAME="TTY" |
64682333 GKH |
446 | EOF |
447 | }, | |
448 | { | |
c4edd0ad | 449 | desc => "ATTRS match", |
fa19f181 | 450 | subsys => "tty", |
c7fcba1b | 451 | devpath => "/devices/virtual/tty/console", |
fa19f181 | 452 | exp_name => "foo" , |
65005a7f | 453 | rules => <<EOF |
28ce66de | 454 | KERNEL=="console", NAME="TTY" |
6880b25d | 455 | ATTRS{dev}=="5:1", NAME="foo" |
a402404f KS |
456 | EOF |
457 | }, | |
458 | { | |
459 | desc => "ATTR (empty file)", | |
460 | subsys => "tty", | |
461 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", | |
462 | exp_name => "empty" , | |
463 | rules => <<EOF | |
464 | KERNEL=="sda", ATTR{test_empty_file}=="?*", NAME:="something" | |
465 | KERNEL=="sda", ATTR{test_empty_file}!="", NAME:="not-empty" | |
466 | KERNEL=="sda", ATTR{test_empty_file}=="", NAME:="empty" | |
467 | KERNEL=="sda", ATTR{test_empty_file}!="?*", NAME:="not-something" | |
468 | KERNEL=="sda", NAME="wrong" | |
469 | EOF | |
470 | }, | |
471 | { | |
472 | desc => "ATTR (non-existent file)", | |
473 | subsys => "tty", | |
474 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", | |
475 | exp_name => "non-existent" , | |
476 | rules => <<EOF | |
477 | KERNEL=="sda", ATTR{nofile}=="?*", NAME:="something" | |
478 | KERNEL=="sda", ATTR{nofile}!="", NAME:="not-empty" | |
479 | KERNEL=="sda", ATTR{nofile}=="", NAME:="empty" | |
480 | KERNEL=="sda", ATTR{nofile}!="?*", NAME:="not-something" | |
481 | KERNEL=="sda", TEST!="nofile", NAME:="non-existent" | |
482 | KERNEL=="sda", NAME="wrong" | |
772558f4 GKH |
483 | EOF |
484 | }, | |
485 | { | |
fa19f181 KS |
486 | desc => "program and bus type match", |
487 | subsys => "block", | |
c7fcba1b | 488 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
03b24b71 | 489 | exp_name => "scsi-0:0:0:0" , |
65005a7f | 490 | rules => <<EOF |
c4edd0ad KS |
491 | SUBSYSTEMS=="usb", PROGRAM=="/bin/echo -n usb-%b", NAME="%c" |
492 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n scsi-%b", NAME="%c" | |
493 | SUBSYSTEMS=="foo", PROGRAM=="/bin/echo -n foo-%b", NAME="%c" | |
724257d9 GKH |
494 | EOF |
495 | }, | |
496 | { | |
fa19f181 KS |
497 | desc => "create all possible partitions", |
498 | subsys => "block", | |
c7fcba1b | 499 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fa19f181 | 500 | exp_name => "boot_disk15" , |
15139b8a | 501 | exp_majorminor => "8:15", |
65005a7f | 502 | rules => <<EOF |
c7fcba1b | 503 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", NAME{all_partitions}="boot_disk" |
50e5de03 KS |
504 | EOF |
505 | }, | |
506 | { | |
fa19f181 KS |
507 | desc => "sysfs parent hierarchy", |
508 | subsys => "tty", | |
f2041f01 | 509 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 510 | exp_name => "modem" , |
65005a7f | 511 | rules => <<EOF |
c7fcba1b | 512 | ATTRS{idProduct}=="007b", NAME="modem" |
f0142622 GKH |
513 | EOF |
514 | }, | |
515 | { | |
fa19f181 KS |
516 | desc => "name test with ! in the name", |
517 | subsys => "block", | |
c7fcba1b KS |
518 | devpath => "/devices/virtual/block/fake!blockdev0", |
519 | exp_name => "is/a/fake/blockdev0" , | |
65005a7f | 520 | rules => <<EOF |
c7fcba1b KS |
521 | SUBSYSTEMS=="scsi", NAME="is/not/a/%k" |
522 | SUBSYSTEM=="block", NAME="is/a/%k" | |
523 | KERNEL=="ttyACM0", NAME="modem" | |
b9fc973b GKH |
524 | EOF |
525 | }, | |
526 | { | |
fa19f181 KS |
527 | desc => "name test with ! in the name, but no matching rule", |
528 | subsys => "block", | |
c7fcba1b KS |
529 | devpath => "/devices/virtual/block/fake!blockdev0", |
530 | exp_name => "fake/blockdev0" , | |
65005a7f | 531 | rules => <<EOF |
c7fcba1b | 532 | KERNEL=="ttyACM0", NAME="modem" |
93656247 PM |
533 | EOF |
534 | }, | |
535 | { | |
c4edd0ad | 536 | desc => "KERNELS rule", |
fa19f181 | 537 | subsys => "block", |
c7fcba1b | 538 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fa19f181 | 539 | exp_name => "scsi-0:0:0:0", |
65005a7f | 540 | rules => <<EOF |
c4edd0ad KS |
541 | SUBSYSTEMS=="usb", KERNELS=="0:0:0:0", NAME="not-scsi" |
542 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:1", NAME="no-match" | |
543 | SUBSYSTEMS=="scsi", KERNELS==":0", NAME="short-id" | |
544 | SUBSYSTEMS=="scsi", KERNELS=="/0:0:0:0", NAME="no-match" | |
545 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", NAME="scsi-0:0:0:0" | |
93656247 PM |
546 | EOF |
547 | }, | |
548 | { | |
c4edd0ad | 549 | desc => "KERNELS wildcard all", |
fa19f181 | 550 | subsys => "block", |
c7fcba1b | 551 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fa19f181 | 552 | exp_name => "scsi-0:0:0:0", |
65005a7f | 553 | rules => <<EOF |
c4edd0ad KS |
554 | SUBSYSTEMS=="scsi", KERNELS=="*:1", NAME="no-match" |
555 | SUBSYSTEMS=="scsi", KERNELS=="*:0:1", NAME="no-match" | |
556 | SUBSYSTEMS=="scsi", KERNELS=="*:0:0:1", NAME="no-match" | |
6880b25d | 557 | SUBSYSTEMS=="scsi", KERNEL=="0:0:0:0", NAME="before" |
c4edd0ad | 558 | SUBSYSTEMS=="scsi", KERNELS=="*", NAME="scsi-0:0:0:0" |
93656247 PM |
559 | EOF |
560 | }, | |
561 | { | |
c4edd0ad | 562 | desc => "KERNELS wildcard partial", |
fa19f181 | 563 | subsys => "block", |
c7fcba1b | 564 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fa19f181 | 565 | exp_name => "scsi-0:0:0:0", |
65005a7f | 566 | rules => <<EOF |
6880b25d | 567 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", NAME="before" |
c4edd0ad | 568 | SUBSYSTEMS=="scsi", KERNELS=="*:0", NAME="scsi-0:0:0:0" |
93656247 PM |
569 | EOF |
570 | }, | |
571 | { | |
c4edd0ad | 572 | desc => "KERNELS wildcard partial 2", |
fa19f181 | 573 | subsys => "block", |
c7fcba1b | 574 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fa19f181 | 575 | exp_name => "scsi-0:0:0:0", |
65005a7f | 576 | rules => <<EOF |
6880b25d | 577 | SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", NAME="before" |
c4edd0ad | 578 | SUBSYSTEMS=="scsi", KERNELS=="*:0:0:0", NAME="scsi-0:0:0:0" |
eef54479 KS |
579 | EOF |
580 | }, | |
581 | { | |
582 | desc => "substitute attr with link target value (first match)", | |
583 | subsys => "block", | |
c7fcba1b | 584 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
eef54479 KS |
585 | exp_name => "driver-is-sd", |
586 | rules => <<EOF | |
587 | SUBSYSTEMS=="scsi", NAME="driver-is-\$attr{driver}" | |
588 | EOF | |
589 | }, | |
590 | { | |
591 | desc => "substitute attr with link target value (currently selected device)", | |
592 | subsys => "block", | |
c7fcba1b KS |
593 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
594 | exp_name => "driver-is-ahci", | |
eef54479 KS |
595 | rules => <<EOF |
596 | SUBSYSTEMS=="pci", NAME="driver-is-\$attr{driver}" | |
d5f91372 KS |
597 | EOF |
598 | }, | |
599 | { | |
c4edd0ad | 600 | desc => "ignore ATTRS attribute whitespace", |
fa19f181 | 601 | subsys => "block", |
c7fcba1b | 602 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fa19f181 | 603 | exp_name => "ignored", |
65005a7f | 604 | rules => <<EOF |
c4edd0ad | 605 | SUBSYSTEMS=="scsi", ATTRS{whitespace_test}=="WHITE SPACE", NAME="ignored" |
d5f91372 KS |
606 | EOF |
607 | }, | |
608 | { | |
c4edd0ad | 609 | desc => "do not ignore ATTRS attribute whitespace", |
fa19f181 | 610 | subsys => "block", |
c7fcba1b | 611 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fa19f181 | 612 | exp_name => "matched-with-space", |
65005a7f | 613 | rules => <<EOF |
c4edd0ad KS |
614 | SUBSYSTEMS=="scsi", ATTRS{whitespace_test}=="WHITE SPACE ", NAME="wrong-to-ignore" |
615 | SUBSYSTEMS=="scsi", ATTRS{whitespace_test}=="WHITE SPACE ", NAME="matched-with-space" | |
0a5417a0 KS |
616 | EOF |
617 | }, | |
618 | { | |
8b36cc0f | 619 | desc => "permissions USER=bad GROUP=name", |
b8669191 | 620 | subsys => "tty", |
5c0f595d | 621 | devpath => "/devices/virtual/tty/tty33", |
b8669191 | 622 | exp_name => "tty33", |
4ae6d03f | 623 | exp_perms => "0:0:0660", |
65005a7f | 624 | rules => <<EOF |
28ce66de | 625 | KERNEL=="tty33", NAME="tty33", OWNER="bad", GROUP="name" |
b8669191 GKH |
626 | EOF |
627 | }, | |
628 | { | |
8b36cc0f | 629 | desc => "permissions OWNER=5000", |
fa19f181 | 630 | subsys => "block", |
c7fcba1b | 631 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fa19f181 | 632 | exp_name => "node", |
4ae6d03f | 633 | exp_perms => "5000::0660", |
65005a7f | 634 | rules => <<EOF |
c4edd0ad | 635 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", OWNER="5000" |
b8669191 GKH |
636 | EOF |
637 | }, | |
638 | { | |
8b36cc0f | 639 | desc => "permissions GROUP=100", |
b8669191 | 640 | subsys => "block", |
c7fcba1b | 641 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
b8669191 | 642 | exp_name => "node", |
4ae6d03f | 643 | exp_perms => ":100:0660", |
65005a7f | 644 | rules => <<EOF |
c4edd0ad | 645 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", GROUP="100" |
9b434de1 KS |
646 | EOF |
647 | }, | |
648 | { | |
649 | desc => "textual user id", | |
650 | subsys => "block", | |
c7fcba1b | 651 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
9b434de1 | 652 | exp_name => "node", |
0bb43877 | 653 | exp_perms => "nobody::0660", |
65005a7f | 654 | rules => <<EOF |
c4edd0ad | 655 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", OWNER="nobody" |
9b434de1 KS |
656 | EOF |
657 | }, | |
658 | { | |
659 | desc => "textual group id", | |
660 | subsys => "block", | |
c7fcba1b | 661 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
9b434de1 KS |
662 | exp_name => "node", |
663 | exp_perms => ":daemon:0660", | |
65005a7f | 664 | rules => <<EOF |
c4edd0ad | 665 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", GROUP="daemon" |
c8278763 KS |
666 | EOF |
667 | }, | |
668 | { | |
669 | desc => "textual user/group id", | |
670 | subsys => "block", | |
c7fcba1b | 671 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
c8278763 | 672 | exp_name => "node", |
0bb43877 | 673 | exp_perms => "root:mail:0660", |
65005a7f | 674 | rules => <<EOF |
c4edd0ad | 675 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", OWNER="root", GROUP="mail" |
b8669191 GKH |
676 | EOF |
677 | }, | |
678 | { | |
8b36cc0f | 679 | desc => "permissions MODE=0777", |
b8669191 | 680 | subsys => "block", |
c7fcba1b | 681 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
b8669191 GKH |
682 | exp_name => "node", |
683 | exp_perms => "::0777", | |
65005a7f | 684 | rules => <<EOF |
c4edd0ad | 685 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", MODE="0777" |
b8669191 GKH |
686 | EOF |
687 | }, | |
688 | { | |
8b36cc0f | 689 | desc => "permissions OWNER=5000 GROUP=100 MODE=0777", |
b8669191 | 690 | subsys => "block", |
c7fcba1b | 691 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
b8669191 GKH |
692 | exp_name => "node", |
693 | exp_perms => "5000:100:0777", | |
65005a7f | 694 | rules => <<EOF |
c4edd0ad | 695 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", OWNER="5000", GROUP="100", MODE="0777" |
b8669191 GKH |
696 | EOF |
697 | }, | |
698 | { | |
8b36cc0f | 699 | desc => "permissions OWNER to 5000", |
b8669191 | 700 | subsys => "tty", |
f2041f01 | 701 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 702 | exp_name => "ttyACM0", |
8b36cc0f | 703 | exp_perms => "5000::", |
65005a7f | 704 | rules => <<EOF |
c7fcba1b | 705 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", OWNER="5000" |
b8669191 GKH |
706 | EOF |
707 | }, | |
708 | { | |
8b36cc0f | 709 | desc => "permissions GROUP to 100", |
b8669191 | 710 | subsys => "tty", |
f2041f01 | 711 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 712 | exp_name => "ttyACM0", |
4ae6d03f | 713 | exp_perms => ":100:0660", |
65005a7f | 714 | rules => <<EOF |
c7fcba1b | 715 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", GROUP="100" |
b8669191 GKH |
716 | EOF |
717 | }, | |
718 | { | |
8b36cc0f | 719 | desc => "permissions MODE to 0060", |
b8669191 | 720 | subsys => "tty", |
f2041f01 | 721 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 722 | exp_name => "ttyACM0", |
8b36cc0f | 723 | exp_perms => "::0060", |
65005a7f | 724 | rules => <<EOF |
c7fcba1b | 725 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", MODE="0060" |
b8669191 GKH |
726 | EOF |
727 | }, | |
728 | { | |
8b36cc0f | 729 | desc => "permissions OWNER, GROUP, MODE", |
b8669191 | 730 | subsys => "tty", |
f2041f01 | 731 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 732 | exp_name => "ttyACM0", |
b8669191 | 733 | exp_perms => "5000:100:0777", |
65005a7f | 734 | rules => <<EOF |
c7fcba1b | 735 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", OWNER="5000", GROUP="100", MODE="0777" |
e9390146 KS |
736 | EOF |
737 | }, | |
738 | { | |
739 | desc => "permissions only rule", | |
740 | subsys => "tty", | |
f2041f01 | 741 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 742 | exp_name => "ttyACM0", |
e9390146 | 743 | exp_perms => "5000:100:0777", |
65005a7f | 744 | rules => <<EOF |
c7fcba1b | 745 | KERNEL=="ttyACM[0-9]*", OWNER="5000", GROUP="100", MODE="0777" |
28ce66de | 746 | KERNEL=="ttyUSX[0-9]*", OWNER="5001", GROUP="101", MODE="0444" |
c7fcba1b | 747 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n" |
eb870090 KS |
748 | EOF |
749 | }, | |
750 | { | |
751 | desc => "multiple permissions only rule", | |
752 | subsys => "tty", | |
f2041f01 | 753 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 754 | exp_name => "ttyACM0", |
eb870090 | 755 | exp_perms => "3000:4000:0777", |
65005a7f | 756 | rules => <<EOF |
28ce66de KS |
757 | SUBSYSTEM=="tty", OWNER="3000" |
758 | SUBSYSTEM=="tty", GROUP="4000" | |
759 | SUBSYSTEM=="tty", MODE="0777" | |
760 | KERNEL=="ttyUSX[0-9]*", OWNER="5001", GROUP="101", MODE="0444" | |
c7fcba1b | 761 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n" |
eb870090 KS |
762 | EOF |
763 | }, | |
764 | { | |
765 | desc => "permissions only rule with override at NAME rule", | |
766 | subsys => "tty", | |
f2041f01 | 767 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 768 | exp_name => "ttyACM0", |
eb870090 | 769 | exp_perms => "3000:8000:0777", |
65005a7f | 770 | rules => <<EOF |
28ce66de KS |
771 | SUBSYSTEM=="tty", OWNER="3000" |
772 | SUBSYSTEM=="tty", GROUP="4000" | |
773 | SUBSYSTEM=="tty", MODE="0777" | |
774 | KERNEL=="ttyUSX[0-9]*", OWNER="5001", GROUP="101", MODE="0444" | |
c7fcba1b | 775 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", GROUP="8000" |
fa19f181 KS |
776 | EOF |
777 | }, | |
778 | { | |
779 | desc => "major/minor number test", | |
780 | subsys => "block", | |
c7fcba1b | 781 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fa19f181 | 782 | exp_name => "node", |
fa19f181 | 783 | exp_majorminor => "8:0", |
65005a7f | 784 | rules => <<EOF |
c4edd0ad | 785 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node" |
7d12d4e1 GKH |
786 | EOF |
787 | }, | |
788 | { | |
789 | desc => "big major number test", | |
c7fcba1b KS |
790 | subsys => "misc", |
791 | devpath => "/devices/virtual/misc/misc-fake1", | |
7d12d4e1 GKH |
792 | exp_name => "node", |
793 | exp_majorminor => "4095:1", | |
65005a7f | 794 | rules => <<EOF |
c7fcba1b | 795 | KERNEL=="misc-fake1", NAME="node" |
7d12d4e1 GKH |
796 | EOF |
797 | }, | |
798 | { | |
799 | desc => "big major and big minor number test", | |
c7fcba1b KS |
800 | subsys => "misc", |
801 | devpath => "/devices/virtual/misc/misc-fake89999", | |
7d12d4e1 | 802 | exp_name => "node", |
c7fcba1b | 803 | exp_majorminor => "4095:89999", |
65005a7f | 804 | rules => <<EOF |
c7fcba1b | 805 | KERNEL=="misc-fake89999", NAME="node" |
2b0f835c KS |
806 | EOF |
807 | }, | |
808 | { | |
809 | desc => "multiple symlinks with format char", | |
810 | subsys => "tty", | |
f2041f01 | 811 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 812 | exp_name => "symlink2-ttyACM0", |
2ffc9cc1 | 813 | exp_target => "ttyACM-0", |
65005a7f | 814 | rules => <<EOF |
2ffc9cc1 | 815 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM-%n", SYMLINK="symlink1-%n symlink2-%k symlink3-%b" |
7b2bdb4b KS |
816 | EOF |
817 | }, | |
818 | { | |
819 | desc => "multiple symlinks with a lot of s p a c e s", | |
820 | subsys => "tty", | |
f2041f01 | 821 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
7b2bdb4b KS |
822 | exp_name => "one", |
823 | not_exp_name => " ", | |
c7fcba1b | 824 | exp_target => "ttyACM0", |
7b2bdb4b | 825 | rules => <<EOF |
c7fcba1b | 826 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", SYMLINK=" one two " |
b8669191 GKH |
827 | EOF |
828 | }, | |
829 | { | |
830 | desc => "symlink creation (same directory)", | |
831 | subsys => "tty", | |
f2041f01 | 832 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b KS |
833 | exp_name => "modem0", |
834 | exp_target => "ttyACM0", | |
65005a7f | 835 | rules => <<EOF |
c7fcba1b | 836 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", SYMLINK="modem%n" |
b8669191 GKH |
837 | EOF |
838 | }, | |
839 | { | |
840 | desc => "symlink creation (relative link forward)", | |
841 | subsys => "block", | |
c7fcba1b | 842 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6", |
b8669191 GKH |
843 | exp_name => "1/2/symlink" , |
844 | exp_target => "a/b/node", | |
65005a7f | 845 | rules => <<EOF |
c7fcba1b | 846 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", NAME="1/2/a/b/node", SYMLINK="1/2/symlink" |
b8669191 GKH |
847 | EOF |
848 | }, | |
849 | { | |
850 | desc => "symlink creation (relative link back and forward)", | |
851 | subsys => "block", | |
c7fcba1b | 852 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6", |
b8669191 GKH |
853 | exp_name => "1/2/c/d/symlink" , |
854 | exp_target => "../../a/b/node", | |
65005a7f | 855 | rules => <<EOF |
c7fcba1b | 856 | SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", NAME="1/2/a/b/node", SYMLINK="1/2/c/d/symlink" |
b8669191 GKH |
857 | EOF |
858 | }, | |
859 | { | |
860 | desc => "multiple symlinks", | |
861 | subsys => "tty", | |
f2041f01 | 862 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
b8669191 | 863 | exp_name => "second-0" , |
c7fcba1b | 864 | exp_target => "modem" , |
65005a7f | 865 | rules => <<EOF |
c7fcba1b | 866 | KERNEL=="ttyACM0", NAME="modem", SYMLINK="first-%n second-%n third-%n" |
b8669191 GKH |
867 | EOF |
868 | }, | |
869 | { | |
870 | desc => "symlink only rule", | |
871 | subsys => "block", | |
c7fcba1b | 872 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
b8669191 GKH |
873 | exp_name => "symlink-only2", |
874 | exp_target => "link", | |
65005a7f | 875 | rules => <<EOF |
c4edd0ad KS |
876 | SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="symlink-only1" |
877 | SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="symlink-only2" | |
878 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="link", SYMLINK+="symlink0" | |
b8669191 GKH |
879 | EOF |
880 | }, | |
881 | { | |
882 | desc => "symlink name '.'", | |
883 | subsys => "block", | |
c7fcba1b | 884 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
b8669191 GKH |
885 | exp_name => ".", |
886 | exp_target => "link", | |
1cec1c24 KS |
887 | exp_add_error => "yes", |
888 | exp_rem_error => "yes", | |
65005a7f | 889 | rules => <<EOF |
c4edd0ad | 890 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="link", SYMLINK+="." |
b8669191 GKH |
891 | EOF |
892 | }, | |
893 | { | |
894 | desc => "symlink node to itself", | |
895 | subsys => "tty", | |
5c0f595d | 896 | devpath => "/devices/virtual/tty/tty0", |
b8669191 GKH |
897 | exp_name => "link", |
898 | exp_target => "link", | |
fa33d857 | 899 | exp_add_error => "yes", |
1cec1c24 | 900 | exp_rem_error => "yes", |
db949b02 | 901 | option => "clean", |
65005a7f | 902 | rules => <<EOF |
995aec87 | 903 | KERNEL=="tty0", NAME="link", SYMLINK+="link" |
b8669191 GKH |
904 | EOF |
905 | }, | |
906 | { | |
907 | desc => "symlink %n substitution", | |
908 | subsys => "tty", | |
f2041f01 | 909 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
b8669191 | 910 | exp_name => "symlink0", |
c7fcba1b | 911 | exp_target => "ttyACM0", |
65005a7f | 912 | rules => <<EOF |
c7fcba1b | 913 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", SYMLINK+="symlink%n" |
b8669191 GKH |
914 | EOF |
915 | }, | |
916 | { | |
917 | desc => "symlink %k substitution", | |
918 | subsys => "tty", | |
f2041f01 | 919 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b KS |
920 | exp_name => "symlink-ttyACM0", |
921 | exp_target => "ttyACM0", | |
65005a7f | 922 | rules => <<EOF |
c7fcba1b | 923 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", SYMLINK+="symlink-%k" |
b8669191 GKH |
924 | EOF |
925 | }, | |
926 | { | |
927 | desc => "symlink %M:%m substitution", | |
928 | subsys => "tty", | |
f2041f01 | 929 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b KS |
930 | exp_name => "major-166:0", |
931 | exp_target => "ttyACM0", | |
65005a7f | 932 | rules => <<EOF |
c7fcba1b | 933 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", SYMLINK+="major-%M:%m" |
b8669191 GKH |
934 | EOF |
935 | }, | |
936 | { | |
03b24b71 | 937 | desc => "symlink %b substitution", |
b8669191 | 938 | subsys => "block", |
c7fcba1b | 939 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
03b24b71 | 940 | exp_name => "symlink-0:0:0:0", |
b8669191 | 941 | exp_target => "node", |
65005a7f | 942 | rules => <<EOF |
c4edd0ad | 943 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", SYMLINK+="symlink-%b" |
b8669191 GKH |
944 | EOF |
945 | }, | |
946 | { | |
947 | desc => "symlink %c substitution", | |
948 | subsys => "tty", | |
f2041f01 | 949 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
b8669191 | 950 | exp_name => "test", |
c7fcba1b | 951 | exp_target => "ttyACM0", |
65005a7f | 952 | rules => <<EOF |
c7fcba1b | 953 | KERNEL=="ttyACM[0-9]*", PROGRAM=="/bin/echo test" NAME="ttyACM%n", SYMLINK+="%c" |
b8669191 GKH |
954 | EOF |
955 | }, | |
956 | { | |
957 | desc => "symlink %c{N} substitution", | |
958 | subsys => "tty", | |
f2041f01 | 959 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
b8669191 | 960 | exp_name => "test", |
c7fcba1b | 961 | exp_target => "ttyACM0", |
65005a7f | 962 | rules => <<EOF |
c7fcba1b | 963 | KERNEL=="ttyACM[0-9]*", PROGRAM=="/bin/echo symlink test this" NAME="ttyACM%n", SYMLINK+="%c{2}" |
b8669191 GKH |
964 | EOF |
965 | }, | |
966 | { | |
967 | desc => "symlink %c{N+} substitution", | |
968 | subsys => "tty", | |
f2041f01 | 969 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
b8669191 | 970 | exp_name => "this", |
c7fcba1b | 971 | exp_target => "ttyACM0", |
65005a7f | 972 | rules => <<EOF |
c7fcba1b | 973 | KERNEL=="ttyACM[0-9]*", PROGRAM=="/bin/echo symlink test this" NAME="ttyACM%n", SYMLINK+="%c{2+}" |
b8669191 GKH |
974 | EOF |
975 | }, | |
976 | { | |
977 | desc => "symlink only rule with %c{N+}", | |
978 | subsys => "block", | |
c7fcba1b | 979 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
b8669191 GKH |
980 | exp_name => "test", |
981 | exp_target => "link", | |
65005a7f | 982 | rules => <<EOF |
c4edd0ad KS |
983 | SUBSYSTEMS=="scsi", KERNEL=="sda", PROGRAM=="/bin/echo link test this" SYMLINK+="%c{2+}" |
984 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="link", SYMLINK+="symlink0" | |
b8669191 GKH |
985 | EOF |
986 | }, | |
987 | { | |
988 | desc => "symlink %s{filename} substitution", | |
989 | subsys => "tty", | |
f2041f01 | 990 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b KS |
991 | exp_name => "166:0", |
992 | exp_target => "ttyACM0", | |
65005a7f | 993 | rules => <<EOF |
c7fcba1b | 994 | KERNEL=="ttyACM[0-9]*", NAME="ttyACM%n", SYMLINK+="%s{dev}" |
b8669191 GKH |
995 | EOF |
996 | }, | |
997 | { | |
998 | desc => "program result substitution (numbered part of)", | |
999 | subsys => "block", | |
c7fcba1b | 1000 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
b8669191 GKH |
1001 | exp_name => "link1", |
1002 | exp_target => "node", | |
65005a7f | 1003 | rules => <<EOF |
c4edd0ad | 1004 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n node link1 link2", RESULT=="node *", NAME="%c{1}", SYMLINK+="%c{2} %c{3}" |
b8669191 GKH |
1005 | EOF |
1006 | }, | |
1007 | { | |
1008 | desc => "program result substitution (numbered part of+)", | |
1009 | subsys => "block", | |
c7fcba1b | 1010 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5", |
b8669191 GKH |
1011 | exp_name => "link4", |
1012 | exp_target => "node", | |
65005a7f | 1013 | rules => <<EOF |
c4edd0ad | 1014 | SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n node link1 link2 link3 link4", RESULT=="node *", NAME="%c{1}", SYMLINK+="%c{2+}" |
fd9efc00 KS |
1015 | EOF |
1016 | }, | |
1017 | { | |
1018 | desc => "all_partitions, option-only rule", | |
1019 | subsys => "block", | |
c7fcba1b | 1020 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fd9efc00 | 1021 | exp_name => "node6", |
65005a7f | 1022 | rules => <<EOF |
28ce66de | 1023 | SUBSYSTEM=="block", OPTIONS="all_partitions" |
c4edd0ad | 1024 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node" |
fd9efc00 KS |
1025 | EOF |
1026 | }, | |
1027 | { | |
1028 | desc => "all_partitions, option-only rule (fail on partition)", | |
1029 | subsys => "block", | |
c7fcba1b | 1030 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
fd9efc00 | 1031 | exp_name => "node6", |
1cec1c24 | 1032 | exp_add_error => "yes", |
65005a7f | 1033 | rules => <<EOF |
28ce66de | 1034 | SUBSYSTEM=="block", OPTIONS="all_partitions" |
c4edd0ad | 1035 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node" |
6818c51d KS |
1036 | EOF |
1037 | }, | |
1038 | { | |
7efa217d KS |
1039 | desc => "ignore remove event test", |
1040 | subsys => "block", | |
c7fcba1b | 1041 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
7efa217d | 1042 | exp_name => "node", |
1cec1c24 | 1043 | exp_rem_error => "yes", |
65005a7f | 1044 | rules => <<EOF |
c4edd0ad | 1045 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", OPTIONS="ignore_remove" |
7efa217d KS |
1046 | EOF |
1047 | }, | |
1048 | { | |
1049 | desc => "ignore remove event test (with all partitions)", | |
1050 | subsys => "block", | |
c7fcba1b | 1051 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
7efa217d | 1052 | exp_name => "node14", |
1cec1c24 | 1053 | exp_rem_error => "yes", |
db949b02 | 1054 | option => "clean", |
65005a7f | 1055 | rules => <<EOF |
c4edd0ad | 1056 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", OPTIONS="ignore_remove, all_partitions" |
7efa217d KS |
1057 | EOF |
1058 | }, | |
1059 | { | |
1060 | desc => "SUBSYSTEM match test", | |
6818c51d | 1061 | subsys => "block", |
c7fcba1b | 1062 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
6818c51d | 1063 | exp_name => "node", |
65005a7f | 1064 | rules => <<EOF |
c4edd0ad KS |
1065 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="should_not_match", SUBSYSTEM=="vc" |
1066 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", SUBSYSTEM=="block" | |
1067 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="should_not_match2", SUBSYSTEM=="vc" | |
2092fbcd KS |
1068 | EOF |
1069 | }, | |
1070 | { | |
95776dc6 | 1071 | desc => "DRIVERS match test", |
2092fbcd | 1072 | subsys => "block", |
c7fcba1b | 1073 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
2092fbcd | 1074 | exp_name => "node", |
65005a7f | 1075 | rules => <<EOF |
c4edd0ad KS |
1076 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="should_not_match", DRIVERS=="sd-wrong" |
1077 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", DRIVERS=="sd" | |
c1ab0461 KS |
1078 | EOF |
1079 | }, | |
1080 | { | |
1081 | desc => "temporary node creation test", | |
1082 | subsys => "block", | |
c7fcba1b | 1083 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
fd42f6a1 | 1084 | exp_name => "node", |
65005a7f | 1085 | rules => <<EOF |
c4edd0ad | 1086 | SUBSYSTEMS=="scsi", KERNEL=="sda", PROGRAM=="/usr/bin/test -b %N" NAME="node" |
c1ab0461 KS |
1087 | EOF |
1088 | }, | |
1089 | { | |
1090 | desc => "devpath substitution test", | |
1091 | subsys => "block", | |
c7fcba1b | 1092 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
c1ab0461 | 1093 | exp_name => "sda", |
65005a7f | 1094 | rules => <<EOF |
f49a6b22 | 1095 | SUBSYSTEMS=="scsi", KERNEL=="sda", PROGRAM=="/bin/echo %p", RESULT=="/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda" |
69aa6dfb KS |
1096 | EOF |
1097 | }, | |
1098 | { | |
1099 | desc => "parent node name substitution test sequence 1/2 (keep)", | |
1100 | subsys => "block", | |
c7fcba1b | 1101 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
69aa6dfb KS |
1102 | exp_name => "main_device", |
1103 | option => "keep", | |
65005a7f | 1104 | rules => <<EOF |
c4edd0ad | 1105 | SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="main_device" |
69aa6dfb KS |
1106 | EOF |
1107 | }, | |
1108 | { | |
1109 | desc => "parent node name substitution test sequence 2/2 (clean)", | |
1110 | subsys => "block", | |
c7fcba1b | 1111 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
69aa6dfb KS |
1112 | exp_name => "main_device-part-1", |
1113 | option => "clean", | |
65005a7f | 1114 | rules => <<EOF |
c4edd0ad | 1115 | SUBSYSTEMS=="scsi", KERNEL=="sda1", NAME="%P-part-1" |
69aa6dfb KS |
1116 | EOF |
1117 | }, | |
1118 | { | |
1119 | desc => "udev_root substitution", | |
1120 | subsys => "block", | |
c7fcba1b | 1121 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
69aa6dfb | 1122 | exp_name => "start-udev-root-end", |
65005a7f | 1123 | rules => <<EOF |
c4edd0ad | 1124 | SUBSYSTEMS=="scsi", KERNEL=="sda1", NAME="start-%r-end" |
3b6ed8bb KS |
1125 | EOF |
1126 | }, | |
1127 | { | |
1128 | desc => "last_rule option", | |
1129 | subsys => "block", | |
c7fcba1b | 1130 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
3b6ed8bb | 1131 | exp_name => "last", |
65005a7f | 1132 | rules => <<EOF |
c4edd0ad KS |
1133 | SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="last", OPTIONS="last_rule" |
1134 | SUBSYSTEMS=="scsi", KERNEL=="sda1", NAME="very-last" | |
28ce66de KS |
1135 | EOF |
1136 | }, | |
1137 | { | |
1138 | desc => "negation KERNEL!=", | |
1139 | subsys => "block", | |
c7fcba1b | 1140 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
28ce66de | 1141 | exp_name => "match", |
65005a7f | 1142 | rules => <<EOF |
c4edd0ad | 1143 | SUBSYSTEMS=="scsi", KERNEL!="sda1", NAME="matches-but-is-negated" |
6880b25d | 1144 | SUBSYSTEMS=="scsi", KERNEL=="sda1", NAME="before" |
c4edd0ad | 1145 | SUBSYSTEMS=="scsi", KERNEL!="xsda1", NAME="match" |
28ce66de KS |
1146 | EOF |
1147 | }, | |
1148 | { | |
1149 | desc => "negation SUBSYSTEM!=", | |
1150 | subsys => "block", | |
c7fcba1b | 1151 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
28ce66de | 1152 | exp_name => "not-anything", |
65005a7f | 1153 | rules => <<EOF |
c4edd0ad | 1154 | SUBSYSTEMS=="scsi", SUBSYSTEM=="block", KERNEL!="sda1", NAME="matches-but-is-negated" |
6880b25d | 1155 | SUBSYSTEMS=="scsi", KERNEL=="sda1", NAME="before" |
c4edd0ad | 1156 | SUBSYSTEMS=="scsi", SUBSYSTEM!="anything", NAME="not-anything" |
28ce66de KS |
1157 | EOF |
1158 | }, | |
1159 | { | |
1160 | desc => "negation PROGRAM!= exit code", | |
1161 | subsys => "block", | |
c7fcba1b | 1162 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
28ce66de | 1163 | exp_name => "nonzero-program", |
65005a7f | 1164 | rules => <<EOF |
6880b25d | 1165 | SUBSYSTEMS=="scsi", KERNEL=="sda1", NAME="before" |
28ce66de | 1166 | KERNEL=="sda1", PROGRAM!="/bin/false", NAME="nonzero-program" |
38285d23 KS |
1167 | EOF |
1168 | }, | |
1169 | { | |
1170 | desc => "test for whitespace between the operator", | |
1171 | subsys => "block", | |
c7fcba1b | 1172 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
38285d23 | 1173 | exp_name => "true", |
65005a7f | 1174 | rules => <<EOF |
6880b25d | 1175 | SUBSYSTEMS=="scsi", KERNEL=="sda1", NAME="before" |
38285d23 | 1176 | KERNEL == "sda1" , NAME = "true" |
3e5958de KS |
1177 | EOF |
1178 | }, | |
1179 | { | |
1180 | desc => "ENV{} test", | |
1181 | subsys => "block", | |
c7fcba1b | 1182 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
3e5958de | 1183 | exp_name => "true", |
65005a7f | 1184 | rules => <<EOF |
a1af6b04 | 1185 | ENV{ENV_KEY_TEST}="test" |
c4edd0ad KS |
1186 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="go", NAME="wrong" |
1187 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="test", NAME="true" | |
1188 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="bad", NAME="bad" | |
3e5958de KS |
1189 | EOF |
1190 | }, | |
1191 | { | |
1192 | desc => "ENV{} test", | |
1193 | subsys => "block", | |
c7fcba1b | 1194 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
3e5958de | 1195 | exp_name => "true", |
65005a7f | 1196 | rules => <<EOF |
a1af6b04 | 1197 | ENV{ENV_KEY_TEST}="test" |
c4edd0ad | 1198 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="go", NAME="wrong" |
6880b25d KS |
1199 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="yes", ENV{ACTION}=="add", ENV{DEVPATH}=="*/block/sda/sdax1", NAME="no" |
1200 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="test", ENV{ACTION}=="add", ENV{DEVPATH}=="*/block/sda/sda1", NAME="true" | |
c4edd0ad | 1201 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="bad", NAME="bad" |
5618b561 KS |
1202 | EOF |
1203 | }, | |
1204 | { | |
1205 | desc => "ENV{} test (assign)", | |
1206 | subsys => "block", | |
c7fcba1b | 1207 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
5618b561 KS |
1208 | exp_name => "true", |
1209 | rules => <<EOF | |
c4edd0ad KS |
1210 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}="true" |
1211 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="yes", NAME="no" | |
6880b25d | 1212 | SUBSYSTEMS=="scsi", KERNEL=="sda1", NAME="before" |
c4edd0ad | 1213 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="true", NAME="true" |
ac528431 KS |
1214 | EOF |
1215 | }, | |
1216 | { | |
1217 | desc => "ENV{} test (assign 2 times)", | |
1218 | subsys => "block", | |
c7fcba1b | 1219 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
ac528431 KS |
1220 | exp_name => "true", |
1221 | rules => <<EOF | |
1222 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}="true" | |
1223 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}="absolutely-\$env{ASSIGN}" | |
6880b25d | 1224 | SUBSYSTEMS=="scsi", KERNEL=="sda1", NAME="before" |
ac528431 KS |
1225 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="yes", NAME="no" |
1226 | SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="absolutely-true", NAME="true" | |
5618b561 KS |
1227 | EOF |
1228 | }, | |
1229 | { | |
1230 | desc => "ENV{} test (assign2)", | |
1231 | subsys => "block", | |
c7fcba1b | 1232 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
5618b561 KS |
1233 | exp_name => "part", |
1234 | rules => <<EOF | |
d59c84ef KS |
1235 | SUBSYSTEM=="block", KERNEL=="*[0-9]", ENV{PARTITION}="true", ENV{MAINDEVICE}="false" |
1236 | SUBSYSTEM=="block", KERNEL=="*[!0-9]", ENV{PARTITION}="false", ENV{MAINDEVICE}="true" | |
5618b561 | 1237 | ENV{MAINDEVICE}=="true", NAME="disk" |
6880b25d | 1238 | SUBSYSTEM=="block", NAME="before" |
5618b561 | 1239 | ENV{PARTITION}=="true", NAME="part" |
18614ab2 KS |
1240 | EOF |
1241 | }, | |
1242 | { | |
1243 | desc => "untrusted string sanitize", | |
1244 | subsys => "block", | |
c7fcba1b | 1245 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
18614ab2 KS |
1246 | exp_name => "sane", |
1247 | rules => <<EOF | |
c4edd0ad | 1248 | SUBSYSTEMS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e name; (/sbin/badprogram)", RESULT=="name_ _/sbin/badprogram_", NAME="sane" |
764ce7f2 KS |
1249 | EOF |
1250 | }, | |
1251 | { | |
1252 | desc => "untrusted string sanitize (don't replace utf8)", | |
1253 | subsys => "block", | |
c7fcba1b | 1254 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
764ce7f2 KS |
1255 | exp_name => "uber", |
1256 | rules => <<EOF | |
c4edd0ad | 1257 | SUBSYSTEMS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e \\xc3\\xbcber" RESULT=="\xc3\xbcber", NAME="uber" |
764ce7f2 KS |
1258 | EOF |
1259 | }, | |
1260 | { | |
1261 | desc => "untrusted string sanitize (replace invalid utf8)", | |
1262 | subsys => "block", | |
c7fcba1b | 1263 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
764ce7f2 KS |
1264 | exp_name => "replaced", |
1265 | rules => <<EOF | |
c4edd0ad | 1266 | SUBSYSTEMS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e \\xef\\xe8garbage", RESULT=="__garbage", NAME="replaced" |
98bbc835 KS |
1267 | EOF |
1268 | }, | |
1269 | { | |
6880b25d | 1270 | desc => "read sysfs value from parent device", |
98bbc835 | 1271 | subsys => "block", |
f2041f01 | 1272 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
c7fcba1b | 1273 | exp_name => "serial-354172020305000", |
98bbc835 | 1274 | rules => <<EOF |
6880b25d | 1275 | KERNEL=="ttyACM*", ATTRS{serial}=="?*", NAME="serial-%s{serial}" |
db949b02 KS |
1276 | EOF |
1277 | }, | |
1278 | { | |
1279 | desc => "match against empty key string", | |
1280 | subsys => "block", | |
c7fcba1b | 1281 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
db949b02 KS |
1282 | exp_name => "ok", |
1283 | rules => <<EOF | |
c4edd0ad KS |
1284 | KERNEL=="sda", ATTRS{nothing}!="", NAME="not-1-ok" |
1285 | KERNEL=="sda", ATTRS{nothing}=="", NAME="not-2-ok" | |
1286 | KERNEL=="sda", ATTRS{vendor}!="", NAME="ok" | |
1287 | KERNEL=="sda", ATTRS{vendor}=="", NAME="not-3-ok" | |
821d0ec8 KS |
1288 | EOF |
1289 | }, | |
1290 | { | |
1291 | desc => "check ACTION value", | |
1292 | subsys => "block", | |
c7fcba1b | 1293 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
821d0ec8 KS |
1294 | exp_name => "ok", |
1295 | rules => <<EOF | |
1296 | ACTION=="unknown", KERNEL=="sda", NAME="unknown-not-ok" | |
1297 | ACTION=="add", KERNEL=="sda", NAME="ok" | |
1298 | EOF | |
1299 | }, | |
1300 | { | |
6880b25d | 1301 | desc => "apply NAME final", |
821d0ec8 | 1302 | subsys => "block", |
c7fcba1b | 1303 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
821d0ec8 KS |
1304 | exp_name => "link", |
1305 | exp_target => "ok", | |
1306 | rules => <<EOF | |
6880b25d | 1307 | KERNEL=="sda", NAME:="ok" |
821d0ec8 KS |
1308 | KERNEL=="sda", NAME="not-ok" |
1309 | KERNEL=="sda", SYMLINK+="link" | |
1310 | EOF | |
1311 | }, | |
1312 | { | |
1313 | desc => "test RUN key", | |
1314 | subsys => "block", | |
c7fcba1b | 1315 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
821d0ec8 KS |
1316 | exp_name => "testsymlink", |
1317 | exp_target => "ok", | |
1318 | exp_rem_error => "yes", | |
1319 | option => "clean", | |
1320 | rules => <<EOF | |
1321 | KERNEL=="sda", NAME="ok", RUN+="/bin/ln -s ok %r/testsymlink" | |
1322 | KERNEL=="sda", NAME="not-ok" | |
f040a4a2 KS |
1323 | EOF |
1324 | }, | |
1325 | { | |
1326 | desc => "test RUN key and DEVNAME", | |
1327 | subsys => "block", | |
c7fcba1b | 1328 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
f040a4a2 KS |
1329 | exp_name => "testsymlink", |
1330 | exp_target => "ok", | |
1331 | exp_rem_error => "yes", | |
1332 | option => "clean", | |
1333 | rules => <<EOF | |
f040a4a2 | 1334 | KERNEL=="sda", NAME="not-ok" |
6880b25d | 1335 | KERNEL=="sda", NAME="ok", RUN+="/bin/sh -c 'ln -s `basename \$\$DEVNAME` %r/testsymlink'" |
821d0ec8 KS |
1336 | EOF |
1337 | }, | |
1338 | { | |
1339 | desc => "test RUN key remove", | |
1340 | subsys => "block", | |
c7fcba1b | 1341 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
821d0ec8 KS |
1342 | exp_name => "testsymlink2", |
1343 | exp_target => "ok2", | |
1344 | rules => <<EOF | |
1345 | KERNEL=="sda", NAME="ok2", RUN+="/bin/ln -s ok2 %r/testsymlink2" | |
1346 | KERNEL=="sda", ACTION=="remove", RUN+="/bin/rm -f %r/testsymlink2" | |
1347 | KERNEL=="sda", NAME="not-ok2" | |
c974742b KS |
1348 | EOF |
1349 | }, | |
1350 | { | |
1351 | desc => "final assignment", | |
1352 | subsys => "block", | |
c7fcba1b | 1353 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
c974742b | 1354 | exp_name => "ok", |
d960ad15 | 1355 | exp_perms => "root:tty:0640", |
c974742b | 1356 | rules => <<EOF |
d960ad15 | 1357 | KERNEL=="sda", GROUP:="tty" |
c974742b KS |
1358 | KERNEL=="sda", GROUP="not-ok", MODE="0640", NAME="ok" |
1359 | EOF | |
1360 | }, | |
1361 | { | |
d960ad15 | 1362 | desc => "final assignment 2", |
c974742b | 1363 | subsys => "block", |
c7fcba1b | 1364 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
c974742b | 1365 | exp_name => "ok", |
d960ad15 | 1366 | exp_perms => "root:tty:0640", |
c974742b | 1367 | rules => <<EOF |
d960ad15 | 1368 | KERNEL=="sda", GROUP:="tty" |
c974742b KS |
1369 | SUBSYSTEM=="block", MODE:="640" |
1370 | KERNEL=="sda", GROUP="not-ok", MODE="0666", NAME="ok" | |
bd0ed2ff KS |
1371 | EOF |
1372 | }, | |
1373 | { | |
1374 | desc => "env substitution", | |
1375 | subsys => "block", | |
c7fcba1b | 1376 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
bd0ed2ff KS |
1377 | exp_name => "node-add-me", |
1378 | rules => <<EOF | |
1379 | KERNEL=="sda", MODE="0666", NAME="node-\$env{ACTION}-me" | |
995aec87 KS |
1380 | EOF |
1381 | }, | |
1382 | { | |
1383 | desc => "reset list to current value", | |
1384 | subsys => "tty", | |
f2041f01 | 1385 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
995aec87 KS |
1386 | exp_name => "three", |
1387 | not_exp_name => "two", | |
1388 | exp_target => "node", | |
1389 | rules => <<EOF | |
c7fcba1b KS |
1390 | KERNEL=="ttyACM[0-9]*", SYMLINK+="one" |
1391 | KERNEL=="ttyACM[0-9]*", SYMLINK+="two" | |
1392 | KERNEL=="ttyACM[0-9]*", SYMLINK="three" | |
1393 | KERNEL=="ttyACM[0-9]*", NAME="node" | |
a72e3f66 KS |
1394 | EOF |
1395 | }, | |
1396 | { | |
1397 | desc => "test empty NAME", | |
1398 | subsys => "tty", | |
f2041f01 | 1399 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
6880b25d | 1400 | exp_name => "<none>", |
647f7c49 KS |
1401 | not_exp_name => "ttyACM0", |
1402 | exp_add_error => "yes", | |
1403 | rules => <<EOF | |
1404 | KERNEL=="ttyACM[0-9]*", NAME="" | |
1405 | EOF | |
1406 | }, | |
1407 | { | |
1408 | desc => "test empty NAME (empty override)", | |
1409 | subsys => "tty", | |
1410 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", | |
1411 | exp_name => "<none>", | |
a72e3f66 KS |
1412 | not_exp_name => "wrong", |
1413 | exp_add_error => "yes", | |
1414 | rules => <<EOF | |
c7fcba1b | 1415 | KERNEL=="ttyACM[0-9]*", NAME="wrong" |
6880b25d | 1416 | KERNEL=="ttyACM[0-9]*", NAME="" |
a72e3f66 KS |
1417 | EOF |
1418 | }, | |
1419 | { | |
647f7c49 | 1420 | desc => "test empty NAME (non-empty override)", |
a72e3f66 | 1421 | subsys => "tty", |
f2041f01 | 1422 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
a72e3f66 KS |
1423 | exp_name => "right", |
1424 | rules => <<EOF | |
c7fcba1b KS |
1425 | KERNEL=="ttyACM[0-9]*", NAME="" |
1426 | KERNEL=="ttyACM[0-9]*", NAME="wrong" | |
6880b25d | 1427 | KERNEL=="ttyACM[0-9]*", NAME="right" |
0cd4ac47 KS |
1428 | EOF |
1429 | }, | |
1430 | { | |
1431 | desc => "test multi matches", | |
1432 | subsys => "tty", | |
f2041f01 | 1433 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
0cd4ac47 KS |
1434 | exp_name => "right", |
1435 | rules => <<EOF | |
6880b25d | 1436 | KERNEL=="ttyACM*", NAME="before" |
c7fcba1b | 1437 | KERNEL=="ttyACM*|nothing", NAME="right" |
0cd4ac47 KS |
1438 | EOF |
1439 | }, | |
1440 | { | |
1441 | desc => "test multi matches 2", | |
1442 | subsys => "tty", | |
f2041f01 | 1443 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", |
0cd4ac47 KS |
1444 | exp_name => "right", |
1445 | rules => <<EOF | |
1446 | KERNEL=="dontknow*|*nothing", NAME="nomatch" | |
6880b25d | 1447 | KERNEL=="ttyACM*", NAME="before" |
c7fcba1b | 1448 | KERNEL=="dontknow*|ttyACM*|nothing*", NAME="right" |
91a75e4a KS |
1449 | EOF |
1450 | }, | |
1451 | { | |
1452 | desc => "test multi matches 3", | |
1453 | subsys => "tty", | |
1454 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", | |
1455 | exp_name => "right", | |
1456 | rules => <<EOF | |
1457 | KERNEL=="dontknow|nothing", NAME="nomatch" | |
1458 | KERNEL=="dontknow|ttyACM0a|nothing|attyACM0", NAME="wrong1" | |
1459 | KERNEL=="X|attyACM0|dontknow|ttyACM0a|nothing|attyACM0", NAME="wrong2" | |
1460 | KERNEL=="dontknow|ttyACM0|nothing", NAME="right" | |
1461 | EOF | |
1462 | }, | |
1463 | { | |
1464 | desc => "test multi matches 4", | |
1465 | subsys => "tty", | |
1466 | devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0", | |
1467 | exp_name => "right", | |
1468 | rules => <<EOF | |
1469 | KERNEL=="dontknow|nothing", NAME="nomatch" | |
1470 | KERNEL=="dontknow|ttyACM0a|nothing|attyACM0", NAME="wrong1" | |
1471 | KERNEL=="X|attyACM0|dontknow|ttyACM0a|nothing|attyACM0", NAME="wrong2" | |
1472 | KERNEL=="all|dontknow|ttyACM0", NAME="right" | |
1473 | KERNEL=="ttyACM0a|nothing", NAME="wrong3" | |
0bfb84e1 KS |
1474 | EOF |
1475 | }, | |
1476 | { | |
1477 | desc => "IMPORT parent test sequence 1/2 (keep)", | |
1478 | subsys => "block", | |
c7fcba1b | 1479 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
0bfb84e1 KS |
1480 | exp_name => "parent", |
1481 | option => "keep", | |
1482 | rules => <<EOF | |
1483 | KERNEL=="sda", IMPORT="/bin/echo -e \'PARENT_KEY=parent_right\\nWRONG_PARENT_KEY=parent_wrong'" | |
1484 | KERNEL=="sda", NAME="parent" | |
1485 | EOF | |
1486 | }, | |
1487 | { | |
1488 | desc => "IMPORT parent test sequence 2/2 (keep)", | |
1489 | subsys => "block", | |
c7fcba1b | 1490 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
0bfb84e1 KS |
1491 | exp_name => "parentenv-parent_right", |
1492 | option => "clean", | |
1493 | rules => <<EOF | |
1494 | KERNEL=="sda1", IMPORT{parent}="PARENT*", NAME="parentenv-\$env{PARENT_KEY}\$env{WRONG_PARENT_KEY}" | |
594dd610 KS |
1495 | EOF |
1496 | }, | |
1497 | { | |
1498 | desc => "GOTO test", | |
1499 | subsys => "block", | |
c7fcba1b | 1500 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
594dd610 KS |
1501 | exp_name => "right", |
1502 | rules => <<EOF | |
1503 | KERNEL=="sda1", GOTO="TEST" | |
1504 | KERNEL=="sda1", NAME="wrong" | |
6880b25d | 1505 | KERNEL=="sda1", GOTO="BAD" |
594dd610 | 1506 | KERNEL=="sda1", NAME="", LABEL="NO" |
9dae0e89 KS |
1507 | KERNEL=="sda1", NAME="right", LABEL="TEST", GOTO="end" |
1508 | KERNEL=="sda1", NAME="wrong2", LABEL="BAD" | |
1509 | LABEL="end" | |
0c377989 KS |
1510 | EOF |
1511 | }, | |
1512 | { | |
1513 | desc => "GOTO label does not exist", | |
1514 | subsys => "block", | |
1515 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", | |
1516 | exp_name => "right", | |
1517 | rules => <<EOF | |
1518 | KERNEL=="sda1", GOTO="does-not-exist" | |
1519 | KERNEL=="sda1", NAME="right", | |
1520 | LABEL="exists" | |
d59c84ef KS |
1521 | EOF |
1522 | }, | |
1523 | { | |
1524 | desc => "NAME compare test", | |
1525 | subsys => "block", | |
c7fcba1b | 1526 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
d59c84ef KS |
1527 | exp_name => "link", |
1528 | exp_target => "node", | |
1529 | not_exp_name => "wronglink", | |
1530 | rules => <<EOF | |
1531 | KERNEL=="sda1", NAME="node" | |
1532 | KERNEL=="sda2", NAME="wrong" | |
1533 | KERNEL=="sda1", NAME=="wrong*", SYMLINK+="wronglink" | |
1534 | KERNEL=="sda1", NAME=="?*", SYMLINK+="link" | |
1535 | KERNEL=="sda1", NAME=="node*", SYMLINK+="link2" | |
19096c08 KS |
1536 | EOF |
1537 | }, | |
1538 | { | |
1539 | desc => "NAME compare test 2", | |
1540 | subsys => "block", | |
c7fcba1b | 1541 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
19096c08 KS |
1542 | exp_name => "link2", |
1543 | exp_target => "sda1", | |
1544 | not_exp_name => "link", | |
1545 | rules => <<EOF | |
1546 | KERNEL=="sda1", NAME=="?*", SYMLINK+="link" | |
1547 | KERNEL=="sda1", NAME!="?*", SYMLINK+="link2" | |
d59c84ef KS |
1548 | EOF |
1549 | }, | |
1550 | { | |
1551 | desc => "invalid key operation", | |
1552 | subsys => "block", | |
c7fcba1b | 1553 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
d59c84ef KS |
1554 | exp_name => "yes", |
1555 | rules => <<EOF | |
864b9b5e | 1556 | KERNEL="sda1", NAME="no" |
d59c84ef | 1557 | KERNEL=="sda1", NAME="yes" |
864b9b5e KS |
1558 | EOF |
1559 | }, | |
1560 | { | |
1561 | desc => "operator chars in attribute", | |
1562 | subsys => "block", | |
c7fcba1b | 1563 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
864b9b5e KS |
1564 | exp_name => "yes", |
1565 | rules => <<EOF | |
1566 | KERNEL=="sda", ATTR{test:colon+plus}=="?*", NAME="yes" | |
d4ae9925 KS |
1567 | EOF |
1568 | }, | |
1569 | { | |
1570 | desc => "overlong comment line", | |
1571 | subsys => "block", | |
c7fcba1b | 1572 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1", |
d4ae9925 KS |
1573 | exp_name => "yes", |
1574 | rules => <<EOF | |
1575 | # 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 | |
d960ad15 KS |
1576 | # 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
1577 | KERNEL=="sda1", NAME=="no" | |
d4ae9925 | 1578 | KERNEL=="sda1", NAME="yes" |
4ad47b2d KS |
1579 | EOF |
1580 | }, | |
1581 | { | |
1582 | desc => "magic subsys/kernel lookup", | |
1583 | subsys => "block", | |
c7fcba1b KS |
1584 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
1585 | exp_name => "00:16:41:e2:8d:ff", | |
4ad47b2d KS |
1586 | rules => <<EOF |
1587 | KERNEL=="sda", NAME="\$attr{[net/eth0]address}" | |
03f65fe6 KS |
1588 | EOF |
1589 | }, | |
1590 | { | |
1591 | desc => "TEST absolute path", | |
1592 | subsys => "block", | |
c7fcba1b | 1593 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
03f65fe6 KS |
1594 | exp_name => "there", |
1595 | rules => <<EOF | |
1596 | TEST=="/etc/hosts", NAME="there" | |
d960ad15 | 1597 | TEST!="/etc/hosts", NAME="notthere" |
03f65fe6 KS |
1598 | EOF |
1599 | }, | |
1600 | { | |
1601 | desc => "TEST subsys/kernel lookup", | |
1602 | subsys => "block", | |
c7fcba1b | 1603 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
03f65fe6 KS |
1604 | exp_name => "yes", |
1605 | rules => <<EOF | |
1606 | KERNEL=="sda", TEST=="[net/eth0]", NAME="yes" | |
1607 | EOF | |
1608 | }, | |
1609 | { | |
1610 | desc => "TEST relative path", | |
1611 | subsys => "block", | |
c7fcba1b | 1612 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
03f65fe6 KS |
1613 | exp_name => "relative", |
1614 | rules => <<EOF | |
1615 | KERNEL=="sda", TEST=="size", NAME="relative" | |
0ea5e96e KS |
1616 | EOF |
1617 | }, | |
1618 | { | |
1619 | desc => "TEST wildcard substitution (find queue/nr_requests)", | |
1620 | subsys => "block", | |
c7fcba1b | 1621 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
0ea5e96e KS |
1622 | exp_name => "found-subdir", |
1623 | rules => <<EOF | |
1624 | KERNEL=="sda", TEST=="*/nr_requests", NAME="found-subdir" | |
cf100ca7 KS |
1625 | EOF |
1626 | }, | |
1627 | { | |
1628 | desc => "TEST MODE=0000", | |
1629 | subsys => "block", | |
c7fcba1b | 1630 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
cf100ca7 KS |
1631 | exp_name => "sda", |
1632 | exp_perms => "0:0:0000", | |
1633 | rules => <<EOF | |
1634 | KERNEL=="sda", MODE="0000" | |
a367f04e GKH |
1635 | EOF |
1636 | }, | |
ff94cec3 | 1637 | { |
bec7e07a | 1638 | desc => "TEST PROGRAM feeds OWNER, GROUP, MODE", |
ff94cec3 | 1639 | subsys => "block", |
c7fcba1b | 1640 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
ff94cec3 | 1641 | exp_name => "sda", |
bec7e07a | 1642 | exp_perms => "5000:100:0400", |
ff94cec3 | 1643 | rules => <<EOF |
6880b25d | 1644 | KERNEL=="sda", MODE="666" |
bec7e07a | 1645 | KERNEL=="sda", PROGRAM=="/bin/echo 5000 100 0400", OWNER="%c{1}", GROUP="%c{2}", MODE="%c{3}" |
ff94cec3 EK |
1646 | EOF |
1647 | }, | |
1648 | { | |
1649 | desc => "TEST PROGRAM feeds MODE with overflow", | |
1650 | subsys => "block", | |
c7fcba1b | 1651 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", |
ff94cec3 | 1652 | exp_name => "sda", |
6880b25d | 1653 | exp_perms => "0:0:0660", |
ff94cec3 | 1654 | rules => <<EOF |
6880b25d | 1655 | KERNEL=="sda", MODE="440" |
ff94cec3 | 1656 | KERNEL=="sda", PROGRAM=="/bin/echo 0 0 0400letsdoabuffferoverflow0123456789012345789012345678901234567890", OWNER="%c{1}", GROUP="%c{2}", MODE="%c{3}" |
dc4c7e46 KS |
1657 | EOF |
1658 | }, | |
1659 | { | |
1660 | desc => "magic [subsys/sysname] attribute substitution", | |
1661 | subsys => "block", | |
1662 | devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", | |
1663 | exp_name => "sda-8741C4G-end", | |
1664 | exp_perms => "0:0:0660", | |
1665 | rules => <<EOF | |
427e20b2 KS |
1666 | KERNEL=="sda", PROGRAM="/bin/true create-envp" |
1667 | KERNEL=="sda", ENV{TESTENV}="change-envp" | |
c6243a41 | 1668 | KERNEL=="sda", NAME="%k-%s{[dmi/id]product_name}-end", RUN+="socket:@/org/kernel/udev/monitor" |
ff94cec3 EK |
1669 | EOF |
1670 | }, | |
a367f04e GKH |
1671 | ); |
1672 | ||
1673 | # set env | |
a367f04e | 1674 | $ENV{SYSFS_PATH} = $sysfs; |
65005a7f | 1675 | $ENV{UDEV_CONFIG_FILE} = $udev_conf; |
a367f04e GKH |
1676 | |
1677 | sub udev { | |
65005a7f | 1678 | my ($action, $subsys, $devpath, $rules) = @_; |
a367f04e GKH |
1679 | |
1680 | $ENV{DEVPATH} = $devpath; | |
a367f04e | 1681 | |
65005a7f KS |
1682 | # create temporary rules |
1683 | open CONF, ">$udev_rules" || die "unable to create rules file: $udev_rules"; | |
1684 | print CONF $$rules; | |
a367f04e GKH |
1685 | close CONF; |
1686 | ||
1687 | $ENV{ACTION} = $action; | |
a1af6b04 | 1688 | $ENV{SUBSYSTEM} = $subsys; |
e08109cb | 1689 | if ($valgrind > 0) { |
a1af6b04 | 1690 | system("$udev_bin_valgrind"); |
e08109cb | 1691 | } else { |
a1af6b04 | 1692 | system("$udev_bin"); |
e08109cb | 1693 | } |
a367f04e GKH |
1694 | } |
1695 | ||
e5fbfe0a | 1696 | my $error = 0; |
72ffa78d | 1697 | |
b8669191 | 1698 | sub permissions_test { |
65005a7f | 1699 | my($rules, $uid, $gid, $mode) = @_; |
b8669191 GKH |
1700 | |
1701 | my $wrong = 0; | |
9b434de1 KS |
1702 | my $userid; |
1703 | my $groupid; | |
1704 | ||
65005a7f | 1705 | $rules->{exp_perms} =~ m/^(.*):(.*):(.*)$/; |
b8669191 | 1706 | if ($1 ne "") { |
9b434de1 KS |
1707 | if (defined(getpwnam($1))) { |
1708 | $userid = int(getpwnam($1)); | |
1709 | } else { | |
1710 | $userid = $1; | |
1711 | } | |
1712 | if ($uid != $userid) { $wrong = 1; } | |
b8669191 GKH |
1713 | } |
1714 | if ($2 ne "") { | |
9b434de1 KS |
1715 | if (defined(getgrnam($2))) { |
1716 | $groupid = int(getgrnam($2)); | |
1717 | } else { | |
1718 | $groupid = $2; | |
1719 | } | |
1720 | if ($gid != $groupid) { $wrong = 1; } | |
b8669191 GKH |
1721 | } |
1722 | if ($3 ne "") { | |
1723 | if (($mode & 07777) != oct($3)) { $wrong = 1; }; | |
1724 | } | |
1725 | if ($wrong == 0) { | |
9b434de1 | 1726 | print "permissions: ok\n"; |
b8669191 | 1727 | } else { |
9b434de1 KS |
1728 | printf " expected permissions are: %s:%s:%#o\n", $1, $2, oct($3); |
1729 | printf " created permissions are : %i:%i:%#o\n", $uid, $gid, $mode & 07777; | |
1730 | print "permissions: error\n"; | |
b8669191 GKH |
1731 | $error++; |
1732 | } | |
1733 | } | |
1734 | ||
1735 | sub major_minor_test { | |
65005a7f | 1736 | my($rules, $rdev) = @_; |
b8669191 GKH |
1737 | |
1738 | my $major = ($rdev >> 8) & 0xfff; | |
1739 | my $minor = ($rdev & 0xff) | (($rdev >> 12) & 0xfff00); | |
1740 | my $wrong = 0; | |
1741 | ||
65005a7f | 1742 | $rules->{exp_majorminor} =~ m/^(.*):(.*)$/; |
b8669191 GKH |
1743 | if ($1 ne "") { |
1744 | if ($major != $1) { $wrong = 1; }; | |
1745 | } | |
1746 | if ($2 ne "") { | |
1747 | if ($minor != $2) { $wrong = 1; }; | |
1748 | } | |
1749 | if ($wrong == 0) { | |
9b434de1 | 1750 | print "major:minor: ok\n"; |
b8669191 | 1751 | } else { |
9b434de1 KS |
1752 | printf " expected major:minor is: %i:%i\n", $1, $2; |
1753 | printf " created major:minor is : %i:%i\n", $major, $minor; | |
1754 | print "major:minor: error\n"; | |
b8669191 GKH |
1755 | $error++; |
1756 | } | |
1757 | } | |
1758 | ||
1759 | sub symlink_test { | |
65005a7f | 1760 | my ($rules) = @_; |
b8669191 | 1761 | |
65005a7f | 1762 | my $output = `ls -l $PWD/$udev_root$rules->{exp_name}`; |
b8669191 GKH |
1763 | |
1764 | if ($output =~ m/(.*)-> (.*)/) { | |
65005a7f | 1765 | if ($2 eq $rules->{exp_target}) { |
9b434de1 | 1766 | print "symlink: ok\n"; |
b8669191 | 1767 | } else { |
65005a7f KS |
1768 | print " expected symlink from: \'$rules->{exp_name}\' to \'$rules->{exp_target}\'\n"; |
1769 | print " created symlink from: \'$rules->{exp_name}\' to \'$2\'\n"; | |
9b434de1 | 1770 | print "symlink: error"; |
65005a7f | 1771 | if ($rules->{exp_add_error}) { |
9b434de1 | 1772 | print " as expected\n"; |
b8669191 | 1773 | } else { |
9b434de1 | 1774 | print "\n"; |
b8669191 GKH |
1775 | $error++; |
1776 | } | |
1777 | } | |
1778 | } else { | |
65005a7f | 1779 | print " expected symlink from: \'$rules->{exp_name}\' to \'$rules->{exp_target}\'\n"; |
9b434de1 | 1780 | print "symlink: not created"; |
65005a7f | 1781 | if ($rules->{exp_add_error}) { |
9b434de1 | 1782 | print " as expected\n"; |
b8669191 | 1783 | } else { |
9b434de1 | 1784 | print "\n"; |
b8669191 GKH |
1785 | $error++; |
1786 | } | |
1787 | } | |
1788 | } | |
1789 | ||
ff94cec3 EK |
1790 | sub make_udev_root { |
1791 | system("rm -rf $udev_root"); | |
1792 | mkdir($udev_root) || die "unable to create udev_root: $udev_root\n"; | |
1793 | # setting group and mode of udev_root ensures the tests work | |
1794 | # even if the parent directory has setgid bit enabled. | |
1795 | chown (0, 0, $udev_root) || die "unable to chown $udev_root\n"; | |
1796 | chmod (0755, $udev_root) || die "unable to chmod $udev_root\n"; | |
1797 | } | |
1798 | ||
2e317184 | 1799 | sub run_test { |
65005a7f | 1800 | my ($rules, $number) = @_; |
fa19f181 | 1801 | |
65005a7f | 1802 | print "TEST $number: $rules->{desc}\n"; |
b8669191 | 1803 | |
65005a7f KS |
1804 | if ($rules->{exp_target}) { |
1805 | print "device \'$rules->{devpath}\' expecting symlink '$rules->{exp_name}' to node \'$rules->{exp_target}\'\n"; | |
b8669191 | 1806 | } else { |
65005a7f | 1807 | print "device \'$rules->{devpath}\' expecting node \'$rules->{exp_name}\'\n"; |
b8669191 GKH |
1808 | } |
1809 | ||
a367f04e | 1810 | |
65005a7f | 1811 | udev("add", $rules->{subsys}, $rules->{devpath}, \$rules->{rules}); |
647f7c49 KS |
1812 | if (defined($rules->{not_exp_name})) { |
1813 | if ((-e "$PWD/$udev_root$rules->{not_exp_name}") || | |
1814 | (-l "$PWD/$udev_root$rules->{not_exp_name}")) { | |
1815 | print "nonexistent: error \'$rules->{not_exp_name}\' not expected to be there\n"; | |
1816 | $error++ | |
1817 | } | |
1818 | } | |
1819 | ||
65005a7f KS |
1820 | if ((-e "$PWD/$udev_root$rules->{exp_name}") || |
1821 | (-l "$PWD/$udev_root$rules->{exp_name}")) { | |
fa19f181 KS |
1822 | |
1823 | my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, | |
65005a7f | 1824 | $atime, $mtime, $ctime, $blksize, $blocks) = stat("$PWD/$udev_root$rules->{exp_name}"); |
fa19f181 | 1825 | |
65005a7f KS |
1826 | if (defined($rules->{exp_perms})) { |
1827 | permissions_test($rules, $uid, $gid, $mode); | |
c612a0ac | 1828 | } |
65005a7f KS |
1829 | if (defined($rules->{exp_majorminor})) { |
1830 | major_minor_test($rules, $rdev); | |
b8669191 | 1831 | } |
65005a7f KS |
1832 | if (defined($rules->{exp_target})) { |
1833 | symlink_test($rules); | |
fa19f181 | 1834 | } |
9b434de1 | 1835 | print "add: ok\n"; |
a367f04e | 1836 | } else { |
9b434de1 | 1837 | print "add: error"; |
65005a7f | 1838 | if ($rules->{exp_add_error}) { |
9b434de1 | 1839 | print " as expected\n"; |
b8669191 | 1840 | } else { |
9b434de1 | 1841 | print "\n"; |
b8669191 GKH |
1842 | system("tree $udev_root"); |
1843 | print "\n"; | |
1844 | $error++; | |
1845 | } | |
a367f04e GKH |
1846 | } |
1847 | ||
65005a7f | 1848 | if (defined($rules->{option}) && $rules->{option} eq "keep") { |
0345b862 KS |
1849 | print "\n\n"; |
1850 | return; | |
1851 | } | |
1852 | ||
65005a7f KS |
1853 | udev("remove", $rules->{subsys}, $rules->{devpath}, \$rules->{rules}); |
1854 | if ((-e "$PWD/$udev_root$rules->{exp_name}") || | |
1855 | (-l "$PWD/$udev_root$rules->{exp_name}")) { | |
9b434de1 | 1856 | print "remove: error"; |
65005a7f | 1857 | if ($rules->{exp_rem_error}) { |
9b434de1 | 1858 | print " as expected\n"; |
b8669191 | 1859 | } else { |
9b434de1 | 1860 | print "\n"; |
b8669191 GKH |
1861 | system("tree $udev_root"); |
1862 | print "\n"; | |
1863 | $error++; | |
1864 | } | |
a367f04e | 1865 | } else { |
9b434de1 | 1866 | print "remove: ok\n"; |
a367f04e | 1867 | } |
0345b862 | 1868 | |
9b434de1 KS |
1869 | print "\n"; |
1870 | ||
db949b02 | 1871 | if (defined($rules->{option}) && $rules->{option} eq "clean") { |
ff94cec3 | 1872 | make_udev_root (); |
0345b862 KS |
1873 | } |
1874 | ||
a367f04e GKH |
1875 | } |
1876 | ||
800ab95b GKH |
1877 | # only run if we have root permissions |
1878 | # due to mknod restrictions | |
1879 | if (!($<==0)) { | |
1880 | print "Must have root permissions to run properly.\n"; | |
1881 | exit; | |
1882 | } | |
1883 | ||
2e317184 | 1884 | # prepare |
282988c4 | 1885 | make_udev_root(); |
2e317184 | 1886 | |
65005a7f KS |
1887 | # create config file |
1888 | open CONF, ">$udev_conf" || die "unable to create config file: $udev_conf"; | |
2e317184 | 1889 | print CONF "udev_root=\"$udev_root\"\n"; |
282988c4 | 1890 | print CONF "udev_rules=\"$PWD\"\n"; |
37a123a9 | 1891 | print CONF "udev_log=\"err\"\n"; |
2e317184 GKH |
1892 | close CONF; |
1893 | ||
1894 | my $test_num = 1; | |
e08109cb | 1895 | my @list; |
2e317184 | 1896 | |
e08109cb KS |
1897 | foreach my $arg (@ARGV) { |
1898 | if ($arg =~ m/--valgrind/) { | |
1899 | $valgrind = 1; | |
1900 | printf("using valgrind\n"); | |
0345b862 | 1901 | } else { |
e08109cb KS |
1902 | push(@list, $arg); |
1903 | } | |
1904 | } | |
1905 | ||
1906 | if ($list[0]) { | |
1907 | foreach my $arg (@list) { | |
1908 | if (defined($tests[$arg-1]->{desc})) { | |
1909 | print "udev-test will run test number $arg:\n\n"; | |
1910 | run_test($tests[$arg-1], $arg); | |
1911 | } else { | |
1912 | print "test does not exist.\n"; | |
1913 | } | |
0345b862 | 1914 | } |
2e317184 GKH |
1915 | } else { |
1916 | # test all | |
1917 | print "\nudev-test will run ".($#tests + 1)." tests:\n\n"; | |
1918 | ||
65005a7f KS |
1919 | foreach my $rules (@tests) { |
1920 | run_test($rules, $test_num); | |
2e317184 | 1921 | $test_num++; |
2e317184 GKH |
1922 | } |
1923 | } | |
1924 | ||
a367f04e GKH |
1925 | print "$error errors occured\n\n"; |
1926 | ||
1927 | # cleanup | |
1928 | system("rm -rf $udev_root"); | |
65005a7f KS |
1929 | unlink($udev_rules); |
1930 | unlink($udev_conf); | |
a367f04e | 1931 | |
034b37c8 AJ |
1932 | if ($error > 0) { |
1933 | exit(1); | |
1934 | } | |
1935 | exit(0); |