From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 2/2] shell lib: Add support for test cleanup
Date: Tue, 25 Feb 2025 11:25:32 +0100 [thread overview]
Message-ID: <Z72anBFr2n4REM3E@yuki.lan> (raw)
In-Reply-To: <20250217074413.GA2350499@pevik>
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-02-25 10:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 11:21 [LTP] [PATCH 0/2] shell lib: Add very simple cleanup support Cyril Hrubis
2025-02-14 11:21 ` [LTP] [PATCH 1/2] testcases/lib/run_tests.sh Cyril Hrubis
2025-02-14 13:37 ` Petr Vorel
2025-02-28 11:49 ` Petr Vorel
2025-02-14 11:21 ` [LTP] [PATCH 2/2] shell lib: Add support for test cleanup Cyril Hrubis
2025-02-14 13:55 ` Petr Vorel
2025-02-14 14:07 ` Cyril Hrubis
2025-02-14 14:18 ` Cyril Hrubis
2025-02-17 7:44 ` Petr Vorel
2025-02-25 10:25 ` Cyril Hrubis [this message]
2025-02-25 11:00 ` Petr Vorel
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=Z72anBFr2n4REM3E@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox