All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscall/read: add new testcase for read
@ 2017-11-10  8:56 Lucas Boehm
  2017-11-20 11:27 ` Jan Stancek
  0 siblings, 1 reply; 4+ messages in thread
From: Lucas Boehm @ 2017-11-10  8:56 UTC (permalink / raw)
  To: ltp

 Check the return value of read
 1. Count bytes are read from the current file
 2. Current offset is modified by lseek()
 3. Count bytes are read from the current file

Signed-off-by: Lucas Boehm <lucas@opentech.at>
---
 testcases/kernel/syscalls/read/read05.c | 76 +++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 testcases/kernel/syscalls/read/read05.c

diff --git a/testcases/kernel/syscalls/read/read05.c b/testcases/kernel/syscalls/read/read05.c
new file mode 100644
index 000000000..49ef053fc
--- /dev/null
+++ b/testcases/kernel/syscalls/read/read05.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2017 Lucas Boehm <lucas@opentech.at>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ /* Check the return value of read
+ *
+ * 1. Count bytes are read from the current file
+ * 2. Current offset is modified by lseek()
+ * 3. Return value equals read
+ */
+
+#include <errno.h>
+#include "tst_test.h"
+#include <stdio.h>
+
+#define SIZE 512
+
+static int fd;
+static char buf[SIZE];
+int pos;
+
+static void verify_read(void)
+{
+	SAFE_LSEEK(fd, 0, SEEK_SET);
+
+	TEST(read(fd, buf, SIZE/2));
+
+	if (TEST_RETURN == -1)
+		tst_res(TFAIL | TTERRNO, "read(2) failed");
+	else
+		tst_res(TPASS, "read(2) returned %ld", TEST_RETURN);
+
+
+	SAFE_LSEEK(fd, 2, SEEK_CUR);
+
+	TEST(read(fd, buf, SIZE/2));
+
+
+	if (TEST_RETURN == -1)
+		tst_res(TFAIL | TTERRNO, "read(2) failed");
+	else
+		tst_res(TPASS, "read(2) returned %ld", TEST_RETURN);
+}
+
+static void setup(void)
+{
+	memset(buf, '*', SIZE);
+	fd = SAFE_OPEN("testfile", O_RDWR | O_CREAT, 0700);
+	SAFE_WRITE(1, fd, buf, SIZE);
+}
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.test_all = verify_read,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+};
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH] syscall/read: add new testcase for read
  2017-11-10  8:56 [LTP] [PATCH] syscall/read: add new testcase for read Lucas Boehm
@ 2017-11-20 11:27 ` Jan Stancek
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Stancek @ 2017-11-20 11:27 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> Check the return value of read

Hi,

Is this testing some known kernel bug?
How is it different from what read01 and lseek01 already do?

Regards,
Jan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH] syscall/read: add new testcase for read
  2017-11-09  9:29 Lucas Boehm
@ 2017-11-20 11:53 ` Richard Palethorpe
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Palethorpe @ 2017-11-20 11:53 UTC (permalink / raw)
  To: ltp

Hello Lucas,

Lucas Boehm writes:

>  Check the return value of read
>  1. Count bytes are read from the current file
>  2. Current offset is modified by lseek()
>  3. Count bytes are read from the current file
>
> Signed-off-by: Lucas Boehm <lucas@opentech.at>

The test lseek01 already uses seek before performing a read and checks
that the correct data was read.

-- 
Thank you,
Richard.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH] syscall/read: add new testcase for read
@ 2017-11-09  9:29 Lucas Boehm
  2017-11-20 11:53 ` Richard Palethorpe
  0 siblings, 1 reply; 4+ messages in thread
From: Lucas Boehm @ 2017-11-09  9:29 UTC (permalink / raw)
  To: ltp

 Check the return value of read
 1. Count bytes are read from the current file
 2. Current offset is modified by lseek()
 3. Count bytes are read from the current file

Signed-off-by: Lucas Boehm <lucas@opentech.at>
---
 testcases/kernel/syscalls/read/read05.c | 76 +++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 testcases/kernel/syscalls/read/read05.c

diff --git a/testcases/kernel/syscalls/read/read05.c b/testcases/kernel/syscalls/read/read05.c
new file mode 100644
index 000000000..49ef053fc
--- /dev/null
+++ b/testcases/kernel/syscalls/read/read05.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2017 Lucas Boehm <lucas@opentech.at>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+ /* Check the return value of read
+ *
+ * 1. Count bytes are read from the current file
+ * 2. Current offset is modified by lseek()
+ * 3. Return value equals read
+ */
+
+#include <errno.h>
+#include "tst_test.h"
+#include <stdio.h>
+
+#define SIZE 512
+
+static int fd;
+static char buf[SIZE];
+int pos;
+
+static void verify_read(void)
+{
+	SAFE_LSEEK(fd, 0, SEEK_SET);
+
+	TEST(read(fd, buf, SIZE/2));
+
+	if (TEST_RETURN == -1)
+		tst_res(TFAIL | TTERRNO, "read(2) failed");
+	else
+		tst_res(TPASS, "read(2) returned %ld", TEST_RETURN);
+
+
+	SAFE_LSEEK(fd, 2, SEEK_CUR);
+
+	TEST(read(fd, buf, SIZE/2));
+
+
+	if (TEST_RETURN == -1)
+		tst_res(TFAIL | TTERRNO, "read(2) failed");
+	else
+		tst_res(TPASS, "read(2) returned %ld", TEST_RETURN);
+}
+
+static void setup(void)
+{
+	memset(buf, '*', SIZE);
+	fd = SAFE_OPEN("testfile", O_RDWR | O_CREAT, 0700);
+	SAFE_WRITE(1, fd, buf, SIZE);
+}
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.test_all = verify_read,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+};
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-20 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-10  8:56 [LTP] [PATCH] syscall/read: add new testcase for read Lucas Boehm
2017-11-20 11:27 ` Jan Stancek
  -- strict thread matches above, loose matches on Subject: below --
2017-11-09  9:29 Lucas Boehm
2017-11-20 11:53 ` Richard Palethorpe

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.