summaryrefslogtreecommitdiffstats
path: root/test/udev-test.pl (follow)
Commit message (Collapse)AuthorAgeFilesLines
* licensing: add forgotten spdx headersZbigniew Jędrzejewski-Szmek2021-10-011-0/+1
| | | | | Those are all "our" files, but we forgot to add the headers, most likely because of non-standard file extensions.
* udev-test: add a testcase for string_escape=replaceYu Watanabe2021-06-261-0/+15
|
* test/udev-test: gracefully exit when imports failZbigniew Jędrzejewski-Szmek2020-11-171-5/+13
| | | | | | | | | In Fedora rawhide various perl modules are now available as separate packages that are not pulled in by dependencies. If we don't have some package, skip the tests. This ugly code is apparently the way to do conditional imports: https://www.cs.ait.ac.th/~on/O/oreilly/perl/cookbook/ch12_03.htm.
* test: fix typoYu Watanabe2020-11-131-1/+1
|
* test/udev_test.pl: add "expected good" countMartin Wilck2020-11-021-2/+19
| | | | | | Since 'test/udev-test.pl: count "good" results', we know how many checks succeeded. Add an "expected good" count to make that number more meaningful.
* test/udev-test.pl: suppress umount error message at startupMartin Wilck2020-11-021-1/+1
| | | | | | umount emits an error message "no mount point specified" if the tmpfs isn't mounted yet, which is the normal case. Suppress that by redirecting stderr.
* test/udev-test.pl: generator for large list of block devicesMartin Wilck2020-11-021-1/+59
| | | | | | Manually listing all devices in the test definition becomes cumbersome with lots of devices. Add a function that scans on all block devices in the test sysfs and generates a list of devices to test.
* test/udev-test.pl: add repeat countMartin Wilck2020-11-021-0/+5
| | | | for easier reproduction of sporadic test failures.
* tests/udev-test.pl: add multiple device testMartin Wilck2020-11-021-0/+169
| | | | | | | | | Add 4 new tests using multiple devices. Number 2-4 use many devices claiming the same symlink, where only one device has a higher priority thatn the others. They fail sporadically with the current code, if a race condition causes the symlink to point to the wrong device. Test 4 is like test 2 with sleeps in between, it's much less likely to fail.
* test/udev-test.pl: count "good" resultsMartin Wilck2020-11-021-2/+15
| | | | | This is helpful to catch possible regressions in the test. Also, don't count wait() errors, they are likely not udev errors.
* test/udev-test.pl: merge import parent tests into oneMartin Wilck2020-11-021-12/+5
| | | | | As we can test multiple devices and multiple links per device in one test now, these two tests can be merged into one.
* test/udev-test.pl: merge "space and var with space" testsMartin Wilck2020-11-021-28/+3
| | | | | As we can check multiple links in a single test now, these 3 tests can be merged into one.
* test/udev-test.pl: remove bogus rules from magic subsys testMartin Wilck2020-11-021-2/+0
| | | | | These rules have survived from an ancient version of the code and save no purpose any more.
* test/udev-test.pl: Make some tests a little harderMartin Wilck2020-11-021-4/+9
| | | | | Add some rules that make it a bit harder to pass, mainly the non-existence checks.
* test/udev-test.pl: last_rule is unsupportedMartin Wilck2020-11-021-0/+3
| | | | | | the "last_rule" option hasn't been supported for some time. Therefore this test fails if a "not_exp_links" attribute is added, as it should be. Mark it appropriately.
* test/udev-test.pl: fix wrong test descriptionsMartin Wilck2020-11-021-7/+8
| | | | udev hasn't supported renaming device nodes for some time.
* test/udev-test.pl: allow checking multiple symlinksMartin Wilck2020-11-021-199/+296
| | | | | | | Instead of testing the existence or non-exisitence of just a single symlink, allow testing of several links per device. Change the test definitions accordingly.
* test/udev-test.pl: test correctness of symlink targetsMartin Wilck2020-11-021-5/+18
| | | | | | | Test if symlinks are created correctly by comparing the symlink targets to the devnode path. This implies (for the symlink) that major/minor numbers and permissions are correct, as we have tested that on the devnode already.
* test/udev-test.pl: use computed devnode nameMartin Wilck2020-11-021-26/+66
| | | | | | | | | | | | | | | | More often than not, the created devnode is the basename of the sysfs entry. The "devnode" device may be used to override the auto-detected node name. Permissions and major/minor number are now verified on the devnode itself, not on symlinks. For those tests where exp_name is set to the computed devnode name, the explicit "exp_name" can be removed. "exp_name" is only required for symlinks. This allows separate testing for devnodes and symlinks an a follow-up patch.
* test/udev-test.pl: allow concurrent additions and removalsMartin Wilck2020-11-021-18/+72
| | | | | | | | Allow testing cases where multiple devices are added and removed simultaneously. Tests are started as synchronously as possible using a semaphore, in order to test possible race conditions. If this isn't desired, the test parameter "sleep_us" can be set to the number of microseconds to wait between udev invocations.
* test/udev-test.pl: create rules only onceMartin Wilck2020-11-021-4/+9
| | | | | It's not necessary to write the rules for every udev run, as we now may have many (rather than just 2) per test.
* test/udev-test.pl: allow multiple devices per testMartin Wilck2020-11-021-423/+929
| | | | | | | Allow testing cases where multiple devices are added and removed. This implies a change of the data structure: every test allows for multiple devices to be added, and "exp_name" etc. are now properties of the device, not of the test.
* udev-test: do not rely on "mail" group being definedZbigniew Jędrzejewski-Szmek2020-09-041-2/+2
| | | | | | | "audio" should be there, at least we declare it. "mail" nowadays is less likely to exist than in the past. Fixes one of the items in #16942.
* test: add test case for multi matches when use "||"gaoyi2020-07-121-0/+11
| | | | Signed-off-by: gaoyi <ymuemc@163.com>
* test: add test cases for empty string matchYu Watanabe2019-09-111-0/+66
|
* test/udev-test.pl: cleanup if skipping testDan Streetman2019-07-091-4/+9
| | | | | | | | | | | | | | | | | | | | In Ubuntu CI, udev-test.pl is run from the debian/test/udev script, in a test dir created for it; but udev-test.pl setup mounts a dir, so if it doesn't cleanup/unmount before exiting, the test dir autopkgtest created for it can't be removed, and autopkgtest aborts the entire test suite, for example this output (from a test run inside an armhf container): autopkgtest [12:45:36]: test udev: [----------------------- umount: test/tmpfs: no mount point specified. mknod: test/tmpfs/dev/null: Operation not permitted unable to create test/tmpfs/dev/null at ./udev-test.pl line 1611. Failed to set up the environment, skipping the test at ./udev-test.pl line 1731. autopkgtest [12:45:41]: test udev: -----------------------] autopkgtest [12:45:44]: test udev: - - - - - - - - - - results - - - - - - - - - - udev FAIL non-zero exit status 77 rm: cannot remove '/tmp/autopkgtest.ocPFA6/autopkgtest_tmp/test/tmpfs': Device or resource busy autopkgtest [12:46:22]: ERROR: "rm -rf /tmp/autopkgtest.ocPFA6/udev-artifacts /tmp/autopkgtest.ocPFA6/autopkgtest_tmp" failed with stderr "rm:
* codespell: fix spelling errorsBen Boeckel2019-04-291-1/+1
|
* test-udev: fix alignment and drop unnecessary white spacesYu Watanabe2019-02-211-57/+57
|
* test-udev: add more tests for line continuationYu Watanabe2019-02-211-0/+34
|
* test-udev: add more tests for line continuations and commentsYu Watanabe2019-02-191-2/+10
|
* test-udev: use proper semantics for too long line with continuationYu Watanabe2019-02-191-3/+4
| | | | Follow-up for 1e797cf596df50a6bdd8cbf8e9b2467a3a934171.
* test-udev: add a testcase of too long lineYu Watanabe2019-02-181-0/+15
|
* udev-test: check if permitted to create block device nodesAlexey Bogdanenko2018-12-111-0/+8
|
* udev-test: fix missing directory test/runAlexey Bogdanenko2018-12-091-0/+5
| | | | | | | | | Fixes the following error: Failed to mount test /run: No such file or directory By the time command "./test-udev check" calls function "fake_filesystems", directory "test/run" must be present.
* udev-test: fix test skip conditionAlexey Bogdanenko2018-12-091-1/+1
| | | | | | | | | | When there is a failure to setup the environment, the following happens: 1. Command "./test-udev check" exits with non-zero code. 2. Perl function "system" returns the code. 3. The code is evaluated as true by Perl. Then we stop the test.
* udev-test: skip the test only if it can't setup its environmentEvgeny Vereshchagin2018-11-101-3/+21
| | | | This is basically a replacement for 0eb3cc88504b5d8f74.
* udev-test: remove a check for whether the test is run in a containerEvgeny Vereshchagin2018-11-091-7/+0
| | | | It's too broad a check that prevents the test from running on Travis CI.
* test: missing "die"Yu Watanabe2018-11-071-1/+1
| | | | Follow-up for a41ff38b0999fb83464309a29b8f39450b8d4b85.
* test: create /dev/null in test-udev.plYu Watanabe2018-10-231-1/+2
|
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-1/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* tree-wide: use proper unicode © instead of (C) where we canLennart Poettering2018-06-141-2/+2
| | | | | | Let's use a proper unicode copyright symbol where we can, it's prettier. This important patch is very important.
* tests: stop using `nobody` in test-udev.pl (#8239)Evgeny Vereshchagin2018-02-211-2/+2
| | | | | | | | | | | | | | | | | `nobody` is a special user, whose credentials should be extracted with `get_user_creds`. `getpwnam` called in `test-udev.pl` is a bit different, which causes the test to fail with the following error: ``` device '/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda' expecting node/link 'node' expected permissions are: nobody::0600 created permissions are : 65534:0:0600 permissions: error add: ok remove: ok ``` The ideal fix would probably be to implement `get_user_creds` in Perl, but in this PR the issue is simply got around by using `daemon` instead of `nobody`. Closes https://github.com/systemd/systemd/issues/8196.
* more portable perl shebangs (#7701)Jörg Thalheim2017-12-191-1/+1
| | | | | | | | same motivation as in #5816: - distributions have scripts to rewrite shebangs on installation and they know what locations to rely on. - For tests/compilation we should rather rely on the user to have setup there PATH correctly.
* udev-rules: all values can contain escaped double quotes now (#6890)Franck Bui2017-09-281-0/+24
| | | | | | | | | | | | | | | | | This is primarly useful to support escaped double quotes in PROGRAM or IMPORT{program} directives. The only possibilty before this patch was to use an external shell script but this seems too cumbersome for trivial logics such as PROGRAM=="/bin/sh -c 'FOO=\"%s{model}\"; echo ${FOO:0:4}'" or any similar shell constructs that needs to deals with patterns including whitespaces. As it's the case for single quote and for directives running a program, words within escaped double quotes will be considered as a single argument. Fixes: #6835
* tests: add tests for SYMLINK containing whitespace in variable (#5158)Dan Streetman2017-01-261-0/+80
| | | | | | | add udev-test.pl tests for whitespace in a substituted variable, to verify the variable whitespace is replaced with underscores. Tests for the change made by commit 0a10235ed453 ("udev-rules: perform whitespace replacement for symlink subst values")
* tests: let's stick to 8ch indenting, in perl code tooLennart Poettering2016-08-191-2/+2
|
* Merge pull request 3821 from davide125/fix-testsZbigniew Jędrzejewski-Szmek2016-08-011-2/+9
|\
| * tests: skip udev-test if running inside a chrootDavide Cavalca2016-07-291-0/+7
|/
* test: udev: Check tagsMartin Pitt2016-04-061-0/+24
| | | | | | | | Add two more tests: - Add a single tag, match on it, don't match on another. - Add 10.000 tags to a device, ensure that udev survives this. (Reproduces crash fixed by commit 1d88a271a)
* test: udev: check exit code of test-udevMartin Pitt2016-04-061-6/+15
| | | | | We expect test-udev to succeed. Verify that its exit code is zero, particularly to spot crashes (e. g. a segfault would be error code 139).