From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH 2/6] fs: rewrite stream01 test using new API
Date: Thu, 19 Feb 2026 14:05:40 +0100 [thread overview]
Message-ID: <aZcKpKvJNU73Ow1G@yuki.lan> (raw)
In-Reply-To: <20260123-stream_refactoring-v1-2-281b85f6ab02@suse.com>
Hi!
> -char *TCID = "stream01";
> -int TST_TOTAL = 1;
> -int local_flag;
> +static void read_file(const char *file)
> +{
> + char buf[2];
> + FILE *stream;
>
> -#define PASSED 1
> -#define FAILED 0
> + memset(buf, 0, sizeof(buf));
>
> -/* XXX: add setup and cleanup. */
> + stream = SAFE_FOPEN(file, "r");
> + SAFE_FREAD(buf, 1, 1, stream);
Here we read at most 1 character from the stream.
> + SAFE_FCLOSE(stream);
>
> -char progname[] = "stream01()";
> -char tempfile1[40] = "";
> -char tempfile2[40] = "";
> + TST_EXP_EXPR((buf[0] == 'a') && (buf[1] == 0),
^
Hence this is always true
> + "%s file contains the correct data", file);
If we wanted to assert that the file has a single characted written into
it we need to let the fread() read the whole buffer:
SAFE_FREAD(buf, 2, 1, stream);
With that there is at least chance that the buf[1] may be overwritten
with some data.
Or we can check the size returned from fread(), if it was 1 there was a
single characted in the file. But again, we have to pass buffer that is
at least 2 bytes long.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-02-19 13:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 16:18 [LTP] [PATCH 0/6] Rewrite fs stream testing suite Andrea Cervesato
2026-01-23 16:18 ` [LTP] [PATCH 1/6] Add safe macros for " Andrea Cervesato
2026-02-19 12:31 ` Cyril Hrubis
2026-03-04 9:49 ` Andrea Cervesato via ltp
2026-03-04 10:06 ` Cyril Hrubis
2026-03-04 10:11 ` Andrea Cervesato via ltp
2026-03-04 10:30 ` Cyril Hrubis
2026-03-04 12:20 ` Andrea Cervesato via ltp
2026-01-23 16:18 ` [LTP] [PATCH 2/6] fs: rewrite stream01 test using new API Andrea Cervesato
2026-02-19 13:05 ` Cyril Hrubis [this message]
2026-01-23 16:18 ` [LTP] [PATCH 3/6] fs: rewrite stream02 " Andrea Cervesato
2026-03-02 12:01 ` Cyril Hrubis
2026-01-23 16:18 ` [LTP] [PATCH 4/6] fs: rewrite stream03 " Andrea Cervesato
2026-03-02 13:02 ` Cyril Hrubis
2026-01-23 16:18 ` [LTP] [PATCH 5/6] fs: rewrite stream04 " Andrea Cervesato
2026-03-02 13:14 ` Cyril Hrubis
2026-01-23 16:18 ` [LTP] [PATCH 6/6] fs: rewrite stream05 " Andrea Cervesato
2026-03-02 13:52 ` Cyril Hrubis
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=aZcKpKvJNU73Ow1G@yuki.lan \
--to=chrubis@suse.cz \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.