$rules_10k_tags .= 'KERNEL=="sda", TAG+="test' . $i . "\"\n";
}
+my $rules_10k_tags_continuation = "KERNEL==\"sda\", \\\n";
+for (my $i = 1; $i < 10000; ++$i) {
+ $rules_10k_tags_continuation .= 'TAG+="test' . $i . "\",\\\n";
+}
+$rules_10k_tags_continuation .= "TAG+=\"test10000\"\\n";
+
my @tests = (
{
desc => "no rules",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "sda" ,
+ exp_name => "sda",
exp_rem_error => "yes",
rules => <<EOF
#
{
desc => "label test of scsi disc",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "boot_disk" ,
+ exp_name => "boot_disk",
rules => <<EOF
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
KERNEL=="ttyACM0", SYMLINK+="modem"
{
desc => "label test of scsi disc",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "boot_disk" ,
+ exp_name => "boot_disk",
rules => <<EOF
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
KERNEL=="ttyACM0", SYMLINK+="modem"
{
desc => "label test of scsi disc",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "boot_disk" ,
+ exp_name => "boot_disk",
rules => <<EOF
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
KERNEL=="ttyACM0", SYMLINK+="modem"
{
desc => "label test of scsi partition",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "boot_disk1" ,
+ exp_name => "boot_disk1",
rules => <<EOF
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="boot_disk%n"
EOF
{
desc => "label test of pattern match",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "boot_disk1" ,
+ exp_name => "boot_disk1",
rules => <<EOF
SUBSYSTEMS=="scsi", ATTRS{vendor}=="?ATA", SYMLINK+="boot_disk%n-1"
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA?", SYMLINK+="boot_disk%n-2"
{
desc => "label test of multiple sysfs files",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "boot_disk1" ,
+ exp_name => "boot_disk1",
rules => <<EOF
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS X ", SYMLINK+="boot_diskX%n"
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", SYMLINK+="boot_disk%n"
{
desc => "label test of max sysfs files (skip invalid rule)",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
- exp_name => "boot_disk1" ,
+ exp_name => "boot_disk1",
rules => <<EOF
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"
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", SYMLINK+="boot_disk%n"
{
desc => "catch device by *",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem/0" ,
+ exp_name => "modem/0",
rules => <<EOF
KERNEL=="ttyACM*", SYMLINK+="modem/%n"
EOF
{
desc => "catch device by * - take 2",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem/0" ,
+ exp_name => "modem/0",
rules => <<EOF
KERNEL=="*ACM1", SYMLINK+="bad"
KERNEL=="*ACM0", SYMLINK+="modem/%n"
{
desc => "catch device by ?",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem/0" ,
+ exp_name => "modem/0",
rules => <<EOF
KERNEL=="ttyACM??*", SYMLINK+="modem/%n-1"
KERNEL=="ttyACM??", SYMLINK+="modem/%n-2"
{
desc => "catch device by character class",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem/0" ,
+ exp_name => "modem/0",
rules => <<EOF
KERNEL=="ttyACM[A-Z]*", SYMLINK+="modem/%n-1"
KERNEL=="ttyACM?[0-9]", SYMLINK+="modem/%n-2"
{
desc => "replace kernel name",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
+ exp_name => "modem",
rules => <<EOF
KERNEL=="ttyACM0", SYMLINK+="modem"
EOF
{
desc => "Handle comment lines in config file (and replace kernel name)",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
+ exp_name => "modem",
rules => <<EOF
# this is a comment
KERNEL=="ttyACM0", SYMLINK+="modem"
{
desc => "Handle comment lines in config file with whitespace (and replace kernel name)",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
+ exp_name => "modem",
rules => <<EOF
# this is a comment with whitespace before the comment
KERNEL=="ttyACM0", SYMLINK+="modem"
{
desc => "Handle whitespace only lines (and replace kernel name)",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "whitespace" ,
+ exp_name => "whitespace",
rules => <<EOF
{
desc => "Handle empty lines in config file (and replace kernel name)",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
+ exp_name => "modem",
rules => <<EOF
KERNEL=="ttyACM0", SYMLINK+="modem"
{
desc => "Handle backslashed multi lines in config file (and replace kernel name)",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
+ exp_name => "modem",
rules => <<EOF
KERNEL=="ttyACM0", \\
SYMLINK+="modem"
{
desc => "Handle stupid backslashed multi lines in config file (and replace kernel name)",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
+ exp_name => "modem",
rules => <<EOF
#
{
desc => "subdirectory handling",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "sub/direct/ory/modem" ,
+ exp_name => "sub/direct/ory/modem",
rules => <<EOF
KERNEL=="ttyACM0", SYMLINK+="sub/direct/ory/modem"
EOF
{
desc => "parent device name match of scsi partition",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "first_disk5" ,
+ exp_name => "first_disk5",
rules => <<EOF
SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="first_disk%n"
EOF
{
desc => "test substitution chars",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "Major:8:minor:5:kernelnumber:5:id:0:0:0:0" ,
+ exp_name => "Major:8:minor:5:kernelnumber:5:id:0:0:0:0",
rules => <<EOF
SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="Major:%M:minor:%m:kernelnumber:%n:id:%b"
EOF
{
desc => "sustitution of sysfs value (%s{file})",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "disk-ATA-sda" ,
+ exp_name => "disk-ATA-sda",
rules => <<EOF
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", SYMLINK+="disk-%s{vendor}-%k"
KERNEL=="ttyACM0", SYMLINK+="modem"
{
desc => "program result substitution",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "special-device-5" ,
- not_exp_name => "not" ,
+ exp_name => "special-device-5",
+ not_exp_name => "not",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="-special-*", SYMLINK+="not"
SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n special-device", RESULT=="special-*", SYMLINK+="%c-%n"
{
desc => "program result substitution (newline removal)",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "newline_removed" ,
+ exp_name => "newline_removed",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo test", RESULT=="test", SYMLINK+="newline_removed"
EOF
{
desc => "program result substitution",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "test-0:0:0:0" ,
+ exp_name => "test-0:0:0:0",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n test-%b", RESULT=="test-0:0*", SYMLINK+="%c"
EOF
{
desc => "program with lots of arguments",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "foo9" ,
+ exp_name => "foo9",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", SYMLINK+="%c{7}"
EOF
{
desc => "program with subshell",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "bar9" ,
+ exp_name => "bar9",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c 'echo foo3 foo4 foo5 foo6 foo7 foo8 foo9 | sed s/foo9/bar9/'", KERNEL=="sda5", SYMLINK+="%c{7}"
EOF
{
desc => "program arguments combined with apostrophes",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "foo7" ,
+ exp_name => "foo7",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n 'foo3 foo4' 'foo5 foo6 foo7 foo8'", KERNEL=="sda5", SYMLINK+="%c{5}"
EOF
{
desc => "program arguments combined with escaped double quotes, part 1",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "foo2" ,
+ exp_name => "foo2",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c 'printf %%s \\\"foo1 foo2\\\" | grep \\\"foo1 foo2\\\"'", KERNEL=="sda5", SYMLINK+="%c{2}"
EOF
{
desc => "program arguments combined with escaped double quotes, part 2",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "foo2" ,
+ exp_name => "foo2",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c \\\"printf %%s 'foo1 foo2' | grep 'foo1 foo2'\\\"", KERNEL=="sda5", SYMLINK+="%c{2}"
EOF
{
desc => "program arguments combined with escaped double quotes, part 3",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "foo2" ,
+ exp_name => "foo2",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/sh -c 'printf \\\"%%s %%s\\\" \\\"foo1 foo2\\\" \\\"foo3\\\"| grep \\\"foo1 foo2\\\"'", KERNEL=="sda5", SYMLINK+="%c{2}"
EOF
{
desc => "characters before the %c{N} substitution",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "my-foo9" ,
+ exp_name => "my-foo9",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", SYMLINK+="my-%c{7}"
EOF
{
desc => "substitute the second to last argument",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "my-foo8" ,
+ exp_name => "my-foo8",
rules => <<EOF
SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n foo3 foo4 foo5 foo6 foo7 foo8 foo9", KERNEL=="sda5", SYMLINK+="my-%c{6}"
EOF
{
desc => "test substitution by variable name 3",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "850:0:0:05" ,
+ exp_name => "850:0:0:05",
rules => <<EOF
SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="%M%m%b%n"
EOF
{
desc => "test substitution by variable name 4",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "855" ,
+ exp_name => "855",
rules => <<EOF
SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="\$major\$minor\$number"
EOF
{
desc => "test substitution by variable name 5",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
- exp_name => "8550:0:0:0" ,
+ exp_name => "8550:0:0:0",
rules => <<EOF
SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", DEVPATH=="*/sda/*", SYMLINK+="\$major%m%n\$id"
EOF
{
desc => "non matching SUBSYSTEMS",
devpath => "/devices/virtual/tty/console",
- exp_name => "TTY" ,
+ exp_name => "TTY",
rules => <<EOF
SUBSYSTEMS=="foo", ATTRS{dev}=="5:1", SYMLINK+="foo"
KERNEL=="console", SYMLINK+="TTY"
{
desc => "ATTRS match",
devpath => "/devices/virtual/tty/console",
- exp_name => "foo" ,
+ exp_name => "foo",
rules => <<EOF
KERNEL=="console", SYMLINK+="TTY"
ATTRS{dev}=="5:1", SYMLINK+="foo"
{
desc => "ATTR (empty file)",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "empty" ,
+ exp_name => "empty",
rules => <<EOF
KERNEL=="sda", ATTR{test_empty_file}=="?*", SYMLINK+="something"
KERNEL=="sda", ATTR{test_empty_file}!="", SYMLINK+="not-empty"
{
desc => "ATTR (non-existent file)",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "non-existent" ,
+ exp_name => "non-existent",
rules => <<EOF
KERNEL=="sda", ATTR{nofile}=="?*", SYMLINK+="something"
KERNEL=="sda", ATTR{nofile}!="", SYMLINK+="not-empty"
{
desc => "program and bus type match",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
- exp_name => "scsi-0:0:0:0" ,
+ exp_name => "scsi-0:0:0:0",
rules => <<EOF
SUBSYSTEMS=="usb", PROGRAM=="/bin/echo -n usb-%b", SYMLINK+="%c"
SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n scsi-%b", SYMLINK+="%c"
{
desc => "sysfs parent hierarchy",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "modem" ,
+ exp_name => "modem",
rules => <<EOF
ATTRS{idProduct}=="007b", SYMLINK+="modem"
EOF
{
desc => "name test with ! in the name",
devpath => "/devices/virtual/block/fake!blockdev0",
- exp_name => "is/a/fake/blockdev0" ,
+ exp_name => "is/a/fake/blockdev0",
rules => <<EOF
SUBSYSTEMS=="scsi", SYMLINK+="is/not/a/%k"
SUBSYSTEM=="block", SYMLINK+="is/a/%k"
{
desc => "name test with ! in the name, but no matching rule",
devpath => "/devices/virtual/block/fake!blockdev0",
- exp_name => "fake/blockdev0" ,
+ exp_name => "fake/blockdev0",
exp_rem_error => "yes",
rules => <<EOF
KERNEL=="ttyACM0", SYMLINK+="modem"
desc => "KERNELS wildcard partial 2",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
exp_name => "scsi-0:0:0:0",
- rules => <<EOF
+ rules => <<EOF
SUBSYSTEMS=="scsi", KERNELS=="0:0:0:0", SYMLINK+="before"
SUBSYSTEMS=="scsi", KERNELS=="*:0:0:0", SYMLINK+="scsi-0:0:0:0"
EOF
devpath => "/devices/virtual/misc/misc-fake1",
exp_name => "node",
exp_majorminor => "4095:1",
- rules => <<EOF
+ rules => <<EOF
KERNEL=="misc-fake1", SYMLINK+="node"
EOF
},
desc => "multiple symlinks with a lot of s p a c e s",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
exp_name => "one",
- not_exp_name => " ",
+ not_exp_name => " ",
rules => <<EOF
KERNEL=="ttyACM[0-9]*", SYMLINK=" one two "
EOF
{
desc => "multiple symlinks",
devpath => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
- exp_name => "second-0" ,
+ exp_name => "second-0",
rules => <<EOF
KERNEL=="ttyACM0", SYMLINK="first-%n second-%n third-%n"
EOF
desc => "symlink name '.'",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
exp_name => ".",
- exp_add_error => "yes",
- exp_rem_error => "yes",
+ exp_add_error => "yes",
+ exp_rem_error => "yes",
rules => <<EOF
SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="."
EOF
desc => "symlink node to itself",
devpath => "/devices/virtual/tty/tty0",
exp_name => "link",
- exp_add_error => "yes",
- exp_rem_error => "yes",
- option => "clean",
+ exp_add_error => "yes",
+ exp_rem_error => "yes",
+ option => "clean",
rules => <<EOF
KERNEL=="tty0", SYMLINK+="tty0"
EOF
desc => "add and match tag",
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
exp_name => "found",
- not_exp_name => "bad" ,
+ not_exp_name => "bad",
rules => <<EOF
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", TAG+="green"
TAGS=="green", SYMLINK+="found"
exp_name => "found",
rules => $rules_10k_tags . <<EOF
TAGS=="test1", TAGS=="test500", TAGS=="test1234", TAGS=="test9999", TAGS=="test10000", SYMLINK+="found"
+EOF
+ },
+ {
+ desc => "continuations",
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+ exp_name => "found",
+ not_exp_name => "bad",
+ rules => $rules_10k_tags_continuation . <<EOF
+TAGS=="test1", TAGS=="test500", TAGS=="test1234", TAGS=="test9999", TAGS=="test10000", SYMLINK+="bad"
+KERNEL=="sda",\\
+# comment in continuation
+TAG+="hoge1",\\
+ # space before comment
+TAG+="hoge2",\\
+# spaces before and after token are dropped
+ TAG+="hoge3", \\
+\\
+ \\
+TAG+="hoge4"
+TAGS=="hoge1", TAGS=="hoge2", TAGS=="hoge3", TAGS=="hoge4", SYMLINK+="found"
+EOF
+ },
+ {
+ desc => "continuations with empty line",
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+ exp_name => "found",
+ not_exp_name => "bad",
+ rules => <<EOF
+# empty line finishes continuation
+KERNEL=="sda", TAG+="foo" \\
+
+KERNEL=="sdb", TAG+="hoge"
+KERNEL=="sda", TAG+="aaa" \\
+KERNEL=="sdb", TAG+="bbb"
+TAGS=="foo", SYMLINK+="found"
+TAGS=="aaa", SYMLINK+="bad"
+EOF
+ },
+ {
+ desc => "continuations with white only line",
+ devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
+ exp_name => "found",
+ not_exp_name => "bad",
+ rules => <<EOF
+# space only line finishes continuation
+KERNEL=="sda", TAG+="foo" \\
+ \t
+KERNEL=="sdb", TAG+="hoge"
+KERNEL=="sda", TAG+="aaa" \\
+KERNEL=="sdb", TAG+="bbb"
+TAGS=="foo", SYMLINK+="found"
+TAGS=="aaa", SYMLINK+="bad"
EOF
},
);
system("umount", $udev_tmpfs);
rmdir($udev_tmpfs);
mkdir($udev_tmpfs) || die "unable to create udev_tmpfs: $udev_tmpfs\n";
- system("mount", "-o", "rw,mode=755,nosuid,noexec,nodev", "-t", "tmpfs", "tmpfs", $udev_tmpfs) && die "unable to mount tmpfs";
+
+ if (system("mount", "-o", "rw,mode=755,nosuid,noexec", "-t", "tmpfs", "tmpfs", $udev_tmpfs)) {
+ warn "unable to mount tmpfs";
+ return 0;
+ }
mkdir($udev_dev) || die "unable to create udev_dev: $udev_dev\n";
# setting group and mode of udev_dev ensures the tests work
chown (0, 0, $udev_dev) || die "unable to chown $udev_dev\n";
chmod (0755, $udev_dev) || die "unable to chmod $udev_dev\n";
+ if (system("mknod", $udev_dev . "/null", "c", "1", "3")) {
+ warn "unable to create $udev_dev/null";
+ return 0;
+ }
+
+ # check if we are permitted to create block device nodes
+ my $block_device_filename = $udev_dev . "/sda";
+ if (system("mknod", $block_device_filename, "b", "8", "0")) {
+ warn "unable to create $block_device_filename";
+ return 0;
+ }
+ unlink $block_device_filename;
+
system("cp", "-r", "test/sys/", $udev_sys) && die "unable to copy test/sys";
system("rm", "-rf", "$udev_run");
+
+ if (!mkdir($udev_run)) {
+ warn "unable to create directory $udev_run";
+ return 0;
+ }
+
+ return 1;
}
sub run_test {
exit($EXIT_TEST_SKIP);
}
-# skip the test when running in a container
-system("systemd-detect-virt", "-c", "-q");
-if ($? >> 8 == 0) {
- print "Running in a container, skipping the test.\n";
+if (!udev_setup()) {
+ warn "Failed to set up the environment, skipping the test";
exit($EXIT_TEST_SKIP);
}
-udev_setup();
+if (system($udev_bin, "check")) {
+ warn "$udev_bin failed to set up the environment, skipping the test";
+ exit($EXIT_TEST_SKIP);
+}
my $test_num = 1;
my @list;