Commit edd83fe9 authored by Peter Hutterer's avatar Peter Hutterer

test: mkdir -p the udev rules and hwdb directories

Especially /run/udev/rules.d may not exist, causing a test suite failure.

https://bugs.freedesktop.org/show_bug.cgi?id=103527Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit d332a64d)
parent e7be9098
......@@ -27,6 +27,7 @@
#include <check.h>
#include <dirent.h>
#include <errno.h>
#include <libgen.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <getopt.h>
......@@ -1071,20 +1072,35 @@ litest_install_model_quirks(struct list *created_files_list)
list_insert(created_files_list, &file->link);
}
static void
litest_init_udev_rules(struct list *created_files)
static inline void
mkdir_p(const char *dir)
{
char *path, *parent;
int rc;
rc = mkdir(UDEV_RULES_D, 0755);
if (rc == -1 && errno != EEXIST)
litest_abort_msg("Failed to create udev rules directory (%s)\n",
strerror(errno));
if (streq(dir, "/"))
return;
path = strdup(dir);
parent = dirname(path);
mkdir_p(parent);
rc = mkdir(dir, 0755);
rc = mkdir(UDEV_HWDB_D, 0755);
if (rc == -1 && errno != EEXIST)
litest_abort_msg("Failed to create udev hwdb directory (%s)\n",
if (rc == -1 && errno != EEXIST) {
litest_abort_msg("Failed to create directory %s (%s)\n",
dir,
strerror(errno));
}
free(path);
}
static void
litest_init_udev_rules(struct list *created_files)
{
mkdir_p(UDEV_RULES_D);
mkdir_p(UDEV_HWDB_D);
litest_install_model_quirks(created_files);
litest_init_all_device_udev_rules(created_files);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment