On Tue, 2014-04-22 at 09:14 -0400, Jan Stancek wrote:
>
> ----- Original Message -----
> > From: "Zeng Linggang" <[email protected]>
> > To: "ltp-list" <[email protected]>
> > 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 <[email protected]>
> > ---
> > 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 <[email protected]>
> > + *
> > + * 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
> > [email protected]
> > 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list