linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shuah Khan <shuahkh@osg.samsung.com>
To: akpm@linux-foundation.org, gregkh@linuxfoundation.org,
	colin.king@canonical.com, dbueso@suse.de, ebiederm@xmission.com,
	serge.hallyn@ubuntu.com, thierry@linux.vnet.ibm.com,
	felipensp@gmail.com
Cc: Shuah Khan <shuahkh@osg.samsung.com>,
	linux-api@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/7] selftests/ipc: change ipc test to use kselftest exit codes
Date: Mon, 15 Sep 2014 16:33:58 -0600	[thread overview]
Message-ID: <1410820442-8774-4-git-send-email-shuahkh@osg.samsung.com> (raw)
In-Reply-To: <1410820442-8774-1-git-send-email-shuahkh@osg.samsung.com>

Change ipc test to use kselftest exit codes in kselftest.h
to report test results. With this change this test exits with
EXIT_FAIL instead of -errno. Changed print errno in test fail
messages to not loose that information.

Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
 tools/testing/selftests/ipc/msgque.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c
index 552f081..2812017 100644
--- a/tools/testing/selftests/ipc/msgque.c
+++ b/tools/testing/selftests/ipc/msgque.c
@@ -5,6 +5,8 @@
 #include <linux/msg.h>
 #include <fcntl.h>
 
+#include "../kselftest.h"
+
 #define MAX_MSG_SIZE		32
 
 struct msg1 {
@@ -195,58 +197,58 @@ int main(int argc, char **argv)
 
 	if (getuid() != 0) {
 		printf("Please run the test as root - Exiting.\n");
-		exit(1);
+		exit(EXIT_FAIL);
 	}
 
 	msgque.key = ftok(argv[0], 822155650);
 	if (msgque.key == -1) {
-		printf("Can't make key\n");
-		return -errno;
+		printf("Can't make key: %d\n", -errno);
+		return EXIT_FAIL;
 	}
 
 	msgque.msq_id = msgget(msgque.key, IPC_CREAT | IPC_EXCL | 0666);
 	if (msgque.msq_id == -1) {
 		err = -errno;
-		printf("Can't create queue\n");
+		printf("Can't create queue: %d\n", err);
 		goto err_out;
 	}
 
 	err = fill_msgque(&msgque);
 	if (err) {
-		printf("Failed to fill queue\n");
+		printf("Failed to fill queue: %d\n", err);
 		goto err_destroy;
 	}
 
 	err = dump_queue(&msgque);
 	if (err) {
-		printf("Failed to dump queue\n");
+		printf("Failed to dump queue: %d\n", err);
 		goto err_destroy;
 	}
 
 	err = check_and_destroy_queue(&msgque);
 	if (err) {
-		printf("Failed to check and destroy queue\n");
+		printf("Failed to check and destroy queue: %d\n", err);
 		goto err_out;
 	}
 
 	err = restore_queue(&msgque);
 	if (err) {
-		printf("Failed to restore queue\n");
+		printf("Failed to restore queue: %d\n", err);
 		goto err_destroy;
 	}
 
 	err = check_and_destroy_queue(&msgque);
 	if (err) {
-		printf("Failed to test queue\n");
+		printf("Failed to test queue: %d\n", err);
 		goto err_out;
 	}
-	return 0;
+	return EXIT_PASS;
 
 err_destroy:
 	if (msgctl(msgque.msq_id, IPC_RMID, 0)) {
 		printf("Failed to destroy queue: %d\n", -errno);
-		return -errno;
+		return EXIT_FAIL;
 	}
 err_out:
-	return err;
+	return EXIT_FAIL;
 }
-- 
1.9.1


  parent reply	other threads:[~2014-09-15 22:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15 22:33 [PATCH 0/7] kselftest new exit codes and test changes to use them Shuah Khan
2014-09-15 22:33 ` [PATCH 1/7] selftests: add header file for test exit code defines Shuah Khan
2014-09-16 16:04   ` Davidlohr Bueso
2014-09-16 17:31     ` Shuah Khan
2014-09-16 17:40       ` Andy Lutomirski
2014-09-16 17:47         ` Shuah Khan
2014-09-15 22:33 ` [PATCH 2/7] selftests/breakpoints: change breakpoints test to use kselftest exit codes Shuah Khan
2014-09-15 22:33 ` Shuah Khan [this message]
2014-09-15 22:33 ` [PATCH 4/7] selftests/kcmp: change kcmp " Shuah Khan
2014-09-15 22:34 ` [PATCH 5/7] selftests/mount: change mount " Shuah Khan
2014-09-15 22:34 ` [PATCH 6/7] selftests/ptrace: change ptrace " Shuah Khan
2014-09-15 22:34 ` [PATCH 7/7] selftests/timers: change timers " Shuah Khan

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=1410820442-8774-4-git-send-email-shuahkh@osg.samsung.com \
    --to=shuahkh@osg.samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=colin.king@canonical.com \
    --cc=dbueso@suse.de \
    --cc=ebiederm@xmission.com \
    --cc=felipensp@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge.hallyn@ubuntu.com \
    --cc=thierry@linux.vnet.ibm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).