From: Garrett C. <ris...@li...> - 2010-06-20 22:51:10
|
The branch, pu, has been updated via 3cc6f028b8eeda2e20f308dc8a81020332d8c524 (commit) via b4fcfce584f11cca39fba11d17fef6637ed41a9e (commit) via 5e6a5f8ad3be208d14826f77111d512c8758bc04 (commit) via 1caa7da8563958edbc538c22caffad1baf34855e (commit) via 8ef4bbfddc7922d8978d53f972c50024e6a10729 (commit) from 796175696e5a0bdef6a0a0de6dd4ffd3208c9d23 (commit) - Log ----------------------------------------------------------------- commit 3cc6f028b8eeda2e20f308dc8a81020332d8c524 Author: Garrett Cooper <yan...@gm...> Date: Sun Jun 20 15:48:42 2010 -0700 Revert "Dummy commit." This reverts commit b4fcfce584f11cca39fba11d17fef6637ed41a9e. commit b4fcfce584f11cca39fba11d17fef6637ed41a9e Author: Garrett Cooper <yan...@gm...> Date: Sun Jun 20 15:44:07 2010 -0700 Dummy commit. commit 5e6a5f8ad3be208d14826f77111d512c8758bc04 Author: Garrett Cooper <yan...@gm...> Date: Sun Jun 20 15:05:39 2010 -0700 Default to $PWD if a directory is not specified. Signed-off-by: Garrett Cooper <yan...@gm...> commit 1caa7da8563958edbc538c22caffad1baf34855e Author: Garrett Cooper <yan...@gm...> Date: Sun Jun 20 15:04:07 2010 -0700 Clean up test. Signed-off-by: Garrett Cooper <yan...@gm...> commit 8ef4bbfddc7922d8978d53f972c50024e6a10729 Author: Garrett Cooper <yan...@gm...> Date: Sun Jun 20 14:45:34 2010 -0700 Fix Makefile so that it actually compiles again. Signed-off-by: Garrett Cooper <yan...@gm...> ----------------------------------------------------------------------- Summary of changes: .../functional/mqueues/GNUmakefile | 16 ++-- .../functional/mqueues/send_rev_1.c | 78 +++++++++++--------- testcases/open_posix_testsuite/locate-test | 28 +++---- 3 files changed, 64 insertions(+), 58 deletions(-) diff --git a/testcases/open_posix_testsuite/functional/mqueues/GNUmakefile b/testcases/open_posix_testsuite/functional/mqueues/GNUmakefile index dd01e42..cf1e447 100644 --- a/testcases/open_posix_testsuite/functional/mqueues/GNUmakefile +++ b/testcases/open_posix_testsuite/functional/mqueues/GNUmakefile @@ -1,13 +1,11 @@ -INCLUDE = -I../../include -LIB=-lrt -lpthread - -CFLAGS=-Wall -O2 -g +CFLAGS+= -Wall +CPPFLAGS+= -I../../include +LDLIBS= -lrt -lpthread all: send_rev_1.test send_rev_2.test -%.test : %.c - $(CC) $(CFLAGS) $(INCLUDE) $< -o $@ $(LIB) -clean: - rm *.test +%.test: %.o + $(LINK.o) $< $(LOADLIBES) $(LDLIBS) -o $@ - +clean: + rm -f *.test diff --git a/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c b/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c index 03385ae..7d45cc6 100644 --- a/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c +++ b/testcases/open_posix_testsuite/functional/mqueues/send_rev_1.c @@ -10,32 +10,31 @@ * */ -#include <stdio.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdlib.h> -#include <sys/wait.h> #include <sys/mman.h> -#include <string.h> -#include <getopt.h> +#include <sys/wait.h> +#include <fcntl.h> #include <limits.h> #include <mqueue.h> - +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> #include "posixtest.h" -#define MQ_NAME "/testmsg" +#define MQ_NAME "/testmsg" #define MSG_SIZE 128 #define MAX_MSG 3 int main(int argc, char *argv[]) { - mqd_t mq = 0; - pid_t pid; struct mq_attr mqstat, attr; - int oflag = O_CREAT|O_RDWR; - const char *s_msg_ptr[] = {"msg test 1", "msg test 2", "msg test 3"}; char r_msg_ptr[MAX_MSG][MSG_SIZE]; + const char *s_msg_ptr[] = {"msg test 1", "msg test 2", "msg test 3"}; int i; + int oflag = O_CREAT|O_RDWR; + int ret_code = PTS_PASS; + mqd_t mq = 0; + pid_t pid; memset(&mqstat, 0, sizeof(mqstat)); mqstat.mq_maxmsg = MAX_MSG; @@ -47,43 +46,54 @@ int main(int argc, char *argv[]) return PTS_UNRESOLVED; #endif */ - if( ((mqd_t) -1) == (mq = mq_open(MQ_NAME,oflag,0777, &mqstat)) ) { + if(((mqd_t) -1) == (mq = mq_open(MQ_NAME, oflag, 0777, &mqstat))) { perror("mq_open doesn't return success \n"); return PTS_UNRESOLVED; } - - if ( 0 != (pid = fork() )) { + + switch ((pid = fork())) { + case -1: + perror("fork"); + ret_code = PTS_UNRESOLVED; + break; + case 0: mq_getattr(mq, &attr); - for (i=0; i < MAX_MSG; i++) { + for (i = 0; i < MAX_MSG && ret_code == PTS_PASS; i++) { printf("[%d] s_msg_ptr is '%s' \n", i+1, s_msg_ptr[i]); printf("Prepare to send message...\n"); if ( -1 == mq_send(mq, s_msg_ptr[i], attr.mq_msgsize, 1)) { perror("mq_send doesn't return success \n"); - mq_close(mq); - mq_unlink(MQ_NAME); - return PTS_UNRESOLVED; + ret_code = PTS_UNRESOLVED; + } else { + printf("Process %ld send message '%s' to " + "process %ld \n", + (long)getpid(), s_msg_ptr[i], (long)pid); } - printf("Process %ld send message '%s' to process %ld \n", (long)getpid(), s_msg_ptr[i], (long)pid); } - wait(NULL); - } - else { + (void)wait(NULL); + break; + default: printf("Enter into child process...\n"); mq_getattr(mq, &attr); - for (i = 0; i < MAX_MSG; i++) { + for (i = 0; i < MAX_MSG && ret_code == PTS_PASS; i++) { printf("Prepare to receive [%d] messages...\n", i+1); if (-1 == mq_receive(mq, r_msg_ptr[i], attr.mq_msgsize, NULL)) { perror("mq_receive doesn't return success \n"); - mq_close(mq); - mq_unlink(MQ_NAME); - return PTS_UNRESOLVED; + ret_code = PTS_UNRESOLVED; + } else { + printf("process %ld receive message '%s' from " + "process %ld \n", + (long)getpid(), r_msg_ptr[i], (long)getppid()); } - printf("process %ld receive message '%s' from process %ld \n", (long)getpid(), r_msg_ptr[i], (long)getppid()); } + exit(ret_code); + /* NOTREACHED */ + break; } - - mq_close(mq); - mq_unlink(MQ_NAME); - return PTS_PASS; -} + (void) mq_close(mq); + (void) mq_unlink(MQ_NAME); + + return ret_code; + +} diff --git a/testcases/open_posix_testsuite/locate-test b/testcases/open_posix_testsuite/locate-test index 9e246e2..3d8c8ee 100755 --- a/testcases/open_posix_testsuite/locate-test +++ b/testcases/open_posix_testsuite/locate-test @@ -92,17 +92,17 @@ do esac done +# Simple version right now, just locate all: +WHERE=${1:-$PWD} + # Need the DIRECTORY arg ... -if [ -z "$1" ] +if [ ! -d "$WHERE" ] then echo "Error: no root directory specified" 1>&2 - usage 1>&2; - exit 1; + usage >&2 + exit 1 fi -# Simple version right now, just locate all: -WHERE="$1" - # Force something .c or .sh # Avoid .o, backups # IF --execs, force it has no "-buildonly" @@ -112,12 +112,10 @@ find "$WHERE" -type f \ \( -name "[0-9]*-*.c" -o -name "[0-9]*-[0-9]*.sh" \) \ ! -name \*.o ! -name \*~ \ \) \ - $buildable $execs \ - | if [ $print_execs -eq 1 ] - then - sed 's/\.\(sh\|c\)$/.test/' - else - cat - fi - - + $buildable $execs | \ + if [ $print_execs -eq 1 ] + then + sed 's/\.\(sh\|c\)$/.test/' + else + cat + fi hooks/post-receive -- ltp |