2 # SPDX-License-Identifier: LGPL-2.1-or-later
6 # Provides automated testing of the udev binary.
7 # The whole test is self contained in this file, except the matching sysfs tree.
8 # Simply extend the @tests array, to add a new test variant.
10 # Every test is driven by its own temporary config file.
11 # This program prepares the environment, creates the config and calls udev.
13 # udev parses the rules, looks at the provided sysfs and
14 # first creates and then removes the device node.
15 # After creation and removal the result is checked against the
16 # expected value and the result is printed.
18 # Copyright © 2004 Leann Ogasawara <ogasawara@osdl.org>
24 my $EXIT_TEST_SKIP = 77;
26 unless (eval "use POSIX qw(WIFEXITED WEXITSTATUS);
27 use Cwd
qw(getcwd abs_path);
29 use IPC
::SysV
qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT);
30 use Time
::HiRes
qw(usleep); 1") {
31 warn "Failed to import dependencies
, skipping the test
: $@
";
32 exit($EXIT_TEST_SKIP);
36 # Relax sd-device's sysfs verification, since we want to provide a fake sysfs
37 # here that actually is a tmpfs.
38 $ENV{"SYSTEMD_DEVICE_VERIFY_SYSFS
"}="0";
40 my $udev_bin = "./test
-udev
";
44 my $udev_bin_valgrind = "valgrind
--tool
=memcheck
--leak
-check
=yes
--track
-origins
=yes
--quiet
$udev_bin";
45 my $udev_bin_gdb = "gdb
--args
$udev_bin";
46 my $udev_bin_strace = "strace
-efile
$udev_bin";
47 my $udev_run = "test
/run
";
48 my $udev_tmpfs = "test
/tmpfs
";
49 my $udev_sys = "${udev_tmpfs
}/sys
";
50 my $udev_dev = "${udev_tmpfs
}/dev
";
51 my $udev_rules_dir = "$udev_run/udev/rules
.d
";
52 my $udev_rules = "$udev_rules_dir/udev
-test
.rules
";
53 my $EXIT_TEST_SKIP = 77;
55 my $rules_10k_tags = "";
56 for (my $i = 1; $i <= 10000; ++$i) {
57 $rules_10k_tags .= 'KERNEL=="sda
", TAG+="test
' . $i . "\"\n";
60 my $rules_10k_tags_continuation = "KERNEL==\"sda\", \\\n";
61 for (my $i = 1; $i < 10000; ++$i) {
62 $rules_10k_tags_continuation .= 'TAG
+="test' . $i . "\",\\\n";
64 $rules_10k_tags_continuation .= "TAG
+=\"test10000
\"\\n
";
66 # Create a device list with all block devices under /sys
67 # (except virtual devices and cd-roms)
68 # the optional argument exp_func returns expected and non-expected
69 # symlinks for the device.
74 foreach my $bd (glob "$udev_sys/dev
/block
/*") {
75 my $tgt = readlink($bd);
76 my ($exp, $notexp) = (undef, undef);
78 next if ($tgt =~ m!/virtual/! || $tgt =~ m!/sr[0-9]*$!);
80 $tgt =~ s!^\.\./\.\.!!;
81 ($exp, $notexp) = $exp_func->($tgt) if defined($exp_func);
85 not_exp_links => $notexp,
87 push(@devices, $device);
92 # This generator returns a suitable exp_func for use with
95 my ($pattern, $links, $donot) = @_;
99 if ($name =~ /$pattern/) {
100 return ($links, undef);
102 return (undef, $links);
104 return (undef, undef);
115 devpath => "/devices/pci0000:00/0000:00:1f.2/host0
/target0:0:0/0:0:0:0/block/sda",
116 exp_rem_error => "yes
",
119 devpath => "/devices/pci0000:00/0000:00:1f.2/host0
/target0:0:0/0:0:0:0/block/sda/sda1
",
120 exp_rem_error => "yes
",
127 desc
=> "label test of scsi disc",
130 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
131 exp_links
=> ["boot_disk"],
134 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
135 KERNEL=="ttyACM0", SYMLINK+="modem"
139 desc
=> "label test of scsi disc",
142 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
143 exp_links
=> ["boot_disk"],
146 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
147 KERNEL=="ttyACM0", SYMLINK+="modem"
151 desc
=> "label test of scsi disc",
154 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
155 exp_links
=> ["boot_disk"],
158 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
159 KERNEL=="ttyACM0", SYMLINK+="modem"
163 desc
=> "label test of scsi partition",
166 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
167 exp_links
=> ["boot_disk1"],
170 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
174 desc
=> "label test of pattern match",
177 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
178 exp_links
=> ["boot_disk1", "boot_disk1-4", "boot_disk1-5"],
179 not_exp_links
=> ["boot_disk1-1", "boot_disk1-2", "boot_disk1-3", "boot_disk1-6", "boot_disk1-7"]
182 SUBSYSTEMS=="scsi", ATTRS{vendor}=="?ATA", SYMLINK+="boot_disk%n-1"
183 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA?", SYMLINK+="boot_disk%n-2"
184 SUBSYSTEMS=="scsi", ATTRS{vendor}=="A??", SYMLINK+="boot_disk%n"
185 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATAS", SYMLINK+="boot_disk%n-3"
186 SUBSYSTEMS=="scsi", ATTRS{vendor}=="AT?", SYMLINK+="boot_disk%n-4"
187 SUBSYSTEMS=="scsi", ATTRS{vendor}=="??A", SYMLINK+="boot_disk%n-5"
188 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", GOTO="skip-6"
189 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n-6"
191 SUBSYSTEMS=="scsi", GOTO="skip-7"
192 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n-7"
197 desc
=> "label test of multiple sysfs files",
200 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
201 exp_links
=> ["boot_disk1"],
202 not_exp_links
=> ["boot_diskX1"],
205 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS X ", SYMLINK+="boot_diskX%n"
206 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", SYMLINK+="boot_disk%n"
210 desc
=> "label test of max sysfs files (skip invalid rule)",
213 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
214 exp_links
=> ["boot_disk1", "boot_diskXY1"],
215 not_exp_links
=> ["boot_diskXX1"],
218 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", ATTRS{queue_depth}=="32", SYMLINK+="boot_diskXX%n"
219 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", ATTRS{queue_depth}=="1", SYMLINK+="boot_diskXY%n"
220 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", SYMLINK+="boot_disk%n"
224 desc
=> "catch device by *",
227 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
228 exp_links
=> ["modem/0", "catch-all"],
231 KERNEL=="ttyACM*", SYMLINK+="modem/%n"
232 KERNEL=="*", SYMLINK+="catch-all"
237 desc
=> "catch device by * - take 2",
240 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
241 exp_links
=> ["modem/0"],
242 not_exp_links
=> ["bad"],
245 KERNEL=="*ACM1", SYMLINK+="bad"
246 KERNEL=="*ACM0", SYMLINK+="modem/%n"
250 desc
=> "catch device by ?",
253 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
254 exp_links
=> ["modem/0"],
255 not_exp_links
=> ["modem/0-1", "modem/0-2"],
258 KERNEL=="ttyACM??*", SYMLINK+="modem/%n-1"
259 KERNEL=="ttyACM??", SYMLINK+="modem/%n-2"
260 KERNEL=="ttyACM?", SYMLINK+="modem/%n"
264 desc
=> "catch device by character class",
267 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
268 exp_links
=> ["modem/0"],
269 not_exp_links
=> ["modem/0-1", "modem/0-2"],
272 KERNEL=="ttyACM[A-Z]*", SYMLINK+="modem/%n-1"
273 KERNEL=="ttyACM?[0-9]", SYMLINK+="modem/%n-2"
274 KERNEL=="ttyACM[0-9]*", SYMLINK+="modem/%n"
278 desc
=> "don't replace kernel name",
281 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
282 exp_links
=> ["modem"],
285 KERNEL=="ttyACM0", SYMLINK+="modem"
289 desc
=> "Handle comment lines in config file (and don't replace kernel name)",
292 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
293 exp_links
=> ["modem"],
297 KERNEL=="ttyACM0", SYMLINK+="modem"
302 desc
=> "Handle comment lines in config file with whitespace (and don't replace kernel name)",
305 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
306 exp_links
=> ["modem"],
309 # this is a comment with whitespace before the comment
310 KERNEL=="ttyACM0", SYMLINK+="modem"
315 desc
=> "Handle whitespace only lines (and don't replace kernel name)",
318 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
319 exp_links
=> ["whitespace"],
325 # this is a comment with whitespace before the comment
326 KERNEL=="ttyACM0", SYMLINK+="whitespace"
333 desc
=> "Handle empty lines in config file (and don't replace kernel name)",
336 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
337 exp_links
=> ["modem"],
341 KERNEL=="ttyACM0", SYMLINK+="modem"
346 desc
=> "Handle backslashed multi lines in config file (and don't replace kernel name)",
349 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
350 exp_links
=> ["modem"],
353 KERNEL=="ttyACM0", \\
359 desc
=> "preserve backslashes, if they are not for a newline",
362 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
363 exp_links
=> ["aaa"],
366 KERNEL=="ttyACM0", PROGRAM=="/bin/echo -e \\101", RESULT=="A", SYMLINK+="aaa"
371 desc
=> "Handle stupid backslashed multi lines in config file (and don't replace kernel name)",
374 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
375 exp_links
=> ["modem"],
386 KERNEL=="ttyACM0", \\
392 desc
=> "subdirectory handling",
395 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
396 exp_links
=> ["sub/direct/ory/modem"],
399 KERNEL=="ttyACM0", SYMLINK+="sub/direct/ory/modem"
403 desc
=> "parent device name match of scsi partition",
406 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
407 exp_links
=> ["first_disk5"],
410 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="first_disk%n"
414 desc
=> "test substitution chars",
417 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
418 exp_links
=> ["Major:8:minor:5:kernelnumber:5:id:0:0:0:0"],
421 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="Major:%M:minor:%m:kernelnumber:%n:id:%b"
425 desc
=> "import of shell-value returned from program",
428 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
429 exp_links
=> ["node12345678"],
432 SUBSYSTEMS=="scsi", IMPORT{program}="/bin/echo -e \' TEST_KEY=12345678\\n TEST_key2=98765\'", SYMLINK+="node\$env{TEST_KEY}"
433 KERNEL=="ttyACM0", SYMLINK+="modem"
437 desc
=> "substitution of sysfs value (%s{file})",
440 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
441 exp_links
=> ["disk-ATA-sda"],
442 not_exp_links
=> ["modem"],
445 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="disk-%s{vendor}-%k"
446 KERNEL=="ttyACM0", SYMLINK+="modem"
450 desc
=> "program result substitution",
453 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
454 exp_links
=> ["special-device-5"],
455 not_exp_links
=> ["not"],
458 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="-special-*", SYMLINK+="not"
459 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special-*", SYMLINK+="%c-%n"
463 desc
=> "program result substitution (newline removal)",
466 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
467 exp_links
=> ["newline_removed"],
470 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo test", RESULT=="test", SYMLINK+="newline_removed"
474 desc
=> "program result substitution",
477 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
478 exp_links
=> ["test-0:0:0:0"],
481 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n test-%b", RESULT=="test-0:0*", SYMLINK+="%c"
485 desc
=> "program with lots of arguments",
488 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
489 exp_links
=> ["foo9"],
490 not_exp_links
=> ["foo3", "foo4", "foo5", "foo6", "foo7", "foo8"],
493 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", SYMLINK+="%c{7}"
497 desc
=> "program with subshell",
500 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
501 exp_links
=> ["bar9"],
502 not_exp_links
=> ["foo3", "foo4", "foo5", "foo6", "foo7", "foo8"],
505 SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c 'echo foo3 foo4 foo5 foo6 foo7 foo8 foo9 | sed s/foo9/bar9/'", KERNEL=="sda5", SYMLINK+="%c{7}"
509 desc
=> "program arguments combined with apostrophes",
512 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
513 exp_links
=> ["foo7"],
514 not_exp_links
=> ["foo3", "foo4", "foo5", "foo6", "foo8"],
517 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n 'foo3 foo4' 'foo5 foo6 foo7 foo8'", KERNEL=="sda5", SYMLINK+="%c{5}"
521 desc
=> "program arguments combined with escaped double quotes, part 1",
524 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
525 exp_links
=> ["foo2"],
526 not_exp_links
=> ["foo1"],
529 SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c 'printf %%s \\\"foo1 foo2\\\" | grep \\\"foo1 foo2\\\"'", KERNEL=="sda5", SYMLINK+="%c{2}"
533 desc
=> "program arguments combined with escaped double quotes, part 2",
536 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
537 exp_links
=> ["foo2"],
538 not_exp_links
=> ["foo1"],
541 SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c \\\"printf %%s 'foo1 foo2' | grep 'foo1 foo2'\\\"", KERNEL=="sda5", SYMLINK+="%c{2}"
545 desc
=> "program arguments combined with escaped double quotes, part 3",
548 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
549 exp_links
=> ["foo2"],
550 not_exp_links
=> ["foo1", "foo3"],
553 SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c 'printf \\\"%%s %%s\\\" \\\"foo1 foo2\\\" \\\"foo3\\\"| grep \\\"foo1 foo2\\\"'", KERNEL=="sda5", SYMLINK+="%c{2}"
557 desc
=> "characters before the %c{N} substitution",
560 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
561 exp_links
=> ["my-foo9"],
564 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", SYMLINK+="my-%c{7}"
568 desc
=> "substitute the second to last argument",
571 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
572 exp_links
=> ["my-foo8"],
573 not_exp_links
=> ["my-foo3", "my-foo4", "my-foo5", "my-foo6", "my-foo7", "my-foo9"],
576 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", SYMLINK+="my-%c{6}"
580 desc
=> "test substitution by variable name",
583 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
584 exp_links
=> ["Major:8-minor:5-kernelnumber:5-id:0:0:0:0"],
587 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="Major:\$major-minor:\$minor-kernelnumber:\$number-id:\$id"
591 desc
=> "test substitution by variable name 2",
594 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
595 exp_links
=> ["Major:8-minor:5-kernelnumber:5-id:0:0:0:0"],
598 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="Major:\$major-minor:%m-kernelnumber:\$number-id:\$id"
602 desc
=> "test substitution by variable name 3",
605 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
606 exp_links
=> ["850:0:0:05"],
609 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="%M%m%b%n"
613 desc
=> "test substitution by variable name 4",
616 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
617 exp_links
=> ["855"],
620 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="\$major\$minor\$number"
624 desc
=> "test substitution by variable name 5",
627 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
628 exp_links
=> ["8550:0:0:0"],
631 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="\$major%m%n\$id"
635 desc
=> "non matching SUBSYSTEMS for device with no parent",
638 devpath
=> "/devices/virtual/tty/console",
639 exp_links
=> ["TTY"],
640 not_exp_links
=> ["foo"],
643 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo", RESULT=="foo", SYMLINK+="foo"
644 KERNEL=="console", SYMLINK+="TTY"
648 desc
=> "non matching SUBSYSTEMS",
651 devpath
=> "/devices/virtual/tty/console",
652 exp_links
=> ["TTY"],
653 not_exp_links
=> ["foo"],
656 SUBSYSTEMS=="foo", ATTRS{dev}=="5:1", SYMLINK+="foo"
657 KERNEL=="console", SYMLINK+="TTY"
661 desc
=> "ATTRS match",
664 devpath
=> "/devices/virtual/tty/console",
665 exp_links
=> ["foo", "TTY"],
668 KERNEL=="console", SYMLINK+="TTY"
669 ATTRS{dev}=="5:1", SYMLINK+="foo"
673 desc
=> "ATTR (empty file)",
676 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
677 exp_links
=> ["empty", "not-something"],
678 not_exp_links
=> ["something", "not-empty"],
681 KERNEL=="sda", ATTR{test_empty_file}=="?*", SYMLINK+="something"
682 KERNEL=="sda", ATTR{test_empty_file}!="", SYMLINK+="not-empty"
683 KERNEL=="sda", ATTR{test_empty_file}=="", SYMLINK+="empty"
684 KERNEL=="sda", ATTR{test_empty_file}!="?*", SYMLINK+="not-something"
688 desc
=> "ATTR (non-existent file)",
691 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
692 exp_links
=> ["non-existent", "wrong"],
693 not_exp_links
=> ["something", "empty", "not-empty",
694 "not-something", "something"],
697 KERNEL=="sda", ATTR{nofile}=="?*", SYMLINK+="something"
698 KERNEL=="sda", ATTR{nofile}!="", SYMLINK+="not-empty"
699 KERNEL=="sda", ATTR{nofile}=="", SYMLINK+="empty"
700 KERNEL=="sda", ATTR{nofile}!="?*", SYMLINK+="not-something"
701 KERNEL=="sda", TEST!="nofile", SYMLINK+="non-existent"
702 KERNEL=="sda", SYMLINK+="wrong"
706 desc
=> "program and bus type match",
709 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
710 exp_links
=> ["scsi-0:0:0:0"],
713 SUBSYSTEMS=="usb", PROGRAM=="/bin/echo -n usb-%b", SYMLINK+="%c"
714 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n scsi-%b", SYMLINK+="%c"
715 SUBSYSTEMS=="foo", PROGRAM=="/bin/echo -n foo-%b", SYMLINK+="%c"
719 desc
=> "sysfs parent hierarchy",
722 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
723 exp_links
=> ["modem"],
726 ATTRS{idProduct}=="007b", SYMLINK+="modem"
730 desc
=> "name test with ! in the name",
733 devpath
=> "/devices/virtual/block/fake!blockdev0",
734 devnode
=> "fake/blockdev0",
735 exp_links
=> ["is/a/fake/blockdev0"],
736 not_exp_links
=> ["is/not/a/fake/blockdev0", "modem"],
739 SUBSYSTEMS=="scsi", SYMLINK+="is/not/a/%k"
740 SUBSYSTEM=="block", SYMLINK+="is/a/%k"
741 KERNEL=="ttyACM0", SYMLINK+="modem"
745 desc
=> "name test with ! in the name, but no matching rule",
748 devpath
=> "/devices/virtual/block/fake!blockdev0",
749 devnode
=> "fake/blockdev0",
750 not_exp_links
=> ["modem"],
753 KERNEL=="ttyACM0", SYMLINK+="modem"
757 desc
=> "KERNELS rule",
760 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
761 exp_links
=> ["scsi-0:0:0:0"],
762 not_exp_links
=> ["no-match", "short-id", "not-scsi"],
765 SUBSYSTEMS=="usb", KERNELS=="0:0:0:0", SYMLINK+="not-scsi"
766 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:1", SYMLINK+="no-match"
767 SUBSYSTEMS=="scsi", KERNELS==":0", SYMLINK+="short-id"
768 SUBSYSTEMS=="scsi", KERNELS=="/0:0:0:0", SYMLINK+="no-match"
769 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="scsi-0:0:0:0"
773 desc
=> "KERNELS wildcard all",
776 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
777 exp_links
=> ["scsi-0:0:0:0"],
778 not_exp_links
=> ["no-match", "before"],
781 SUBSYSTEMS=="scsi", KERNELS=="*:1", SYMLINK+="no-match"
782 SUBSYSTEMS=="scsi", KERNELS=="*:0:1", SYMLINK+="no-match"
783 SUBSYSTEMS=="scsi", KERNELS=="*:0:0:1", SYMLINK+="no-match"
784 SUBSYSTEMS=="scsi", KERNEL=="0:0:0:0", SYMLINK+="before"
785 SUBSYSTEMS=="scsi", KERNELS=="*", SYMLINK+="scsi-0:0:0:0"
789 desc
=> "KERNELS wildcard partial",
792 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
793 exp_links
=> ["scsi-0:0:0:0", "before"],
796 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="before"
797 SUBSYSTEMS=="scsi", KERNELS=="*:0", SYMLINK+="scsi-0:0:0:0"
801 desc
=> "KERNELS wildcard partial 2",
804 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
805 exp_links
=> ["scsi-0:0:0:0", "before"],
808 SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="before"
809 SUBSYSTEMS=="scsi", KERNELS=="*:0:0:0", SYMLINK+="scsi-0:0:0:0"
813 desc
=> "substitute attr with link target value (first match)",
816 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
817 exp_links
=> ["driver-is-sd"],
820 SUBSYSTEMS=="scsi", SYMLINK+="driver-is-\$attr{driver}"
824 desc
=> "substitute attr with link target value (currently selected device)",
827 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
828 exp_links
=> ["driver-is-ahci"],
831 SUBSYSTEMS=="pci", SYMLINK+="driver-is-\$attr{driver}"
835 desc
=> "ignore ATTRS attribute whitespace",
838 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
839 exp_links
=> ["ignored"],
842 SUBSYSTEMS=="scsi", ATTRS{whitespace_test}=="WHITE SPACE", SYMLINK+="ignored"
846 desc
=> "do not ignore ATTRS attribute whitespace",
849 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
850 exp_links
=> ["matched-with-space"],
851 not_exp_links
=> ["wrong-to-ignore"],
854 SUBSYSTEMS=="scsi", ATTRS{whitespace_test}=="WHITE SPACE ", SYMLINK+="wrong-to-ignore"
855 SUBSYSTEMS=="scsi", ATTRS{whitespace_test}=="WHITE SPACE ", SYMLINK+="matched-with-space"
859 desc
=> "permissions USER=bad GROUP=name",
862 devpath
=> "/devices/virtual/tty/tty33",
863 exp_perms
=> "0:0:0600",
866 KERNEL=="tty33", OWNER="bad", GROUP="name"
870 desc
=> "permissions OWNER=1",
873 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
874 exp_links
=> ["node"],
875 exp_perms
=> "1::0600",
878 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OWNER="1"
882 desc
=> "permissions GROUP=1",
885 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
886 exp_links
=> ["node"],
887 exp_perms
=> ":1:0660",
890 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", GROUP="1"
894 desc
=> "textual user id",
897 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
898 exp_links
=> ["node"],
899 exp_perms
=> "daemon::0600",
902 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OWNER="daemon"
906 desc
=> "textual group id",
909 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
910 exp_links
=> ["node"],
911 exp_perms
=> ":daemon:0660",
914 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", GROUP="daemon"
918 desc
=> "textual user/group id",
921 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
922 exp_links
=> ["node"],
923 exp_perms
=> "root:audio:0660",
926 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OWNER="root", GROUP="audio"
930 desc
=> "permissions MODE=0777",
933 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
934 exp_links
=> ["node"],
935 exp_perms
=> "::0777",
938 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", MODE="0777"
942 desc
=> "permissions OWNER=1 GROUP=1 MODE=0777",
945 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
946 exp_links
=> ["node"],
947 exp_perms
=> "1:1:0777",
950 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OWNER="1", GROUP="1", MODE="0777"
954 desc
=> "permissions OWNER to 1",
957 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
961 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", OWNER="1"
965 desc
=> "permissions GROUP to 1",
968 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
969 exp_perms
=> ":1:0660",
972 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", GROUP="1"
976 desc
=> "permissions MODE to 0060",
979 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
980 exp_perms
=> "::0060",
983 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", MODE="0060"
987 desc
=> "permissions OWNER, GROUP, MODE",
990 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
991 exp_perms
=> "1:1:0777",
994 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", OWNER="1", GROUP="1", MODE="0777"
998 desc
=> "permissions only rule",
1001 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1002 exp_perms
=> "1:1:0777",
1005 KERNEL=="ttyACM[0-9]*", OWNER="1", GROUP="1", MODE="0777"
1006 KERNEL=="ttyUSX[0-9]*", OWNER="2", GROUP="2", MODE="0444"
1007 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n"
1011 desc
=> "multiple permissions only rule",
1014 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1015 exp_perms
=> "1:1:0777",
1018 SUBSYSTEM=="tty", OWNER="1"
1019 SUBSYSTEM=="tty", GROUP="1"
1020 SUBSYSTEM=="tty", MODE="0777"
1021 KERNEL=="ttyUSX[0-9]*", OWNER="2", GROUP="2", MODE="0444"
1022 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n"
1026 desc
=> "permissions only rule with override at SYMLINK+ rule",
1029 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1030 exp_perms
=> "1:2:0777",
1033 SUBSYSTEM=="tty", OWNER="1"
1034 SUBSYSTEM=="tty", GROUP="1"
1035 SUBSYSTEM=="tty", MODE="0777"
1036 KERNEL=="ttyUSX[0-9]*", OWNER="2", GROUP="2", MODE="0444"
1037 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", GROUP="2"
1041 desc
=> "major/minor number test",
1044 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1045 exp_links
=> ["node"],
1046 exp_majorminor
=> "8:0",
1049 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node"
1053 desc
=> "big major number test",
1056 devpath
=> "/devices/virtual/misc/misc-fake1",
1057 exp_links
=> ["node"],
1058 exp_majorminor
=> "4095:1",
1061 KERNEL=="misc-fake1", SYMLINK+="node"
1065 desc
=> "big major and big minor number test",
1068 devpath
=> "/devices/virtual/misc/misc-fake89999",
1069 exp_links
=> ["node"],
1070 exp_majorminor
=> "4095:89999",
1073 KERNEL=="misc-fake89999", SYMLINK+="node"
1077 desc
=> "multiple symlinks with format char",
1080 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1081 exp_links
=> ["symlink1-0", "symlink2-ttyACM0", "symlink3-"],
1084 KERNEL=="ttyACM[0-9]*", SYMLINK="symlink1-%n symlink2-%k symlink3-%b"
1088 desc
=> "multiple symlinks with a lot of s p a c e s",
1091 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1092 exp_links
=> ["one", "two"],
1093 not_exp_links
=> [" "],
1096 KERNEL=="ttyACM[0-9]*", SYMLINK=" one two "
1100 desc
=> "symlink with spaces in substituted variable",
1103 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1104 exp_links
=> ["name-one_two_three-end"],
1105 not_exp_links
=> [" "],
1108 ENV{WITH_WS}="one two three"
1109 SYMLINK="name-\$env{WITH_WS}-end"
1113 desc
=> "symlink with leading space in substituted variable",
1116 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1117 exp_links
=> ["name-one_two_three-end"],
1118 not_exp_links
=> [" "],
1121 ENV{WITH_WS}=" one two three"
1122 SYMLINK="name-\$env{WITH_WS}-end"
1126 desc
=> "symlink with trailing space in substituted variable",
1129 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1130 exp_links
=> ["name-one_two_three-end"],
1131 not_exp_links
=> [" "],
1134 ENV{WITH_WS}="one two three "
1135 SYMLINK="name-\$env{WITH_WS}-end"
1139 desc
=> "symlink with lots of space in substituted variable",
1142 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1143 exp_links
=> ["name-one_two_three-end"],
1144 not_exp_links
=> [" "],
1147 ENV{WITH_WS}=" one two three "
1148 SYMLINK="name-\$env{WITH_WS}-end"
1152 desc
=> "symlink with multiple spaces in substituted variable",
1155 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1156 exp_links
=> ["name-one_two_three-end"],
1157 not_exp_links
=> [" "],
1160 ENV{WITH_WS}=" one two three "
1161 SYMLINK="name-\$env{WITH_WS}-end"
1165 desc
=> "symlink with space and var with space",
1168 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1169 exp_links
=> ["first", "name-one_two_three-end",
1170 "another_symlink", "a", "b", "c"],
1171 not_exp_links
=> [" "],
1174 ENV{WITH_WS}=" one two three "
1175 SYMLINK=" first name-\$env{WITH_WS}-end another_symlink a b c "
1179 desc
=> "symlink with env which contain slash (see #19309)",
1182 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1183 exp_links
=> ["first", "name-aaa_bbb_ccc-end",
1184 "another_symlink", "a", "b", "c"],
1185 not_exp_links
=> ["ame-aaa/bbb/ccc-end"],
1188 ENV{WITH_SLASH}="aaa/bbb/ccc"
1189 OPTIONS="string_escape=replace", ENV{REPLACED}="\$env{WITH_SLASH}"
1190 SYMLINK=" first name-\$env{REPLACED}-end another_symlink a b c "
1194 desc
=> "symlink creation (same directory)",
1197 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1198 exp_links
=> ["modem0"],
1201 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", SYMLINK="modem%n"
1205 desc
=> "multiple symlinks",
1208 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1209 exp_links
=> ["first-0", "second-0", "third-0"],
1212 KERNEL=="ttyACM0", SYMLINK="first-%n second-%n third-%n"
1216 desc
=> "symlink name '.'",
1219 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1221 exp_add_error
=> "yes",
1222 exp_rem_error
=> "yes",
1225 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="."
1229 desc
=> "symlink node to itself",
1232 devpath
=> "/devices/virtual/tty/tty0",
1233 exp_links
=> ["link"],
1234 exp_add_error
=> "yes",
1235 exp_rem_error
=> "yes",
1239 KERNEL=="tty0", SYMLINK+="tty0"
1243 desc
=> "symlink %n substitution",
1246 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1247 exp_links
=> ["symlink0"],
1250 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", SYMLINK+="symlink%n"
1254 desc
=> "symlink %k substitution",
1257 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1258 exp_links
=> ["symlink-ttyACM0"],
1261 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", SYMLINK+="symlink-%k"
1265 desc
=> "symlink %M:%m substitution",
1268 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1269 exp_links
=> ["major-166:0"],
1272 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", SYMLINK+="major-%M:%m"
1276 desc
=> "symlink %b substitution",
1279 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1280 exp_links
=> ["symlink-0:0:0:0"],
1283 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="symlink-%b"
1287 desc
=> "symlink %c substitution",
1290 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1291 exp_links
=> ["test"],
1294 KERNEL=="ttyACM[0-9]*", PROGRAM=="/bin/echo test", SYMLINK+="%c"
1298 desc
=> "symlink %c{N} substitution",
1301 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1302 exp_links
=> ["test"],
1303 not_exp_links
=> ["symlink", "this"],
1306 KERNEL=="ttyACM[0-9]*", PROGRAM=="/bin/echo symlink test this", SYMLINK+="%c{2}"
1310 desc
=> "symlink %c{N+} substitution",
1313 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1314 exp_links
=> ["test", "this"],
1315 not_exp_links
=> ["symlink"],
1318 KERNEL=="ttyACM[0-9]*", PROGRAM=="/bin/echo symlink test this", SYMLINK+="%c{2+}"
1322 desc
=> "symlink only rule with %c{N+}",
1325 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1326 exp_links
=> ["test", "this"],
1327 not_exp_links
=> ["symlink"],
1330 SUBSYSTEMS=="scsi", KERNEL=="sda", PROGRAM=="/bin/echo link test this" SYMLINK+="%c{2+}"
1334 desc
=> "symlink %s{filename} substitution",
1337 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1338 exp_links
=> ["166:0"],
1341 KERNEL=="ttyACM[0-9]*", SYMLINK+="%s{dev}"
1345 desc
=> "program result substitution (numbered part of)",
1348 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
1349 exp_links
=> ["link1", "link2"],
1350 not_exp_links
=> ["node"],
1353 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n node link1 link2", RESULT=="node *", SYMLINK+="%c{2} %c{3}"
1357 desc
=> "program result substitution (numbered part of+)",
1360 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
1361 exp_links
=> ["link1", "link2", "link3", "link4"],
1362 not_exp_links
=> ["node"],
1365 SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n node link1 link2 link3 link4", RESULT=="node *", SYMLINK+="%c{2+}"
1369 desc
=> "SUBSYSTEM match test",
1372 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1373 exp_links
=> ["node"],
1374 not_exp_links
=> ["should_not_match", "should_not_match2"],
1377 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="should_not_match", SUBSYSTEM=="vc"
1378 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", SUBSYSTEM=="block"
1379 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="should_not_match2", SUBSYSTEM=="vc"
1383 desc
=> "DRIVERS match test",
1386 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1387 exp_links
=> ["node"],
1388 not_exp_links
=> ["should_not_match"]
1391 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="should_not_match", DRIVERS=="sd-wrong"
1392 SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", DRIVERS=="sd"
1396 desc
=> "devnode substitution test",
1399 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1400 exp_links
=> ["node"],
1403 SUBSYSTEMS=="scsi", KERNEL=="sda", PROGRAM=="/usr/bin/test -b %N" SYMLINK+="node"
1407 desc
=> "parent node name substitution test",
1410 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1411 exp_links
=> ["sda-part-1"],
1414 SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="%P-part-%n"
1418 desc
=> "udev_root substitution",
1421 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1422 exp_links
=> ["start-/dev-end"],
1425 SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="start-%r-end"
1429 # This is not supported any more
1430 desc
=> "last_rule option",
1433 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1434 exp_links
=> ["last"],
1435 not_exp_links
=> ["very-last"],
1436 exp_nodev_error
=> "yes",
1439 SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="last", OPTIONS="last_rule"
1440 SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="very-last"
1444 desc
=> "negation KERNEL!=",
1447 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1448 exp_links
=> ["match", "before"],
1449 not_exp_links
=> ["matches-but-is-negated"],
1452 SUBSYSTEMS=="scsi", KERNEL!="sda1", SYMLINK+="matches-but-is-negated"
1453 SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="before"
1454 SUBSYSTEMS=="scsi", KERNEL!="xsda1", SYMLINK+="match"
1458 desc
=> "negation SUBSYSTEM!=",
1461 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1462 exp_links
=> ["before", "not-anything"],
1463 not_exp_links
=> ["matches-but-is-negated"],
1466 SUBSYSTEMS=="scsi", SUBSYSTEM=="block", KERNEL!="sda1", SYMLINK+="matches-but-is-negated"
1467 SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="before"
1468 SUBSYSTEMS=="scsi", SUBSYSTEM!="anything", SYMLINK+="not-anything"
1472 desc
=> "negation PROGRAM!= exit code",
1475 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1476 exp_links
=> ["before", "nonzero-program"],
1479 SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="before"
1480 KERNEL=="sda1", PROGRAM!="/bin/false", SYMLINK+="nonzero-program"
1484 desc
=> "ENV{} test",
1487 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1488 exp_links
=> ["true"],
1489 not_exp_links
=> ["bad", "wrong"],
1492 ENV{ENV_KEY_TEST}="test"
1493 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="go", SYMLINK+="wrong"
1494 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="test", SYMLINK+="true"
1495 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="bad", SYMLINK+="bad"
1499 desc
=> "ENV{} test",
1502 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1503 exp_links
=> ["true"],
1504 not_exp_links
=> ["bad", "wrong", "no"],
1507 ENV{ENV_KEY_TEST}="test"
1508 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="go", SYMLINK+="wrong"
1509 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="yes", ENV{ACTION}=="add", ENV{DEVPATH}=="*/block/sda/sdax1", SYMLINK+="no"
1510 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="test", ENV{ACTION}=="add", ENV{DEVPATH}=="*/block/sda/sda1", SYMLINK+="true"
1511 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ENV_KEY_TEST}=="bad", SYMLINK+="bad"
1515 desc
=> "ENV{} test (assign)",
1518 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1519 exp_links
=> ["true", "before"],
1520 not_exp_links
=> ["no"],
1523 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}="true"
1524 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="yes", SYMLINK+="no"
1525 SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="before"
1526 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="true", SYMLINK+="true"
1530 desc
=> "ENV{} test (assign 2 times)",
1533 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1534 exp_links
=> ["true", "before"],
1535 not_exp_links
=> ["no", "bad"],
1538 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}="true"
1539 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}="absolutely-\$env{ASSIGN}"
1540 SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="before"
1541 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="yes", SYMLINK+="no"
1542 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="true", SYMLINK+="bad"
1543 SUBSYSTEMS=="scsi", KERNEL=="sda1", ENV{ASSIGN}=="absolutely-true", SYMLINK+="true"
1547 desc
=> "ENV{} test (assign2)",
1550 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1551 exp_links
=> ["part"],
1552 not_exp_links
=> ["disk"],
1555 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1556 exp_links
=> ["disk"],
1557 not_exp_links
=> ["part"],
1561 SUBSYSTEM=="block", KERNEL=="*[0-9]", ENV{PARTITION}="true", ENV{MAINDEVICE}="false"
1562 SUBSYSTEM=="block", KERNEL=="*[!0-9]", ENV{PARTITION}="false", ENV{MAINDEVICE}="true"
1563 ENV{MAINDEVICE}=="true", SYMLINK+="disk"
1564 SUBSYSTEM=="block", SYMLINK+="before"
1565 ENV{PARTITION}=="true", SYMLINK+="part"
1569 desc
=> "untrusted string sanitize",
1572 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1573 exp_links
=> ["sane"],
1576 SUBSYSTEMS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e name; (/usr/bin/badprogram)", RESULT=="name_ _/usr/bin/badprogram_", SYMLINK+="sane"
1580 desc
=> "untrusted string sanitize (don't replace utf8)",
1583 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1584 exp_links
=> ["uber"],
1587 SUBSYSTEMS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e \\xc3\\xbcber" RESULT=="\xc3\xbcber", SYMLINK+="uber"
1591 desc
=> "untrusted string sanitize (replace invalid utf8)",
1594 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1595 exp_links
=> ["replaced"],
1598 SUBSYSTEMS=="scsi", KERNEL=="sda1", PROGRAM=="/bin/echo -e \\xef\\xe8garbage", RESULT=="__garbage", SYMLINK+="replaced"
1602 desc
=> "read sysfs value from parent device",
1605 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1606 exp_links
=> ["serial-354172020305000"],
1609 KERNEL=="ttyACM*", ATTRS{serial}=="?*", SYMLINK+="serial-%s{serial}"
1613 desc
=> "match against empty key string",
1616 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1617 exp_links
=> ["ok"],
1618 not_exp_links
=> ["not-1-ok", "not-2-ok", "not-3-ok"],
1621 KERNEL=="sda", ATTRS{nothing}!="", SYMLINK+="not-1-ok"
1622 KERNEL=="sda", ATTRS{nothing}=="", SYMLINK+="not-2-ok"
1623 KERNEL=="sda", ATTRS{vendor}!="", SYMLINK+="ok"
1624 KERNEL=="sda", ATTRS{vendor}=="", SYMLINK+="not-3-ok"
1628 desc
=> "check ACTION value",
1631 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1632 exp_links
=> ["ok"],
1633 not_exp_links
=> ["unknown-not-ok"],
1636 ACTION=="unknown", KERNEL=="sda", SYMLINK+="unknown-not-ok"
1637 ACTION=="add", KERNEL=="sda", SYMLINK+="ok"
1641 desc
=> "final assignment",
1644 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1645 exp_links
=> ["ok"],
1646 exp_perms
=> "root:tty:0640",
1649 KERNEL=="sda", GROUP:="tty"
1650 KERNEL=="sda", GROUP="root", MODE="0640", SYMLINK+="ok"
1654 desc
=> "final assignment 2",
1657 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1658 exp_links
=> ["ok"],
1659 exp_perms
=> "root:tty:0640",
1662 KERNEL=="sda", GROUP:="tty"
1663 SUBSYSTEM=="block", MODE:="640"
1664 KERNEL=="sda", GROUP="root", MODE="0666", SYMLINK+="ok"
1668 desc
=> "env substitution",
1671 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1672 exp_links
=> ["node-add-me"],
1675 KERNEL=="sda", MODE="0666", SYMLINK+="node-\$env{ACTION}-me"
1679 desc
=> "reset list to current value",
1682 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1683 exp_links
=> ["three"],
1684 not_exp_links
=> ["two", "one"],
1687 KERNEL=="ttyACM[0-9]*", SYMLINK+="one"
1688 KERNEL=="ttyACM[0-9]*", SYMLINK+="two"
1689 KERNEL=="ttyACM[0-9]*", SYMLINK="three"
1693 desc
=> "test empty SYMLINK+ (empty override)",
1696 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1697 exp_links
=> ["right"],
1698 not_exp_links
=> ["wrong"],
1701 KERNEL=="ttyACM[0-9]*", SYMLINK+="wrong"
1702 KERNEL=="ttyACM[0-9]*", SYMLINK=""
1703 KERNEL=="ttyACM[0-9]*", SYMLINK+="right"
1707 desc
=> "test multi matches",
1710 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1711 exp_links
=> ["right", "before"],
1714 KERNEL=="ttyACM*", SYMLINK+="before"
1715 KERNEL=="ttyACM*|nothing", SYMLINK+="right"
1719 desc
=> "test multi matches 2",
1722 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1723 exp_links
=> ["right", "before"],
1724 not_exp_links
=> ["nomatch"],
1727 KERNEL=="dontknow*|*nothing", SYMLINK+="nomatch"
1728 KERNEL=="ttyACM*", SYMLINK+="before"
1729 KERNEL=="dontknow*|ttyACM*|nothing*", SYMLINK+="right"
1733 desc
=> "test multi matches 3",
1736 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1737 exp_links
=> ["right"],
1738 not_exp_links
=> ["nomatch", "wrong1", "wrong2"],
1741 KERNEL=="dontknow|nothing", SYMLINK+="nomatch"
1742 KERNEL=="dontknow|ttyACM0a|nothing|attyACM0", SYMLINK+="wrong1"
1743 KERNEL=="X|attyACM0|dontknow|ttyACM0a|nothing|attyACM0", SYMLINK+="wrong2"
1744 KERNEL=="dontknow|ttyACM0|nothing", SYMLINK+="right"
1748 desc
=> "test multi matches 4",
1751 devpath
=> "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
1752 exp_links
=> ["right"],
1753 not_exp_links
=> ["nomatch", "wrong1", "wrong2", "wrong3"],
1756 KERNEL=="dontknow|nothing", SYMLINK+="nomatch"
1757 KERNEL=="dontknow|ttyACM0a|nothing|attyACM0", SYMLINK+="wrong1"
1758 KERNEL=="X|attyACM0|dontknow|ttyACM0a|nothing|attyACM0", SYMLINK+="wrong2"
1759 KERNEL=="all|dontknow|ttyACM0", SYMLINK+="right"
1760 KERNEL=="ttyACM0a|nothing", SYMLINK+="wrong3"
1764 desc
=> "test multi matches 5",
1767 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1768 exp_links
=> ["found"],
1769 not_exp_name
=> "bad",
1772 KERNEL=="sda", TAG="foo"
1773 TAGS=="|foo", SYMLINK+="found"
1774 TAGS=="|aaa", SYMLINK+="bad"
1778 desc
=> "test multi matches 6",
1781 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1782 exp_links
=> ["found"],
1783 not_exp_name
=> "bad",
1786 KERNEL=="sda", TAG=""
1787 TAGS=="|foo", SYMLINK+="found"
1788 TAGS=="aaa|bbb", SYMLINK+="bad"
1792 desc
=> "test multi matches 7",
1795 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1796 exp_links
=> ["found"],
1797 not_exp_name
=> "bad",
1800 KERNEL=="sda", TAG="foo"
1801 TAGS=="foo||bar", SYMLINK+="found"
1802 TAGS=="aaa||bbb", SYMLINK+="bad"
1806 desc
=> "test multi matches 8",
1809 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1810 exp_links
=> ["found"],
1811 not_exp_name
=> "bad",
1814 KERNEL=="sda", TAG=""
1815 TAGS=="foo||bar", SYMLINK+="found"
1816 TAGS=="aaa|bbb", SYMLINK+="bad"
1820 desc
=> "test multi matches 9",
1823 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1824 exp_links
=> ["found"],
1825 not_exp_name
=> "bad",
1828 KERNEL=="sda", TAG="foo"
1829 TAGS=="foo|", SYMLINK+="found"
1830 TAGS=="aaa|", SYMLINK+="bad"
1834 desc
=> "test multi matches 10",
1837 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1838 exp_links
=> ["found"],
1839 not_exp_name
=> "bad",
1842 KERNEL=="sda", TAG=""
1843 TAGS=="foo|", SYMLINK+="found"
1844 TAGS=="aaa|bbb", SYMLINK+="bad"
1848 desc
=> "test multi matches 11",
1851 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1852 exp_links
=> ["found"],
1853 not_exp_name
=> "bad",
1856 KERNEL=="sda", TAG="c"
1857 TAGS=="foo||bar||c", SYMLINK+="found"
1858 TAGS=="aaa||bbb||ccc", SYMLINK+="bad"
1862 desc
=> "IMPORT parent test",
1865 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1866 exp_links
=> ["parent"],
1869 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1870 exp_links
=> ["parentenv-parent_right"],
1872 sleep_us
=> 500000, # Serialized! We need to sleep here after adding sda
1874 KERNEL=="sda1", IMPORT{parent}="PARENT*", SYMLINK+="parentenv-\$env{PARENT_KEY}\$env{WRONG_PARENT_KEY}"
1875 KERNEL=="sda", IMPORT{program}="/bin/echo -e \'PARENT_KEY=parent_right\\nWRONG_PARENT_KEY=parent_wrong'"
1876 KERNEL=="sda", SYMLINK+="parent"
1880 desc
=> "GOTO test",
1883 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1884 exp_links
=> ["right"],
1885 not_exp_test
=> ["wrong", "wrong2"],
1888 KERNEL=="sda1", GOTO="TEST"
1889 KERNEL=="sda1", SYMLINK+="wrong"
1890 KERNEL=="sda1", GOTO="BAD"
1891 KERNEL=="sda1", SYMLINK+="", LABEL="NO"
1892 KERNEL=="sda1", SYMLINK+="right", LABEL="TEST", GOTO="end"
1893 KERNEL=="sda1", SYMLINK+="wrong2", LABEL="BAD"
1898 desc
=> "GOTO label does not exist",
1901 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1902 exp_links
=> ["right"],
1905 KERNEL=="sda1", GOTO="does-not-exist"
1906 KERNEL=="sda1", SYMLINK+="right",
1911 desc
=> "SYMLINK+ compare test",
1914 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1915 exp_links
=> ["right", "link"],
1916 not_exp_links
=> ["wrong"],
1919 KERNEL=="sda1", SYMLINK+="link"
1920 KERNEL=="sda1", SYMLINK=="link*", SYMLINK+="right"
1921 KERNEL=="sda1", SYMLINK=="nolink*", SYMLINK+="wrong"
1925 desc
=> "invalid key operation",
1928 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1929 exp_links
=> ["yes"],
1930 not_exp_links
=> ["no"],
1933 KERNEL="sda1", SYMLINK+="no"
1934 KERNEL=="sda1", SYMLINK+="yes"
1938 desc
=> "operator chars in attribute",
1941 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1942 exp_links
=> ["yes"],
1945 KERNEL=="sda", ATTR{test:colon+plus}=="?*", SYMLINK+="yes"
1949 desc
=> "overlong comment line",
1952 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
1953 exp_links
=> ["yes"],
1954 not_exp_links
=> ["no"],
1957 # 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
1958 # 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
1959 KERNEL=="sda1", SYMLINK+=="no"
1960 KERNEL=="sda1", SYMLINK+="yes"
1964 desc
=> "magic subsys/kernel lookup",
1967 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1968 exp_links
=> ["00:16:41:e2:8d:ff"],
1971 KERNEL=="sda", SYMLINK+="\$attr{[net/eth0]address}"
1975 desc
=> "TEST absolute path",
1978 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1979 exp_links
=> ["there"],
1980 not_exp_links
=> ["notthere"],
1983 TEST=="/etc/passwd", SYMLINK+="there"
1984 TEST!="/etc/passwd", SYMLINK+="notthere"
1988 desc
=> "TEST subsys/kernel lookup",
1991 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
1992 exp_links
=> ["yes"],
1995 KERNEL=="sda", TEST=="[net/eth0]", SYMLINK+="yes"
1999 desc
=> "TEST relative path",
2002 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2003 exp_links
=> ["relative"],
2006 KERNEL=="sda", TEST=="size", SYMLINK+="relative"
2010 desc
=> "TEST wildcard substitution (find queue/nr_requests)",
2013 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2014 exp_links
=> ["found-subdir"],
2017 KERNEL=="sda", TEST=="*/nr_requests", SYMLINK+="found-subdir"
2021 desc
=> "TEST MODE=0000",
2024 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2025 exp_perms
=> "0:0:0000",
2026 exp_rem_error
=> "yes",
2029 KERNEL=="sda", MODE="0000"
2033 desc
=> "TEST PROGRAM feeds OWNER, GROUP, MODE",
2036 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2037 exp_perms
=> "1:1:0400",
2040 KERNEL=="sda", MODE="666"
2041 KERNEL=="sda", PROGRAM=="/bin/echo 1 1 0400", OWNER="%c{1}", GROUP="%c{2}", MODE="%c{3}"
2045 desc
=> "TEST PROGRAM feeds MODE with overflow",
2048 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2049 exp_perms
=> "0:0:0440",
2050 exp_rem_error
=> "yes",
2053 KERNEL=="sda", MODE="440"
2054 KERNEL=="sda", PROGRAM=="/bin/echo 0 0 0400letsdoabuffferoverflow0123456789012345789012345678901234567890", OWNER="%c{1}", GROUP="%c{2}", MODE="%c{3}"
2058 desc
=> "magic [subsys/sysname] attribute substitution",
2061 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2062 exp_links
=> ["sda-8741C4G-end"],
2063 exp_perms
=> "0:0:0600",
2066 KERNEL=="sda", SYMLINK+="%k-%s{[dmi/id]product_name}-end"
2070 desc
=> "builtin path_id",
2073 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2074 exp_links
=> ["disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0"],
2077 KERNEL=="sda", IMPORT{builtin}="path_id"
2078 KERNEL=="sda", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/\$env{ID_PATH}"
2082 desc
=> "add and match tag",
2085 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2086 exp_links
=> ["found"],
2087 not_exp_links
=> ["bad"],
2090 SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", TAG+="green"
2091 TAGS=="green", SYMLINK+="found"
2092 TAGS=="blue", SYMLINK+="bad"
2096 desc
=> "don't crash with lots of tags",
2099 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2100 exp_links
=> ["found"],
2102 rules
=> $rules_10k_tags . <<EOF
2103 TAGS=="test1", TAGS=="test500", TAGS=="test1234", TAGS=="test9999", TAGS=="test10000", SYMLINK+="found"
2107 desc
=> "continuations",
2110 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2111 exp_links
=> ["found"],
2112 not_exp_name
=> "bad",
2114 rules
=> $rules_10k_tags_continuation . <<EOF
2115 TAGS=="test1", TAGS=="test500", TAGS=="test1234", TAGS=="test9999", TAGS=="test10000", SYMLINK+="bad"
2117 # comment in continuation
2119 # space before comment
2121 # spaces before and after token are dropped
2126 TAGS=="hoge1", TAGS=="hoge2", TAGS=="hoge3", TAGS=="hoge4", SYMLINK+="found"
2130 desc
=> "continuations with empty line",
2133 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2134 exp_links
=> ["found"],
2135 not_exp_name
=> "bad",
2139 # empty line finishes continuation
2140 KERNEL=="sda", TAG+="foo" \\
2142 KERNEL=="sdb", TAG+="hoge"
2143 KERNEL=="sda", TAG+="aaa" \\
2144 KERNEL=="sdb", TAG+="bbb"
2145 TAGS=="foo", SYMLINK+="found"
2146 TAGS=="aaa", SYMLINK+="bad"
2150 desc
=> "continuations with white only line",
2153 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
2154 exp_links
=> ["found"],
2155 not_exp_name
=> "bad",
2158 # space only line finishes continuation
2159 KERNEL=="sda", TAG+="foo" \\
2161 KERNEL=="sdb", TAG+="hoge"
2162 KERNEL=="sda", TAG+="aaa" \\
2163 KERNEL=="sdb", TAG+="bbb"
2164 TAGS=="foo", SYMLINK+="found"
2165 TAGS=="aaa", SYMLINK+="bad"
2169 desc
=> "multiple devices",
2172 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
2173 exp_links
=> ["part-1"],
2176 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
2177 exp_links
=> ["part-5"],
2180 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
2181 exp_links
=> ["part-6"],
2184 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
2185 exp_links
=> ["part-7"],
2188 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
2189 exp_links
=> ["part-8"],
2192 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
2193 exp_links
=> ["part-9"],
2196 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
2197 exp_links
=> ["part-10"],
2201 SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
2205 desc
=> "multiple devices, same link name, positive prio",
2209 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
2210 exp_links
=> ["part-1"],
2211 not_exp_links
=> ["partition"],
2214 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
2215 exp_links
=> ["part-5"],
2216 not_exp_links
=> ["partition"],
2219 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
2220 not_exp_links
=> ["partition"],
2221 exp_links
=> ["part-6"],
2224 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
2225 exp_links
=> ["part-7", "partition"],
2228 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
2229 not_exp_links
=> ["partition"],
2230 exp_links
=> ["part-8"],
2233 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
2234 not_exp_links
=> ["partition"],
2235 exp_links
=> ["part-9"],
2238 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
2239 not_exp_links
=> ["partition"],
2240 exp_links
=> ["part-10"],
2244 SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
2245 SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="partition"
2246 KERNEL=="*7", OPTIONS+="link_priority=10"
2250 desc
=> "multiple devices, same link name, negative prio",
2253 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
2254 exp_links
=> ["part-1"],
2255 not_exp_links
=> ["partition"],
2258 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
2259 exp_links
=> ["part-5"],
2260 not_exp_links
=> ["partition"],
2263 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
2264 not_exp_links
=> ["partition"],
2265 exp_links
=> ["part-6"],
2268 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
2269 exp_links
=> ["part-7", "partition"],
2272 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
2273 not_exp_links
=> ["partition"],
2274 exp_links
=> ["part-8"],
2277 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
2278 not_exp_links
=> ["partition"],
2279 exp_links
=> ["part-9"],
2282 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
2283 not_exp_links
=> ["partition"],
2284 exp_links
=> ["part-10"],
2288 SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
2289 SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="partition"
2290 KERNEL!="*7", OPTIONS+="link_priority=-10"
2294 desc
=> "multiple devices, same link name, positive prio, sleep",
2297 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
2298 exp_links
=> ["part-1"],
2299 not_exp_links
=> ["partition"],
2302 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
2303 exp_links
=> ["part-5"],
2304 not_exp_links
=> ["partition"],
2307 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
2308 not_exp_links
=> ["partition"],
2309 exp_links
=> ["part-6"],
2312 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7",
2313 exp_links
=> ["part-7", "partition"],
2316 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8",
2317 not_exp_links
=> ["partition"],
2318 exp_links
=> ["part-8"],
2321 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9",
2322 not_exp_links
=> ["partition"],
2323 exp_links
=> ["part-9"],
2326 devpath
=> "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10",
2327 not_exp_links
=> ["partition"],
2328 exp_links
=> ["part-10"],
2333 SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="part-%n"
2334 SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sda?*", ENV{DEVTYPE}=="partition", SYMLINK+="partition"
2335 KERNEL=="*7", OPTIONS+="link_priority=10"
2339 desc
=> 'all_block_devs',
2340 generator
=> expect_for_some
("\\/sda6\$", ["blockdev"]),
2343 SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNEL=="sd*", SYMLINK+="blockdev"
2344 KERNEL=="sda6", OPTIONS+="link_priority=10"
2352 # create temporary rules
2353 system("mkdir", "-p", "$udev_rules_dir");
2354 open CONF
, ">$udev_rules" || die "unable to create rules file: $udev_rules";
2360 my ($action, $devpath) = @_;
2362 if ($valgrind > 0) {
2363 return system("$udev_bin_valgrind $action $devpath");
2364 } elsif ($gdb > 0) {
2365 return system("$udev_bin_gdb $action $devpath");
2366 } elsif ($strace > 0) {
2367 return system("$udev_bin_strace $action $devpath");
2369 return system("$udev_bin", "$action", "$devpath");
2377 sub permissions_test
{
2378 my($rules, $uid, $gid, $mode) = @_;
2384 $rules->{exp_perms
} =~ m/^(.*):(.*):(.*)$/;
2386 if (defined(getpwnam($1))) {
2387 $userid = int(getpwnam($1));
2391 if ($uid != $userid) { $wrong = 1; }
2394 if (defined(getgrnam($2))) {
2395 $groupid = int(getgrnam($2));
2399 if ($gid != $groupid) { $wrong = 1; }
2402 if (($mode & 07777) != oct($3)) { $wrong = 1; };
2405 print "permissions: ok\n";
2408 printf " expected permissions are: %s:%s:%#o\n", $1, $2, oct($3);
2409 printf " created permissions are : %i:%i:%#o\n", $uid, $gid, $mode & 07777;
2410 print "permissions: error\n";
2416 sub major_minor_test
{
2417 my($rules, $rdev) = @_;
2419 my $major = ($rdev >> 8) & 0xfff;
2420 my $minor = ($rdev & 0xff) | (($rdev >> 12) & 0xfff00);
2423 $rules->{exp_majorminor
} =~ m/^(.*):(.*)$/;
2425 if ($major != $1) { $wrong = 1; };
2428 if ($minor != $2) { $wrong = 1; };
2431 print "major:minor: ok\n";
2434 printf " expected major:minor is: %i:%i\n", $1, $2;
2435 printf " created major:minor is : %i:%i\n", $major, $minor;
2436 print "major:minor: error\n";
2443 system("umount \"$udev_tmpfs\" 2>/dev/null");
2445 mkdir($udev_tmpfs) || die "unable to create udev_tmpfs: $udev_tmpfs\n";
2447 if (system("mount", "-o", "rw,mode=0755,nosuid,noexec", "-t", "tmpfs", "tmpfs", $udev_tmpfs)) {
2448 warn "unable to mount tmpfs";
2452 mkdir($udev_dev) || die "unable to create udev_dev: $udev_dev\n";
2453 # setting group and mode of udev_dev ensures the tests work
2454 # even if the parent directory has setgid bit enabled.
2455 chown (0, 0, $udev_dev) || die "unable to chown $udev_dev\n";
2456 chmod (0755, $udev_dev) || die "unable to chmod $udev_dev\n";
2458 if (system("mknod", $udev_dev . "/null", "c", "1", "3")) {
2459 warn "unable to create $udev_dev/null";
2463 # check if we are permitted to create block device nodes
2464 my $block_device_filename = $udev_dev . "/sda";
2465 if (system("mknod", $block_device_filename, "b", "8", "0")) {
2466 warn "unable to create $block_device_filename";
2469 unlink $block_device_filename;
2471 system("cp", "-r", "test/sys/", $udev_sys) && die "unable to copy test/sys";
2473 system("rm", "-rf", "$udev_run");
2475 if (!mkdir($udev_run)) {
2476 warn "unable to create directory $udev_run";
2487 if (defined($device->{devnode
})) {
2488 $devnode = "$udev_dev/$device->{devnode}";
2490 $devnode = "$device->{devpath}";
2491 $devnode =~ s!.*/!$udev_dev/!;
2498 my $devnode = get_devnode
($device);
2500 my @st = lstat("$devnode");
2501 if (! (-b _
|| -c _
)) {
2502 print "add $devnode: error\n";
2503 system("tree", "$udev_dev");
2508 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
2509 $atime, $mtime, $ctime, $blksize, $blocks) = @st;
2511 if (defined($device->{exp_perms
})) {
2512 permissions_test
($device, $uid, $gid, $mode);
2514 if (defined($device->{exp_majorminor
})) {
2515 major_minor_test
($device, $rdev);
2517 print "add $devnode: ok\n";
2522 sub get_link_target
{
2526 my $dir = "$udev_dev/$link";
2527 my $tgt = readlink("$udev_dev/$link");
2528 $dir =~ s!/[^/]*$!!;
2529 $tgt = abs_path
("$dir/$tgt");
2534 sub check_link_add
{
2535 my ($link, $devnode, $err_expected) = @_;
2537 my @st = lstat("$udev_dev/$link");
2539 my $tgt = get_link_target
($link);
2541 if ($tgt ne $devnode) {
2542 print "symlink $link: error, found -> $tgt\n";
2544 system("tree", "$udev_dev");
2546 print "symlink $link: ok\n";
2550 print "symlink $link: error";
2551 if ($err_expected) {
2552 print " as expected\n";
2556 system("tree", "$udev_dev");
2564 sub check_link_nonexistent
{
2565 my ($link, $devnode, $err_expected) = @_;
2567 if ((-e
"$udev_dev/$link") || (-l
"$udev_dev/$link")) {
2568 my $tgt = get_link_target
($link);
2570 if ($tgt ne $devnode) {
2571 print "nonexistent: '$link' points to other device (ok)\n";
2574 print "nonexistent: error \'$link\' should not be there";
2575 if ($err_expected) {
2576 print " (as expected)\n";
2580 system("tree", "$udev_dev");
2587 print "nonexistent $link: ok\n";
2594 my $devnode = check_devnode
($device);
2596 if (defined($device->{exp_links
})) {
2597 foreach my $link (@
{$device->{exp_links
}}) {
2598 check_link_add
($link, $devnode,
2599 $device->{exp_add_error
});
2602 if (defined $device->{not_exp_links
}) {
2603 foreach my $link (@
{$device->{not_exp_links
}}) {
2604 check_link_nonexistent
($link, $devnode,
2605 $device->{exp_nodev_error
});
2610 sub check_remove_devnode
{
2612 my $devnode = get_devnode
($device);
2614 if (-e
"$devnode") {
2615 print "remove $devnode: error";
2617 system("tree", "$udev_dev");
2622 print "remove $devnode: ok\n";
2627 sub check_link_remove
{
2628 my ($link, $err_expected) = @_;
2630 if ((-e
"$udev_dev/$link") ||
2631 (-l
"$udev_dev/$link")) {
2632 print "remove $link: error";
2633 if ($err_expected) {
2634 print " as expected\n";
2638 system("tree", "$udev_dev");
2644 print "remove $link: ok\n";
2652 check_remove_devnode
($device);
2654 return if (!defined($device->{exp_links
}));
2656 foreach my $link (@
{$device->{exp_links
}}) {
2657 check_link_remove
($link, $device->{exp_rem_error
});
2662 my ($action, $dev, $sleep_us, $sema) = @_;
2664 # Notify main process that this worker has started
2669 usleep
($sleep_us) if defined ($sleep_us);
2670 my $rc = udev
($action, $dev->{devpath
});
2674 sub fork_and_run_udev
{
2675 my ($action, $rules, $sema) = @_;
2676 my @devices = @
{$rules->{devices
}};
2680 $sema->setval(0, 1);
2681 foreach $dev (@devices) {
2685 run_udev
($action, $dev,
2686 defined($rules->{sleep_us
}) ?
$k * $rules->{sleep_us
} : undef,
2694 # This operation waits for all workers to become ready, and
2695 # starts them off when that's the case.
2696 $sema->op(0, -($#devices + 2), 0);
2698 foreach $dev (@devices) {
2702 $pid = waitpid($dev->{pid
}, 0);
2704 print "error waiting for pid dev->{pid}\n";
2706 if (WIFEXITED
($?
)) {
2707 $rc = WEXITSTATUS
($?
);
2710 print "$udev_bin $action for $dev->{devpath} failed with code $rc\n";
2720 my ($rules, $number, $sema) = @_;
2724 my $cur_good = $good;
2725 my $cur_error = $error;
2727 if (!defined $rules->{devices
}) {
2728 $rules->{devices
} = all_block_devs
($rules->{generator
});
2730 @devices = @
{$rules->{devices
}};
2731 # For each device: exit status and devnode test for add & remove
2732 $ntests += 4 * ($#devices + 1);
2734 foreach my $dev (@devices) {
2735 $ntests += 2 * ($#{$dev->{exp_links}} + 1)
2736 + ($#{$dev->{not_exp_links}} + 1)
2737 + (defined $dev->{exp_perms
} ?
1 : 0)
2738 + (defined $dev->{exp_majorminor
} ?
1 : 0);
2740 if (defined $rules->{repeat
}) {
2741 $ntests *= $rules->{repeat
};
2743 $exp_good += $ntests;
2744 print "TEST $number: $rules->{desc}\n";
2745 create_rules
(\
$rules->{rules
});
2748 fork_and_run_udev
("add", $rules, $sema);
2750 foreach my $dev (@devices) {
2754 if (defined($rules->{option
}) && $rules->{option
} eq "keep") {
2759 fork_and_run_udev
("remove", $rules, $sema);
2761 foreach my $dev (@devices) {
2765 if (defined($rules->{repeat
}) && --($rules->{repeat
}) > 0) {
2768 printf "TEST $number: errors: %d good: %d/%d\n\n", $error-$cur_error,
2769 $good-$cur_good, $ntests;
2771 if (defined($rules->{option
}) && $rules->{option
} eq "clean") {
2778 system("rm", "-rf", "$udev_run");
2779 system("umount", "$udev_tmpfs");
2783 # only run if we have root permissions
2784 # due to mknod restrictions
2786 print "Must have root permissions to run properly.\n";
2787 exit($EXIT_TEST_SKIP);
2790 # skip the test when running in a chroot
2791 system("systemd-detect-virt", "-r", "-q");
2793 print "Running in a chroot, skipping the test.\n";
2794 exit($EXIT_TEST_SKIP);
2797 if (!udev_setup
()) {
2798 warn "Failed to set up the environment, skipping the test";
2800 exit($EXIT_TEST_SKIP);
2803 if (system($udev_bin, "check")) {
2804 warn "$udev_bin failed to set up the environment, skipping the test";
2806 exit($EXIT_TEST_SKIP);
2812 foreach my $arg (@ARGV) {
2813 if ($arg =~ m/--valgrind/) {
2815 printf("using valgrind\n");
2816 } elsif ($arg =~ m/--gdb/) {
2818 printf("using gdb\n");
2819 } elsif ($arg =~ m/--strace/) {
2821 printf("using strace\n");
2826 my $sema = IPC
::Semaphore
->new(IPC_PRIVATE
, 1, S_IRUSR
| S_IWUSR
| IPC_CREAT
);
2829 foreach my $arg (@list) {
2830 if (defined($tests[$arg-1]->{desc
})) {
2831 print "udev-test will run test number $arg:\n\n";
2832 run_test
($tests[$arg-1], $arg, $sema);
2834 print "test does not exist.\n";
2839 print "\nudev-test will run ".($#tests + 1)." tests:\n\n";
2841 foreach my $rules (@tests) {
2842 run_test
($rules, $test_num, $sema);
2848 print "$error errors occurred. $good/$exp_good good results.\n\n";