From: Garrett C. <su...@li...> - 2011-01-28 10:04:16
|
The branch, master, has been updated via e8c4e2230cb4e73769c36c0021d07f5e134d0589 (commit) via 09d0036c47151a634542f0d984e2cc431b7d4002 (commit) from f9e342dc738dc41f4ac77b46edacc5755a3e728d (commit) - Log ----------------------------------------------------------------- commit e8c4e2230cb4e73769c36c0021d07f5e134d0589 Author: Garrett Cooper <yan...@gm...> Date: Fri Jan 28 02:03:06 2011 -0800 Get rid of extra cleanup call at end of parent() Signed-off-by: Peng Haitao <pe...@cn...> commit 09d0036c47151a634542f0d984e2cc431b7d4002 Author: Garrett Cooper <yan...@gm...> Date: Fri Jan 28 02:02:33 2011 -0800 Style cleanup and use SAFE_PIPE macro. Signed-off-by: Garrett Cooper <yan...@gm...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/sigrelse/sigrelse01.c | 83 +++++----------------- 1 files changed, 19 insertions(+), 64 deletions(-) diff --git a/testcases/kernel/syscalls/sigrelse/sigrelse01.c b/testcases/kernel/syscalls/sigrelse/sigrelse01.c index 0d0e12b..2f40725 100644 --- a/testcases/kernel/syscalls/sigrelse/sigrelse01.c +++ b/testcases/kernel/syscalls/sigrelse/sigrelse01.c @@ -98,18 +98,18 @@ * ***************************************************************************/ +#include <sys/types.h> +#include <sys/wait.h> #include <errno.h> -#include <signal.h> -#include <unistd.h> #include <fcntl.h> -#include <string.h> +#include <signal.h> #include <stdlib.h> +#include <string.h> #include <time.h> -#include <sys/types.h> -#include <sys/wait.h> - +#include <unistd.h> #include "test.h" #include "usctest.h" +#include "safe_macros.h" #ifdef __linux__ /* glibc2.2 definition needs -D_XOPEN_SOURCE, which breaks other things. */ @@ -207,9 +207,6 @@ int main(int argc, char **argv) */ setup(); - /*************************************************************** - * check looping state if -c option given - ***************************************************************/ for (lc = 0; TEST_LOOPING(lc); lc++) { Tst_count = 0; @@ -236,9 +233,6 @@ int main(int argc, char **argv) } - /* - * cleanup and exit - */ cleanup(); tst_exit(); @@ -374,8 +368,6 @@ static void parent() break; } - cleanup(); - } /* end of parent */ /**************************************************************************** @@ -564,8 +556,7 @@ static int setup_sigs() * signal after the signal has been released. All signals must be * caught in order for a PASS. ****************************************************************************/ -static void handler(sig) -int sig; /* the signal causing the execution of this handler */ +static void handler(int sig) { static int s = 0; /* semaphore so that we don't handle 2 */ /* sigs at once */ @@ -639,9 +630,7 @@ int fd; * write_pipe(msg) : write msg to pipe. If it fails, put message in * mesg and return -1, else return 0. ****************************************************************************/ -static int write_pipe(fd, msg) -int fd; -char *msg; /* expected message from pipe */ +static int write_pipe(int fd, char *msg) { #if DEBUG > 0 @@ -711,14 +700,8 @@ static void wait_a_while () if (sig_caught == TRUE) break; } - - return; - } /* end of wait_a_while */ -/***************************************************************************** - * getout() : attempt to kill child process and call cleanup(). - ****************************************************************************/ static void getout() { if (pid > 0 && kill(pid, SIGKILL) < 0) @@ -728,11 +711,7 @@ static void getout() } /* end of getout */ #ifdef VAX -/*********************************************************************** - * unit test for vax only - ***********************************************************************/ -static int sighold(signo) -int signo; +static int sighold(int signo) { return 0; } @@ -744,11 +723,7 @@ int signo; } #endif -/*********************************************************************** - * This function is where signals not under test are ignored - ***********************************************************************/ -int choose_sig(sig) -int sig; +int choose_sig(int sig) { switch (sig) { @@ -778,13 +753,10 @@ int sig; } - return 1; /* choose signal */ + return 1; -} /* end of choose_sig */ +} -/*************************************************************** - * setup() - performs all ONE TIME setup for this test. - ***************************************************************/ void setup() { @@ -792,52 +764,35 @@ void setup() TEST_PAUSE; - /* create a temporary directory and go to it */ tst_tmpdir(); /* set up pipe for parent/child communications */ - if (pipe(pipe_fd) < 0) { - tst_resm(TBROK|TERRNO, "pipe() failed"); - cleanup(); - } + SAFE_PIPE(cleanup, pipe_fd); /* * Cause the read to return 0 once EOF is encountered and the * read to return -1 if pipe is empty. */ if (fcntl(pipe_fd[0], F_SETFL, O_NONBLOCK) == -1) - tst_brkm(TBROK, cleanup, - "fcntl(Fds[0], F_SETFL, O_NONBLOCK) failed: errno=%d", - errno); + tst_brkm(TBROK|TERRNO, cleanup, + "fcntl(Fds[0], F_SETFL, O_NONBLOCK) failed"); /* set up pipe for parent/child communications */ - if (pipe(pipe_fd2) < 0) { - tst_resm(TBROK|TERRNO, "pipe() failed"); - cleanup(); - } + SAFE_PIPE(cleanup, pipe_fd2); /* * Cause the read to return 0 once EOF is encountered and the * read to return -1 if pipe is empty. */ if (fcntl(pipe_fd2[0], F_SETFL, O_NONBLOCK) == -1) - tst_brkm(TBROK, cleanup, - "fcntl(Fds[0], F_SETFL, O_NONBLOCK) failed: errno=%d", - errno); + tst_brkm(TBROK|TERRNO, cleanup, + "fcntl(Fds[0], F_SETFL, O_NONBLOCK) failed"); } -/*************************************************************** - * 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; tst_rmdir(); -} \ No newline at end of file +} hooks/post-receive -- ltp |