From 1e9925735acf65caf9d16da013dbafa84d2dae94 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 21 Mar 2018 20:08:16 +1000 Subject: [PATCH] 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 --- test/litest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/litest.c b/test/litest.c index d0d03f3a..9f4681bb 100644 --- a/test/litest.c +++ b/test/litest.c @@ -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);