[LTP] [PATCH 2/2] shell lib: Add support for test cleanup
Cyril Hrubis
chrubis@suse.cz
Tue Feb 25 11:25:32 CET 2025
Hi!
> 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).
Will do.
> +++ 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;
> + }
I guess that I should check the f instead:
if (!f) {
fprintf(stderr, "Failed to open '%s': %s", path, strerror(errno));
exit(1);
}
> while (fgets(line, sizeof(line), f)) {
> /* Strip newline */
> line[strlen(line)-1] = 0;
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list