test: reliably sort the udev rules

This guarantees the device rules have a static order between test runs.
Previously and in some cases, the temporary file name could affect the order
of the udev rules - let's not do that.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2018-03-21 20:08:16 +10:00
parent ce80e40006
commit 1e9925735a

View file

@ -1224,20 +1224,22 @@ litest_init_device_udev_rules(struct litest_test_device *dev)
int fd;
FILE *f;
char *path = NULL;
static int count;
if (!dev->udev_rule)
return NULL;
rc = xasprintf(&path,
"%s/%s%s-XXXXXX.rules",
"%s/%s%03d-%s-XXXXXX.rules",
UDEV_RULES_D,
UDEV_RULE_PREFIX,
++count,
dev->shortname);
litest_assert_int_eq(rc,
(int)(
strlen(UDEV_RULES_D) +
strlen(UDEV_RULE_PREFIX) +
strlen(dev->shortname) + 14));
strlen(dev->shortname) + 18));
fd = mkstemps(path, 6);
litest_assert_int_ne(fd, -1);