[LTP] [PATCH 3/9] metadata: metaparse: Apply macros in arrays.
Cyril Hrubis
chrubis@suse.cz
Wed Dec 18 20:00:23 CET 2024
This fixes many cases mostly paths in save_restore:
...
- "INTEGER_PROCFILE",
+ "/proc/sys/fs/pipe-max-size",
...
"needs_drivers": [
- "HW_MODULE"
+ "hwpoison_inject"
],
...
"save_restore": [
[
- "CORE_PATTERN",
+ "/proc/sys/kernel/core_pattern",
...
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
metadata/metaparse.c | 42 ++++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/metadata/metaparse.c b/metadata/metaparse.c
index 486475780..969293cfc 100644
--- a/metadata/metaparse.c
+++ b/metadata/metaparse.c
@@ -317,9 +317,28 @@ static void close_include(FILE *inc)
fclose(inc);
}
+static void try_apply_macro(char **res)
+{
+ ENTRY macro = {
+ .key = *res,
+ };
+
+ ENTRY *ret;
+
+ ret = hsearch(macro, FIND);
+
+ if (!ret)
+ return;
+
+ if (verbose)
+ fprintf(stderr, "APPLYING MACRO %s=%s\n", ret->key, (char*)ret->data);
+
+ *res = ret->data;
+}
+
static int parse_array(FILE *f, struct data_node *node)
{
- const char *token;
+ char *token;
for (;;) {
if (!(token = next_token(f, NULL)))
@@ -346,6 +365,8 @@ static int parse_array(FILE *f, struct data_node *node)
if (!strcmp(token, "NULL"))
continue;
+ try_apply_macro(&token);
+
struct data_node *str = data_node_string(token);
data_node_array_add(node, str);
@@ -354,25 +375,6 @@ static int parse_array(FILE *f, struct data_node *node)
return 0;
}
-static void try_apply_macro(char **res)
-{
- ENTRY macro = {
- .key = *res,
- };
-
- ENTRY *ret;
-
- ret = hsearch(macro, FIND);
-
- if (!ret)
- return;
-
- if (verbose)
- fprintf(stderr, "APPLYING MACRO %s=%s\n", ret->key, (char*)ret->data);
-
- *res = ret->data;
-}
-
static int parse_get_array_len(FILE *f)
{
const char *token;
--
2.45.2
More information about the ltp
mailing list