* [LTP] [PATCH v2] Add io_read_eof in common.h utilities
@ 2021-12-13 12:14 Andrea Cervesato via ltp
2021-12-14 16:40 ` Petr Vorel
2021-12-15 13:06 ` Cyril Hrubis
0 siblings, 2 replies; 3+ messages in thread
From: Andrea Cervesato via ltp @ 2021-12-13 12:14 UTC (permalink / raw)
To: ltp
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
testcases/kernel/io/ltp-aiodio/common.h | 30 +++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/testcases/kernel/io/ltp-aiodio/common.h b/testcases/kernel/io/ltp-aiodio/common.h
index c9fd0bbaa..c27c3a0ad 100644
--- a/testcases/kernel/io/ltp-aiodio/common.h
+++ b/testcases/kernel/io/ltp-aiodio/common.h
@@ -86,6 +86,36 @@ static inline void io_read(const char *filename, int filesize, volatile int *run
SAFE_CLOSE(fd);
}
+static inline void io_read_eof(const char *filename, volatile int *run_child)
+{
+ char buff[4096];
+ int fd;
+ int r;
+
+ while ((fd = open(filename, O_RDONLY, 0666)) < 0)
+ usleep(100);
+
+ tst_res(TINFO, "child %i reading file", getpid());
+
+ while (*run_child) {
+ off_t offset;
+ char *bufoff;
+
+ offset = SAFE_LSEEK(fd, SEEK_END, 0);
+
+ r = SAFE_READ(0, fd, buff, sizeof(buff));
+ if (r > 0) {
+ bufoff = check_zero(buff, r);
+ if (bufoff) {
+ tst_res(TINFO, "non-zero read at offset %p", offset + bufoff);
+ break;
+ }
+ }
+ }
+
+ SAFE_CLOSE(fd);
+}
+
/*
* This code tries to create dirty free blocks on
* the HDD so there is a chance that blocks to be allocated
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v2] Add io_read_eof in common.h utilities
2021-12-13 12:14 [LTP] [PATCH v2] Add io_read_eof in common.h utilities Andrea Cervesato via ltp
@ 2021-12-14 16:40 ` Petr Vorel
2021-12-15 13:06 ` Cyril Hrubis
1 sibling, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2021-12-14 16:40 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi,
...
> +static inline void io_read_eof(const char *filename, volatile int *run_child)
> +{
> + char buff[4096];
> + int fd;
> + int r;
> +
> + while ((fd = open(filename, O_RDONLY, 0666)) < 0)
Just for a record [1] this open should be checked for errno == EINVAL
in case of /tmp/ being tmpfs.
Kind regards,
Petr
[1] https://lore.kernel.org/ltp/YbjIqypOcAYAnLbl@pevik/T/#t
> + usleep(100);
> +
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v2] Add io_read_eof in common.h utilities
2021-12-13 12:14 [LTP] [PATCH v2] Add io_read_eof in common.h utilities Andrea Cervesato via ltp
2021-12-14 16:40 ` Petr Vorel
@ 2021-12-15 13:06 ` Cyril Hrubis
1 sibling, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2021-12-15 13:06 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-15 13:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-13 12:14 [LTP] [PATCH v2] Add io_read_eof in common.h utilities Andrea Cervesato via ltp
2021-12-14 16:40 ` Petr Vorel
2021-12-15 13:06 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).