Merge pull request #23119 from yuwata/test-sd-device-exclude-bdi
test: exclude "bdi" subsystem
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <errno.h>
|
||||
#include <fnmatch.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@@ -2070,3 +2071,27 @@ bool set_equal(Set *a, Set *b) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool set_fnmatch_one(Set *patterns, const char *needle) {
|
||||
const char *p;
|
||||
|
||||
assert(needle);
|
||||
|
||||
SET_FOREACH(p, patterns)
|
||||
if (fnmatch(p, needle, 0) == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool set_fnmatch(Set *include_patterns, Set *exclude_patterns, const char *needle) {
|
||||
assert(needle);
|
||||
|
||||
if (set_fnmatch_one(exclude_patterns, needle))
|
||||
return false;
|
||||
|
||||
if (set_isempty(include_patterns))
|
||||
return true;
|
||||
|
||||
return set_fnmatch_one(include_patterns, needle);
|
||||
}
|
||||
|
||||
@@ -153,3 +153,5 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, set_free_free);
|
||||
int set_strjoin(Set *s, const char *separator, bool wrap_with_separator, char **ret);
|
||||
|
||||
bool set_equal(Set *a, Set *b);
|
||||
|
||||
bool set_fnmatch(Set *include_patterns, Set *exclude_patterns, const char *needle);
|
||||
|
||||
Reference in New Issue
Block a user