[LTP] [PATCH 2/2] shell lib: Add support for test cleanup

Petr Vorel pvorel@suse.cz
Mon Feb 17 08:44:13 CET 2025


Hi Cyril,

could we get check for file existence, the same way it's done in metaparse.c?

Also, I'd prefer if both tools exit 1 in case of missing file (so that CI
notifies the problem).

Kind regards,
Petr

+++ metadata/metaparse-sh.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <libgen.h>
+#include <unistd.h>
 
 #include "data_storage.h"
 
@@ -46,6 +47,11 @@ static void parse_shell(char *path)
 	FILE *f = fopen(path, "r");
 	enum state state = NONE;
 
+	if (access(path, F_OK)) {
+		fprintf(stderr, "file %s does not exist\n", path);
+		return;
+	}
+
 	while (fgets(line, sizeof(line), f)) {
 		/* Strip newline */
 		line[strlen(line)-1] = 0;


More information about the ltp mailing list