cleanup the getrlimit01.c

Signed-off-by: Zeng Linggang <[email protected]>
---
 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. <[email protected]>
  *
  *   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. <[email protected]>
- *
- *    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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to