All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/1] syscalls/mq_notify01: prevent deadlock, cleanup
Date: Thu, 24 Nov 2016 15:53:59 +0100	[thread overview]
Message-ID: <20161124145358.GE14986@rei.lan> (raw)
In-Reply-To: <20161124113205.26581-1-pvorel@suse.cz>

Hi!
Pushed with a few minor changes, thanks.

Commented diff follows:

diff --git a/testcases/kernel/syscalls/mq_notify/mq_notify01.c b/testcases/kernel/syscalls/mq_notify/mq_notify01.c
index a0aee1b..68fabff 100644
--- a/testcases/kernel/syscalls/mq_notify/mq_notify01.c
+++ b/testcases/kernel/syscalls/mq_notify/mq_notify01.c
@@ -16,15 +16,10 @@
  * the GNU General Public License for more details.
  */
 #define _XOPEN_SOURCE 600
-#include <sys/syscall.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/uio.h>
-#include <getopt.h>
-#include <libgen.h>
 #include <limits.h>
 #include <errno.h>
-#include <stdio.h>
 #include <unistd.h>
 #include <string.h>
 #include <mqueue.h>
@@ -32,7 +27,6 @@
 #include <stdlib.h>
 #include <fcntl.h>
 
-#include "linux_syscall_numbers.h"
 #include "tst_test.h"
 
  *** Remove a few more useless includes
 
 #define MAX_MSGSIZE     8192
@@ -111,6 +105,7 @@ static struct test_case tcase[] = {
 static void setup(void)
 {
 	int i;
+
 	for (i = 0; i < MSG_SIZE; i++)
 		smsg[i] = i;
 }
@@ -160,16 +155,16 @@ static void do_test(unsigned int i)
 		fd = INT_MAX - 1;
 		break;
 	case FD_FILE:
-		TEST(fd = open("/", O_RDONLY));
-		if (TEST_RETURN < 0) {
-			tst_res(TFAIL, "can't open \"/\".");
+		fd = open("/", O_RDONLY);
+		if (fd < 0) {
+			tst_res(TBROK | TERRNO, "can't open \"/\".");
 			goto CLEANUP;
 		}
 		break;
 	default:
-		TEST(fd = mq_open(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU, NULL));
-		if (TEST_RETURN < 0) {
-			tst_res(TFAIL | TTERRNO, "mq_open failed");
+		fd = mq_open(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU, NULL);
+		if (fd < 0) {
+			tst_res(TBROK | TERRNO, "mq_open failed");
 			goto CLEANUP;
 		}
 	}
@@ -185,7 +180,7 @@ static void do_test(unsigned int i)
 		memset(&sigact, 0, sizeof(sigact));
 		sigact.sa_sigaction = sigfunc;
 		sigact.sa_flags = SA_SIGINFO;
-		TEST(rc = sigaction(SIGUSR1, &sigact, NULL));
+		rc = sigaction(SIGUSR1, &sigact, NULL);
 		break;
 	case SIGEV_THREAD:
 		notified = cmp_ok = 0;
@@ -196,9 +191,9 @@ static void do_test(unsigned int i)
 	}
 
 	if (tc->ttype == ALREADY_REGISTERED) {
-		TEST(rc = mq_notify(fd, &ev));
-		if (TEST_RETURN < 0) {
-			tst_res(TFAIL | TTERRNO, "mq_notify failed");
+		rc = mq_notify(fd, &ev);
+		if (rc < 0) {
+			tst_res(TBROK | TERRNO, "mq_notify failed");
 			goto CLEANUP;
 		}
 	}

 *** Got rid of a few more useless TEST() uses

@@ -216,23 +211,26 @@ static void do_test(unsigned int i)
 			usleep(10000);
 
 		if (str_debug && tc->notify == SIGEV_SIGNAL) {
-			tst_res(TINFO, "si_code  E:%d,\tR:%d", info.si_code, SI_MESGQ);
-			tst_res(TINFO, "si_signo E:%d,\tR:%d", info.si_signo, SIGUSR1);
+			tst_res(TINFO, "si_code  E:%d,\tR:%d",
+				info.si_code, SI_MESGQ);
+			tst_res(TINFO, "si_signo E:%d,\tR:%d",
+				info.si_signo, SIGUSR1);
 			tst_res(TINFO, "si_value E:0x%x,\tR:0x%x",
-					info.si_value.sival_int, USER_DATA);
-			tst_res(TINFO, "si_pid   E:%d,\tR:%d", info.si_pid, getpid());
-			tst_res(TINFO, "si_uid   E:%d,\tR:%d", info.si_uid, getuid());
+				info.si_value.sival_int, USER_DATA);
+			tst_res(TINFO, "si_pid   E:%d,\tR:%d",
+				info.si_pid, getpid());
+			tst_res(TINFO, "si_uid   E:%d,\tR:%d",
+				info.si_uid, getuid());
 		}
 	}
 
-	/* result check */
 	if ((TEST_RETURN != 0 && TEST_ERRNO != tc->err) || !cmp_ok) {
-		tst_res(TFAIL, "%s r/w check returned: %ld, expected: %d,"
-			" returned errno: %s (%d), expected errno: %s (%d)",
-			tc->desc, TEST_RETURN, tc->ret, tst_strerrno(TEST_ERRNO),
-			TEST_ERRNO, tst_strerrno(tc->err), tc->err);
+		tst_res(TFAIL | TTERRNO, "%s r/w check returned: %ld, "
+			"expected: %d, expected errno: %s (%d)", tc->desc,
+			TEST_RETURN, tc->ret, tst_strerrno(tc->err), tc->err);
 	} else {
-		tst_res(TPASS, "%s returned: %ld", tc->desc, TEST_RETURN);
+		tst_res(TPASS | TTERRNO, "%s returned: %ld",
+			tc->desc, TEST_RETURN);
 	}
 
 CLEANUP:

 *** Fixed a few over 80 chars lines and made use of TTERRNO flag
     instead of printing TEST_ERRNO via %d

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2016-11-24 14:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-24 11:32 [LTP] [PATCH v3 1/1] syscalls/mq_notify01: prevent deadlock, cleanup Petr Vorel
2016-11-24 14:53 ` Cyril Hrubis [this message]
2016-11-25  7:48   ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161124145358.GE14986@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.