No code changes, just converting from DOS text format to UNIX text format.
diff --git a/testcases/kernel/syscalls/clone/clone01.c b/testcases/kernel/syscalls/clone/clone01.c
index 279aff9..5b5ae1b 100644
--- a/testcases/kernel/syscalls/clone/clone01.c
+++ b/testcases/kernel/syscalls/clone/clone01.c
@@ -1,197 +1,197 @@
-/*
- * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
- *
- * 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., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- */
-/**********************************************************
- *
- * TEST IDENTIFIER : clone01
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : Basic test for clone(2)
- *
- * TEST CASE TOTAL : 1
- *
- * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * DESCRIPTION
- * This is a Phase I test for the clone(2) system call.
- * It is intended to provide a limited exposure of the system call.
- *
- * Setup:
- * Setup signal handling.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Loop if the proper options are given.
- * Call clone() with only SIGCHLD flag
- *
- * CHILD:
- * return 0;
- *
- * PARENT:
- * wait for child to finish
- * If return values from clone() & wait() are equal & != -1
- * test passed
- * else
- * test failed
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- * USAGE: <for command-line>
- * clone01 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- * where, -c n : Run n copies concurrently.
- * -e : Turn on errno logging.
- * -h : Show help screen
- * -f : Turn off functional testing
- * -i n : Execute test n times.
- * -I x : Execute test for x seconds.
- * -p : Pause for SIGUSR1 before starting
- * -P x : Pause for x seconds between iterations.
- * -t : Turn on syscall timing.
- *
- ****************************************************************/
-
-#include <errno.h>
-#include <sched.h>
-#include <sys/wait.h>
-#include "test.h"
-#include "usctest.h"
-
-#define CHILD_STACK_SIZE 1024
-
-#if defined (__s390__) || (__s390x__)
-#define clone __clone
-extern int __clone(int(void*),void*,int,void*);
-#endif
-
-static void setup();
-static void cleanup();
-static int do_child();
-
-char *TCID="clone01"; /* Test program identifier. */
-int TST_TOTAL=1; /* Total number of test cases. */
-extern int Tst_count; /* Test Case counter for tst_* routines */
-
-int
-main(int ac, char **av)
-{
-
- int lc; /* loop counter */
- char *msg; /* message returned from parse_opts */
- void *child_stack; /* stack for child */
- int status, child_pid;
-
- /* parse standard options */
- if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL))
- != (char *)NULL) {
- tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
- }
-
- /* perform global setup for test */
- setup();
-
- /* Allocate stack for child */
- if((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) {
- tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
- }
-
- /* check looping state if -i option given */
- for (lc=0; TEST_LOOPING(lc); lc++) {
-
- /* reset Tst_count in case we are looping. */
- Tst_count=0;
-
- /*
- * Call clone(2)
- */
-#ifdef __hppa__
- TEST(clone(do_child, child_stack, SIGCHLD, NULL));
-#else
- TEST(clone(do_child, child_stack + CHILD_STACK_SIZE, SIGCHLD, NULL));
-#endif
-
- if ((child_pid = wait(&status)) == -1) {
- tst_brkm(TBROK, cleanup, "wait() failed; error no ="
- " %d, %s", errno, strerror(errno));
- }
-
- /* check return code */
- if (TEST_RETURN == child_pid) {
- tst_resm(TPASS, "clone() returned %d", TEST_RETURN);
- } else {
- tst_resm(TFAIL, "clone() returned %d, errno = %d ",
- "wait() returned %d", TEST_RETURN, TEST_ERRNO,
- child_pid);
- }
-
- } /* End for TEST_LOOPING */
-
- free(child_stack);
-
- /* cleanup and exit */
- cleanup();
-
- /*NOTREACHED*/
- return 0;
-
-} /* End main */
-
-/* setup() - performs all ONE TIME setup for this test */
-void
-setup()
-{
-
- /* capture signals */
- tst_sig(FORK, DEF_HANDLER, cleanup);
-
- /* Pause if that option was specified */
- TEST_PAUSE;
-
-} /* End setup() */
-
-
-/*
- *cleanup() - performs all ONE TIME cleanup for this test at
- * completion or premature exit.
- */
-void
-cleanup()
-{
-
- /*
- * print timing stats if that option was specified.
- * print errno log if that option was specified.
- */
- TEST_CLEANUP;
-
- /* exit with return code appropriate for results */
- tst_exit();
-} /* End cleanup() */
-
-/*
- * do_child() - function executed by child
- */
-int
-do_child(void)
-{
- return 0;
-}
-
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
+ *
+ * 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., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ */
+/**********************************************************
+ *
+ * TEST IDENTIFIER : clone01
+ *
+ * EXECUTED BY : anyone
+ *
+ * TEST TITLE : Basic test for clone(2)
+ *
+ * TEST CASE TOTAL : 1
+ *
+ * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
+ *
+ * SIGNALS
+ * Uses SIGUSR1 to pause before test if option set.
+ * (See the parse_opts(3) man page).
+ *
+ * DESCRIPTION
+ * This is a Phase I test for the clone(2) system call.
+ * It is intended to provide a limited exposure of the system call.
+ *
+ * Setup:
+ * Setup signal handling.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Call clone() with only SIGCHLD flag
+ *
+ * CHILD:
+ * return 0;
+ *
+ * PARENT:
+ * wait for child to finish
+ * If return values from clone() & wait() are equal & != -1
+ * test passed
+ * else
+ * test failed
+ *
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ *
+ * USAGE: <for command-line>
+ * clone01 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -h : Show help screen
+ * -f : Turn off functional testing
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -p : Pause for SIGUSR1 before starting
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ ****************************************************************/
+
+#include <errno.h>
+#include <sched.h>
+#include <sys/wait.h>
+#include "test.h"
+#include "usctest.h"
+
+#define CHILD_STACK_SIZE 1024
+
+#if defined (__s390__) || (__s390x__)
+#define clone __clone
+extern int __clone(int(void*),void*,int,void*);
+#endif
+
+static void setup();
+static void cleanup();
+static int do_child();
+
+char *TCID="clone01"; /* Test program identifier. */
+int TST_TOTAL=1; /* Total number of test cases. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+
+int
+main(int ac, char **av)
+{
+
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ void *child_stack; /* stack for child */
+ int status, child_pid;
+
+ /* parse standard options */
+ if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL))
+ != (char *)NULL) {
+ tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ /* perform global setup for test */
+ setup();
+
+ /* Allocate stack for child */
+ if((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) {
+ tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
+ }
+
+ /* check looping state if -i option given */
+ for (lc=0; TEST_LOOPING(lc); lc++) {
+
+ /* reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ /*
+ * Call clone(2)
+ */
+#ifdef __hppa__
+ TEST(clone(do_child, child_stack, SIGCHLD, NULL));
+#else
+ TEST(clone(do_child, child_stack + CHILD_STACK_SIZE, SIGCHLD, NULL));
+#endif
+
+ if ((child_pid = wait(&status)) == -1) {
+ tst_brkm(TBROK, cleanup, "wait() failed; error no ="
+ " %d, %s", errno, strerror(errno));
+ }
+
+ /* check return code */
+ if (TEST_RETURN == child_pid) {
+ tst_resm(TPASS, "clone() returned %d", TEST_RETURN);
+ } else {
+ tst_resm(TFAIL, "clone() returned %d, errno = %d ",
+ "wait() returned %d", TEST_RETURN, TEST_ERRNO,
+ child_pid);
+ }
+
+ } /* End for TEST_LOOPING */
+
+ free(child_stack);
+
+ /* cleanup and exit */
+ cleanup();
+
+ /*NOTREACHED*/
+ return 0;
+
+} /* End main */
+
+/* setup() - performs all ONE TIME setup for this test */
+void
+setup()
+{
+
+ /* capture signals */
+ tst_sig(FORK, DEF_HANDLER, cleanup);
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+
+} /* End setup() */
+
+
+/*
+ *cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ */
+void
+cleanup()
+{
+
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+} /* End cleanup() */
+
+/*
+ * do_child() - function executed by child
+ */
+int
+do_child(void)
+{
+ return 0;
+}
+
diff --git a/testcases/kernel/syscalls/clone/clone02.c b/testcases/kernel/syscalls/clone/clone02.c
index d519e2a..7fd5486 100644
--- a/testcases/kernel/syscalls/clone/clone02.c
+++ b/testcases/kernel/syscalls/clone/clone02.c
@@ -1,579 +1,579 @@
-/*
- * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
- *
- * 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., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- */
-/**********************************************************
- *
- * TEST IDENTIFIER : clone02
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : Functionality tests for clone(2)
- *
- * TEST CASE TOTAL : 2
- *
- * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * DESCRIPTION
- *
- * Setup:
- * Setup signal handling.
- * Pause for SIGUSR1 if option specified.
- * generate a unique file name fore each test instance
- *
- * Test:
- * Loop if the proper options are given.
- * TEST1
- * -----
- * Call clone() with all resources shared.
- *
- * CHILD:
- * modify the shared resources
- * return 1 on success
- * PARENT:
- * wait for child to finish
- * verify that the shared resourses are modified
- * return 1 on success
- * If parent & child returns successfully
- * test passed
- * else
- * test failed
- *
- * TEST2
- * -----
- * Call clone() with no resources shared.
- *
- * CHILD:
- * modify the resources in child's address space
- * return 1 on success
- * PARENT:
- * wait for child to finish
- * verify that the parent's resourses are not modified
- * return 1 on success
- * If parent & child returns successfully
- * test passed
- * else
- * test failed
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- * USAGE: <for command-line>
- * clone02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- * where, -c n : Run n copies concurrently.
- * -e : Turn on errno logging.
- * -h : Show help screen
- * -f : Turn off functional testing
- * -i n : Execute test n times.
- * -I x : Execute test for x seconds.
- * -p : Pause for SIGUSR1 before starting
- * -P x : Pause for x seconds between iterations.
- * -t : Turn on syscall timing.
- *
- ****************************************************************/
-
-#include <errno.h>
-#include <sched.h>
-#include <fcntl.h>
-#include <sys/wait.h>
-#include "test.h"
-#include "usctest.h"
-
-#define CHILD_STACK_SIZE 1024
-#define FLAG_ALL CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD
-#define FLAG_NONE SIGCHLD
-#define PARENT_VALUE 1
-#define CHILD_VALUE 2
-#define TRUE 1
-#define FALSE 0
-
-#if defined (__s390__) || (__s390x__)
-#define clone __clone
-extern int __clone(int(void*),void*,int,void*);
-#endif
-
-
-static void setup();
-static int test_setup();
-static void cleanup();
-static void test_cleanup();
-static int child_fn();
-static int parent_test1();
-static int parent_test2();
-static int test_VM();
-static int test_FS();
-static int test_FILES();
-static int test_SIG();
-static int modified_VM();
-static int modified_FS();
-static int modified_FILES();
-static int modified_SIG();
-static void sig_child_defined_handler();
-static void sig_default_handler();
-
-
-static int fd_parent;
-static char file_name[25];
-static int parent_variable;
-static char cwd_parent[FILENAME_MAX];
-static int parent_got_signal, child_pid;
-
-char *TCID="clone02"; /* Test program identifier. */
-extern int Tst_count; /* Test Case counter for tst_* routines */
-
-struct test_case_t {
- int flags;
- int (*parent_fn)();
-} test_cases[] = {
- { FLAG_ALL, parent_test1},
- { FLAG_NONE, parent_test2}
-};
-
-int TST_TOTAL = sizeof(test_cases) / sizeof(test_cases[0]);
-
-
-int
-main(int ac, char **av)
-{
-
- int lc; /* loop counter */
- char *msg; /* message returned from parse_opts */
- void *child_stack; /* stack for child */
- int status, i;
-
- /* parse standard options */
- if ((msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL) {
- tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
- }
-
- /* perform global setup for test */
- setup();
-
- /* Allocate stack for child */
- if((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) {
- tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
- }
-
- /* check looping state if -c option given */
- for (lc=0; TEST_LOOPING(lc); lc++) {
-
- /* reset Tst_count in case we are looping. */
- Tst_count=0;
-
- for (i=0; i<TST_TOTAL; ++i) {
-
- /*Do test specific setup */
- if (!(test_setup())) {
- tst_resm(TWARN, "test_setup() failed,"
- "skipping this test case");
- continue;
- }
-
- /* Test the system call */
-#ifdef __hppa__
- TEST(clone(child_fn, child_stack,
- test_cases[i].flags, NULL));
-#else
- TEST(clone(child_fn, child_stack + CHILD_STACK_SIZE,
- test_cases[i].flags, NULL));
-#endif
-
- /* check return code */
- if (TEST_RETURN == -1) {
- tst_resm(TFAIL, "clone() Failed, errno = %d :"
- " %s", TEST_ERRNO,
- strerror(TEST_ERRNO));
- /* Cleanup & continue with next test case */
- test_cleanup();
- continue;
- }
-
- /* Wait for child to finish */
- if ((wait(&status)) < 0) {
- tst_resm(TWARN, "wait() failed, skipping this"
- " test case");
- /* Cleanup & continue with next test case */
- test_cleanup();
- continue;
- }
-
- /*
- * Check the return value from child function and
- * parent function. If both functions returned
- * successfully, test passed, else failed
- */
- if ((WIFEXITED(status)) && (WEXITSTATUS(status)) &&
- (test_cases[i].parent_fn())) {
- tst_resm(TPASS, "Test Passed");
- } else {
- tst_resm(TFAIL, "Test Failed");
- }
-
- /* Do test specific cleanup */
- test_cleanup();
- }
- } /* End for TEST_LOOPING */
-
- free(child_stack);
-
- /* cleanup and exit */
- cleanup();
-
- /*NOTREACHED*/
- return 0;
-
-} /* End main */
-
-/* setup() - performs all ONE TIME setup for this test */
-void
-setup()
-{
-
- /* capture signals */
- tst_sig(FORK, DEF_HANDLER, cleanup);
-
- /* Pause if that option was specified */
- TEST_PAUSE;
-
- /* Create temporary directory and 'cd' to it. */
- tst_tmpdir();
-
- /* Get unique file name for each child process */
- if ((sprintf(file_name, "parent_file_%d", getpid())) <= 0 ) {
- tst_brkm(TBROK, cleanup, "sprintf() failed");
- }
-
-} /* End setup() */
-
-
-/*
- *cleanup() - performs all ONE TIME cleanup for this test at
- * completion or premature exit.
- */
-void
-cleanup()
-{
-
- /*
- * print timing stats if that option was specified.
- * print errno log if that option was specified.
- */
- TEST_CLEANUP;
-
- /* Remove temperory file */
- if ((unlink(file_name)) == -1 ) {
- tst_resm(TWARN, "Couldn't delete file, %s", file_name);
- }
- tst_rmdir();
-
- /* exit with return code appropriate for results */
- tst_exit();
-} /* End cleanup() */
-
-/*
- * test_setup() - test specific setup function
- */
-int
-test_setup()
-{
-
- struct sigaction def_act;
-
- /* Save current working directory of parent */
- if ((getcwd(cwd_parent, sizeof(cwd_parent))) == NULL) {
- tst_resm(TWARN, "getcwd() failed in test_setup()");
- return 0;
- }
-
- /*
- * Set value for parent_variable in parent, which will be
- * changed by child in test_VM(), for testing CLONE_VM flag
- */
- parent_variable = PARENT_VALUE;
-
- /*
- * Open file from parent, which will be closed by
- * child in test_FILES(), used for testing CLONE_FILES flag
- */
- if ((fd_parent = open(file_name, O_CREAT | O_RDWR)) == -1) {
- tst_resm(TWARN, "open() failed in test_setup()");
- return 0;
- }
-
- /*
- * set parent_got_signal to FALSE, used for testing
- * CLONE_SIGHAND flag
- */
- parent_got_signal = FALSE;
-
- /* Setup signal handler for SIGUSR2 */
- def_act.sa_handler = sig_default_handler;
- def_act.sa_flags = SA_RESTART;
-
- if ((sigaction(SIGUSR2, &def_act, NULL)) == -1) {
- tst_resm(TWARN, "sigaction() failed in test_setup()\n");
- return 0;
- }
-
- /* test_setup() returns success*/
- return 1;
-}
-
-/*
- * test_cleanup() - test specific cleanup function
- */
-void
-test_cleanup()
-{
-
- /* Restore parent's working directory */
- if ((chdir(cwd_parent)) == -1) {
- /* we have to exit here */
- tst_brkm(TBROK, cleanup, "chdir() failed in test_cleanup()");
- }
-
-}
-
-/*
- * child_fn() - child function
- */
-int
-child_fn()
-{
-
- /* save child pid */
- child_pid = getpid();
-
- if (test_VM() && test_FILES() && test_FS() && test_SIG()) {
- return 1;
- }
- return 0;
-}
-
-/*
- * parent_test1() - parent function for test1
- */
-int
-parent_test1()
-{
-
- /*
- * For first test case (with all flags set), all resources are
- * shared between parent and child. So whatever changes made by
- * child should get reflected in parent also. modified_*()
- * functions check this. All of them should return 1 for
- * parent_test1() to return 1
- */
-
- if(modified_VM() && modified_FILES() && modified_FS() &&
- modified_SIG()) {
- return 1;
- }
- return 0;
-}
-
-/*
- * parent_test2 - parent function for test 2
- */
-int
-parent_test2()
-{
-
- /*
- * For second test case (with no resouce shared), all of the
- * modified_*() functions should return 0 for parent_test2()
- * to return 1
- */
-
- if ( modified_VM() || modified_FILES() || modified_FS() ||
- modified_SIG()) {
- return 0;
- }
- return 1;
-}
-
-/*
- * test_VM() - function to change parent_variable from child's
- * address space. If CLONE_VM flag is set, child shares
- * the memory space with parent so this will be visible
- * to parent also.
- */
-
-int
-test_VM()
-{
- parent_variable = CHILD_VALUE;
- return 1;
-}
-
-/*
- * test_FILES() - This function closes a file descriptor opened by
- * parent. If CLONE_FILES flag is set, the parent and
- * the child process share the same file descriptor
- * table. so this affects the parent also
- */
-int
-test_FILES()
-{
- if ((close(fd_parent)) == -1) {
- tst_resm(TWARN, "close() failed in test_FILES()");
- return 0;
- }
- return 1;
-}
-
-/*
- * test_FS() - This function changes the current working directory
- * of the child process. If CLONE_FS flag is set, this
- * will be visible to parent also.
- */
-int
-test_FS()
-{
- if((chdir("/tmp")) == -1) {
- tst_resm(TWARN, "chdir() failed in test_FS()");
- return 0;
- }
- return 1;
-}
-
-/*
- * test_SIG() - This function changes the signal handler for SIGUSR2
- * signal for child. If CLONE_SIGHAND flag is set, this
- * affects parent also.
- */
-int
-test_SIG()
-{
-
- struct sigaction new_act;
-
- new_act.sa_handler = sig_child_defined_handler;
- new_act.sa_flags = SA_RESTART;
-
- /* Set signal handler to sig_child_defined_handler */
- if ((sigaction(SIGUSR2, &new_act, NULL)) == -1) {
- tst_resm(TWARN, "signal() failed in test_SIG()");
- return 0;
- }
-
- /* Send SIGUSR2 signal to parent */
- if ((kill(getppid(), SIGUSR2)) == -1) {
- tst_resm(TWARN, "kill() failed in test_SIG()");
- return 0;
- }
- return 1;
-}
-
-/*
- * modified_VM() - This function is called by parent process to check
- * whether child's modification to parent_variable
- * is visible to parent
- */
-
-int
-modified_VM()
-{
-
- if (parent_variable == CHILD_VALUE) {
- /* child has modified parent_variable */
- return 1;
- }
- return 0;
-}
-
-/*
- * modified_FILES() - This function checks for file descriptor table
- * modifications done by child
- */
-int
-modified_FILES()
-{
- char buff[20];
-
- if (((read(fd_parent, buff, sizeof(buff))) == -1) &&
- (errno == EBADF)) {
- /* Child has closed this file descriptor */
- return 1;
- }
-
- /* close fd_parent*/
- if ((close(fd_parent)) == -1) {
- tst_resm(TWARN, "close() failed in modified_FILES()");
- }
-
- return 0;
-}
-
-/*
- * modified_FS() - This function checks parent's current working directory
- * to see whether its modified by child or not.
- */
-int
-modified_FS()
-{
- char cwd[FILENAME_MAX];
-
- if ((getcwd(cwd, sizeof(cwd))) == NULL) {
- tst_resm(TWARN, "getcwd() failed \n");
- }
-
- if ( !(strcmp(cwd, cwd_parent) )) {
- /* cwd hasn't changed */
- return 0;
- }
- return 1;
-}
-
-/*
- * modified_SIG() - This function checks whether child has changed
- * parent's signal handler for signal, SIGUSR2
- */
-int
-modified_SIG()
-{
-
- if (parent_got_signal) {
- /*
- * parent came through sig_child_defined_handler()
- * this means child has changed parent's handler
- */
- return 1;
- }
- return 0;
-}
-
-/*
- * sig_child_defined_handler() - Signal handler installed by child
- */
-void
-sig_child_defined_handler(int pid)
-{
- if((getpid()) == child_pid) {
- /* Child got signal, give warning */
- tst_resm(TWARN, "Child got SIGUSR2 signal");
- } else {
- parent_got_signal = TRUE;
- }
-}
-
-/* sig_default_handler() - Default handler for parent */
-void
-sig_default_handler()
-{
-}
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
+ *
+ * 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., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ */
+/**********************************************************
+ *
+ * TEST IDENTIFIER : clone02
+ *
+ * EXECUTED BY : anyone
+ *
+ * TEST TITLE : Functionality tests for clone(2)
+ *
+ * TEST CASE TOTAL : 2
+ *
+ * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
+ *
+ * SIGNALS
+ * Uses SIGUSR1 to pause before test if option set.
+ * (See the parse_opts(3) man page).
+ *
+ * DESCRIPTION
+ *
+ * Setup:
+ * Setup signal handling.
+ * Pause for SIGUSR1 if option specified.
+ * generate a unique file name fore each test instance
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * TEST1
+ * -----
+ * Call clone() with all resources shared.
+ *
+ * CHILD:
+ * modify the shared resources
+ * return 1 on success
+ * PARENT:
+ * wait for child to finish
+ * verify that the shared resourses are modified
+ * return 1 on success
+ * If parent & child returns successfully
+ * test passed
+ * else
+ * test failed
+ *
+ * TEST2
+ * -----
+ * Call clone() with no resources shared.
+ *
+ * CHILD:
+ * modify the resources in child's address space
+ * return 1 on success
+ * PARENT:
+ * wait for child to finish
+ * verify that the parent's resourses are not modified
+ * return 1 on success
+ * If parent & child returns successfully
+ * test passed
+ * else
+ * test failed
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ *
+ * USAGE: <for command-line>
+ * clone02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -h : Show help screen
+ * -f : Turn off functional testing
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -p : Pause for SIGUSR1 before starting
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ ****************************************************************/
+
+#include <errno.h>
+#include <sched.h>
+#include <fcntl.h>
+#include <sys/wait.h>
+#include "test.h"
+#include "usctest.h"
+
+#define CHILD_STACK_SIZE 1024
+#define FLAG_ALL CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | SIGCHLD
+#define FLAG_NONE SIGCHLD
+#define PARENT_VALUE 1
+#define CHILD_VALUE 2
+#define TRUE 1
+#define FALSE 0
+
+#if defined (__s390__) || (__s390x__)
+#define clone __clone
+extern int __clone(int(void*),void*,int,void*);
+#endif
+
+
+static void setup();
+static int test_setup();
+static void cleanup();
+static void test_cleanup();
+static int child_fn();
+static int parent_test1();
+static int parent_test2();
+static int test_VM();
+static int test_FS();
+static int test_FILES();
+static int test_SIG();
+static int modified_VM();
+static int modified_FS();
+static int modified_FILES();
+static int modified_SIG();
+static void sig_child_defined_handler();
+static void sig_default_handler();
+
+
+static int fd_parent;
+static char file_name[25];
+static int parent_variable;
+static char cwd_parent[FILENAME_MAX];
+static int parent_got_signal, child_pid;
+
+char *TCID="clone02"; /* Test program identifier. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+
+struct test_case_t {
+ int flags;
+ int (*parent_fn)();
+} test_cases[] = {
+ { FLAG_ALL, parent_test1},
+ { FLAG_NONE, parent_test2}
+};
+
+int TST_TOTAL = sizeof(test_cases) / sizeof(test_cases[0]);
+
+
+int
+main(int ac, char **av)
+{
+
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ void *child_stack; /* stack for child */
+ int status, i;
+
+ /* parse standard options */
+ if ((msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL) {
+ tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ /* perform global setup for test */
+ setup();
+
+ /* Allocate stack for child */
+ if((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) {
+ tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
+ }
+
+ /* check looping state if -c option given */
+ for (lc=0; TEST_LOOPING(lc); lc++) {
+
+ /* reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ for (i=0; i<TST_TOTAL; ++i) {
+
+ /*Do test specific setup */
+ if (!(test_setup())) {
+ tst_resm(TWARN, "test_setup() failed,"
+ "skipping this test case");
+ continue;
+ }
+
+ /* Test the system call */
+#ifdef __hppa__
+ TEST(clone(child_fn, child_stack,
+ test_cases[i].flags, NULL));
+#else
+ TEST(clone(child_fn, child_stack + CHILD_STACK_SIZE,
+ test_cases[i].flags, NULL));
+#endif
+
+ /* check return code */
+ if (TEST_RETURN == -1) {
+ tst_resm(TFAIL, "clone() Failed, errno = %d :"
+ " %s", TEST_ERRNO,
+ strerror(TEST_ERRNO));
+ /* Cleanup & continue with next test case */
+ test_cleanup();
+ continue;
+ }
+
+ /* Wait for child to finish */
+ if ((wait(&status)) < 0) {
+ tst_resm(TWARN, "wait() failed, skipping this"
+ " test case");
+ /* Cleanup & continue with next test case */
+ test_cleanup();
+ continue;
+ }
+
+ /*
+ * Check the return value from child function and
+ * parent function. If both functions returned
+ * successfully, test passed, else failed
+ */
+ if ((WIFEXITED(status)) && (WEXITSTATUS(status)) &&
+ (test_cases[i].parent_fn())) {
+ tst_resm(TPASS, "Test Passed");
+ } else {
+ tst_resm(TFAIL, "Test Failed");
+ }
+
+ /* Do test specific cleanup */
+ test_cleanup();
+ }
+ } /* End for TEST_LOOPING */
+
+ free(child_stack);
+
+ /* cleanup and exit */
+ cleanup();
+
+ /*NOTREACHED*/
+ return 0;
+
+} /* End main */
+
+/* setup() - performs all ONE TIME setup for this test */
+void
+setup()
+{
+
+ /* capture signals */
+ tst_sig(FORK, DEF_HANDLER, cleanup);
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+
+ /* Create temporary directory and 'cd' to it. */
+ tst_tmpdir();
+
+ /* Get unique file name for each child process */
+ if ((sprintf(file_name, "parent_file_%d", getpid())) <= 0 ) {
+ tst_brkm(TBROK, cleanup, "sprintf() failed");
+ }
+
+} /* End setup() */
+
+
+/*
+ *cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ */
+void
+cleanup()
+{
+
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* Remove temperory file */
+ if ((unlink(file_name)) == -1 ) {
+ tst_resm(TWARN, "Couldn't delete file, %s", file_name);
+ }
+ tst_rmdir();
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+} /* End cleanup() */
+
+/*
+ * test_setup() - test specific setup function
+ */
+int
+test_setup()
+{
+
+ struct sigaction def_act;
+
+ /* Save current working directory of parent */
+ if ((getcwd(cwd_parent, sizeof(cwd_parent))) == NULL) {
+ tst_resm(TWARN, "getcwd() failed in test_setup()");
+ return 0;
+ }
+
+ /*
+ * Set value for parent_variable in parent, which will be
+ * changed by child in test_VM(), for testing CLONE_VM flag
+ */
+ parent_variable = PARENT_VALUE;
+
+ /*
+ * Open file from parent, which will be closed by
+ * child in test_FILES(), used for testing CLONE_FILES flag
+ */
+ if ((fd_parent = open(file_name, O_CREAT | O_RDWR)) == -1) {
+ tst_resm(TWARN, "open() failed in test_setup()");
+ return 0;
+ }
+
+ /*
+ * set parent_got_signal to FALSE, used for testing
+ * CLONE_SIGHAND flag
+ */
+ parent_got_signal = FALSE;
+
+ /* Setup signal handler for SIGUSR2 */
+ def_act.sa_handler = sig_default_handler;
+ def_act.sa_flags = SA_RESTART;
+
+ if ((sigaction(SIGUSR2, &def_act, NULL)) == -1) {
+ tst_resm(TWARN, "sigaction() failed in test_setup()\n");
+ return 0;
+ }
+
+ /* test_setup() returns success*/
+ return 1;
+}
+
+/*
+ * test_cleanup() - test specific cleanup function
+ */
+void
+test_cleanup()
+{
+
+ /* Restore parent's working directory */
+ if ((chdir(cwd_parent)) == -1) {
+ /* we have to exit here */
+ tst_brkm(TBROK, cleanup, "chdir() failed in test_cleanup()");
+ }
+
+}
+
+/*
+ * child_fn() - child function
+ */
+int
+child_fn()
+{
+
+ /* save child pid */
+ child_pid = getpid();
+
+ if (test_VM() && test_FILES() && test_FS() && test_SIG()) {
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * parent_test1() - parent function for test1
+ */
+int
+parent_test1()
+{
+
+ /*
+ * For first test case (with all flags set), all resources are
+ * shared between parent and child. So whatever changes made by
+ * child should get reflected in parent also. modified_*()
+ * functions check this. All of them should return 1 for
+ * parent_test1() to return 1
+ */
+
+ if(modified_VM() && modified_FILES() && modified_FS() &&
+ modified_SIG()) {
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * parent_test2 - parent function for test 2
+ */
+int
+parent_test2()
+{
+
+ /*
+ * For second test case (with no resouce shared), all of the
+ * modified_*() functions should return 0 for parent_test2()
+ * to return 1
+ */
+
+ if ( modified_VM() || modified_FILES() || modified_FS() ||
+ modified_SIG()) {
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * test_VM() - function to change parent_variable from child's
+ * address space. If CLONE_VM flag is set, child shares
+ * the memory space with parent so this will be visible
+ * to parent also.
+ */
+
+int
+test_VM()
+{
+ parent_variable = CHILD_VALUE;
+ return 1;
+}
+
+/*
+ * test_FILES() - This function closes a file descriptor opened by
+ * parent. If CLONE_FILES flag is set, the parent and
+ * the child process share the same file descriptor
+ * table. so this affects the parent also
+ */
+int
+test_FILES()
+{
+ if ((close(fd_parent)) == -1) {
+ tst_resm(TWARN, "close() failed in test_FILES()");
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * test_FS() - This function changes the current working directory
+ * of the child process. If CLONE_FS flag is set, this
+ * will be visible to parent also.
+ */
+int
+test_FS()
+{
+ if((chdir("/tmp")) == -1) {
+ tst_resm(TWARN, "chdir() failed in test_FS()");
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * test_SIG() - This function changes the signal handler for SIGUSR2
+ * signal for child. If CLONE_SIGHAND flag is set, this
+ * affects parent also.
+ */
+int
+test_SIG()
+{
+
+ struct sigaction new_act;
+
+ new_act.sa_handler = sig_child_defined_handler;
+ new_act.sa_flags = SA_RESTART;
+
+ /* Set signal handler to sig_child_defined_handler */
+ if ((sigaction(SIGUSR2, &new_act, NULL)) == -1) {
+ tst_resm(TWARN, "signal() failed in test_SIG()");
+ return 0;
+ }
+
+ /* Send SIGUSR2 signal to parent */
+ if ((kill(getppid(), SIGUSR2)) == -1) {
+ tst_resm(TWARN, "kill() failed in test_SIG()");
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * modified_VM() - This function is called by parent process to check
+ * whether child's modification to parent_variable
+ * is visible to parent
+ */
+
+int
+modified_VM()
+{
+
+ if (parent_variable == CHILD_VALUE) {
+ /* child has modified parent_variable */
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * modified_FILES() - This function checks for file descriptor table
+ * modifications done by child
+ */
+int
+modified_FILES()
+{
+ char buff[20];
+
+ if (((read(fd_parent, buff, sizeof(buff))) == -1) &&
+ (errno == EBADF)) {
+ /* Child has closed this file descriptor */
+ return 1;
+ }
+
+ /* close fd_parent*/
+ if ((close(fd_parent)) == -1) {
+ tst_resm(TWARN, "close() failed in modified_FILES()");
+ }
+
+ return 0;
+}
+
+/*
+ * modified_FS() - This function checks parent's current working directory
+ * to see whether its modified by child or not.
+ */
+int
+modified_FS()
+{
+ char cwd[FILENAME_MAX];
+
+ if ((getcwd(cwd, sizeof(cwd))) == NULL) {
+ tst_resm(TWARN, "getcwd() failed \n");
+ }
+
+ if ( !(strcmp(cwd, cwd_parent) )) {
+ /* cwd hasn't changed */
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * modified_SIG() - This function checks whether child has changed
+ * parent's signal handler for signal, SIGUSR2
+ */
+int
+modified_SIG()
+{
+
+ if (parent_got_signal) {
+ /*
+ * parent came through sig_child_defined_handler()
+ * this means child has changed parent's handler
+ */
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * sig_child_defined_handler() - Signal handler installed by child
+ */
+void
+sig_child_defined_handler(int pid)
+{
+ if((getpid()) == child_pid) {
+ /* Child got signal, give warning */
+ tst_resm(TWARN, "Child got SIGUSR2 signal");
+ } else {
+ parent_got_signal = TRUE;
+ }
+}
+
+/* sig_default_handler() - Default handler for parent */
+void
+sig_default_handler()
+{
+}
diff --git a/testcases/kernel/syscalls/clone/clone03.c b/testcases/kernel/syscalls/clone/clone03.c
index 3fc16c0..97f879c 100644
--- a/testcases/kernel/syscalls/clone/clone03.c
+++ b/testcases/kernel/syscalls/clone/clone03.c
@@ -1,239 +1,239 @@
-/*
- * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
- *
- * 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., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- */
-/**********************************************************
- *
- * TEST IDENTIFIER : clone03
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : test for clone(2)
- *
- * TEST CASE TOTAL : 1
- *
- * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * DESCRIPTION
- * Check for equality of pid of child & return value of clone(2)
- *
- * Setup:
- * Setup signal handling.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Open a pipe.
- * Loop if the proper options are given.
- * Call clone(2) called without SIGCHLD
- *
- * CHILD:
- * writes the pid to pipe
- * PARENT:
- * reads child'd pid from pipe
- * if child's pid == return value from clone(2)
- * Test passed
- * else
- * test failed
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- * USAGE: <for command-line>
- * clone03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- * where, -c n : Run n copies concurrently.
- * -e : Turn on errno logging.
- * -h : Show help screen
- * -f : Turn off functional testing
- * -i n : Execute test n times.
- * -I x : Execute test for x seconds.
- * -p : Pause for SIGUSR1 before starting
- * -P x : Pause for x seconds between iterations.
- * -t : Turn on syscall timing.
- *
- ****************************************************************/
-
-#include <errno.h>
-#include <sched.h>
-#include "test.h"
-#include "usctest.h"
-
-#define CHILD_STACK_SIZE 1024
-
-#if defined (__s390__) || (__s390x__)
-#define clone __clone
-extern int __clone(int(void*),void*,int,void*);
-#endif
-
-
-static void setup();
-static void cleanup();
-static int child_fn();
-
-static int pfd[2];
-
-char *TCID="clone03"; /* Test program identifier. */
-int TST_TOTAL=1; /* Total number of test cases. */
-extern int Tst_count; /* Test Case counter for tst_* routines */
-
-int
-main(int ac, char **av)
-{
-
- int lc; /* loop counter */
- char *msg; /* message returned from parse_opts */
- void *child_stack; /* stack for child */
- char buff[10];
- int child_pid;
-
- /* parse standard options */
- if ((msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL) {
- tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
- }
-
- /* perform global setup for test */
- setup();
-
- /* Allocate stack for child */
- if((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) {
- tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
- }
-
- /* check looping state if -i option given */
- for (lc=0; TEST_LOOPING(lc); lc++) {
-
- /* reset Tst_count in case we are looping. */
- Tst_count=0;
-
- /* Open a pipe */
- if ((pipe(pfd)) == -1) {
- tst_brkm(TBROK, cleanup, "pipe() failed");
- }
-
- /*
- * Call clone(2)
- */
-#ifdef __hppa__
- TEST(clone(child_fn, child_stack, (int)NULL, NULL));
-#else
- TEST(clone(child_fn, child_stack + CHILD_STACK_SIZE, (int)NULL, NULL));
-#endif
-
- /* check return code */
- if (TEST_RETURN == -1) {
- tst_resm(TFAIL, "clone() Failed, errno = %d :"
- " %s", TEST_ERRNO, strerror(TEST_ERRNO));
- cleanup();
- }
-
- /* close write end from parent */
- if ((close(pfd[1])) == -1) {
- tst_brkm(TBROK, cleanup, "close(pfd[1]) failed");
- }
-
- /* Read pid from read end */
- if ((read(pfd[0], buff, sizeof(buff))) == -1) {
- tst_brkm(TBROK, cleanup, "read from pipe failed");
- }
-
- /* Close read end from parent */
- if ((close(pfd[0])) == -1) {
- tst_resm(TWARN, "close(pfd[0]) failed");
- }
-
- /* Get child's pid from pid string */
- child_pid = atoi(buff);
-
- if(TEST_RETURN == child_pid) {
- tst_resm(TPASS, "Test passed");
- } else {
- tst_resm(TFAIL, "Test failed");
- }
-
- } /* End for TEST_LOOPING */
-
- free(child_stack);
- /* cleanup and exit */
- cleanup();
-
- /*NOTREACHED*/
- return 0;
-
-} /* End main */
-
-/* setup() - performs all ONE TIME setup for this test */
-void
-setup()
-{
-
- /* capture signals */
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- /* Pause if that option was specified */
- TEST_PAUSE;
-
-} /* End setup() */
-
-
-/*
- *cleanup() - performs all ONE TIME cleanup for this test at
- * completion or premature exit.
- */
-void
-cleanup()
-{
-
- /*
- * print timing stats if that option was specified.
- * print errno log if that option was specified.
- */
- TEST_CLEANUP;
-
- /* exit with return code appropriate for results */
- tst_exit();
-} /* End cleanup() */
-
-/*
- * child_fn() - function executed by child
- */
-
-int
-child_fn(void)
-{
-
- char pid[10];
-
- /* Close read end from child */
- if ((close(pfd[0])) == -1) {
- tst_brkm(TBROK, cleanup, "close(pfd[0]) failed");
- }
-
- /* Construct pid string */
- sprintf(pid,"%d", getpid());
-
- /* Write pid string to pipe */
- if ((write(pfd[1], pid, sizeof(pid))) == -1) {
- tst_brkm(TBROK, cleanup, "write to pipe failed");
- }
-
- /* Close write end of pipe from child */
- if ((close(pfd[1])) == -1) {
- tst_resm(TWARN, "close(pfd[1]) failed");
- }
- return 1;
-}
-
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
+ *
+ * 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., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ */
+/**********************************************************
+ *
+ * TEST IDENTIFIER : clone03
+ *
+ * EXECUTED BY : anyone
+ *
+ * TEST TITLE : test for clone(2)
+ *
+ * TEST CASE TOTAL : 1
+ *
+ * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
+ *
+ * SIGNALS
+ * Uses SIGUSR1 to pause before test if option set.
+ * (See the parse_opts(3) man page).
+ *
+ * DESCRIPTION
+ * Check for equality of pid of child & return value of clone(2)
+ *
+ * Setup:
+ * Setup signal handling.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Open a pipe.
+ * Loop if the proper options are given.
+ * Call clone(2) called without SIGCHLD
+ *
+ * CHILD:
+ * writes the pid to pipe
+ * PARENT:
+ * reads child'd pid from pipe
+ * if child's pid == return value from clone(2)
+ * Test passed
+ * else
+ * test failed
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ *
+ * USAGE: <for command-line>
+ * clone03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -h : Show help screen
+ * -f : Turn off functional testing
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -p : Pause for SIGUSR1 before starting
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ ****************************************************************/
+
+#include <errno.h>
+#include <sched.h>
+#include "test.h"
+#include "usctest.h"
+
+#define CHILD_STACK_SIZE 1024
+
+#if defined (__s390__) || (__s390x__)
+#define clone __clone
+extern int __clone(int(void*),void*,int,void*);
+#endif
+
+
+static void setup();
+static void cleanup();
+static int child_fn();
+
+static int pfd[2];
+
+char *TCID="clone03"; /* Test program identifier. */
+int TST_TOTAL=1; /* Total number of test cases. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+
+int
+main(int ac, char **av)
+{
+
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ void *child_stack; /* stack for child */
+ char buff[10];
+ int child_pid;
+
+ /* parse standard options */
+ if ((msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL) {
+ tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ /* perform global setup for test */
+ setup();
+
+ /* Allocate stack for child */
+ if((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) {
+ tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
+ }
+
+ /* check looping state if -i option given */
+ for (lc=0; TEST_LOOPING(lc); lc++) {
+
+ /* reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ /* Open a pipe */
+ if ((pipe(pfd)) == -1) {
+ tst_brkm(TBROK, cleanup, "pipe() failed");
+ }
+
+ /*
+ * Call clone(2)
+ */
+#ifdef __hppa__
+ TEST(clone(child_fn, child_stack, (int)NULL, NULL));
+#else
+ TEST(clone(child_fn, child_stack + CHILD_STACK_SIZE, (int)NULL, NULL));
+#endif
+
+ /* check return code */
+ if (TEST_RETURN == -1) {
+ tst_resm(TFAIL, "clone() Failed, errno = %d :"
+ " %s", TEST_ERRNO, strerror(TEST_ERRNO));
+ cleanup();
+ }
+
+ /* close write end from parent */
+ if ((close(pfd[1])) == -1) {
+ tst_brkm(TBROK, cleanup, "close(pfd[1]) failed");
+ }
+
+ /* Read pid from read end */
+ if ((read(pfd[0], buff, sizeof(buff))) == -1) {
+ tst_brkm(TBROK, cleanup, "read from pipe failed");
+ }
+
+ /* Close read end from parent */
+ if ((close(pfd[0])) == -1) {
+ tst_resm(TWARN, "close(pfd[0]) failed");
+ }
+
+ /* Get child's pid from pid string */
+ child_pid = atoi(buff);
+
+ if(TEST_RETURN == child_pid) {
+ tst_resm(TPASS, "Test passed");
+ } else {
+ tst_resm(TFAIL, "Test failed");
+ }
+
+ } /* End for TEST_LOOPING */
+
+ free(child_stack);
+ /* cleanup and exit */
+ cleanup();
+
+ /*NOTREACHED*/
+ return 0;
+
+} /* End main */
+
+/* setup() - performs all ONE TIME setup for this test */
+void
+setup()
+{
+
+ /* capture signals */
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+
+} /* End setup() */
+
+
+/*
+ *cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ */
+void
+cleanup()
+{
+
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+} /* End cleanup() */
+
+/*
+ * child_fn() - function executed by child
+ */
+
+int
+child_fn(void)
+{
+
+ char pid[10];
+
+ /* Close read end from child */
+ if ((close(pfd[0])) == -1) {
+ tst_brkm(TBROK, cleanup, "close(pfd[0]) failed");
+ }
+
+ /* Construct pid string */
+ sprintf(pid,"%d", getpid());
+
+ /* Write pid string to pipe */
+ if ((write(pfd[1], pid, sizeof(pid))) == -1) {
+ tst_brkm(TBROK, cleanup, "write to pipe failed");
+ }
+
+ /* Close write end of pipe from child */
+ if ((close(pfd[1])) == -1) {
+ tst_resm(TWARN, "close(pfd[1]) failed");
+ }
+ return 1;
+}
+
diff --git a/testcases/kernel/syscalls/clone/clone04.c b/testcases/kernel/syscalls/clone/clone04.c
index 4fa148a..b7cec2f 100644
--- a/testcases/kernel/syscalls/clone/clone04.c
+++ b/testcases/kernel/syscalls/clone/clone04.c
@@ -1,217 +1,217 @@
-/*
- * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
- *
- * 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 to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
- /*******************************************************************
- *
- * TEST IDENTIFIER : clone04
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : test for checking error conditions for clone(2)
- *
- * TEST CASE TOTAL : 2
- *
- * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * DESCRIPTION
- * Verify that,
- * 1) clone(2) returns -1 and sets errno to EINVAL if the specified
- * child function is invalid.
- * 2) clone(2) returns -1 and sets errno to EINVAL if
- * child stack is NULL
- *
- * ALGORITHM
- * 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)) &
- * (errno set == expected errno)
- * Issue sys call fails with expected return value and errno.
- * Otherwise,
- * Issue sys call returns unexpected value.
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- * USAGE: <for command-line>
- * clone04 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- * where, -c n : Run n copies concurrently.
- * -e : Turn on errno logging.
- * -h : Show help screen
- * -f : Turn off functional testing
- * -i n : Execute test n times.
- * -I x : Execute test for x seconds.
- * -p : Pause for SIGUSR1 before starting
- * -P x : Pause for x seconds between iterations.
- * -t : Turn on syscall timing.
- *
- *********************************************************************/
-#include <sched.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include "test.h"
-#include "usctest.h"
-
-#define CHILD_STACK_SIZE 1024
-
-#if defined (__s390__) || (__s390x__)
-#define clone __clone
-extern int __clone(int(void*),void*,int,void*);
-#endif
-
-static void cleanup(void);
-static void setup(void);
-static int child_fn();
-
-char *TCID= "clone04";
-extern int Tst_count;
-
-static int exp_enos[] = {EINVAL, 0}; /* 0 terminated list of *
- * expected errnos */
-static struct test_case_t {
- int (*child_fn)();
- int exp_errno;
- char err_desc[10];
-} test_cases[] = {
- { (int)NULL, EINVAL, "EINVAL" },
- { child_fn, EINVAL, "EINVAL" },
-};
-
-int TST_TOTAL = sizeof(test_cases) / sizeof(test_cases[0]);
-
-int
-main(int ac, char **av)
-{
- int lc, ind; /* loop counter */
- char *msg; /* message returned from parse_opts */
- void *child_stack;
- void *test_stack;
-
- /* parse standard options */
- if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL))
- != (char *) NULL) {
- tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
- }
-
- setup(); /* global setup */
-
- /* Allocate stack for child */
- child_stack = (void *) malloc(CHILD_STACK_SIZE);
-
- /* The following loop checks looping state if -i option given */
-
- for (lc = 0; TEST_LOOPING(lc); lc++) {
- /* reset Tst_count in case we are looping */
- Tst_count = 0;
-
- for (ind = 0; ind < TST_TOTAL; ind++) {
- if (ind == 0) {
- if (child_stack == NULL) {
- tst_resm(TWARN, "Can not allocate stack for"
- "child, skipping test case");
- continue;
- }
-#ifdef __hppa__
- test_stack = child_stack;
-#else
- test_stack = child_stack + CHILD_STACK_SIZE;
-#endif
- }
- else
- test_stack = (void *) NULL;
-
- /*
- * call the system call with the TEST() macro
- */
- TEST(clone(test_cases[ind].child_fn, test_stack,
- (int)NULL, NULL));
-
- if ((TEST_RETURN == -1) &&
- (TEST_ERRNO == test_cases[ind].exp_errno)) {
- tst_resm(TPASS, "expected failure; Got %s",
- test_cases[ind].err_desc);
- } else {
- tst_resm(TFAIL, "Call failed to produce "
- "expected error; Expected errno: %d "
- "Got : %d, %s",
- test_cases[ind].exp_errno,
- TEST_ERRNO, strerror(TEST_ERRNO));
- }
- TEST_ERROR_LOG(TEST_ERRNO);
- }
- }
-
- free(child_stack);
-
- cleanup();
-
- /*NOTREACHED*/
- return 0;
-
-}
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void
-setup(void)
-{
-
- /* capture signals */
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- /* Set up the expected error numbers for -e option */
- TEST_EXP_ENOS(exp_enos);
-
- /* Pause if that option was specified */
- TEST_PAUSE;
-
-}
-
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * or premature exit.
- */
-void
-cleanup(void)
-{
-
- /*
- * print timing stats if that option was specified.
- * print errno log if that option was specified.
- */
- TEST_CLEANUP;
-
- /* exit with return code appropriate for results */
- tst_exit();
-}
-
-/*
- * child_fn() - Child function
- */
-int
-child_fn()
-{
- return 1;
-}
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
+ *
+ * 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 to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+ /*******************************************************************
+ *
+ * TEST IDENTIFIER : clone04
+ *
+ * EXECUTED BY : anyone
+ *
+ * TEST TITLE : test for checking error conditions for clone(2)
+ *
+ * TEST CASE TOTAL : 2
+ *
+ * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
+ *
+ * SIGNALS
+ * Uses SIGUSR1 to pause before test if option set.
+ * (See the parse_opts(3) man page).
+ *
+ * DESCRIPTION
+ * Verify that,
+ * 1) clone(2) returns -1 and sets errno to EINVAL if the specified
+ * child function is invalid.
+ * 2) clone(2) returns -1 and sets errno to EINVAL if
+ * child stack is NULL
+ *
+ * ALGORITHM
+ * 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)) &
+ * (errno set == expected errno)
+ * Issue sys call fails with expected return value and errno.
+ * Otherwise,
+ * Issue sys call returns unexpected value.
+ *
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ *
+ * USAGE: <for command-line>
+ * clone04 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -h : Show help screen
+ * -f : Turn off functional testing
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -p : Pause for SIGUSR1 before starting
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ *********************************************************************/
+#include <sched.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include "test.h"
+#include "usctest.h"
+
+#define CHILD_STACK_SIZE 1024
+
+#if defined (__s390__) || (__s390x__)
+#define clone __clone
+extern int __clone(int(void*),void*,int,void*);
+#endif
+
+static void cleanup(void);
+static void setup(void);
+static int child_fn();
+
+char *TCID= "clone04";
+extern int Tst_count;
+
+static int exp_enos[] = {EINVAL, 0}; /* 0 terminated list of *
+ * expected errnos */
+static struct test_case_t {
+ int (*child_fn)();
+ int exp_errno;
+ char err_desc[10];
+} test_cases[] = {
+ { (int)NULL, EINVAL, "EINVAL" },
+ { child_fn, EINVAL, "EINVAL" },
+};
+
+int TST_TOTAL = sizeof(test_cases) / sizeof(test_cases[0]);
+
+int
+main(int ac, char **av)
+{
+ int lc, ind; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ void *child_stack;
+ void *test_stack;
+
+ /* parse standard options */
+ if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL))
+ != (char *) NULL) {
+ tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ setup(); /* global setup */
+
+ /* Allocate stack for child */
+ child_stack = (void *) malloc(CHILD_STACK_SIZE);
+
+ /* The following loop checks looping state if -i option given */
+
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ /* reset Tst_count in case we are looping */
+ Tst_count = 0;
+
+ for (ind = 0; ind < TST_TOTAL; ind++) {
+ if (ind == 0) {
+ if (child_stack == NULL) {
+ tst_resm(TWARN, "Can not allocate stack for"
+ "child, skipping test case");
+ continue;
+ }
+#ifdef __hppa__
+ test_stack = child_stack;
+#else
+ test_stack = child_stack + CHILD_STACK_SIZE;
+#endif
+ }
+ else
+ test_stack = (void *) NULL;
+
+ /*
+ * call the system call with the TEST() macro
+ */
+ TEST(clone(test_cases[ind].child_fn, test_stack,
+ (int)NULL, NULL));
+
+ if ((TEST_RETURN == -1) &&
+ (TEST_ERRNO == test_cases[ind].exp_errno)) {
+ tst_resm(TPASS, "expected failure; Got %s",
+ test_cases[ind].err_desc);
+ } else {
+ tst_resm(TFAIL, "Call failed to produce "
+ "expected error; Expected errno: %d "
+ "Got : %d, %s",
+ test_cases[ind].exp_errno,
+ TEST_ERRNO, strerror(TEST_ERRNO));
+ }
+ TEST_ERROR_LOG(TEST_ERRNO);
+ }
+ }
+
+ free(child_stack);
+
+ cleanup();
+
+ /*NOTREACHED*/
+ return 0;
+
+}
+
+/*
+ * setup() - performs all the ONE TIME setup for this test.
+ */
+void
+setup(void)
+{
+
+ /* capture signals */
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ /* Set up the expected error numbers for -e option */
+ TEST_EXP_ENOS(exp_enos);
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+
+}
+
+/*
+ * cleanup() - performs all the ONE TIME cleanup for this test at completion
+ * or premature exit.
+ */
+void
+cleanup(void)
+{
+
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+}
+
+/*
+ * child_fn() - Child function
+ */
+int
+child_fn()
+{
+ return 1;
+}
diff --git a/testcases/kernel/syscalls/clone/clone05.c b/testcases/kernel/syscalls/clone/clone05.c
index 9897c0b..9672cae 100644
--- a/testcases/kernel/syscalls/clone/clone05.c
+++ b/testcases/kernel/syscalls/clone/clone05.c
@@ -1,198 +1,198 @@
-/*
- * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
- *
- * 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., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- */
-/**********************************************************
- *
- * TEST IDENTIFIER : clone05
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : test for CLONE_VFORK flag
- *
- * TEST CASE TOTAL : 1
- *
- * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * DESCRIPTION
- * Call clone() with CLONE_VFORK flag set. verify that
- * execution of parent is suspended until child finishes
- *
- * Setup:
- * Setup signal handling.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Loop if the proper options are given.
- * Execute system call with CLONE_VM & CLONE_VFORK flags
- *
- * CHILD:
- * sleeps for a second, changes parent_variable to 1
- * PARENT:
- * If return code is not -1 and parent_variable == 1
- * test passed
- * else
- * test failed
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- * USAGE: <for command-line>
- * clone05 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- * where, -c n : Run n copies concurrently.
- * -e : Turn on errno logging.
- * -h : Show help screen
- * -f : Turn off functional testing
- * -i n : Execute test n times.
- * -I x : Execute test for x seconds.
- * -p : Pause for SIGUSR1 before starting
- * -P x : Pause for x seconds between iterations.
- * -t : Turn on syscall timing.
- ****************************************************************/
-
-#include <errno.h>
-#include <sched.h>
-#include <sys/wait.h>
-#include "test.h"
-#include "usctest.h"
-
-#if defined (__s390__) || (__s390x__)
-#define clone __clone
-extern int __clone(int(void*),void*,int,void*);
-#endif
-
-
-#define CHILD_STACK_SIZE 1024
-#define FLAG CLONE_VM | CLONE_VFORK
-
-static void setup();
-static void cleanup();
-static int child_fn();
-
-static int parent_variable = 0;
-
-char *TCID="clone05"; /* Test program identifier. */
-int TST_TOTAL=1; /* Total number of test cases. */
-extern int Tst_count; /* Test Case counter for tst_* routines */
-
-int
-main(int ac, char **av)
-{
-
- int lc; /* loop counter */
- char *msg; /* message returned from parse_opts */
- void *child_stack; /* stack for child */
-
- /* parse standard options */
- if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL))
- != (char *)NULL) {
- tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
- }
-
- /* perform global setup for test */
- setup();
-
- /* Allocate stack for child */
- if((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) {
- tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
- }
-
- /* check looping state if -i option given */
- for (lc=0; TEST_LOOPING(lc); lc++) {
-
- /* reset Tst_count in case we are looping. */
- Tst_count=0;
-
- /*
- * Call clone(2)
- */
-#ifdef __hppa__
- TEST(clone(child_fn, child_stack, FLAG, NULL));
-#else
- TEST(clone(child_fn, child_stack + CHILD_STACK_SIZE, FLAG, NULL));
-#endif
-
- /* check return code & parent_variable*/
- if ((TEST_RETURN != -1) && (parent_variable)) {
- tst_resm(TPASS, "Test Passed");
- } else {
- tst_resm(TFAIL, "Test Failed");
- }
-
- /* Reset parent_variable */
- parent_variable = 0;
- } /* End for TEST_LOOPING */
-
- free (child_stack);
-
- /* cleanup and exit */
- cleanup();
-
- /*NOTREACHED*/
- return 0;
-
-} /* End main */
-
-/* setup() - performs all ONE TIME setup for this test */
-void
-setup()
-{
-
- /* capture signals */
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- /* Pause if that option was specified */
- TEST_PAUSE;
-
-} /* End setup() */
-
-/*
- *cleanup() - performs all ONE TIME cleanup for this test at
- * completion or premature exit.
- */
-void
-cleanup()
-{
-
- /*
- * print timing stats if that option was specified.
- * print errno log if that option was specified.
- */
- TEST_CLEANUP;
-
- /* exit with return code appropriate for results */
- tst_exit();
-
-} /* End cleanup() */
-
-
-/*
- * do_child() - function executed by child
- */
-int
-child_fn()
-{
- /*
- * Sleep for a second, to ensure that child does not exit
- * immediately
- */
- sleep(1);
- parent_variable = 1;
- return 1;
-}
-
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
+ *
+ * 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., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ */
+/**********************************************************
+ *
+ * TEST IDENTIFIER : clone05
+ *
+ * EXECUTED BY : anyone
+ *
+ * TEST TITLE : test for CLONE_VFORK flag
+ *
+ * TEST CASE TOTAL : 1
+ *
+ * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
+ *
+ * SIGNALS
+ * Uses SIGUSR1 to pause before test if option set.
+ * (See the parse_opts(3) man page).
+ *
+ * DESCRIPTION
+ * Call clone() with CLONE_VFORK flag set. verify that
+ * execution of parent is suspended until child finishes
+ *
+ * Setup:
+ * Setup signal handling.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Execute system call with CLONE_VM & CLONE_VFORK flags
+ *
+ * CHILD:
+ * sleeps for a second, changes parent_variable to 1
+ * PARENT:
+ * If return code is not -1 and parent_variable == 1
+ * test passed
+ * else
+ * test failed
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ *
+ * USAGE: <for command-line>
+ * clone05 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -h : Show help screen
+ * -f : Turn off functional testing
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -p : Pause for SIGUSR1 before starting
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ ****************************************************************/
+
+#include <errno.h>
+#include <sched.h>
+#include <sys/wait.h>
+#include "test.h"
+#include "usctest.h"
+
+#if defined (__s390__) || (__s390x__)
+#define clone __clone
+extern int __clone(int(void*),void*,int,void*);
+#endif
+
+
+#define CHILD_STACK_SIZE 1024
+#define FLAG CLONE_VM | CLONE_VFORK
+
+static void setup();
+static void cleanup();
+static int child_fn();
+
+static int parent_variable = 0;
+
+char *TCID="clone05"; /* Test program identifier. */
+int TST_TOTAL=1; /* Total number of test cases. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+
+int
+main(int ac, char **av)
+{
+
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ void *child_stack; /* stack for child */
+
+ /* parse standard options */
+ if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL))
+ != (char *)NULL) {
+ tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ /* perform global setup for test */
+ setup();
+
+ /* Allocate stack for child */
+ if((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) {
+ tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
+ }
+
+ /* check looping state if -i option given */
+ for (lc=0; TEST_LOOPING(lc); lc++) {
+
+ /* reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ /*
+ * Call clone(2)
+ */
+#ifdef __hppa__
+ TEST(clone(child_fn, child_stack, FLAG, NULL));
+#else
+ TEST(clone(child_fn, child_stack + CHILD_STACK_SIZE, FLAG, NULL));
+#endif
+
+ /* check return code & parent_variable*/
+ if ((TEST_RETURN != -1) && (parent_variable)) {
+ tst_resm(TPASS, "Test Passed");
+ } else {
+ tst_resm(TFAIL, "Test Failed");
+ }
+
+ /* Reset parent_variable */
+ parent_variable = 0;
+ } /* End for TEST_LOOPING */
+
+ free (child_stack);
+
+ /* cleanup and exit */
+ cleanup();
+
+ /*NOTREACHED*/
+ return 0;
+
+} /* End main */
+
+/* setup() - performs all ONE TIME setup for this test */
+void
+setup()
+{
+
+ /* capture signals */
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+
+} /* End setup() */
+
+/*
+ *cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ */
+void
+cleanup()
+{
+
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+
+} /* End cleanup() */
+
+
+/*
+ * do_child() - function executed by child
+ */
+int
+child_fn()
+{
+ /*
+ * Sleep for a second, to ensure that child does not exit
+ * immediately
+ */
+ sleep(1);
+ parent_variable = 1;
+ return 1;
+}
+
diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
index 2eb4424..8ed5715 100644
--- a/testcases/kernel/syscalls/clone/clone06.c
+++ b/testcases/kernel/syscalls/clone/clone06.c
@@ -1,244 +1,244 @@
-/*
- * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
- *
- * 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., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- */
-/**********************************************************
- *
- * TEST IDENTIFIER : clone06
- *
- * EXECUTED BY : anyone
- *
- * TEST TITLE : Test to verify inheritance of environment variables.
- *
- * TEST CASE TOTAL : 1
- *
- * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * DESCRIPTION
- * Test to verify inheritance of environment variables by child.
- *
- * Setup:
- * Setup signal handling.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Loop if the proper options are given.
- * Call clone()
- *
- * CHILD:
- * get the value for environment variable, TERM and write it
- * to pipe.
- *
- * PARENT:
- * Reads the value for environment variable, TERM from pipe.
- * Compare child's TERM value with that of parent,
- * if same,
- * Test Passed.
- * else
- * Test failed.
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- * USAGE: <for command-line>
- * clone06 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
- * where, -c n : Run n copies concurrently.
- * -e : Turn on errno logging.
- * -h : Show help screen
- * -f : Turn off functional testing
- * -i n : Execute test n times.
- * -I x : Execute test for x seconds.
- * -p : Pause for SIGUSR1 before starting
- * -P x : Pause for x seconds between iterations.
- * -t : Turn on syscall timing.
- *
- ****************************************************************/
-
-#include <errno.h>
-#include <sched.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include "test.h"
-#include "usctest.h"
-
-#if defined (__s390__) || (__s390x__)
-#define clone __clone
-extern int __clone(int(void*),void*,int,void*);
-#endif
-
-
-#define CHILD_STACK_SIZE 1024
-#define MAX_LINE_LENGTH 256
-
-static void setup();
-static void cleanup();
-static int child_environ();
-
-static int pfd[2];
-
-char *TCID = "clone06"; /* Test program identifier. */
-int TST_TOTAL = 1; /* Total number of test cases. */
-extern int Tst_count; /* Test Case counter for tst_* routines */
-
-int
-main(int ac, char **av)
-{
-
- int lc; /* loop counter */
- char *msg; /* message returned from parse_opts */
- void *child_stack; /* stack for child */
- char *parent_env;
- char buff[MAX_LINE_LENGTH];
-
- /* parse standard options */
- if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL))
- != (char *)NULL) {
- tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
- }
-
- /* perform global setup for test */
- setup();
-
- /* Allocate stack for child */
- if((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) {
- tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
- }
-
- /* check looping state if -i option given */
- for (lc = 0; TEST_LOOPING(lc); lc++) {
-
- /* reset Tst_count in case we are looping. */
- Tst_count = 0;
-
- /* Open a pipe */
- if ((pipe(pfd)) == -1) {
- tst_brkm(TBROK, cleanup, "pipe() failed");
- }
-
- /*
- * Call clone(2)
- */
-#ifdef __hppa__
- TEST(clone(child_environ, child_stack, (int)NULL, NULL));
-#else
- TEST(clone(child_environ, child_stack + CHILD_STACK_SIZE, (int)NULL, NULL));
-#endif
-
- /* check return code */
- if (TEST_RETURN == -1) {
- tst_resm(TFAIL, "clone() Failed, errno = %d :"
- " %s", TEST_ERRNO, strerror(TEST_ERRNO));
- cleanup();
- }
-
- /* close write end from parent */
- if ((close(pfd[1])) == -1) {
- tst_resm(TWARN, "close(pfd[1]) failed");
- }
-
- /* Read env var from read end */
- if ((read(pfd[0], buff, sizeof(buff))) == -1) {
- tst_brkm(TBROK, cleanup, "read from pipe failed");
- }
-
- /* Close read end from parent */
- if ((close(pfd[0])) == -1) {
- tst_resm(TWARN, "close(pfd[0]) failed");
- }
-
- parent_env = getenv("TERM");
-
- if ((strcmp(buff, parent_env)) == 0) {
- tst_resm(TPASS, "Test Passed");
- } else {
- tst_resm(TFAIL, "Test Failed");
- }
- } /* End for TEST_LOOPING */
-
- free(child_stack);
-
- /* cleanup and exit */
- cleanup();
-
- /*NOTREACHED*/
- return 0;
-
-} /* End main */
-
-/* setup() - performs all ONE TIME setup for this test */
-void
-setup()
-{
- /* capture signals */
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- /* Pause if that option was specified */
- TEST_PAUSE;
-} /* End setup() */
-
-
-/*
- *cleanup() - performs all ONE TIME cleanup for this test at
- * completion or premature exit.
- */
-void
-cleanup()
-{
- /*
- * print timing stats if that option was specified.
- * print errno log if that option was specified.
- */
- TEST_CLEANUP;
-
- /* exit with return code appropriate for results */
- tst_exit();
-} /* End cleanup() */
-
-/*
- * child_environ() - function executed by child.
- * Gets the value for environment variable,TERM &
- * writes it to a pipe.
- */
-int
-child_environ(void)
-{
-
- char var[MAX_LINE_LENGTH];
-
- /* Close read end from child */
- if ((close(pfd[0])) == -1) {
- tst_brkm(TBROK, cleanup, "close(pfd[0]) failed");
- }
-
- if ((sprintf(var, getenv("TERM"))) <= 0){
- tst_resm(TWARN, "sprintf() failed");
- }
-
- if ((write(pfd[1], var, MAX_LINE_LENGTH)) == -1) {
- tst_resm(TWARN, "write to pipe failed");
- }
-
- /* Close write end of pipe from child */
- if ((close(pfd[1])) == -1) {
- tst_resm(TWARN, "close(pfd[1]) failed");
- }
-
- return 0;
-}
-
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
+ *
+ * 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., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ */
+/**********************************************************
+ *
+ * TEST IDENTIFIER : clone06
+ *
+ * EXECUTED BY : anyone
+ *
+ * TEST TITLE : Test to verify inheritance of environment variables.
+ *
+ * TEST CASE TOTAL : 1
+ *
+ * AUTHOR : Saji Kumar.V.R <saji.kumar@wipro.com>
+ *
+ * SIGNALS
+ * Uses SIGUSR1 to pause before test if option set.
+ * (See the parse_opts(3) man page).
+ *
+ * DESCRIPTION
+ * Test to verify inheritance of environment variables by child.
+ *
+ * Setup:
+ * Setup signal handling.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Call clone()
+ *
+ * CHILD:
+ * get the value for environment variable, TERM and write it
+ * to pipe.
+ *
+ * PARENT:
+ * Reads the value for environment variable, TERM from pipe.
+ * Compare child's TERM value with that of parent,
+ * if same,
+ * Test Passed.
+ * else
+ * Test failed.
+ *
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ *
+ * USAGE: <for command-line>
+ * clone06 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-h] [-f] [-p]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -h : Show help screen
+ * -f : Turn off functional testing
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -p : Pause for SIGUSR1 before starting
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ ****************************************************************/
+
+#include <errno.h>
+#include <sched.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include "test.h"
+#include "usctest.h"
+
+#if defined (__s390__) || (__s390x__)
+#define clone __clone
+extern int __clone(int(void*),void*,int,void*);
+#endif
+
+
+#define CHILD_STACK_SIZE 1024
+#define MAX_LINE_LENGTH 256
+
+static void setup();
+static void cleanup();
+static int child_environ();
+
+static int pfd[2];
+
+char *TCID = "clone06"; /* Test program identifier. */
+int TST_TOTAL = 1; /* Total number of test cases. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+
+int
+main(int ac, char **av)
+{
+
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ void *child_stack; /* stack for child */
+ char *parent_env;
+ char buff[MAX_LINE_LENGTH];
+
+ /* parse standard options */
+ if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL))
+ != (char *)NULL) {
+ tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ /* perform global setup for test */
+ setup();
+
+ /* Allocate stack for child */
+ if((child_stack = (void *) malloc(CHILD_STACK_SIZE)) == NULL) {
+ tst_brkm(TBROK, cleanup, "Cannot allocate stack for child");
+ }
+
+ /* check looping state if -i option given */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+
+ /* reset Tst_count in case we are looping. */
+ Tst_count = 0;
+
+ /* Open a pipe */
+ if ((pipe(pfd)) == -1) {
+ tst_brkm(TBROK, cleanup, "pipe() failed");
+ }
+
+ /*
+ * Call clone(2)
+ */
+#ifdef __hppa__
+ TEST(clone(child_environ, child_stack, (int)NULL, NULL));
+#else
+ TEST(clone(child_environ, child_stack + CHILD_STACK_SIZE, (int)NULL, NULL));
+#endif
+
+ /* check return code */
+ if (TEST_RETURN == -1) {
+ tst_resm(TFAIL, "clone() Failed, errno = %d :"
+ " %s", TEST_ERRNO, strerror(TEST_ERRNO));
+ cleanup();
+ }
+
+ /* close write end from parent */
+ if ((close(pfd[1])) == -1) {
+ tst_resm(TWARN, "close(pfd[1]) failed");
+ }
+
+ /* Read env var from read end */
+ if ((read(pfd[0], buff, sizeof(buff))) == -1) {
+ tst_brkm(TBROK, cleanup, "read from pipe failed");
+ }
+
+ /* Close read end from parent */
+ if ((close(pfd[0])) == -1) {
+ tst_resm(TWARN, "close(pfd[0]) failed");
+ }
+
+ parent_env = getenv("TERM");
+
+ if ((strcmp(buff, parent_env)) == 0) {
+ tst_resm(TPASS, "Test Passed");
+ } else {
+ tst_resm(TFAIL, "Test Failed");
+ }
+ } /* End for TEST_LOOPING */
+
+ free(child_stack);
+
+ /* cleanup and exit */
+ cleanup();
+
+ /*NOTREACHED*/
+ return 0;
+
+} /* End main */
+
+/* setup() - performs all ONE TIME setup for this test */
+void
+setup()
+{
+ /* capture signals */
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+} /* End setup() */
+
+
+/*
+ *cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ */
+void
+cleanup()
+{
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+} /* End cleanup() */
+
+/*
+ * child_environ() - function executed by child.
+ * Gets the value for environment variable,TERM &
+ * writes it to a pipe.
+ */
+int
+child_environ(void)
+{
+
+ char var[MAX_LINE_LENGTH];
+
+ /* Close read end from child */
+ if ((close(pfd[0])) == -1) {
+ tst_brkm(TBROK, cleanup, "close(pfd[0]) failed");
+ }
+
+ if ((sprintf(var, getenv("TERM"))) <= 0){
+ tst_resm(TWARN, "sprintf() failed");
+ }
+
+ if ((write(pfd[1], var, MAX_LINE_LENGTH)) == -1) {
+ tst_resm(TWARN, "write to pipe failed");
+ }
+
+ /* Close write end of pipe from child */
+ if ((close(pfd[1])) == -1) {
+ tst_resm(TWARN, "close(pfd[1]) failed");
+ }
+
+ return 0;
+}
+