* [LTP] [PATCH v2] Add common.h utilities for aiodio tests
@ 2021-11-30 10:52 Andrea Cervesato via ltp
2021-11-30 10:55 ` Cyril Hrubis
2021-11-30 10:59 ` Cyril Hrubis
0 siblings, 2 replies; 3+ messages in thread
From: Andrea Cervesato via ltp @ 2021-11-30 10:52 UTC (permalink / raw)
To: ltp
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
testcases/kernel/io/ltp-aiodio/common.h | 54 +++++++++++++++++++++++++
1 file changed, 54 insertions(+)
create mode 100644 testcases/kernel/io/ltp-aiodio/common.h
diff --git a/testcases/kernel/io/ltp-aiodio/common.h b/testcases/kernel/io/ltp-aiodio/common.h
new file mode 100644
index 000000000..860abcc2a
--- /dev/null
+++ b/testcases/kernel/io/ltp-aiodio/common.h
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2021 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
+ */
+
+#ifndef AIODIO_COMMON_H__
+#define AIODIO_COMMON_H__
+
+#include <stdlib.h>
+#include "tst_test.h"
+
+static char *check_zero(char *buf, int size)
+{
+ char *p;
+
+ p = buf;
+
+ while (size > 0) {
+ if (*buf != 0) {
+ tst_res(TINFO,
+ "non zero buffer at buf[%lu] => 0x%02x,%02x,%02x,%02x",
+ buf - p, (unsigned int)buf[0],
+ size > 1 ? (unsigned int)buf[1] : 0,
+ size > 2 ? (unsigned int)buf[2] : 0,
+ size > 3 ? (unsigned int)buf[3] : 0);
+ tst_res(TINFO, "buf %p, p %p", buf, p);
+ return buf;
+ }
+ buf++;
+ size--;
+ }
+
+ return 0;
+}
+
+static void io_append(const char *path, char pattern, int flags, size_t bs, size_t bcount)
+{
+ int fd;
+ size_t i;
+ char *bufptr;
+
+ bufptr = SAFE_MEMALIGN(getpagesize(), bs);
+ memset(bufptr, pattern, bs);
+
+ fd = SAFE_OPEN(path, flags, 0666);
+
+ for (i = 0; i < bcount; i++)
+ SAFE_WRITE(1, fd, bufptr, bs);
+
+ free(bufptr);
+ SAFE_CLOSE(fd);
+}
+
+#endif /* AIODIO_COMMON_H__ */
\ No newline at end of file
--
2.34.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-30 10:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-30 10:52 [LTP] [PATCH v2] Add common.h utilities for aiodio tests Andrea Cervesato via ltp
2021-11-30 10:55 ` Cyril Hrubis
2021-11-30 10:59 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox