test: rework how udev-test is invoked

As part of the build, we would populate build/test/sys/ using
sys-script.py, and then udev-test.p[ly] would create a tmpfs instance
on build/test/tmpfs and copy the sys tree to build/test/tmpfs/sys.

Also, we had udev-test.p[ly] which called test-udev. test-udev was
marked as a manual test and installed, but neither udev-test.p[ly] or
sys-script.py were.

test-udev is renamed to udev-rule-runner, which reduces confusion and
frees up the test-udev name. udev-test.py is renamed to test-udev.py.
All three files are now installed.

test-udev.py is modified to internally call sys-script.py to set up the
sys tree. Copying and creating it from scratch should take the same
amount of time. We avoid having a magic directory, everything is now
done underneath a temporary directory.

test-udev.py is now a normal installed test, and run-unit-tests.py will
pick it up. When test-udev.py is invoked from meson, the path to
udev-rule-runner is passed via envvar; when it is invoked via
run-unit-tests.py or directly, it looks for udev-rule-runner in a relative
path.

The goal of this whole change is to let Debian drop the 'udev' test.
It called sys-script.py and udev-test.pl from the source directory and
had to recreate a bunch of the logic. Now test-udev.py will now be called
via 'upstream'.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-05-09 08:11:10 +02:00
parent 09ea351b6f
commit 0454cf05d3
5 changed files with 71 additions and 37 deletions
+1 -1
View File
@@ -409,7 +409,7 @@ tests += [
'timeout' : 120,
},
{
'sources' : files('test-udev.c'),
'sources' : files('udev-rule-runner.c'),
'link_with' : [
libshared,
libudevd_core,
@@ -62,11 +62,11 @@ static int fake_filesystems(void) {
const char *error;
bool ignore_mount_error;
} fakefss[] = {
{ "test/tmpfs/sys", "/sys", "Failed to mount test /sys", false },
{ "test/tmpfs/dev", "/dev", "Failed to mount test /dev", false },
{ "test/run", "/run", "Failed to mount test /run", false },
{ "test/run", "/etc/udev/rules.d", "Failed to mount empty /etc/udev/rules.d", true },
{ "test/run", UDEVLIBEXECDIR "/rules.d", "Failed to mount empty " UDEVLIBEXECDIR "/rules.d", true },
{ "tmpfs/sys", "/sys", "Failed to mount test /sys", false },
{ "tmpfs/dev", "/dev", "Failed to mount test /dev", false },
{ "run", "/run", "Failed to mount test /run", false },
{ "run", "/etc/udev/rules.d", "Failed to mount empty /etc/udev/rules.d", true },
{ "run", UDEVLIBEXECDIR "/rules.d", "Failed to mount empty " UDEVLIBEXECDIR "/rules.d", true },
};
int r;