All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Wang <li.wang@linux.dev>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v5 2/2] metaparse: Explicitly parse essential headers for macros
Date: Thu,  4 Jun 2026 17:42:00 +0800	[thread overview]
Message-ID: <20260604094200.21643-2-li.wang@linux.dev> (raw)
In-Reply-To: <20260604094200.21643-1-li.wang@linux.dev>

The metadata parser misses important path definition macros located in
tst_path_defs.h. This occurs because the file is included via
tst_test.h, which is intentionally ignored by the skip_includes[]
array to reduce parsing overhead. As a result, the dependency chain
is broken, and the underlying macros are never extracted.

To fix this without parsing the entirety of tst_test.h, this patch
introduces a must_includes[] array and a parse_must_files() function.
This allows the parser to explicitly locate and extract '#define' macros
from specific foundational headers directly from the include paths.

This data driven approach keeps the logic clean and provides an easily
extensible way to handle future headers that might face the same
include-skip issue.

Fixes: da3088183a ("metadata: metaparse: Implement recursive include")
Signed-off-by: Li Wang <li.wang@linux.dev>
---
 metadata/metaparse.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/metadata/metaparse.c b/metadata/metaparse.c
index c495d2eb5..561cbb9d2 100644
--- a/metadata/metaparse.c
+++ b/metadata/metaparse.c
@@ -968,6 +968,33 @@ static struct data_node *parse_file(const char *fname)
 	return res;
 }
 
+static const char *must_includes[] = {
+	"tst_path_defs.h",
+	NULL
+};
+
+static void parse_must_files(void)
+{
+	unsigned int i, j;
+	FILE *f;
+	const char *token;
+
+	for (i = 0; must_includes[i]; i++) {
+		for (j = 0; j < cmdline_includepaths; j++) {
+			f = open_file(cmdline_includepath[j], must_includes[i]);
+			if (!f)
+				continue;
+
+			while ((token = next_token(f, NULL))) {
+				if (!strcmp(token, "define"))
+					parse_macro(f);
+			}
+			fclose(f);
+			break;
+		}
+	}
+}
+
 struct typemap {
 	const char *id;
 	enum data_type type;
@@ -1176,6 +1203,8 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
+	parse_must_files();
+
 	res = parse_file(argv[optind]);
 	if (!res)
 		return 0;
-- 
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-06-04  9:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-04  9:41 [LTP] [PATCH v5 1/2] lib: Introduce tst_path_defs.h to consolidate system paths Li Wang
2026-06-04  9:42 ` Li Wang [this message]
2026-06-04  9:47   ` [LTP] [PATCH v5 2/2] metaparse: Explicitly parse essential headers for macros Cyril Hrubis
2026-06-04  9:50 ` [LTP] [PATCH v5 1/2] lib: Introduce tst_path_defs.h to consolidate system paths Cyril Hrubis
2026-06-04  9:57   ` Li Wang
2026-06-05  5:18   ` Li Wang
2026-06-04  9:52 ` Li Wang
2026-06-04 11:37 ` [LTP] " linuxtestproject.agent

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260604094200.21643-2-li.wang@linux.dev \
    --to=li.wang@linux.dev \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.