diff mbox series

[1/3] test/parser: Make parser_scandir() ignore files with path len less than dir

Message ID 20180606135936.2461-2-javierm@redhat.com
State Superseded
Headers show
Series discover/grub: Some improvements and fixes for BLS support | expand

Commit Message

Javier Martinez Canillas June 6, 2018, 1:59 p.m. UTC
Both the test files and directories added into the test harness are stored
into the same file list. So the parser_scandir() stub compares the absolute
file path of the files and the directory to scan, to know if a file belongs
to the directory.

Files whose absolute file path length isn't bigger than the directory to
scan should just be ignored, since it means they can't be from that dir.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>

 test/parser/utils.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series


diff --git a/test/parser/utils.c b/test/parser/utils.c
index 394efb3b209..c6d1a170a9b 100644
--- a/test/parser/utils.c
+++ b/test/parser/utils.c
@@ -325,6 +325,9 @@  int parser_scandir(struct discover_context *ctx, const char *dirname,
 		if (f->dev != ctx->device)
+		if (strlen(f->name) <= strlen(dirname))
+			continue;
 		filename = strrchr(f->name, '/');
 		if (!filename)