From: Jan Stancek <jstancek@redhat.com>
To: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
Cc: ltp-list <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH 2/2] sbrk/sbrk02.c: add ENOMEM errno test
Date: Tue, 22 Apr 2014 09:14:39 -0400 (EDT) [thread overview]
Message-ID: <64087164.7823458.1398172479616.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1398159660.2772.8.camel@G08JYZSD130126>
----- 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
next prev parent reply other threads:[~2014-04-22 13:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=64087164.7823458.1398172479616.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=zenglg.jy@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.