* [LTP] [PATCH 1/2] getrlimit/getrlimit01.c: cleanup
@ 2013-12-12 10:26 zenglg.jy
2014-01-06 5:49 ` zenglg.jy
2014-02-04 13:20 ` chrubis
0 siblings, 2 replies; 3+ messages in thread
From: zenglg.jy @ 2013-12-12 10:26 UTC (permalink / raw)
To: ltp-list
cleanup the getrlimit01.c
Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
testcases/kernel/syscalls/getrlimit/getrlimit01.c | 123 +++++-----------------
1 file changed, 29 insertions(+), 94 deletions(-)
diff --git a/testcases/kernel/syscalls/getrlimit/getrlimit01.c b/testcases/kernel/syscalls/getrlimit/getrlimit01.c
index 3fe846b..f397a19 100644
--- a/testcases/kernel/syscalls/getrlimit/getrlimit01.c
+++ b/testcases/kernel/syscalls/getrlimit/getrlimit01.c
@@ -1,6 +1,7 @@
/*
*
* Copyright (c) Wipro Technologies, 2002. All Rights Reserved.
+ * Author: Suresh Babu V. <suresh.babu@wipro.com>
*
* 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
@@ -17,53 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/****************************************************************************
- *
- * TEST IDENTIFIER : getrlimit01
- *
- * TEST TITLE : test for checking functionality of getrlimit(2)
- * $
- * EXECUTED BY : anyone
- *
- * TEST CASE TOTAL : 11
- *
- * AUTHOR : Suresh Babu V. <suresh.babu@wipro.com>
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * DESCRIPTION
- * Verify that,
- * getrlimit(2) call will be successful for all possible resource types.
- *
- * 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
- * Issue sys call failed to get resource limits.
- * Otherwise,
- * Issue sys call is successful and got resource limits.
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- * USAGE: <for command-line>
- * getrlimit01 [-c n] [-e] [-i n] [-I x] [-P x] [-p] [-t] [-h]
- * where, -c n : Run n copies concurrently.
- * -e : Turn on errno logging.
- * -i n : Execute test n times.
- * -I x : Execute test for x seconds.
- * -P x : Pause for x seconds between iterations.
- * -p : Pause for SIGUSR1 before starting.
- * -t : Turn on syscall timing.
- * -h : Display usage information.
- *
- ***************************************************************************/
+/*
+ * Test for checking functionality of getrlimit(2)
+ */
#include <stdio.h>
#include <errno.h>
#include <sys/time.h>
@@ -74,94 +31,72 @@
static void cleanup(void);
static void setup(void);
-char *TCID = "getrlimit01";
-
static struct rlimit rlim;
static struct test_t {
int res;
char *res_str;
} testcases[] = {
- {
- RLIMIT_CPU, "RLIMIT_CPU"}, {
- RLIMIT_FSIZE, "RLIMIT_FSIZE"}, {
- RLIMIT_DATA, "RLIMIT_DATA"}, {
- RLIMIT_STACK, "RLIMIT_STACK"}, {
- RLIMIT_CORE, "RLIMIT_CORE"}, {
- RLIMIT_RSS, "RLIMIT_RSS"}, {
- RLIMIT_NPROC, "RLIMIT_NPROC"}, {
- RLIMIT_NOFILE, "RLIMIT_NOFILE"}, {
- RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK"}, {
- RLIMIT_AS, "RLIMIT_AS"}, {
- RLIMIT_LOCKS, "RLIMIT_LOCKS"}
+ {RLIMIT_CPU, "RLIMIT_CPU"},
+ {RLIMIT_FSIZE, "RLIMIT_FSIZE"},
+ {RLIMIT_DATA, "RLIMIT_DATA"},
+ {RLIMIT_STACK, "RLIMIT_STACK"},
+ {RLIMIT_CORE, "RLIMIT_CORE"},
+ {RLIMIT_RSS, "RLIMIT_RSS"},
+ {RLIMIT_NPROC, "RLIMIT_NPROC"},
+ {RLIMIT_NOFILE, "RLIMIT_NOFILE"},
+ {RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK"},
+ {RLIMIT_AS, "RLIMIT_AS"},
+ {RLIMIT_LOCKS, "RLIMIT_LOCKS"},
};
-int TST_TOTAL = sizeof(testcases) / sizeof(*testcases);
+char *TCID = "getrlimit01";
+int TST_TOTAL = ARRAY_SIZE(testcases);
int main(int ac, char **av)
{
int i;
int lc;
- char *msg; /* parse_opts() return message */
+ char *msg;
- 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);
- tst_exit();
- }
- /* Do initial setup */
setup();
- /* check for looping state if -i option is given */
for (lc = 0; TEST_LOOPING(lc); lc++) {
+
tst_count = 0;
for (i = 0; i < TST_TOTAL; ++i) {
- /*
- * Test the system call with different resoruce types
- * with codes 0 to 10
- */
TEST(getrlimit(testcases[i].res, &rlim));
if (TEST_RETURN == -1) {
- tst_resm(TFAIL, "getrlimit() failed to get %s "
- "values. errno is %d",
+ tst_resm(TFAIL,
+ "getrlimit() test %s failed errno: %d",
testcases[i].res_str, TEST_ERRNO);
} else {
- tst_resm(TPASS, "getrlimit() returned %d; "
- "got %s values ",
- TEST_ERRNO, testcases[i].res_str);
+ tst_resm(TPASS,
+ "getrlimit() test %s success",
+ testcases[i].res_str);
}
}
}
- /* do cleanup and exit */
+
cleanup();
tst_exit();
}
-/*
- * setup() - performs all one time setup for this test.
- */
-void setup()
+static void setup(void)
{
- /* capture the signals */
tst_sig(NOFORK, DEF_HANDLER, cleanup);
- /* Pause if the option was specified */
TEST_PAUSE;
}
-/*
- * cleanup() - performs all one time cleanup for this test
- * completion or premature exit.
- */
-void cleanup()
+static void cleanup(void)
{
- /*
- * print timing stats if that option was specified.
- * print errno log if that option was specified.
- */
TEST_CLEANUP;
-
}
--
1.8.2.1
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&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 1/2] getrlimit/getrlimit01.c: cleanup
2013-12-12 10:26 [LTP] [PATCH 1/2] getrlimit/getrlimit01.c: cleanup zenglg.jy
@ 2014-01-06 5:49 ` zenglg.jy
2014-02-04 13:20 ` chrubis
1 sibling, 0 replies; 3+ messages in thread
From: zenglg.jy @ 2014-01-06 5:49 UTC (permalink / raw)
To: ltp-list
Could anyone help to review this?
Thanks,
Zeng
On Thu, 2013-12-12 at 18:26 +0800, zenglg.jy wrote:
> cleanup the getrlimit01.c
>
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
> ---
> testcases/kernel/syscalls/getrlimit/getrlimit01.c | 123 +++++-----------------
> 1 file changed, 29 insertions(+), 94 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/getrlimit/getrlimit01.c b/testcases/kernel/syscalls/getrlimit/getrlimit01.c
> index 3fe846b..f397a19 100644
> --- a/testcases/kernel/syscalls/getrlimit/getrlimit01.c
> +++ b/testcases/kernel/syscalls/getrlimit/getrlimit01.c
> @@ -1,6 +1,7 @@
> /*
> *
> * Copyright (c) Wipro Technologies, 2002. All Rights Reserved.
> + * Author: Suresh Babu V. <suresh.babu@wipro.com>
> *
> * 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
> @@ -17,53 +18,9 @@
> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> */
>
> -/****************************************************************************
> - *
> - * TEST IDENTIFIER : getrlimit01
> - *
> - * TEST TITLE : test for checking functionality of getrlimit(2)
> - * $
> - * EXECUTED BY : anyone
> - *
> - * TEST CASE TOTAL : 11
> - *
> - * AUTHOR : Suresh Babu V. <suresh.babu@wipro.com>
> - *
> - * SIGNALS
> - * Uses SIGUSR1 to pause before test if option set.
> - * (See the parse_opts(3) man page).
> - *
> - * DESCRIPTION
> - * Verify that,
> - * getrlimit(2) call will be successful for all possible resource types.
> - *
> - * 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
> - * Issue sys call failed to get resource limits.
> - * Otherwise,
> - * Issue sys call is successful and got resource limits.
> - *
> - * Cleanup:
> - * Print errno log and/or timing stats if options given
> - *
> - * USAGE: <for command-line>
> - * getrlimit01 [-c n] [-e] [-i n] [-I x] [-P x] [-p] [-t] [-h]
> - * where, -c n : Run n copies concurrently.
> - * -e : Turn on errno logging.
> - * -i n : Execute test n times.
> - * -I x : Execute test for x seconds.
> - * -P x : Pause for x seconds between iterations.
> - * -p : Pause for SIGUSR1 before starting.
> - * -t : Turn on syscall timing.
> - * -h : Display usage information.
> - *
> - ***************************************************************************/
> +/*
> + * Test for checking functionality of getrlimit(2)
> + */
> #include <stdio.h>
> #include <errno.h>
> #include <sys/time.h>
> @@ -74,94 +31,72 @@
> static void cleanup(void);
> static void setup(void);
>
> -char *TCID = "getrlimit01";
> -
> static struct rlimit rlim;
> static struct test_t {
> int res;
> char *res_str;
> } testcases[] = {
> - {
> - RLIMIT_CPU, "RLIMIT_CPU"}, {
> - RLIMIT_FSIZE, "RLIMIT_FSIZE"}, {
> - RLIMIT_DATA, "RLIMIT_DATA"}, {
> - RLIMIT_STACK, "RLIMIT_STACK"}, {
> - RLIMIT_CORE, "RLIMIT_CORE"}, {
> - RLIMIT_RSS, "RLIMIT_RSS"}, {
> - RLIMIT_NPROC, "RLIMIT_NPROC"}, {
> - RLIMIT_NOFILE, "RLIMIT_NOFILE"}, {
> - RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK"}, {
> - RLIMIT_AS, "RLIMIT_AS"}, {
> - RLIMIT_LOCKS, "RLIMIT_LOCKS"}
> + {RLIMIT_CPU, "RLIMIT_CPU"},
> + {RLIMIT_FSIZE, "RLIMIT_FSIZE"},
> + {RLIMIT_DATA, "RLIMIT_DATA"},
> + {RLIMIT_STACK, "RLIMIT_STACK"},
> + {RLIMIT_CORE, "RLIMIT_CORE"},
> + {RLIMIT_RSS, "RLIMIT_RSS"},
> + {RLIMIT_NPROC, "RLIMIT_NPROC"},
> + {RLIMIT_NOFILE, "RLIMIT_NOFILE"},
> + {RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK"},
> + {RLIMIT_AS, "RLIMIT_AS"},
> + {RLIMIT_LOCKS, "RLIMIT_LOCKS"},
> };
>
> -int TST_TOTAL = sizeof(testcases) / sizeof(*testcases);
> +char *TCID = "getrlimit01";
> +int TST_TOTAL = ARRAY_SIZE(testcases);
>
> int main(int ac, char **av)
> {
> int i;
> int lc;
> - char *msg; /* parse_opts() return message */
> + char *msg;
>
> - 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);
> - tst_exit();
> - }
>
> - /* Do initial setup */
> setup();
>
> - /* check for looping state if -i option is given */
> for (lc = 0; TEST_LOOPING(lc); lc++) {
> +
> tst_count = 0;
>
> for (i = 0; i < TST_TOTAL; ++i) {
>
> - /*
> - * Test the system call with different resoruce types
> - * with codes 0 to 10
> - */
> TEST(getrlimit(testcases[i].res, &rlim));
>
> if (TEST_RETURN == -1) {
> - tst_resm(TFAIL, "getrlimit() failed to get %s "
> - "values. errno is %d",
> + tst_resm(TFAIL,
> + "getrlimit() test %s failed errno: %d",
> testcases[i].res_str, TEST_ERRNO);
> } else {
> - tst_resm(TPASS, "getrlimit() returned %d; "
> - "got %s values ",
> - TEST_ERRNO, testcases[i].res_str);
> + tst_resm(TPASS,
> + "getrlimit() test %s success",
> + testcases[i].res_str);
> }
> }
> }
> - /* do cleanup and exit */
> +
> cleanup();
>
> tst_exit();
> }
>
> -/*
> - * setup() - performs all one time setup for this test.
> - */
> -void setup()
> +static void setup(void)
> {
> - /* capture the signals */
> tst_sig(NOFORK, DEF_HANDLER, cleanup);
>
> - /* Pause if the option was specified */
> TEST_PAUSE;
> }
>
> -/*
> - * cleanup() - performs all one time cleanup for this test
> - * completion or premature exit.
> - */
> -void cleanup()
> +static void cleanup(void)
> {
> - /*
> - * print timing stats if that option was specified.
> - * print errno log if that option was specified.
> - */
> TEST_CLEANUP;
> -
> }
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
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
* Re: [LTP] [PATCH 1/2] getrlimit/getrlimit01.c: cleanup
2013-12-12 10:26 [LTP] [PATCH 1/2] getrlimit/getrlimit01.c: cleanup zenglg.jy
2014-01-06 5:49 ` zenglg.jy
@ 2014-02-04 13:20 ` chrubis
1 sibling, 0 replies; 3+ messages in thread
From: chrubis @ 2014-02-04 13:20 UTC (permalink / raw)
To: zenglg.jy; +Cc: ltp-list
Hi!
> +/*
> + * Test for checking functionality of getrlimit(2)
> + */
I've changed this comment to be more verbose about the test purpose.
> @@ -74,94 +31,72 @@
>
> if (TEST_RETURN == -1) {
> - tst_resm(TFAIL, "getrlimit() failed to get %s "
> - "values. errno is %d",
> + tst_resm(TFAIL,
> + "getrlimit() test %s failed errno: %d",
> testcases[i].res_str, TEST_ERRNO);
Changed the TFAIL to TFAIL | TTERRNO instead of the %d.
And pushed both patches, thanks.
PS: Sorry for the late response, I've had quite a lot of work after I've
returned from Christmas vacation.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
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
end of thread, other threads:[~2014-02-04 13:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-12 10:26 [LTP] [PATCH 1/2] getrlimit/getrlimit01.c: cleanup zenglg.jy
2014-01-06 5:49 ` zenglg.jy
2014-02-04 13:20 ` chrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox