public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 2/3] fcntl/fcntl30.c: add F_SETPIPE_SZ, F_GETPIPE_SZ test for fcntl(2)
@ 2013-12-05  3:49 Xiaoguang Wang
  2013-12-05  5:25 ` Mike Frysinger
  0 siblings, 1 reply; 3+ messages in thread
From: Xiaoguang Wang @ 2013-12-05  3:49 UTC (permalink / raw)
  To: ltp-list


create a new case to test F_SETPIPE_SZ, F_GETPIPE_SZ for fcntl(2)

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 runtest/syscalls                          |   2 +
 testcases/kernel/syscalls/fcntl/fcntl30.c | 140 ++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fcntl/fcntl30.c

diff --git a/runtest/syscalls b/runtest/syscalls
index cace2ca..489f318 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -253,6 +253,8 @@ fcntl28 fcntl28
 fcntl28_64 fcntl28_64
 fcntl29 fcntl29
 fcntl29_64 fcntl29_64
+fcntl30 fcntl30
+fcntl30_64 fcntl30_64
 
 fdatasync01 fdatasync01
 fdatasync02 fdatasync02
diff --git a/testcases/kernel/syscalls/fcntl/fcntl30.c b/testcases/kernel/syscalls/fcntl/fcntl30.c
new file mode 100644
index 0000000..cd1034b
--- /dev/null
+++ b/testcases/kernel/syscalls/fcntl/fcntl30.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013 Fujitsu Ltd.
+ * Author: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * Description:
+ * Verify that,
+ *     Basic test for fcntl(2) using F_SETPIPE_SZ, F_GETPIPE_SZ argument.
+ */
+
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <pwd.h>
+
+#include "test.h"
+#include "usctest.h"
+#include "safe_macros.h"
+
+char *TCID = "fcntl30";
+
+#if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ)
+
+static void setup(void);
+static void cleanup(void);
+
+static int pipe_fds[2];
+static int test_fd;
+static int orig_pipe_size;
+static int new_pipe_size;
+
+int TST_TOTAL = 1;
+
+int main(int ac, char **av)
+{
+	int lc;
+	char *msg;
+	int i;
+
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; i++) {
+			TEST(fcntl(test_fd, F_SETPIPE_SZ, new_pipe_size));
+			if (TEST_RETURN < 0) {
+				tst_brkm(TFAIL | TTERRNO, cleanup,
+					 "fcntl test F_SETPIPE_SZ failed");
+			}
+
+			TEST(fcntl(test_fd, F_GETPIPE_SZ));
+			if (TEST_RETURN < 0) {
+				tst_brkm(TFAIL | TTERRNO, cleanup,
+					 "fcntl test F_GETPIPE_SZ failed");
+			}
+			tst_resm(TINFO, "orig_pipe_size: %d new_pipe_size: %d",
+				 orig_pipe_size, new_pipe_size);
+			if (TEST_RETURN >= new_pipe_size) {
+				tst_resm(TPASS, "fcntl test F_GETPIPE_SZ"
+					 "and F_SETPIPE_SZ success");
+			} else {
+				tst_resm(TFAIL, "fcntl test F_GETPIPE_SZ"
+					 "and F_SETPIPE_SZ fail");
+			}
+
+			/* restore the original pipe size*/
+			TEST(fcntl(test_fd, F_SETPIPE_SZ, orig_pipe_size));
+			if (TEST_RETURN < 0) {
+				tst_brkm(TFAIL | TTERRNO, cleanup, "fcntl "
+					 "restore orignal pipe size failed");
+			}
+		}
+	}
+
+	cleanup();
+	tst_exit();
+}
+
+static void setup(void)
+{
+	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+	tst_tmpdir();
+
+	TEST_PAUSE;
+
+	SAFE_PIPE(cleanup, pipe_fds);
+	test_fd = pipe_fds[1];
+
+	TEST(fcntl(test_fd, F_GETPIPE_SZ));
+	if (TEST_RETURN < 0) {
+		tst_brkm(TFAIL, cleanup,
+			 "fcntl get pipe size failed");
+	}
+
+	orig_pipe_size = TEST_RETURN;
+	new_pipe_size = orig_pipe_size * 2;
+}
+
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+
+	SAFE_CLOSE(NULL, pipe_fds[0]);
+	SAFE_CLOSE(NULL, pipe_fds[1]);
+
+	tst_rmdir();
+}
+#else
+
+int main(int ac, char **av)
+{
+	tst_brkm(TCONF, NULL, "This test can only run on kernels"
+		 "that are 2.6.35 and higher");
+}
+
+#endif
-- 
1.8.2.1


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/3] fcntl/fcntl30.c: add F_SETPIPE_SZ, F_GETPIPE_SZ test for fcntl(2)
  2013-12-05  3:49 [LTP] [PATCH 2/3] fcntl/fcntl30.c: add F_SETPIPE_SZ, F_GETPIPE_SZ test for fcntl(2) Xiaoguang Wang
@ 2013-12-05  5:25 ` Mike Frysinger
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2013-12-05  5:25 UTC (permalink / raw)
  To: ltp-list


[-- Attachment #1.1: Type: Text/Plain, Size: 327 bytes --]

On Wednesday 04 December 2013 22:49:51 Xiaoguang Wang wrote:
> +#if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ)
> ...
> +#else
> +
> +int main(int ac, char **av)
> +{
> +	tst_brkm(TCONF, NULL, "This test can only run on kernels"
> +		 "that are 2.6.35 and higher");
> +}
> +
> +#endif


same comment as your 1/3 patch
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 279 bytes --]

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 2/3] fcntl/fcntl30.c: add F_SETPIPE_SZ, F_GETPIPE_SZ test for fcntl(2)
@ 2013-12-05 11:41 Xiaoguang Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Xiaoguang Wang @ 2013-12-05 11:41 UTC (permalink / raw)
  To: ltp-list


create a new case to test F_SETPIPE_SZ, F_GETPIPE_SZ for fcntl(2)

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 runtest/syscalls                          |   2 +
 testcases/kernel/syscalls/fcntl/fcntl30.c | 144 ++++++++++++++++++++++++++++++
 2 files changed, 146 insertions(+)
 create mode 100644 testcases/kernel/syscalls/fcntl/fcntl30.c

diff --git a/runtest/syscalls b/runtest/syscalls
index cace2ca..489f318 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -253,6 +253,8 @@ fcntl28 fcntl28
 fcntl28_64 fcntl28_64
 fcntl29 fcntl29
 fcntl29_64 fcntl29_64
+fcntl30 fcntl30
+fcntl30_64 fcntl30_64
 
 fdatasync01 fdatasync01
 fdatasync02 fdatasync02
diff --git a/testcases/kernel/syscalls/fcntl/fcntl30.c b/testcases/kernel/syscalls/fcntl/fcntl30.c
new file mode 100644
index 0000000..d72c31d
--- /dev/null
+++ b/testcases/kernel/syscalls/fcntl/fcntl30.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2013 Fujitsu Ltd.
+ * Author: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * Description:
+ * Verify that,
+ *     Basic test for fcntl(2) using F_SETPIPE_SZ, F_GETPIPE_SZ argument.
+ */
+
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <pwd.h>
+
+#include "test.h"
+#include "usctest.h"
+#include "safe_macros.h"
+
+char *TCID = "fcntl30";
+
+#if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ)
+
+static void setup(void);
+static void cleanup(void);
+
+static int pipe_fds[2];
+static int test_fd;
+static int orig_pipe_size;
+static int new_pipe_size;
+
+int TST_TOTAL = 1;
+
+int main(int ac, char **av)
+{
+	int lc;
+	char *msg;
+	int i;
+
+	msg = parse_opts(ac, av, NULL, NULL);
+	if (msg != NULL)
+		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+
+	setup();
+
+	for (lc = 0; TEST_LOOPING(lc); lc++) {
+		tst_count = 0;
+
+		for (i = 0; i < TST_TOTAL; i++) {
+			TEST(fcntl(test_fd, F_SETPIPE_SZ, new_pipe_size));
+			if (TEST_RETURN < 0) {
+				tst_brkm(TFAIL | TTERRNO, cleanup,
+					 "fcntl test F_SETPIPE_SZ failed");
+			}
+
+			TEST(fcntl(test_fd, F_GETPIPE_SZ));
+			if (TEST_RETURN < 0) {
+				tst_brkm(TFAIL | TTERRNO, cleanup,
+					 "fcntl test F_GETPIPE_SZ failed");
+			}
+			tst_resm(TINFO, "orig_pipe_size: %d new_pipe_size: %d",
+				 orig_pipe_size, new_pipe_size);
+			if (TEST_RETURN >= new_pipe_size) {
+				tst_resm(TPASS, "fcntl test F_GETPIPE_SZ"
+					 "and F_SETPIPE_SZ success");
+			} else {
+				tst_resm(TFAIL, "fcntl test F_GETPIPE_SZ"
+					 "and F_SETPIPE_SZ fail");
+			}
+
+			/* restore the original pipe size*/
+			TEST(fcntl(test_fd, F_SETPIPE_SZ, orig_pipe_size));
+			if (TEST_RETURN < 0) {
+				tst_brkm(TFAIL | TTERRNO, cleanup, "fcntl "
+					 "restore orignal pipe size failed");
+			}
+		}
+	}
+
+	cleanup();
+	tst_exit();
+}
+
+static void setup(void)
+{
+	if ((tst_kvercmp(2, 6, 35)) < 0) {
+		tst_brkm(TCONF, NULL, "This test can only run on kernels"
+			 "that are 2.6.35 and higher");
+	}
+
+	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+	tst_tmpdir();
+
+	TEST_PAUSE;
+
+	SAFE_PIPE(cleanup, pipe_fds);
+	test_fd = pipe_fds[1];
+
+	TEST(fcntl(test_fd, F_GETPIPE_SZ));
+	if (TEST_RETURN < 0) {
+		tst_brkm(TFAIL, cleanup,
+			 "fcntl get pipe size failed");
+	}
+
+	orig_pipe_size = TEST_RETURN;
+	new_pipe_size = orig_pipe_size * 2;
+}
+
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+
+	SAFE_CLOSE(NULL, pipe_fds[0]);
+	SAFE_CLOSE(NULL, pipe_fds[1]);
+
+	tst_rmdir();
+}
+#else
+
+int main(int ac, char **av)
+{
+	tst_brkm(TCONF, NULL, "This test can only run on kernels"
+		 "that are 2.6.35 and higher");
+}
+#endif
-- 
1.8.2.1



------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2013-12-05 11:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-05  3:49 [LTP] [PATCH 2/3] fcntl/fcntl30.c: add F_SETPIPE_SZ, F_GETPIPE_SZ test for fcntl(2) Xiaoguang Wang
2013-12-05  5:25 ` Mike Frysinger
  -- strict thread matches above, loose matches on Subject: below --
2013-12-05 11:41 Xiaoguang Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox