* [LTP] [PATCH 1/2] sbrk/sbrk01.c: cleanup
@ 2014-04-22 9:40 Zeng Linggang
2014-04-22 9:41 ` [LTP] [PATCH 2/2] sbrk/sbrk02.c: add ENOMEM errno test Zeng Linggang
2014-04-22 12:38 ` [LTP] [PATCH " Jan Stancek
0 siblings, 2 replies; 12+ messages in thread
From: Zeng Linggang @ 2014-04-22 9:40 UTC (permalink / raw)
To: ltp-list
* Delete some useless commtents.
* Move the test body from main() to sbrk_verify().
* Remove tst_tmpdir().
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
testcases/kernel/syscalls/sbrk/sbrk01.c | 236 +++++++-------------------------
1 file changed, 52 insertions(+), 184 deletions(-)
diff --git a/testcases/kernel/syscalls/sbrk/sbrk01.c b/testcases/kernel/syscalls/sbrk/sbrk01.c
index b2db42c..f2b09f4 100644
--- a/testcases/kernel/syscalls/sbrk/sbrk01.c
+++ b/testcases/kernel/syscalls/sbrk/sbrk01.c
@@ -1,5 +1,7 @@
/*
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ * AUTHOR : William Roske
+ * CO-PILOT : Dave Fenner
*
* 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
@@ -30,84 +32,11 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: sbrk01.c,v 1.8 2009/06/09 16:01:21 subrata_modak Exp $ */
-/**********************************************************
- *
- * OS Test - Silicon Graphics, Inc.
- *
- * TEST IDENTIFIER : sbrk01
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : Basic test for sbrk(2)
- *
- * PARENT DOCUMENT : usctpl01
- *
- * TEST CASE TOTAL : 2
- *
- * WALL CLOCK TIME : 1
- *
- * CPU TYPES : ALL
- *
- * AUTHOR : William Roske
- *
- * CO-PILOT : Dave Fenner
- *
- * DATE STARTED : 06/05/92
- *
- * INITIAL RELEASE : UNICOS 7.0
- *
- * TEST CASES
- *
- * 1.) sbrk(2) returns...(See Description)
- *
- * INPUT SPECIFICATIONS
- * The standard options for system call tests are accepted.
- * (See the parse_opts(3) man page).
- *
- * OUTPUT SPECIFICATIONS
- *$
- * DURATION
- * Terminates - with frequency and infinite modes.
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * RESOURCES
- * None
- *
- * ENVIRONMENTAL NEEDS
- * No run-time environmental needs.
- *
- * SPECIAL PROCEDURAL REQUIREMENTS
- * None
- *
- * INTERCASE DEPENDENCIES
- * None
- *
- * DETAILED DESCRIPTION
- * This is a Phase I test for the sbrk(2) system call. It is intended
- * to provide a limited exposure of the system call, for now. It
- * should/will be extended when full functional tests are written for
- * sbrk(2).
- *
- * Setup:
- * Setup signal handling.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Loop if the proper options are given.
- * Execute system call
- * Check return code, if system call failed (return=-1)
- * Log the errno and Issue a FAIL message.
- * Otherwise, Issue a PASS message.
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
+/*
+ * DESCRIPTION
+ * 1.) test sbrk(8192) should return successfully.
+ * 2.) test sbrk(-8192) should return successfully.
+ */
#include <unistd.h>
#include <errno.h>
@@ -118,146 +47,85 @@
#include "test.h"
#include "usctest.h"
-void setup();
-void cleanup();
-
char *TCID = "sbrk01";
-int TST_TOTAL = 2;
-
-int Increment; /* Amount to make change size by */
#if !defined(UCLINUX)
+static struct test_case_t {
+ long increment;
+} test_cases[] = {
+ {8192},
+ {-8192},
+};
+
+static void setup(void);
+static void sbrk_verify(const struct test_case_t *);
+static void cleanup(void);
+
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+
int main(int ac, char **av)
{
int lc;
char *msg;
- void *tret;
+ int i;
- /***************************************************************
- * parse standard options
- ***************************************************************/
- if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+ msg = parse_opts(ac, av, NULL, NULL);
+ if (msg != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
- }
-
- /***************************************************************
- * perform global setup for test
- ***************************************************************/
setup();
- /***************************************************************
- * check looping state if -c option given
- ***************************************************************/
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
- /*
- * TEST CASE:
- * Increase by 8192 bytes
- */
- Increment = 8192;
-
- /* Call sbrk(2) */
- errno = 0;
- tret = sbrk(Increment); /* Remove -64 IRIX compiler warning */
- TEST_ERRNO = errno;
-
- /* check return code */
- if (tret == (void *)-1) {
- TEST_ERROR_LOG(TEST_ERRNO);
- tst_resm(TFAIL,
- "sbrk - Increase by 8192 bytes failed, errno=%d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- } else {
- /***************************************************************
- * only perform functional verification if flag set (-f not given)
- ***************************************************************/
- if (STD_FUNCTIONAL_TEST) {
- /* No Verification test, yet... */
- tst_resm(TPASS,
- "sbrk - Increase by 8192 bytes returned %p",
- tret);
- }
- }
-
- /*
- * TEST CASE:
- * Decrease to original size
- */
- Increment = (Increment * -1);
-
- /* Call sbrk(2) */
- errno = 0;
- tret = sbrk(Increment);
- TEST_ERRNO = errno;
-
- /* check return code */
- if (tret == (void *)-1) {
- TEST_ERROR_LOG(TEST_ERRNO);
- tst_resm(TFAIL,
- "sbrk - Decrease to original size failed, errno=%d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- } else {
- /***************************************************************
- * only perform functional verification if flag set (-f not given)
- ***************************************************************/
- if (STD_FUNCTIONAL_TEST) {
- /* No Verification test, yet... */
- tst_resm(TPASS,
- "sbrk - Decrease to original size returned %p",
- tret);
- }
- }
-
+ for (i = 0; i < TST_TOTAL; i++)
+ sbrk_verify(&test_cases[i]);
}
- /***************************************************************
- * cleanup and exit
- ***************************************************************/
cleanup();
tst_exit();
}
-#else
-
-int main(void)
+static void setup(void)
{
- tst_resm(TINFO, "test is not available on uClinux");
- tst_exit();
-}
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
-#endif /* if !defined(UCLINUX) */
+ TEST_PAUSE;
+}
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
+static void sbrk_verify(const struct test_case_t *test)
{
+ void *tret;
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- TEST_PAUSE;
+ tret = sbrk(test->increment);
+ TEST_ERRNO = errno;
- /* make a temp dir and cd to it */
- tst_tmpdir();
+ if (tret == (void *)-1) {
+ tst_resm(TFAIL | TTERRNO,
+ "sbrk - Increase by %ld bytes failed, errno=%d : %s",
+ test->increment, TEST_ERRNO, strerror(TEST_ERRNO));
+ } else {
+ tst_resm(TPASS, "sbrk - Increase by %ld bytes returned %p",
+ test->increment, tret);
+ }
}
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- * completion or premature exit.
- ***************************************************************/
-void cleanup(void)
+static void cleanup(void)
{
- /*
- * print timing stats if that option was specified.
- * print errno log if that option was specified.
- */
TEST_CLEANUP;
+}
- tst_rmdir();
+#else
+
+int TST_TOTAL = 1;
+int main(void)
+{
+ tst_resm(TINFO, "test is not available on uClinux");
+ tst_exit();
}
+
+#endif /* if !defined(UCLINUX) */
--
1.8.4.2
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [LTP] [PATCH 2/2] sbrk/sbrk02.c: add ENOMEM errno test
2014-04-22 9:40 [LTP] [PATCH 1/2] sbrk/sbrk01.c: cleanup Zeng Linggang
@ 2014-04-22 9:41 ` Zeng Linggang
2014-04-22 13:14 ` Jan Stancek
2014-04-22 12:38 ` [LTP] [PATCH " Jan Stancek
1 sibling, 1 reply; 12+ messages in thread
From: Zeng Linggang @ 2014-04-22 9:41 UTC (permalink / raw)
To: ltp-list
Add ENOMEM errno test for sbrk(2)
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
runtest/ltplite | 1 +
runtest/stress.part3 | 1 +
runtest/syscalls | 1 +
testcases/kernel/syscalls/.gitignore | 1 +
testcases/kernel/syscalls/sbrk/sbrk02.c | 102 ++++++++++++++++++++++++++++++++
5 files changed, 106 insertions(+)
create mode 100644 testcases/kernel/syscalls/sbrk/sbrk02.c
diff --git a/runtest/ltplite b/runtest/ltplite
index ebe171e..26b7753 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -653,6 +653,7 @@ rmdir04 rmdir04
rmdir05 rmdir05
sbrk01 sbrk01
+sbrk02 sbrk02
sched_get_priority_max01 sched_get_priority_max01
sched_get_priority_max02 sched_get_priority_max02
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index b21e44b..021decf 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -563,6 +563,7 @@ rmdir04 rmdir04
rmdir05 rmdir05
sbrk01 sbrk01
+sbrk02 sbrk02
sched_get_priority_max01 sched_get_priority_max01
sched_get_priority_max02 sched_get_priority_max02
diff --git a/runtest/syscalls b/runtest/syscalls
index fb3e59f..3adeb8a 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -868,6 +868,7 @@ rt_sigqueueinfo01 rt_sigqueueinfo01
rt_sigsuspend01 rt_sigsuspend01
sbrk01 sbrk01
+sbrk02 sbrk02
sched_get_priority_max01 sched_get_priority_max01
sched_get_priority_max02 sched_get_priority_max02
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index d5c7bac..cd51000 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -706,6 +706,7 @@
/rt_sigsuspend/rt_sigsuspend01
/rt_sigtimedwait/rt_sigtimedwait01
/sbrk/sbrk01
+/sbrk/sbrk02
/sched_get_priority_max/sched_get_priority_max01
/sched_get_priority_max/sched_get_priority_max02
/sched_get_priority_min/sched_get_priority_min01
diff --git a/testcases/kernel/syscalls/sbrk/sbrk02.c b/testcases/kernel/syscalls/sbrk/sbrk02.c
new file mode 100644
index 0000000..97b41d9
--- /dev/null
+++ b/testcases/kernel/syscalls/sbrk/sbrk02.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Zeng Linggang <zenglg.jy@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
+ * Check sbrk() with error condition that should produce ENOMEM.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include "test.h"
+#include "usctest.h"
+
+char *TCID = "sbrk02";
+int TST_TOTAL = 1;
+
+static void setup(void);
+static void sbrk_verify(void);
+static void cleanup(void);
+static int exp_enos[] = { ENOMEM, 0 };
+
+static long increment;
+
+int main(int argc, char *argv[])
+{
+ int lc;
+ int i;
+ char *msg;
+
+ msg = parse_opts(argc, argv, 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++)
+ sbrk_verify();
+ }
+
+ cleanup();
+ tst_exit();
+}
+
+static void setup(void)
+{
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ TEST_PAUSE;
+
+ for (increment = 0; errno == 0; increment++)
+ sbrk(increment);
+
+ errno = 0;
+
+ TEST_EXP_ENOS(exp_enos);
+}
+
+static void sbrk_verify(void)
+{
+ void *tret;
+
+ tret = sbrk(increment);
+ TEST_ERRNO = errno;
+
+ if (tret != (void *)-1) {
+ tst_resm(TFAIL,
+ "sbrk(%ld) returned %p, expected (void *)-1, errno=%d",
+ increment, tret, ENOMEM);
+ return;
+ }
+
+ TEST_ERROR_LOG(TEST_ERRNO);
+
+ if (TEST_ERRNO == ENOMEM) {
+ tst_resm(TPASS | TTERRNO, "sbrk(%ld) failed as expected",
+ increment);
+ } else {
+ tst_resm(TFAIL | TTERRNO,
+ "sbrk(%ld) failed unexpectedly; expected: %d - %s",
+ increment, ENOMEM, strerror(ENOMEM));
+ }
+}
+
+static void cleanup(void)
+{
+ TEST_CLEANUP;
+}
--
1.8.4.2
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH 1/2] sbrk/sbrk01.c: cleanup
2014-04-22 9:40 [LTP] [PATCH 1/2] sbrk/sbrk01.c: cleanup Zeng Linggang
2014-04-22 9:41 ` [LTP] [PATCH 2/2] sbrk/sbrk02.c: add ENOMEM errno test Zeng Linggang
@ 2014-04-22 12:38 ` Jan Stancek
1 sibling, 0 replies; 12+ messages in thread
From: Jan Stancek @ 2014-04-22 12:38 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
----- Original Message -----
> From: "Zeng Linggang" <zenglg.jy@cn.fujitsu.com>
> To: "ltp-list" <ltp-list@lists.sourceforge.net>
> Sent: Tuesday, 22 April, 2014 11:40:13 AM
> Subject: [LTP] [PATCH 1/2] sbrk/sbrk01.c: cleanup
>
> * Delete some useless commtents.
> * Move the test body from main() to sbrk_verify().
> * Remove tst_tmpdir().
> * Some cleanup.
>
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> ---
> testcases/kernel/syscalls/sbrk/sbrk01.c | 236
> +++++++-------------------------
> 1 file changed, 52 insertions(+), 184 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/sbrk/sbrk01.c
> b/testcases/kernel/syscalls/sbrk/sbrk01.c
> index b2db42c..f2b09f4 100644
> --- a/testcases/kernel/syscalls/sbrk/sbrk01.c
> +++ b/testcases/kernel/syscalls/sbrk/sbrk01.c
...
>
> -/***************************************************************
> - * setup() - performs all ONE TIME setup for this test.
> - ***************************************************************/
> -void setup(void)
> +static void sbrk_verify(const struct test_case_t *test)
> {
> + void *tret;
>
> - tst_sig(NOFORK, DEF_HANDLER, cleanup);
> -
> - TEST_PAUSE;
> + tret = sbrk(test->increment);
> + TEST_ERRNO = errno;
>
> - /* make a temp dir and cd to it */
> - tst_tmpdir();
> + if (tret == (void *)-1) {
> + tst_resm(TFAIL | TTERRNO,
> + "sbrk - Increase by %ld bytes failed, errno=%d : %s",
> + test->increment, TEST_ERRNO, strerror(TEST_ERRNO));
This looks redundant. You are using TTERRNO and also printing TEST_ERRNO as decimal
and string again. You could just use TERRNO, errno shouldn't change between
call to sbrk() and if condition.
Regards,
Jan
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH 2/2] sbrk/sbrk02.c: add ENOMEM errno test
2014-04-22 9:41 ` [LTP] [PATCH 2/2] sbrk/sbrk02.c: add ENOMEM errno test Zeng Linggang
@ 2014-04-22 13:14 ` Jan Stancek
2014-04-23 1:23 ` Zeng Linggang
2014-04-23 3:51 ` [LTP] [PATCH v2 1/2] sbrk/sbrk01.c: cleanup Zeng Linggang
0 siblings, 2 replies; 12+ messages in thread
From: Jan Stancek @ 2014-04-22 13:14 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
----- Original Message -----
> From: "Zeng Linggang" <zenglg.jy@cn.fujitsu.com>
> To: "ltp-list" <ltp-list@lists.sourceforge.net>
> Sent: Tuesday, 22 April, 2014 11:41:00 AM
> Subject: [LTP] [PATCH 2/2] sbrk/sbrk02.c: add ENOMEM errno test
>
> Add ENOMEM errno test for sbrk(2)
>
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> ---
> runtest/ltplite | 1 +
> runtest/stress.part3 | 1 +
> runtest/syscalls | 1 +
> testcases/kernel/syscalls/.gitignore | 1 +
> testcases/kernel/syscalls/sbrk/sbrk02.c | 102
> ++++++++++++++++++++++++++++++++
> 5 files changed, 106 insertions(+)
> create mode 100644 testcases/kernel/syscalls/sbrk/sbrk02.c
>
Hi,
<snip>
> diff --git a/testcases/kernel/syscalls/sbrk/sbrk02.c
> b/testcases/kernel/syscalls/sbrk/sbrk02.c
> new file mode 100644
> index 0000000..97b41d9
> --- /dev/null
> +++ b/testcases/kernel/syscalls/sbrk/sbrk02.c
> @@ -0,0 +1,102 @@
> +/*
> + * Copyright (c) 2014 Fujitsu Ltd.
> + * Author: Zeng Linggang <zenglg.jy@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
> + * Check sbrk() with error condition that should produce ENOMEM.
> + */
> +
> +#include <errno.h>
> +#include <unistd.h>
> +#include "test.h"
> +#include "usctest.h"
> +
> +char *TCID = "sbrk02";
> +int TST_TOTAL = 1;
> +
> +static void setup(void);
> +static void sbrk_verify(void);
> +static void cleanup(void);
> +static int exp_enos[] = { ENOMEM, 0 };
> +
> +static long increment;
> +
> +int main(int argc, char *argv[])
> +{
> + int lc;
> + int i;
> + char *msg;
> +
> + msg = parse_opts(argc, argv, 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++)
> + sbrk_verify();
> + }
> +
> + cleanup();
> + tst_exit();
> +}
> +
> +static void setup(void)
> +{
> + tst_sig(NOFORK, DEF_HANDLER, cleanup);
> +
> + TEST_PAUSE;
> +
> + for (increment = 0; errno == 0; increment++)
This looks like it takes couple hundred thousand of syscalls to hit
the limit. I'd suggest to set initial increment value somewhere
in range 1M-16M to reach it faster.
sbrk01 test is not suitable for UCLINUX, I suggest we add same ifdef check to sbrk02.
Regards,
Jan
> + sbrk(increment);
> +
> + errno = 0;
> +
> + TEST_EXP_ENOS(exp_enos);
> +}
> +
> +static void sbrk_verify(void)
> +{
> + void *tret;
> +
> + tret = sbrk(increment);
> + TEST_ERRNO = errno;
> +
> + if (tret != (void *)-1) {
> + tst_resm(TFAIL,
> + "sbrk(%ld) returned %p, expected (void *)-1, errno=%d",
> + increment, tret, ENOMEM);
> + return;
> + }
> +
> + TEST_ERROR_LOG(TEST_ERRNO);
> +
> + if (TEST_ERRNO == ENOMEM) {
> + tst_resm(TPASS | TTERRNO, "sbrk(%ld) failed as expected",
> + increment);
> + } else {
> + tst_resm(TFAIL | TTERRNO,
> + "sbrk(%ld) failed unexpectedly; expected: %d - %s",
> + increment, ENOMEM, strerror(ENOMEM));
> + }
> +}
> +
> +static void cleanup(void)
> +{
> + TEST_CLEANUP;
> +}
> --
> 1.8.4.2
>
>
>
>
> ------------------------------------------------------------------------------
> Start Your Social Network Today - Download eXo Platform
> Build your Enterprise Intranet with eXo Platform Software
> Java Based Open Source Intranet - Social, Extensible, Cloud Ready
> Get Started Now And Turn Your Intranet Into A Collaboration Platform
> http://p.sf.net/sfu/ExoPlatform
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
>
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH 2/2] sbrk/sbrk02.c: add ENOMEM errno test
2014-04-22 13:14 ` Jan Stancek
@ 2014-04-23 1:23 ` Zeng Linggang
2014-04-23 3:51 ` [LTP] [PATCH v2 1/2] sbrk/sbrk01.c: cleanup Zeng Linggang
1 sibling, 0 replies; 12+ messages in thread
From: Zeng Linggang @ 2014-04-23 1:23 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
On Tue, 2014-04-22 at 09:14 -0400, Jan Stancek wrote:
>
> ----- Original Message -----
> > From: "Zeng Linggang" <zenglg.jy@cn.fujitsu.com>
> > To: "ltp-list" <ltp-list@lists.sourceforge.net>
> > Sent: Tuesday, 22 April, 2014 11:41:00 AM
> > Subject: [LTP] [PATCH 2/2] sbrk/sbrk02.c: add ENOMEM errno test
> >
> > Add ENOMEM errno test for sbrk(2)
> >
> > Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> > ---
> > runtest/ltplite | 1 +
> > runtest/stress.part3 | 1 +
> > runtest/syscalls | 1 +
> > testcases/kernel/syscalls/.gitignore | 1 +
> > testcases/kernel/syscalls/sbrk/sbrk02.c | 102
> > ++++++++++++++++++++++++++++++++
> > 5 files changed, 106 insertions(+)
> > create mode 100644 testcases/kernel/syscalls/sbrk/sbrk02.c
> >
>
> Hi,
>
> <snip>
>
> > diff --git a/testcases/kernel/syscalls/sbrk/sbrk02.c
> > b/testcases/kernel/syscalls/sbrk/sbrk02.c
> > new file mode 100644
> > index 0000000..97b41d9
> > --- /dev/null
> > +++ b/testcases/kernel/syscalls/sbrk/sbrk02.c
> > @@ -0,0 +1,102 @@
> > +/*
> > + * Copyright (c) 2014 Fujitsu Ltd.
> > + * Author: Zeng Linggang <zenglg.jy@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
> > + * Check sbrk() with error condition that should produce ENOMEM.
> > + */
> > +
> > +#include <errno.h>
> > +#include <unistd.h>
> > +#include "test.h"
> > +#include "usctest.h"
> > +
> > +char *TCID = "sbrk02";
> > +int TST_TOTAL = 1;
> > +
> > +static void setup(void);
> > +static void sbrk_verify(void);
> > +static void cleanup(void);
> > +static int exp_enos[] = { ENOMEM, 0 };
> > +
> > +static long increment;
> > +
> > +int main(int argc, char *argv[])
> > +{
> > + int lc;
> > + int i;
> > + char *msg;
> > +
> > + msg = parse_opts(argc, argv, 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++)
> > + sbrk_verify();
> > + }
> > +
> > + cleanup();
> > + tst_exit();
> > +}
> > +
> > +static void setup(void)
> > +{
> > + tst_sig(NOFORK, DEF_HANDLER, cleanup);
> > +
> > + TEST_PAUSE;
> > +
> > + for (increment = 0; errno == 0; increment++)
>
> This looks like it takes couple hundred thousand of syscalls to hit
> the limit. I'd suggest to set initial increment value somewhere
> in range 1M-16M to reach it faster.
>
Yes, it is a good idea. I will set a bigger initial value.
> sbrk01 test is not suitable for UCLINUX, I suggest we add same ifdef check to sbrk02.
>
OK. I will add ifdef.
And, thanks for your review.
Best regards,
Zeng
> Regards,
> Jan
>
> > + sbrk(increment);
> > +
> > + errno = 0;
> > +
> > + TEST_EXP_ENOS(exp_enos);
> > +}
> > +
> > +static void sbrk_verify(void)
> > +{
> > + void *tret;
> > +
> > + tret = sbrk(increment);
> > + TEST_ERRNO = errno;
> > +
> > + if (tret != (void *)-1) {
> > + tst_resm(TFAIL,
> > + "sbrk(%ld) returned %p, expected (void *)-1, errno=%d",
> > + increment, tret, ENOMEM);
> > + return;
> > + }
> > +
> > + TEST_ERROR_LOG(TEST_ERRNO);
> > +
> > + if (TEST_ERRNO == ENOMEM) {
> > + tst_resm(TPASS | TTERRNO, "sbrk(%ld) failed as expected",
> > + increment);
> > + } else {
> > + tst_resm(TFAIL | TTERRNO,
> > + "sbrk(%ld) failed unexpectedly; expected: %d - %s",
> > + increment, ENOMEM, strerror(ENOMEM));
> > + }
> > +}
> > +
> > +static void cleanup(void)
> > +{
> > + TEST_CLEANUP;
> > +}
> > --
> > 1.8.4.2
> >
> >
> >
> >
> > ------------------------------------------------------------------------------
> > Start Your Social Network Today - Download eXo Platform
> > Build your Enterprise Intranet with eXo Platform Software
> > Java Based Open Source Intranet - Social, Extensible, Cloud Ready
> > Get Started Now And Turn Your Intranet Into A Collaboration Platform
> > http://p.sf.net/sfu/ExoPlatform
> > _______________________________________________
> > Ltp-list mailing list
> > Ltp-list@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/ltp-list
> >
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 12+ messages in thread
* [LTP] [PATCH v2 1/2] sbrk/sbrk01.c: cleanup
2014-04-22 13:14 ` Jan Stancek
2014-04-23 1:23 ` Zeng Linggang
@ 2014-04-23 3:51 ` Zeng Linggang
2014-04-23 3:52 ` [LTP] [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test Zeng Linggang
2014-05-20 16:03 ` [LTP] [PATCH v2 1/2] sbrk/sbrk01.c: cleanup chrubis
1 sibling, 2 replies; 12+ messages in thread
From: Zeng Linggang @ 2014-04-23 3:51 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
* Delete some useless commtents.
* Move the test body from main() to sbrk_verify().
* Remove tst_tmpdir().
* Some cleanup.
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
testcases/kernel/syscalls/sbrk/sbrk01.c | 235 +++++++-------------------------
1 file changed, 51 insertions(+), 184 deletions(-)
diff --git a/testcases/kernel/syscalls/sbrk/sbrk01.c b/testcases/kernel/syscalls/sbrk/sbrk01.c
index b2db42c..0840467 100644
--- a/testcases/kernel/syscalls/sbrk/sbrk01.c
+++ b/testcases/kernel/syscalls/sbrk/sbrk01.c
@@ -1,5 +1,7 @@
/*
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
+ * AUTHOR : William Roske
+ * CO-PILOT : Dave Fenner
*
* 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
@@ -30,84 +32,11 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: sbrk01.c,v 1.8 2009/06/09 16:01:21 subrata_modak Exp $ */
-/**********************************************************
- *
- * OS Test - Silicon Graphics, Inc.
- *
- * TEST IDENTIFIER : sbrk01
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : Basic test for sbrk(2)
- *
- * PARENT DOCUMENT : usctpl01
- *
- * TEST CASE TOTAL : 2
- *
- * WALL CLOCK TIME : 1
- *
- * CPU TYPES : ALL
- *
- * AUTHOR : William Roske
- *
- * CO-PILOT : Dave Fenner
- *
- * DATE STARTED : 06/05/92
- *
- * INITIAL RELEASE : UNICOS 7.0
- *
- * TEST CASES
- *
- * 1.) sbrk(2) returns...(See Description)
- *
- * INPUT SPECIFICATIONS
- * The standard options for system call tests are accepted.
- * (See the parse_opts(3) man page).
- *
- * OUTPUT SPECIFICATIONS
- *$
- * DURATION
- * Terminates - with frequency and infinite modes.
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * RESOURCES
- * None
- *
- * ENVIRONMENTAL NEEDS
- * No run-time environmental needs.
- *
- * SPECIAL PROCEDURAL REQUIREMENTS
- * None
- *
- * INTERCASE DEPENDENCIES
- * None
- *
- * DETAILED DESCRIPTION
- * This is a Phase I test for the sbrk(2) system call. It is intended
- * to provide a limited exposure of the system call, for now. It
- * should/will be extended when full functional tests are written for
- * sbrk(2).
- *
- * Setup:
- * Setup signal handling.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Loop if the proper options are given.
- * Execute system call
- * Check return code, if system call failed (return=-1)
- * Log the errno and Issue a FAIL message.
- * Otherwise, Issue a PASS message.
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
+/*
+ * DESCRIPTION
+ * 1.) test sbrk(8192) should return successfully.
+ * 2.) test sbrk(-8192) should return successfully.
+ */
#include <unistd.h>
#include <errno.h>
@@ -118,146 +47,84 @@
#include "test.h"
#include "usctest.h"
-void setup();
-void cleanup();
-
char *TCID = "sbrk01";
-int TST_TOTAL = 2;
-
-int Increment; /* Amount to make change size by */
#if !defined(UCLINUX)
+static struct test_case_t {
+ long increment;
+} test_cases[] = {
+ {8192},
+ {-8192},
+};
+
+static void setup(void);
+static void sbrk_verify(const struct test_case_t *);
+static void cleanup(void);
+
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+
int main(int ac, char **av)
{
int lc;
char *msg;
- void *tret;
+ int i;
- /***************************************************************
- * parse standard options
- ***************************************************************/
- if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) {
+ msg = parse_opts(ac, av, NULL, NULL);
+ if (msg != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
- }
-
- /***************************************************************
- * perform global setup for test
- ***************************************************************/
setup();
- /***************************************************************
- * check looping state if -c option given
- ***************************************************************/
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
- /*
- * TEST CASE:
- * Increase by 8192 bytes
- */
- Increment = 8192;
-
- /* Call sbrk(2) */
- errno = 0;
- tret = sbrk(Increment); /* Remove -64 IRIX compiler warning */
- TEST_ERRNO = errno;
-
- /* check return code */
- if (tret == (void *)-1) {
- TEST_ERROR_LOG(TEST_ERRNO);
- tst_resm(TFAIL,
- "sbrk - Increase by 8192 bytes failed, errno=%d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- } else {
- /***************************************************************
- * only perform functional verification if flag set (-f not given)
- ***************************************************************/
- if (STD_FUNCTIONAL_TEST) {
- /* No Verification test, yet... */
- tst_resm(TPASS,
- "sbrk - Increase by 8192 bytes returned %p",
- tret);
- }
- }
-
- /*
- * TEST CASE:
- * Decrease to original size
- */
- Increment = (Increment * -1);
-
- /* Call sbrk(2) */
- errno = 0;
- tret = sbrk(Increment);
- TEST_ERRNO = errno;
-
- /* check return code */
- if (tret == (void *)-1) {
- TEST_ERROR_LOG(TEST_ERRNO);
- tst_resm(TFAIL,
- "sbrk - Decrease to original size failed, errno=%d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- } else {
- /***************************************************************
- * only perform functional verification if flag set (-f not given)
- ***************************************************************/
- if (STD_FUNCTIONAL_TEST) {
- /* No Verification test, yet... */
- tst_resm(TPASS,
- "sbrk - Decrease to original size returned %p",
- tret);
- }
- }
-
+ for (i = 0; i < TST_TOTAL; i++)
+ sbrk_verify(&test_cases[i]);
}
- /***************************************************************
- * cleanup and exit
- ***************************************************************/
cleanup();
tst_exit();
}
-#else
-
-int main(void)
+static void setup(void)
{
- tst_resm(TINFO, "test is not available on uClinux");
- tst_exit();
-}
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
-#endif /* if !defined(UCLINUX) */
+ TEST_PAUSE;
+}
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
+static void sbrk_verify(const struct test_case_t *test)
{
+ void *tret;
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- TEST_PAUSE;
+ tret = sbrk(test->increment);
+ TEST_ERRNO = errno;
- /* make a temp dir and cd to it */
- tst_tmpdir();
+ if (tret == (void *)-1) {
+ tst_resm(TFAIL | TTERRNO, "sbrk - Increase by %ld bytes failed",
+ test->increment);
+ } else {
+ tst_resm(TPASS, "sbrk - Increase by %ld bytes returned %p",
+ test->increment, tret);
+ }
}
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- * completion or premature exit.
- ***************************************************************/
-void cleanup(void)
+static void cleanup(void)
{
- /*
- * print timing stats if that option was specified.
- * print errno log if that option was specified.
- */
TEST_CLEANUP;
+}
- tst_rmdir();
+#else
+
+int TST_TOTAL = 1;
+int main(void)
+{
+ tst_resm(TINFO, "test is not available on uClinux");
+ tst_exit();
}
+
+#endif /* if !defined(UCLINUX) */
--
1.8.4.2
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [LTP] [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test
2014-04-23 3:51 ` [LTP] [PATCH v2 1/2] sbrk/sbrk01.c: cleanup Zeng Linggang
@ 2014-04-23 3:52 ` Zeng Linggang
2014-04-23 11:29 ` Jan Stancek
2014-05-20 15:56 ` chrubis
2014-05-20 16:03 ` [LTP] [PATCH v2 1/2] sbrk/sbrk01.c: cleanup chrubis
1 sibling, 2 replies; 12+ messages in thread
From: Zeng Linggang @ 2014-04-23 3:52 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
Add ENOMEM errno test for sbrk(2)
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
runtest/ltplite | 1 +
runtest/stress.part3 | 1 +
runtest/syscalls | 1 +
testcases/kernel/syscalls/.gitignore | 1 +
testcases/kernel/syscalls/sbrk/sbrk02.c | 114 ++++++++++++++++++++++++++++++++
5 files changed, 118 insertions(+)
create mode 100644 testcases/kernel/syscalls/sbrk/sbrk02.c
diff --git a/runtest/ltplite b/runtest/ltplite
index ebe171e..26b7753 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -653,6 +653,7 @@ rmdir04 rmdir04
rmdir05 rmdir05
sbrk01 sbrk01
+sbrk02 sbrk02
sched_get_priority_max01 sched_get_priority_max01
sched_get_priority_max02 sched_get_priority_max02
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index b21e44b..021decf 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -563,6 +563,7 @@ rmdir04 rmdir04
rmdir05 rmdir05
sbrk01 sbrk01
+sbrk02 sbrk02
sched_get_priority_max01 sched_get_priority_max01
sched_get_priority_max02 sched_get_priority_max02
diff --git a/runtest/syscalls b/runtest/syscalls
index fb3e59f..3adeb8a 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -868,6 +868,7 @@ rt_sigqueueinfo01 rt_sigqueueinfo01
rt_sigsuspend01 rt_sigsuspend01
sbrk01 sbrk01
+sbrk02 sbrk02
sched_get_priority_max01 sched_get_priority_max01
sched_get_priority_max02 sched_get_priority_max02
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index d5c7bac..cd51000 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -706,6 +706,7 @@
/rt_sigsuspend/rt_sigsuspend01
/rt_sigtimedwait/rt_sigtimedwait01
/sbrk/sbrk01
+/sbrk/sbrk02
/sched_get_priority_max/sched_get_priority_max01
/sched_get_priority_max/sched_get_priority_max02
/sched_get_priority_min/sched_get_priority_min01
diff --git a/testcases/kernel/syscalls/sbrk/sbrk02.c b/testcases/kernel/syscalls/sbrk/sbrk02.c
new file mode 100644
index 0000000..8961fa9
--- /dev/null
+++ b/testcases/kernel/syscalls/sbrk/sbrk02.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Zeng Linggang <zenglg.jy@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
+ * Check sbrk() with error condition that should produce ENOMEM.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include "test.h"
+#include "usctest.h"
+
+char *TCID = "sbrk02";
+int TST_TOTAL = 1;
+
+#if !defined(UCLINUX)
+
+static void setup(void);
+static void sbrk_verify(void);
+static void cleanup(void);
+static int exp_enos[] = { ENOMEM, 0 };
+
+static long increment;
+
+int main(int argc, char *argv[])
+{
+ int lc;
+ int i;
+ char *msg;
+
+ msg = parse_opts(argc, argv, 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++)
+ sbrk_verify();
+ }
+
+ cleanup();
+ tst_exit();
+}
+
+static void setup(void)
+{
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ TEST_PAUSE;
+
+ for (increment = 16*1024*1024; errno == 0; increment++)
+ sbrk(increment);
+
+ errno = 0;
+
+ TEST_EXP_ENOS(exp_enos);
+}
+
+static void sbrk_verify(void)
+{
+ void *tret;
+
+ tret = sbrk(increment);
+ TEST_ERRNO = errno;
+
+ if (tret != (void *)-1) {
+ tst_resm(TFAIL,
+ "sbrk(%ld) returned %p, expected (void *)-1, errno=%d",
+ increment, tret, ENOMEM);
+ return;
+ }
+
+ TEST_ERROR_LOG(TEST_ERRNO);
+
+ if (TEST_ERRNO == ENOMEM) {
+ tst_resm(TPASS | TTERRNO, "sbrk(%ld) failed as expected",
+ increment);
+ } else {
+ tst_resm(TFAIL | TTERRNO,
+ "sbrk(%ld) failed unexpectedly; expected: %d - %s",
+ increment, ENOMEM, strerror(ENOMEM));
+ }
+}
+
+static void cleanup(void)
+{
+ TEST_CLEANUP;
+}
+
+#else
+
+int main(void)
+{
+ tst_resm(TINFO, "test is not available on uClinux");
+ tst_exit();
+}
+
+#endif /* if !defined(UCLINUX) */
--
1.8.4.2
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test
2014-04-23 3:52 ` [LTP] [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test Zeng Linggang
@ 2014-04-23 11:29 ` Jan Stancek
2014-04-25 9:29 ` Zeng Linggang
2014-05-20 15:50 ` chrubis
2014-05-20 15:56 ` chrubis
1 sibling, 2 replies; 12+ messages in thread
From: Jan Stancek @ 2014-04-23 11:29 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
----- Original Message -----
> From: "Zeng Linggang" <zenglg.jy@cn.fujitsu.com>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: "ltp-list" <ltp-list@lists.sourceforge.net>
> Sent: Wednesday, 23 April, 2014 5:52:56 AM
> Subject: [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test
>
> Add ENOMEM errno test for sbrk(2)
>
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> ---
> runtest/ltplite | 1 +
> runtest/stress.part3 | 1 +
> runtest/syscalls | 1 +
> testcases/kernel/syscalls/.gitignore | 1 +
> testcases/kernel/syscalls/sbrk/sbrk02.c | 114
> ++++++++++++++++++++++++++++++++
Hi,
looks good to me. I saw sbrk02 taking up to couple seconds
to complete on some systems, but that seems acceptable.
If anyone objects, we could change setup() to increment
even more rapidly.
Regards,
Jan
> 5 files changed, 118 insertions(+)
> create mode 100644 testcases/kernel/syscalls/sbrk/sbrk02.c
>
> diff --git a/runtest/ltplite b/runtest/ltplite
> index ebe171e..26b7753 100644
> --- a/runtest/ltplite
> +++ b/runtest/ltplite
> @@ -653,6 +653,7 @@ rmdir04 rmdir04
> rmdir05 rmdir05
>
> sbrk01 sbrk01
> +sbrk02 sbrk02
>
> sched_get_priority_max01 sched_get_priority_max01
> sched_get_priority_max02 sched_get_priority_max02
> diff --git a/runtest/stress.part3 b/runtest/stress.part3
> index b21e44b..021decf 100644
> --- a/runtest/stress.part3
> +++ b/runtest/stress.part3
> @@ -563,6 +563,7 @@ rmdir04 rmdir04
> rmdir05 rmdir05
>
> sbrk01 sbrk01
> +sbrk02 sbrk02
>
> sched_get_priority_max01 sched_get_priority_max01
> sched_get_priority_max02 sched_get_priority_max02
> diff --git a/runtest/syscalls b/runtest/syscalls
> index fb3e59f..3adeb8a 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -868,6 +868,7 @@ rt_sigqueueinfo01 rt_sigqueueinfo01
> rt_sigsuspend01 rt_sigsuspend01
>
> sbrk01 sbrk01
> +sbrk02 sbrk02
>
> sched_get_priority_max01 sched_get_priority_max01
> sched_get_priority_max02 sched_get_priority_max02
> diff --git a/testcases/kernel/syscalls/.gitignore
> b/testcases/kernel/syscalls/.gitignore
> index d5c7bac..cd51000 100644
> --- a/testcases/kernel/syscalls/.gitignore
> +++ b/testcases/kernel/syscalls/.gitignore
> @@ -706,6 +706,7 @@
> /rt_sigsuspend/rt_sigsuspend01
> /rt_sigtimedwait/rt_sigtimedwait01
> /sbrk/sbrk01
> +/sbrk/sbrk02
> /sched_get_priority_max/sched_get_priority_max01
> /sched_get_priority_max/sched_get_priority_max02
> /sched_get_priority_min/sched_get_priority_min01
> diff --git a/testcases/kernel/syscalls/sbrk/sbrk02.c
> b/testcases/kernel/syscalls/sbrk/sbrk02.c
> new file mode 100644
> index 0000000..8961fa9
> --- /dev/null
> +++ b/testcases/kernel/syscalls/sbrk/sbrk02.c
> @@ -0,0 +1,114 @@
> +/*
> + * Copyright (c) 2014 Fujitsu Ltd.
> + * Author: Zeng Linggang <zenglg.jy@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
> + * Check sbrk() with error condition that should produce ENOMEM.
> + */
> +
> +#include <errno.h>
> +#include <unistd.h>
> +#include "test.h"
> +#include "usctest.h"
> +
> +char *TCID = "sbrk02";
> +int TST_TOTAL = 1;
> +
> +#if !defined(UCLINUX)
> +
> +static void setup(void);
> +static void sbrk_verify(void);
> +static void cleanup(void);
> +static int exp_enos[] = { ENOMEM, 0 };
> +
> +static long increment;
> +
> +int main(int argc, char *argv[])
> +{
> + int lc;
> + int i;
> + char *msg;
> +
> + msg = parse_opts(argc, argv, 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++)
> + sbrk_verify();
> + }
> +
> + cleanup();
> + tst_exit();
> +}
> +
> +static void setup(void)
> +{
> + tst_sig(NOFORK, DEF_HANDLER, cleanup);
> +
> + TEST_PAUSE;
> +
> + for (increment = 16*1024*1024; errno == 0; increment++)
> + sbrk(increment);
> +
> + errno = 0;
> +
> + TEST_EXP_ENOS(exp_enos);
> +}
> +
> +static void sbrk_verify(void)
> +{
> + void *tret;
> +
> + tret = sbrk(increment);
> + TEST_ERRNO = errno;
> +
> + if (tret != (void *)-1) {
> + tst_resm(TFAIL,
> + "sbrk(%ld) returned %p, expected (void *)-1, errno=%d",
> + increment, tret, ENOMEM);
> + return;
> + }
> +
> + TEST_ERROR_LOG(TEST_ERRNO);
> +
> + if (TEST_ERRNO == ENOMEM) {
> + tst_resm(TPASS | TTERRNO, "sbrk(%ld) failed as expected",
> + increment);
> + } else {
> + tst_resm(TFAIL | TTERRNO,
> + "sbrk(%ld) failed unexpectedly; expected: %d - %s",
> + increment, ENOMEM, strerror(ENOMEM));
> + }
> +}
> +
> +static void cleanup(void)
> +{
> + TEST_CLEANUP;
> +}
> +
> +#else
> +
> +int main(void)
> +{
> + tst_resm(TINFO, "test is not available on uClinux");
> + tst_exit();
> +}
> +
> +#endif /* if !defined(UCLINUX) */
> --
> 1.8.4.2
>
>
>
>
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test
2014-04-23 11:29 ` Jan Stancek
@ 2014-04-25 9:29 ` Zeng Linggang
2014-05-20 15:50 ` chrubis
1 sibling, 0 replies; 12+ messages in thread
From: Zeng Linggang @ 2014-04-25 9:29 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
On Wed, 2014-04-23 at 07:29 -0400, Jan Stancek wrote:
>
> ----- Original Message -----
> > From: "Zeng Linggang" <zenglg.jy@cn.fujitsu.com>
> > To: "Jan Stancek" <jstancek@redhat.com>
> > Cc: "ltp-list" <ltp-list@lists.sourceforge.net>
> > Sent: Wednesday, 23 April, 2014 5:52:56 AM
> > Subject: [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test
> >
> > Add ENOMEM errno test for sbrk(2)
> >
> > Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> > ---
> > runtest/ltplite | 1 +
> > runtest/stress.part3 | 1 +
> > runtest/syscalls | 1 +
> > testcases/kernel/syscalls/.gitignore | 1 +
> > testcases/kernel/syscalls/sbrk/sbrk02.c | 114
> > ++++++++++++++++++++++++++++++++
>
> Hi,
>
> looks good to me. I saw sbrk02 taking up to couple seconds
> to complete on some systems, but that seems acceptable.
> If anyone objects, we could change setup() to increment
> even more rapidly.
>
Sorry for the delay.
I am OK for the changing if anyone objects.
And thank you for your review again.
Best regards,
Zeng
> Regards,
> Jan
>
> > 5 files changed, 118 insertions(+)
> > create mode 100644 testcases/kernel/syscalls/sbrk/sbrk02.c
> >
> > diff --git a/runtest/ltplite b/runtest/ltplite
> > index ebe171e..26b7753 100644
> > --- a/runtest/ltplite
> > +++ b/runtest/ltplite
> > @@ -653,6 +653,7 @@ rmdir04 rmdir04
> > rmdir05 rmdir05
> >
> > sbrk01 sbrk01
> > +sbrk02 sbrk02
> >
> > sched_get_priority_max01 sched_get_priority_max01
> > sched_get_priority_max02 sched_get_priority_max02
> > diff --git a/runtest/stress.part3 b/runtest/stress.part3
> > index b21e44b..021decf 100644
> > --- a/runtest/stress.part3
> > +++ b/runtest/stress.part3
> > @@ -563,6 +563,7 @@ rmdir04 rmdir04
> > rmdir05 rmdir05
> >
> > sbrk01 sbrk01
> > +sbrk02 sbrk02
> >
> > sched_get_priority_max01 sched_get_priority_max01
> > sched_get_priority_max02 sched_get_priority_max02
> > diff --git a/runtest/syscalls b/runtest/syscalls
> > index fb3e59f..3adeb8a 100644
> > --- a/runtest/syscalls
> > +++ b/runtest/syscalls
> > @@ -868,6 +868,7 @@ rt_sigqueueinfo01 rt_sigqueueinfo01
> > rt_sigsuspend01 rt_sigsuspend01
> >
> > sbrk01 sbrk01
> > +sbrk02 sbrk02
> >
> > sched_get_priority_max01 sched_get_priority_max01
> > sched_get_priority_max02 sched_get_priority_max02
> > diff --git a/testcases/kernel/syscalls/.gitignore
> > b/testcases/kernel/syscalls/.gitignore
> > index d5c7bac..cd51000 100644
> > --- a/testcases/kernel/syscalls/.gitignore
> > +++ b/testcases/kernel/syscalls/.gitignore
> > @@ -706,6 +706,7 @@
> > /rt_sigsuspend/rt_sigsuspend01
> > /rt_sigtimedwait/rt_sigtimedwait01
> > /sbrk/sbrk01
> > +/sbrk/sbrk02
> > /sched_get_priority_max/sched_get_priority_max01
> > /sched_get_priority_max/sched_get_priority_max02
> > /sched_get_priority_min/sched_get_priority_min01
> > diff --git a/testcases/kernel/syscalls/sbrk/sbrk02.c
> > b/testcases/kernel/syscalls/sbrk/sbrk02.c
> > new file mode 100644
> > index 0000000..8961fa9
> > --- /dev/null
> > +++ b/testcases/kernel/syscalls/sbrk/sbrk02.c
> > @@ -0,0 +1,114 @@
> > +/*
> > + * Copyright (c) 2014 Fujitsu Ltd.
> > + * Author: Zeng Linggang <zenglg.jy@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
> > + * Check sbrk() with error condition that should produce ENOMEM.
> > + */
> > +
> > +#include <errno.h>
> > +#include <unistd.h>
> > +#include "test.h"
> > +#include "usctest.h"
> > +
> > +char *TCID = "sbrk02";
> > +int TST_TOTAL = 1;
> > +
> > +#if !defined(UCLINUX)
> > +
> > +static void setup(void);
> > +static void sbrk_verify(void);
> > +static void cleanup(void);
> > +static int exp_enos[] = { ENOMEM, 0 };
> > +
> > +static long increment;
> > +
> > +int main(int argc, char *argv[])
> > +{
> > + int lc;
> > + int i;
> > + char *msg;
> > +
> > + msg = parse_opts(argc, argv, 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++)
> > + sbrk_verify();
> > + }
> > +
> > + cleanup();
> > + tst_exit();
> > +}
> > +
> > +static void setup(void)
> > +{
> > + tst_sig(NOFORK, DEF_HANDLER, cleanup);
> > +
> > + TEST_PAUSE;
> > +
> > + for (increment = 16*1024*1024; errno == 0; increment++)
> > + sbrk(increment);
> > +
> > + errno = 0;
> > +
> > + TEST_EXP_ENOS(exp_enos);
> > +}
> > +
> > +static void sbrk_verify(void)
> > +{
> > + void *tret;
> > +
> > + tret = sbrk(increment);
> > + TEST_ERRNO = errno;
> > +
> > + if (tret != (void *)-1) {
> > + tst_resm(TFAIL,
> > + "sbrk(%ld) returned %p, expected (void *)-1, errno=%d",
> > + increment, tret, ENOMEM);
> > + return;
> > + }
> > +
> > + TEST_ERROR_LOG(TEST_ERRNO);
> > +
> > + if (TEST_ERRNO == ENOMEM) {
> > + tst_resm(TPASS | TTERRNO, "sbrk(%ld) failed as expected",
> > + increment);
> > + } else {
> > + tst_resm(TFAIL | TTERRNO,
> > + "sbrk(%ld) failed unexpectedly; expected: %d - %s",
> > + increment, ENOMEM, strerror(ENOMEM));
> > + }
> > +}
> > +
> > +static void cleanup(void)
> > +{
> > + TEST_CLEANUP;
> > +}
> > +
> > +#else
> > +
> > +int main(void)
> > +{
> > + tst_resm(TINFO, "test is not available on uClinux");
> > + tst_exit();
> > +}
> > +
> > +#endif /* if !defined(UCLINUX) */
> > --
> > 1.8.4.2
> >
> >
> >
> >
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test
2014-04-23 11:29 ` Jan Stancek
2014-04-25 9:29 ` Zeng Linggang
@ 2014-05-20 15:50 ` chrubis
1 sibling, 0 replies; 12+ messages in thread
From: chrubis @ 2014-05-20 15:50 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
Hi!
> looks good to me. I saw sbrk02 taking up to couple seconds
> to complete on some systems, but that seems acceptable.
> If anyone objects, we could change setup() to increment
> even more rapidly.
Generally the testrun should be as fast as possible (think of a farm of
kernel builders that gets latest kernel git, compiles it and runs
tests). So ideally each testcase should not run longer than is needed.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test
2014-04-23 3:52 ` [LTP] [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test Zeng Linggang
2014-04-23 11:29 ` Jan Stancek
@ 2014-05-20 15:56 ` chrubis
1 sibling, 0 replies; 12+ messages in thread
From: chrubis @ 2014-05-20 15:56 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
> +#if !defined(UCLINUX)
If none of the sbrk tests runs on uClinux the UCLINUX ifdefs should be
removed and the whole directory should be skipped on build and install.
(by adding into UCLINUX FILTER_OUT_DIRS in
testacses/kernel/syscalls/Makefile)
Otherwise the test looks fine.
Jan can you please tune the increments, remove the ifdefs and push into
git?
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 1/2] sbrk/sbrk01.c: cleanup
2014-04-23 3:51 ` [LTP] [PATCH v2 1/2] sbrk/sbrk01.c: cleanup Zeng Linggang
2014-04-23 3:52 ` [LTP] [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test Zeng Linggang
@ 2014-05-20 16:03 ` chrubis
1 sibling, 0 replies; 12+ messages in thread
From: chrubis @ 2014-05-20 16:03 UTC (permalink / raw)
To: Zeng Linggang; +Cc: ltp-list
Hi!
> * Delete some useless commtents.
> * Move the test body from main() to sbrk_verify().
> * Remove tst_tmpdir().
> * Some cleanup.
Pushed after I've removed the UCLINUX #ifdefs and added sbrk directory
to UCLINUX FILTER_OUT_DIRS into ../Makefile
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-05-20 16:04 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-22 9:40 [LTP] [PATCH 1/2] sbrk/sbrk01.c: cleanup Zeng Linggang
2014-04-22 9:41 ` [LTP] [PATCH 2/2] sbrk/sbrk02.c: add ENOMEM errno test Zeng Linggang
2014-04-22 13:14 ` Jan Stancek
2014-04-23 1:23 ` Zeng Linggang
2014-04-23 3:51 ` [LTP] [PATCH v2 1/2] sbrk/sbrk01.c: cleanup Zeng Linggang
2014-04-23 3:52 ` [LTP] [PATCH v2 2/2] sbrk/sbrk02.c: add ENOMEM errno test Zeng Linggang
2014-04-23 11:29 ` Jan Stancek
2014-04-25 9:29 ` Zeng Linggang
2014-05-20 15:50 ` chrubis
2014-05-20 15:56 ` chrubis
2014-05-20 16:03 ` [LTP] [PATCH v2 1/2] sbrk/sbrk01.c: cleanup chrubis
2014-04-22 12:38 ` [LTP] [PATCH " Jan Stancek
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.