[LTP] [PATCH 2/2] shell lib: Add support for test cleanup
Petr Vorel
pvorel@suse.cz
Tue Feb 25 12:00:17 CET 2025
Hi Cyril,
> 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);
> }
Yes, that's it. Thanks for both.
Kind regards,
Petr
More information about the ltp
mailing list