From: Mike F. <su...@li...> - 2012-03-23 16:29:30
|
The branch, master, has been updated via 7103d3e8e0f9dc1804ba06ee66ee02753e8ce50e (commit) via 8cd8405d21d9eeb57657865432c65c56171617b3 (commit) from 781a61a591d4a2f6387879051c0750b256c257bb (commit) - Log ----------------------------------------------------------------- commit 7103d3e8e0f9dc1804ba06ee66ee02753e8ce50e Author: Mike Frysinger <va...@ge...> Date: Fri Mar 23 12:27:13 2012 -0400 kill: fix dependency on ipc subdir We need to use MAKE_DEPS to declare the ipc subdir depend otherwise attempting to do `make kill01` without building in the ipc subdir will fail, and we can hit race conditions in the overall `make`. Signed-off-by: Mike Frysinger <va...@ge...> commit 8cd8405d21d9eeb57657865432c65c56171617b3 Author: Wanlong Gao <gao...@cn...> Date: Thu Mar 22 23:41:45 2012 +0800 mq_timedreceive: fix the bad coding style code cleanups Signed-off-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/kill/Makefile | 2 +- .../conformance/interfaces/mq_timedreceive/1-1.c | 76 ++++++++++--------- .../conformance/interfaces/mq_timedreceive/10-1.c | 52 +++++++------- .../conformance/interfaces/mq_timedreceive/10-2.c | 53 +++++++------- .../conformance/interfaces/mq_timedreceive/11-1.c | 73 ++++++++++--------- .../conformance/interfaces/mq_timedreceive/13-1.c | 48 ++++++------ .../conformance/interfaces/mq_timedreceive/14-1.c | 47 ++++++------ .../conformance/interfaces/mq_timedreceive/15-1.c | 57 +++++++-------- .../conformance/interfaces/mq_timedreceive/17-1.c | 47 ++++++------ .../conformance/interfaces/mq_timedreceive/17-2.c | 47 ++++++------ .../conformance/interfaces/mq_timedreceive/17-3.c | 47 ++++++------ .../conformance/interfaces/mq_timedreceive/18-1.c | 69 +++++++++--------- .../conformance/interfaces/mq_timedreceive/18-2.c | 63 ++++++++-------- .../conformance/interfaces/mq_timedreceive/2-1.c | 54 +++++++------- .../conformance/interfaces/mq_timedreceive/5-1.c | 55 +++++++------- .../conformance/interfaces/mq_timedreceive/5-2.c | 63 ++++++++-------- .../conformance/interfaces/mq_timedreceive/5-3.c | 56 +++++++------- .../conformance/interfaces/mq_timedreceive/7-1.c | 43 ++++++------ .../conformance/interfaces/mq_timedreceive/8-1.c | 59 ++++++++-------- 19 files changed, 508 insertions(+), 503 deletions(-) diff --git a/testcases/kernel/syscalls/kill/Makefile b/testcases/kernel/syscalls/kill/Makefile index 6971d96..23dabfc 100644 --- a/testcases/kernel/syscalls/kill/Makefile +++ b/testcases/kernel/syscalls/kill/Makefile @@ -32,7 +32,7 @@ $(LIBDIR): $(LIB): $(LIBDIR) $(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" all -all: | $(LIB) +MAKE_DEPS := $(LIB) CPPFLAGS += -I$(abs_srcdir)/$(LIBDIR) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/1-1.c index 784f6d5..4d90948 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/1-1.c @@ -32,10 +32,10 @@ int main() { - char mqname[NAMESIZE], msgrv1[BUFFER], msgrv2[BUFFER]; - const char *msgptr1 = "test message 1"; - const char *msgptr2 = "test message 2"; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv1[BUFFER], msgrv2[BUFFER]; + const char *msgptr1 = "test message 1"; + const char *msgptr2 = "test message 2"; + mqd_t mqdes; unsigned rvprio, sdprio1 = 1, sdprio2 = 2; struct timespec ts; struct mq_attr attr; @@ -46,70 +46,74 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } - if (mq_send(mqdes, msgptr1, strlen(msgptr1), sdprio1) != 0) { - perror(ERROR_PREFIX "mq_send"); + if (mq_send(mqdes, msgptr1, strlen(msgptr1), sdprio1) != 0) { + perror(ERROR_PREFIX "mq_send"); unresolved = 1; - } - if (mq_send(mqdes, msgptr2, strlen(msgptr2), sdprio2) != 0) { - perror(ERROR_PREFIX "mq_send"); + } + if (mq_send(mqdes, msgptr2, strlen(msgptr2), sdprio2) != 0) { + perror(ERROR_PREFIX "mq_send"); unresolved = 1; - } + } ts.tv_sec = time(NULL) + 1; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv1, BUFFER, &rvprio, &ts) == -1) { + if (mq_timedreceive(mqdes, msgrv1, BUFFER, &rvprio, &ts) == -1) { perror(ERROR_PREFIX "mq_timedreceive"); failure = 1; } if (strncmp(msgptr2, msgrv1, strlen(msgptr2)) != 0) { - printf("FAIL: mq_timedreceive didn't receive the highest priority message\n"); + printf("FAIL: mq_timedreceive didn't receive the highest " + "priority message\n"); failure = 1; } if (rvprio != sdprio2) { - printf("FAIL: receive priority %d != send priority %d \n", rvprio, sdprio2); + printf("FAIL: receive priority %d != send priority %d\n", + rvprio, sdprio2); failure = 1; - } + } ts.tv_sec = time(NULL) + 1; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv2, BUFFER, &rvprio, &ts) == -1) { + if (mq_timedreceive(mqdes, msgrv2, BUFFER, &rvprio, &ts) == -1) { perror(ERROR_PREFIX "mq_timedreceive"); failure = 1; } if (strncmp(msgptr1, msgrv2, strlen(msgptr1)) != 0) { - printf("FAIL: mq_timedreceive didn't receive the correct message\n"); + printf("FAIL: mq_timedreceive didn't receive the correct " + "message\n"); failure = 1; } if (rvprio != sdprio1) { - printf("FAIL: receive priority %d != send priority %d \n", rvprio, sdprio1); + printf("FAIL: receive priority %d != send priority %d\n", + rvprio, sdprio1); failure = 1; - } + } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } + } - if (mq_unlink(mqname) != 0) { + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; - } + } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } - printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + printf("Test PASSED\n"); + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/10-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/10-1.c index af2afc5..e506bdf 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/10-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/10-1.c @@ -31,9 +31,9 @@ int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - const char *msgptr = "test message"; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + const char *msgptr = "test message"; + mqd_t mqdes; unsigned rvprio, sdprio = 1; struct timespec ts; struct mq_attr attr; @@ -44,43 +44,43 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } - if (mq_send(mqdes, msgptr, strlen(msgptr), sdprio) != 0) { - perror(ERROR_PREFIX "mq_send"); + if (mq_send(mqdes, msgptr, strlen(msgptr), sdprio) != 0) { + perror(ERROR_PREFIX "mq_send"); unresolved = 1; - } + } ts.tv_sec = time(NULL) - 1; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv, BUFFER, &rvprio, &ts) == -1) { - perror("FAIL: mq_receive fails unexpectly \n"); + if (mq_timedreceive(mqdes, msgrv, BUFFER, &rvprio, &ts) == -1) { + perror("FAIL: mq_receive fails unexpectly\n"); failure = 1; } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } + } - if (mq_unlink(mqname) != 0) { + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; - } + } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } - printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + printf("Test PASSED\n"); + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/10-2.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/10-2.c index 1cbb5b6..b6253c0 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/10-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/10-2.c @@ -35,9 +35,9 @@ int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - const char *msgptr = "test message"; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + const char *msgptr = "test message"; + mqd_t mqdes; unsigned int rvprio; int sdprio = 1; struct timespec ts; @@ -49,47 +49,48 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } - if (mq_send(mqdes, msgptr, strlen(msgptr), sdprio) != 0) { - perror(ERROR_PREFIX "mq_send"); + if (mq_send(mqdes, msgptr, strlen(msgptr), sdprio) != 0) { + perror(ERROR_PREFIX "mq_send"); unresolved = 1; - } + } sleep(1); /* wait for a while */ - ts.tv_sec = time(NULL) -1; /* Past time */ + ts.tv_sec = time(NULL) - 1; /* Past time */ ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv, BUFFER, &rvprio, &ts) == -1) { + if (mq_timedreceive(mqdes, msgrv, BUFFER, &rvprio, &ts) == -1) { if (errno == ETIMEDOUT) - printf("FAIL: mq_timedreceive returned timeout error\n"); + printf("FAIL: mq_timedreceive returned " + "timeout error\n"); else perror("Unexpected error at mq_timedreceive"); failure = 1; } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } + } - if (mq_unlink(mqname) != 0) { + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; - } + } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } - printf("Test PASSED\n"); - return PTS_PASS; + printf("Test PASSED\n"); + return PTS_PASS; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/11-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/11-1.c index 4913cc0..11f93ab 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/11-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/11-1.c @@ -36,10 +36,10 @@ int main() { - char mqname[NAMESIZE], msgrv1[BUFFER], msgrv2[BUFFER]; - const char *msgptr1 = "test message1"; - const char *msgptr2 = "test message2 with differnet length"; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv1[BUFFER], msgrv2[BUFFER]; + const char *msgptr1 = "test message1"; + const char *msgptr2 = "test message2 with differnet length"; + mqd_t mqdes; int prio1 = 1, prio2 = 2; struct timespec ts; struct mq_attr attr; @@ -50,49 +50,54 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } - if (mq_send(mqdes, msgptr1, strlen(msgptr1), prio1) != 0) { - perror(ERROR_PREFIX "mq_send"); + if (mq_send(mqdes, msgptr1, strlen(msgptr1), prio1) != 0) { + perror(ERROR_PREFIX "mq_send"); unresolved = 1; - } - if (mq_send(mqdes, msgptr2, strlen(msgptr2), prio2) != 0) { - perror(ERROR_PREFIX "mq_send"); + } + if (mq_send(mqdes, msgptr2, strlen(msgptr2), prio2) != 0) { + perror(ERROR_PREFIX "mq_send"); unresolved = 1; - } + } ts.tv_sec = time(NULL) + 1; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv1, BUFFER, NULL, &ts) != strlen(msgptr2)) { - printf("FAIL: mq_timedreceive didn't return the selected message size correctly \n"); + if (mq_timedreceive(mqdes, msgrv1, BUFFER, NULL, &ts) != + strlen(msgptr2)) { + printf("FAIL: mq_timedreceive didn't return the selected " + "message size correctly\n"); failure = 1; } - if (mq_timedreceive(mqdes, msgrv2, BUFFER, NULL, &ts) != strlen(msgptr1)) { - printf("FAIL: mq_timedreceive didn't return the selected message size correctly \n"); + if (mq_timedreceive(mqdes, msgrv2, BUFFER, NULL, &ts) != + strlen(msgptr1)) { + printf("FAIL: mq_timedreceive didn't return the selected " + "message size correctly\n"); failure = 1; } - if (!strcmp(msgrv1,msgrv2)) { - printf("FAIL: mq_timedreceive received the same message twice\n"); + if (!strcmp(msgrv1, msgrv2)) { + printf("FAIL: mq_timedreceive received the same message " + "twice\n"); failure = 1; } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; - } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + } + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/13-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/13-1.c index 4d470b0..bac5e96 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/13-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/13-1.c @@ -33,8 +33,8 @@ int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + mqd_t mqdes; struct timespec ts; struct mq_attr attr; int unresolved = 0, failure = 0; @@ -43,39 +43,39 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; - mqdes = mq_open(mqname, O_CREAT | O_NONBLOCK | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + mqdes = mq_open(mqname, O_CREAT | O_NONBLOCK | O_RDWR, + S_IRUSR | S_IWUSR, &attr); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } ts.tv_sec = time(NULL) + 1; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { if (EAGAIN != errno) { - printf("errno != EAGAIN \n"); + printf("errno != EAGAIN\n"); failure = 1; } - } - else { + } else { printf("mq_timedreceive() succeed unexpectly\n"); failure = 1; } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; - } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); + } + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); return PTS_PASS; -} \ No newline at end of file +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/14-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/14-1.c index cc7a434..b36b4ef 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/14-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/14-1.c @@ -28,14 +28,14 @@ #define FUNCTION "mq_timedreceive" #define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " -#define NAMESIZE 50 -#define BUFFER 40 +#define NAMESIZE 50 +#define BUFFER 40 int main() { char mqname[NAMESIZE]; mqd_t mqdes; - char msgrv[BUFFER]; + char msgrv[BUFFER]; struct timespec ts; struct mq_attr attr; int unresolved = 0, failure = 0; @@ -52,32 +52,31 @@ int main() mqdes = mqdes + 1; ts.tv_sec = time(NULL) + 1; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { if (EBADF != errno) { - printf("errno != EBADF \n"); + printf("errno != EBADF\n"); failure = 1; } - } - else { - printf("mq_timedreceive() succeed unexpectly \n"); + } else { + printf("mq_timedreceive() succeed unexpectly\n"); failure = 1; } if (mq_close(mqdes - 1) != 0) { - perror(ERROR_PREFIX "mq_close()"); - unresolved=1; - } - if (mq_unlink(mqname) != 0) { - perror(ERROR_PREFIX "mq_unlink()"); - unresolved=1; - } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; + perror(ERROR_PREFIX "mq_close()"); + unresolved = 1; + } + if (mq_unlink(mqname) != 0) { + perror(ERROR_PREFIX "mq_unlink()"); + unresolved = 1; + } + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; } printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/15-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/15-1.c index a468077..080d55d 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/15-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/15-1.c @@ -32,59 +32,58 @@ int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - const char *msgptr = "test message"; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + const char *msgptr = "test message"; + mqd_t mqdes; int prio = 1; struct mq_attr mqstat; struct timespec ts; int unresolved = 0, failure = 0; sprintf(mqname, "/" FUNCTION "_" TEST "_%d", getpid()); - memset(&mqstat,0,sizeof(mqstat)); + memset(&mqstat, 0, sizeof(mqstat)); mqstat.mq_msgsize = BUFFER + 1; mqstat.mq_maxmsg = BUFFER + 1; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &mqstat); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } - if (mq_send(mqdes, msgptr, strlen(msgptr), prio) != 0) { - perror(ERROR_PREFIX "mq_send"); + if (mq_send(mqdes, msgptr, strlen(msgptr), prio) != 0) { + perror(ERROR_PREFIX "mq_send"); unresolved = 1; - } + } ts.tv_sec = time(NULL) + 1; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) > 0) { + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) > 0) { printf("FAIL: mq_timedreceive succeed unexpectly\n"); failure = 1; - } - else { + } else { if (EMSGSIZE != errno) { - printf("errno != EMSGSIZE \n"); + printf("errno != EMSGSIZE\n"); failure = 1; } } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } + } - if (mq_unlink(mqname) != 0) { + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; - } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } + } + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-1.c index be9a490..7299c09 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-1.c @@ -35,8 +35,8 @@ int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + mqd_t mqdes; struct timespec ts; struct mq_attr attr; int unresolved = 0, failure = 0; @@ -46,38 +46,37 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } ts.tv_sec = time(NULL) + 1; ts.tv_nsec = -1; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { if (EINVAL != errno) { - printf("errno != EINVAL \n"); + printf("errno != EINVAL\n"); failure = 1; } - } - else { - printf("FAIL: mq_timedreceive() succeed unexpectly \n"); + } else { + printf("FAIL: mq_timedreceive() succeed unexpectly\n"); failure = 1; } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-2.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-2.c index af9e1eb..29a83ab 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-2.c @@ -36,8 +36,8 @@ int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + mqd_t mqdes; struct timespec ts; struct mq_attr attr; int unresolved = 0, failure = 0; @@ -47,38 +47,37 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } ts.tv_sec = time(NULL) + 1; ts.tv_nsec = 1000000000; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { if (EINVAL != errno) { - printf("errno != EINVAL \n"); + printf("errno != EINVAL\n"); failure = 1; } - } - else { - printf("FAIL: mq_timedreceive() succeed unexpectly \n"); + } else { + printf("FAIL: mq_timedreceive() succeed unexpectly\n"); failure = 1; } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-3.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-3.c index 48ee2b4..01133da 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-3.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/17-3.c @@ -36,8 +36,8 @@ int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + mqd_t mqdes; struct timespec ts; struct mq_attr attr; int unresolved = 0, failure = 0; @@ -47,38 +47,37 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } ts.tv_sec = time(NULL) + 1; ts.tv_nsec = 1000000000 + 1; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { if (EINVAL != errno) { - printf("errno != EINVAL \n"); + printf("errno != EINVAL\n"); failure = 1; } - } - else { - printf("FAIL: mq_timedreceive() succeed unexpectly \n"); + } else { + printf("FAIL: mq_timedreceive() succeed unexpectly\n"); failure = 1; } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/18-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/18-1.c index 6606d40..4f5dbd2 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/18-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/18-1.c @@ -35,18 +35,18 @@ #define BUFFER 40 #define TIMEOUT 3 -int blocking = 0; +int blocking; void exit_handler(int signo) { - printf("FAIL: the case is blocking, exit anyway \n"); - blocking = 1; - return; + printf("FAIL: the case is blocking, exit anyway\n"); + blocking = 1; + return; } int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + mqd_t mqdes; struct timespec ts; pid_t pid; struct mq_attr attr; @@ -57,56 +57,55 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } - if ((pid = fork()) != 0) { + } + pid = fork(); + if (pid != 0) { /* Parent process */ struct sigaction act; - act.sa_handler=exit_handler; - act.sa_flags=0; - sigemptyset(&act.sa_mask); - sigaction(SIGABRT, &act, 0); + act.sa_handler = exit_handler; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + sigaction(SIGABRT, &act, 0); ts.tv_sec = time(NULL) + TIMEOUT; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { if (ETIMEDOUT != errno) { - printf("errno != ETIMEDOUT \n"); + printf("errno != ETIMEDOUT\n"); failure = 1; } - } - else { - printf("FAIL: mq_timedreceive() succeed unexpectly \n"); + } else { + printf("FAIL: mq_timedreceive() succeed unexpectly\n"); failure = 1; } /* parent is not blocking on mq_timedreceive, kill child */ kill(pid, SIGABRT); - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; } - if (failure==1 || blocking==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } + if (failure == 1 || blocking == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } - printf("Test PASSED\n"); - return PTS_PASS; - } - else { + printf("Test PASSED\n"); + return PTS_PASS; + } else { sleep(TIMEOUT + 3); /* Parent is probably blocking, send a signal to let it abort */ kill(getppid(), SIGABRT); return 0; } -} \ No newline at end of file +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/18-2.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/18-2.c index 388447b..23a3e8a 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/18-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/18-2.c @@ -36,17 +36,17 @@ #define BUFFER 40 #define TIMEOUT 3 -int blocking = 0; +int blocking; void exit_handler(int signo) { - printf("FAIL: the case is blocking, exit anyway \n"); + printf("FAIL: the case is blocking, exit anyway\n"); blocking = 1; return; } int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + mqd_t mqdes; struct timespec ts; struct mq_attr attr; pid_t pid; @@ -57,26 +57,26 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } - if ((pid = fork()) != 0) { + pid = fork(); + if (pid != 0) { /* Parent process */ struct sigaction act; - act.sa_handler=exit_handler; - act.sa_flags=0; - sigemptyset(&act.sa_mask); - sigaction(SIGABRT, &act, 0); + act.sa_handler = exit_handler; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + sigaction(SIGABRT, &act, 0); ts.tv_sec = time(NULL) - TIMEOUT; ts.tv_nsec = 0; if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) != -1) { printf("FAIL: mq_timedreceive succeed unexpectely\n"); failure = 1; - } - else { + } else { if (errno != ETIMEDOUT) { printf("errno != ETIMEDOUT\n"); failure = 1; @@ -84,31 +84,30 @@ int main() } /* Parent is not blocking, let child abort */ kill(pid, SIGABRT); - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; } - if (failure==1 || blocking==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; - } - else { + if (failure == 1 || blocking == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); + return PTS_PASS; + } else { sleep(TIMEOUT + 3); /* Parent is probably blocking send a signal to let it abort */ kill(getppid(), SIGABRT); return 0; } - printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + printf("Test PASSED\n"); + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/2-1.c index 6ae5c25..dec64d6 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/2-1.c @@ -31,51 +31,51 @@ int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - const char *msgptr = "test message"; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + const char *msgptr = "test message"; + mqd_t mqdes; int prio = 1; struct mq_attr mqstat; struct timespec ts; int unresolved = 0, failure = 0; sprintf(mqname, "/" FUNCTION "_" TEST "_%d", getpid()); - memset(&mqstat,0,sizeof(mqstat)); + memset(&mqstat, 0, sizeof(mqstat)); mqstat.mq_msgsize = BUFFER + 1; mqstat.mq_maxmsg = BUFFER + 1; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &mqstat); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } - if (mq_send(mqdes, msgptr, strlen(msgptr), prio) != 0) { - perror(ERROR_PREFIX "mq_send"); + if (mq_send(mqdes, msgptr, strlen(msgptr), prio) != 0) { + perror(ERROR_PREFIX "mq_send"); unresolved = 1; - } + } ts.tv_sec = time(NULL) + 1; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) > 0) { - printf("FAIL: mq_timedreceive succeed unexpectly \n"); + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) > 0) { + printf("FAIL: mq_timedreceive succeed unexpectly\n"); failure = 1; } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; - } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + } + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-1.c index 230beee..4cb5601 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-1.c @@ -38,9 +38,9 @@ int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - const char *msgptr = "test message "; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + const char *msgptr = "test message "; + mqd_t mqdes; int prio = 1; int pid; struct timespec ts; @@ -52,49 +52,48 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } - if ((pid = fork()) != 0) { + pid = fork(); + if (pid != 0) { /* Parent process */ int status; ts.tv_sec = INT32_MAX; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) > 0) { + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) > 0) { wait(&status); if (WEXITSTATUS(status)) { - printf("mq_send error \n"); + printf("mq_send error\n"); unresolved = 1; } - } - else { - printf("mq_timedreceive didn't block on waiting \n"); + } else { + printf("mq_timedreceive didn't block on waiting\n"); wait(NULL); /* wait for child to exit */ perror(ERROR_PREFIX "mq_timedreceive"); failure = 1; } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; - } - else { + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); + return PTS_PASS; + } else { /* Child Process */ sleep(2); /* sleep 2 seconds, assume that parent will block on waiting then */ @@ -105,4 +104,4 @@ int main() return 0; } return PTS_UNRESOLVED; -} \ No newline at end of file +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-2.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-2.c index 4c85ae7..e81d8d5 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-2.c @@ -34,17 +34,17 @@ #define BUFFER 40 #define TIMEOUT 3 -int blocking = 0; +int blocking; void exit_handler(int signo) { - printf("FAIL: the case is blocking, exit anyway \n"); + printf("FAIL: the case is blocking, exit anyway\n"); blocking = 1; return; } int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + mqd_t mqdes; struct timespec ts; time_t oldtime, newtime; struct mq_attr attr; @@ -56,18 +56,19 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } - if ((pid = fork()) != 0) { + pid = fork(); + if (pid != 0) { /* Parent process */ struct sigaction act; - act.sa_handler=exit_handler; - act.sa_flags=0; - sigemptyset(&act.sa_mask); - sigaction(SIGABRT, &act, 0); + act.sa_handler = exit_handler; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + sigaction(SIGABRT, &act, 0); ts.tv_sec = time(NULL) + TIMEOUT; ts.tv_nsec = 0; @@ -75,36 +76,36 @@ int main() mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts); newtime = time(NULL); if ((newtime - oldtime) < TIMEOUT) { - printf("FAIL: mq_timedreceive didn't block until timout expires\n"); + printf("FAIL: mq_timedreceive didn't block until " + "timout expires\n"); failure = 1; } /* Parent is not blocking, let child abort */ kill(pid, SIGABRT); - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; } - if (failure==1 || blocking==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; - } - else { + if (failure == 1 || blocking == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); + return PTS_PASS; + } else { sleep(TIMEOUT + 3); /* Parent is probably blocking send a signal to let it abort */ kill(getppid(), SIGABRT); return 0; } - printf("Test PASSED\n"); - return PTS_PASS; -} \ No newline at end of file + printf("Test PASSED\n"); + return PTS_PASS; +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-3.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-3.c index dcb7a31..acc6c24 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-3.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-3.c @@ -43,8 +43,8 @@ void stopreceive(int signo) } int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + mqd_t mqdes; int pid; struct mq_attr attr; struct timespec ts; @@ -55,11 +55,13 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } - if ((pid = fork()) != 0) { + } + + pid = fork(); + if (pid != 0) { /* Parent process */ struct sigaction act; act.sa_handler = stopreceive; @@ -70,41 +72,39 @@ int main() ts.tv_sec = INT32_MAX; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) == -1) { wait(NULL); if (EINTR != errno) { - printf("errno != EINTR \n"); + printf("errno != EINTR\n"); failure = 1; } - } - else { + } else { wait(NULL); - printf("mq_timedreceive() succeed unexpectly \n"); + printf("mq_timedreceive() succeed unexpectly\n"); failure = 1; } if (mq_close(mqdes) != 0) { - perror("mq_close() did not return success"); - unresolved=1; - } - if (mq_unlink(mqname) != 0) { - perror("mq_unlink() did not return success"); - unresolved=1; - } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; + perror("mq_close() did not return success"); + unresolved = 1; + } + if (mq_unlink(mqname) != 0) { + perror("mq_unlink() did not return success"); + unresolved = 1; + } + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; } printf("Test PASSED\n"); return PTS_PASS; - } - else { + } else { /* Child Process */ sleep(1); /* give time to parent to set up handler */ /* send signal to parent */ kill(getppid(), SIGABRT); } -} \ No newline at end of file +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/7-1.c index 14a276f..a10ad0c 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/7-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/7-1.c @@ -33,8 +33,8 @@ int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + mqd_t mqdes; struct timespec ts; struct mq_attr attr; int unresolved = 0, failure = 0; @@ -43,37 +43,38 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; - mqdes = mq_open(mqname, O_CREAT | O_NONBLOCK | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + mqdes = mq_open(mqname, O_CREAT | O_NONBLOCK | O_RDWR, + S_IRUSR | S_IWUSR, &attr); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } ts.tv_sec = time(NULL) + 1; ts.tv_nsec = 0; - if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) != -1) { - printf("mq_timedreceive succeed unexpectly \n"); + if (mq_timedreceive(mqdes, msgrv, BUFFER, NULL, &ts) != -1) { + printf("mq_timedreceive succeed unexpectly\n"); failure = 1; } - if (mq_close(mqdes) != 0) { + if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } + } - if (mq_unlink(mqname) != 0) { + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; - } + } - if (failure==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } + if (failure == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } printf("Test PASSED\n"); return PTS_PASS; -} \ No newline at end of file +} diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/8-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/8-1.c index 76c28ac..4b1f568 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/8-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/8-1.c @@ -32,17 +32,17 @@ #define BUFFER 40 #define TIMEOUT 3 -int blocking = 0; +int blocking; void exit_handler(int signo) { - printf("FAIL: the case is blocking, exit anyway \n"); + printf("FAIL: the case is blocking, exit anyway\n"); blocking = 1; return; } int main() { - char mqname[NAMESIZE], msgrv[BUFFER]; - mqd_t mqdes; + char mqname[NAMESIZE], msgrv[BUFFER]; + mqd_t mqdes; struct timespec ts; time_t oldtime, newtime; struct mq_attr attr; @@ -54,18 +54,19 @@ int main() attr.mq_msgsize = BUFFER; attr.mq_maxmsg = BUFFER; mqdes = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); - if (mqdes == (mqd_t)-1) { - perror(ERROR_PREFIX "mq_open"); + if (mqdes == (mqd_t)-1) { + perror(ERROR_PREFIX "mq_open"); unresolved = 1; - } + } - if ((pid = fork()) != 0) { + pid = fork(); + if (pid != 0) { /* Parent process */ struct sigaction act; - act.sa_handler=exit_handler; - act.sa_flags=0; - sigemptyset(&act.sa_mask); - sigaction(SIGABRT, &act, 0); + act.sa_handler = exit_handler; + act.sa_flags = 0; + sigemptyset(&act.sa_mask); + sigaction(SIGABRT, &act, 0); #ifdef _POSIX_TIMERS printf("Using CLOCK_REALTIME\n"); clock_gettime(CLOCK_REALTIME, &ts); @@ -84,35 +85,35 @@ int main() newtime = time(NULL); #endif if ((newtime - oldtime) < TIMEOUT) { - printf("FAIL: mq_timedreceive didn't block until timout expires\n"); + printf("FAIL: mq_timedreceive didn't block until " + "timout expires\n"); failure = 1; } /* Parent is not blocking, let child abort */ kill(pid, SIGABRT); - wait(NULL); + wait(NULL); if (mq_close(mqdes) != 0) { perror(ERROR_PREFIX "mq_close"); unresolved = 1; - } - if (mq_unlink(mqname) != 0) { + } + if (mq_unlink(mqname) != 0) { perror(ERROR_PREFIX "mq_unlink"); unresolved = 1; } - if (failure==1 || blocking==1) { - printf("Test FAILED\n"); - return PTS_FAIL; - } - if (unresolved==1) { - printf("Test UNRESOLVED\n"); - return PTS_UNRESOLVED; - } - printf("Test PASSED\n"); - return PTS_PASS; - } - else { + if (failure == 1 || blocking == 1) { + printf("Test FAILED\n"); + return PTS_FAIL; + } + if (unresolved == 1) { + printf("Test UNRESOLVED\n"); + return PTS_UNRESOLVED; + } + printf("Test PASSED\n"); + return PTS_PASS; + } else { sleep(TIMEOUT + 3); /* Parent is probably blocking send a signal to let it abort */ kill(getppid(), SIGABRT); return 0; } -} \ No newline at end of file +} hooks/post-receive -- ltp |