public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] open_posix_testsuite/../mq_timedsend/12-1: fix long lines
@ 2013-07-24  6:39 Jan Stancek
  2013-07-24  6:39 ` [LTP] [PATCH 2/2] open_posix_testsuite/../mq_timedsend/12-1: fix race Jan Stancek
  0 siblings, 1 reply; 12+ messages in thread
From: Jan Stancek @ 2013-07-24  6:39 UTC (permalink / raw)
  To: ltp-list

Fix lines going over 80 characters.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 .../conformance/interfaces/mq_timedsend/12-1.c     |   77 ++++++++++----------
 1 files changed, 40 insertions(+), 37 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/12-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/12-1.c
index 1984063..29780d0 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/12-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/12-1.c
@@ -11,12 +11,12 @@
  *
  * Steps:
  * 1. Create a thread and set up a signal handler for SIGUSR1
- * 2. Thread indicates to main that it is ready to start calling mq_timedsend until it
- *    blocks for a timeout of 10 seconds.
- * 3. In main, send the thread the SIGUSR1 signal while mq_timedsend is blocking.
- * 4. Check to make sure that mq_timedsend blocked, and that it returned EINTR when it was
- *    interrupted by SIGUSR1.
- *
+ * 2. Thread indicates to main that it is ready to start calling mq_timedsend
+ *    until it blocks for a timeout of 10 seconds.
+ * 3. In main, send the thread the SIGUSR1 signal while mq_timedsend is
+ *    blocking.
+ * 4. Check to make sure that mq_timedsend blocked, and that it returned
+ *    EINTR when it was interrupted by SIGUSR1.
  */
 
 #include <stdio.h>
@@ -43,10 +43,15 @@
 #define INTHREAD 0
 #define INMAIN 1
 
-int sem;			/* manual semaphore */
-int in_handler;			/* flag to indicate signal handler was called */
-int errno_eintr;		/* flag to indicate that errno was set to eintr when mq_timedsend()
-				   was interruped. */
+/* manual semaphore */
+int sem;
+
+/* flag to indicate signal handler was called */
+int in_handler;
+
+/* flag to indicate that errno was set to eintr when mq_timedsend()
+ * was interruped. */
+int errno_eintr;
 
 /*
  * This handler is just used to catch the signal and stop sleep (so the
@@ -61,8 +66,7 @@ void justreturn_handler(int signo)
 
 void *a_thread_func()
 {
-
-	int i;
+	int i, ret;
 	struct sigaction act;
 	char gqname[NAMESIZE];
 	mqd_t gqueue;
@@ -96,26 +100,26 @@ void *a_thread_func()
 	sem = INMAIN;
 
 	for (i = 0; i < MAXMSG + 1; i++) {
-		if (mq_timedsend(gqueue, msgptr, strlen(msgptr), 1, &ts) == -1) {
-			if (errno == EINTR) {
-				if (mq_unlink(gqname) != 0) {
-					perror
-					    ("mq_unlink() did not return success");
-					pthread_exit((void *)PTS_UNRESOLVED);
-					return NULL;
-				}
-				printf
-				    ("thread: mq_timedsend interrupted by signal and correctly set errno to EINTR\n");
-				errno_eintr = 1;
-				pthread_exit((void *)PTS_PASS);
-				return NULL;
-			} else {
-				printf
-				    ("mq_timedsend not interrupted by signal or set errno to incorrect code: %d\n",
-				     errno);
-				pthread_exit((void *)PTS_FAIL);
+		ret = mq_timedsend(gqueue, msgptr, strlen(msgptr), 1, &ts);
+		if (ret	!= -1)
+			continue;
+
+		if (errno == EINTR) {
+			if (mq_unlink(gqname) != 0) {
+				perror("mq_unlink() did not return success");
+				pthread_exit((void *)PTS_UNRESOLVED);
 				return NULL;
 			}
+			printf("thread: mq_timedsend interrupted by signal"
+				" and correctly set errno to EINTR\n");
+			errno_eintr = 1;
+			pthread_exit((void *)PTS_PASS);
+			return NULL;
+		} else {
+			printf("mq_timedsend not interrupted by signal or"
+				" set errno to incorrect code: %d\n", errno);
+			pthread_exit((void *)PTS_FAIL);
+			return NULL;
 		}
 	}
 
@@ -161,23 +165,22 @@ int main(void)
 		return PTS_UNRESOLVED;
 	}
 
-	/* Test to see if the thread blocked correctly in mq_timedsend, and if it returned
-	 * EINTR when it caught the signal */
+	/* Test to see if the thread blocked correctly in mq_timedsend,
+	 * and if it returned EINTR when it caught the signal */
 	if (errno_eintr != 1) {
 		if (sem == INTHREAD) {
-			printf
-			    ("Test FAILED: mq_timedsend() never blocked for any timeout period.\n");
+			printf("Test FAILED: mq_timedsend() never"
+				" blocked for any timeout period.\n");
 			return PTS_FAIL;
 		}
 
 		if (in_handler != 0) {
-			perror
-			    ("Error: signal SIGUSR1 was never received, and/or the signal handler was never called.\n");
+			perror("Error: signal SIGUSR1 was never received and/or"
+				" the signal handler was never called.\n");
 			return PTS_UNRESOLVED;
 		}
 	}
 
 	printf("Test PASSED\n");
 	return PTS_PASS;
-
 }
-- 
1.7.1


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-08-27 11:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-24  6:39 [LTP] [PATCH 1/2] open_posix_testsuite/../mq_timedsend/12-1: fix long lines Jan Stancek
2013-07-24  6:39 ` [LTP] [PATCH 2/2] open_posix_testsuite/../mq_timedsend/12-1: fix race Jan Stancek
2013-07-25 10:07   ` [LTP] [PATCH v2 " Jan Stancek
2013-07-31 14:30     ` [LTP] [PATCH v3 " Jan Stancek
2013-08-12 14:43       ` chrubis
2013-08-13 13:38       ` [LTP] [PATCH v4 " Jan Stancek
2013-08-13 15:13         ` chrubis
2013-08-14 11:28         ` [LTP] [PATCH v5 " Jan Stancek
2013-08-15 12:53           ` chrubis
2013-08-27 11:51             ` chrubis
2013-07-30 17:35   ` [LTP] [PATCH " chrubis
     [not found]     ` <111760967.10033378.1375213746603.JavaMail.root@redhat.com>
2013-07-31 11:07       ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox