fs_config supports shell wildcard patterns
It now supports shell wildcard pattern matching using fnmatch(3).
Bug: 123743953
Test: atest libcutils_test
Change-Id: Ib82ae3bf717cbdba267024e1c9d3da004274b95c
diff --git a/libcutils/tests/Android.bp b/libcutils/tests/Android.bp
index fb9bbdd..3892ce0 100644
--- a/libcutils/tests/Android.bp
+++ b/libcutils/tests/Android.bp
@@ -20,6 +20,7 @@
android: {
srcs: [
"AshmemTest.cpp",
+ "fs_config.cpp",
"MemsetTest.cpp",
"PropertiesTest.cpp",
"sched_policy_test.cpp",
@@ -28,13 +29,13 @@
"android_get_control_socket_test.cpp",
"android_get_control_file_test.cpp",
"multiuser_test.cpp",
- "fs_config.cpp",
],
},
not_windows: {
srcs: [
"test_str_parms.cpp",
+ "fs_config.cpp",
],
},
},
diff --git a/libcutils/tests/fs_config.cpp b/libcutils/tests/fs_config.cpp
index d5dc66a..c26315f 100644
--- a/libcutils/tests/fs_config.cpp
+++ b/libcutils/tests/fs_config.cpp
@@ -42,11 +42,15 @@
const char* path;
bool match;
} fs_config_cmp_tests[] = {
- // clang-format off
+ // clang-format off
{ true, "system/lib", "system/lib/hw", true },
{ true, "vendor/lib", "system/vendor/lib/hw", true },
{ true, "system/vendor/lib", "vendor/lib/hw", true },
{ true, "system/vendor/lib", "system/vendor/lib/hw", true },
+ { true, "foo/*/bar/*", "foo/1/bar/2", true },
+ { true, "foo/*/bar/*", "foo/1/bar", true },
+ { true, "foo/*/bar/*", "foo/1/bar/2/3", true },
+ { true, "foo/*/bar/*", "foo/1/bar/2/3/", true },
{ false, "vendor/bin/wifi", "system/vendor/bin/w", false },
{ false, "vendor/bin/wifi", "system/vendor/bin/wifi", true },
{ false, "vendor/bin/wifi", "system/vendor/bin/wifi2", false },
@@ -58,8 +62,14 @@
{ false, "vendor/bin/*", "system/vendor/bin/wifi", true },
{ false, "system/bin/*", "system/bin", false },
{ false, "system/vendor/bin/*", "vendor/bin/wifi", true },
+ { false, "foo/*/bar/*", "foo/1/bar/2", true },
+ { false, "foo/*/bar/*", "foo/1/bar", false },
+ { false, "foo/*/bar/*", "foo/1/bar/2/3", true },
+ { false, "foo/*/bar/*.so", "foo/1/bar/2/3", false },
+ { false, "foo/*/bar/*.so", "foo/1/bar/2.so", true },
+ { false, "foo/*/bar/*.so", "foo/1/bar/2/3.so", true },
{ false, NULL, NULL, false },
- // clang-format on
+ // clang-format on
};
static bool check_unique(std::vector<const char*>& paths, const std::string& config_name,