All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, Dave Hansen <dave.hansen@linux.intel.com>,
	linuxram@us.ibm.com, tglx@linutronix.de, dave.hansen@intel.com,
	mpe@ellerman.id.au, mingo@kernel.org, akpm@linux-foundation.org,
	shuah@kernel.org
Subject: [PATCH 02/13] x86/pkeys/selftests: Stop using assert()
Date: Wed, 09 May 2018 10:13:40 -0700	[thread overview]
Message-ID: <20180509171340.E63EF7DA@viggo.jf.intel.com> (raw)
In-Reply-To: <20180509171336.76636D88@viggo.jf.intel.com>


From: Dave Hansen <dave.hansen@linux.intel.com>

If we use assert(), the program "crashes".  That can be scary to users,
so stop doing it.  Just exit with a >0 exit code instead.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Ram Pai <linuxram@us.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Michael Ellermen <mpe@ellerman.id.au>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Shuah Khan <shuah@kernel.org>
---

 b/tools/testing/selftests/x86/protection_keys.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff -puN tools/testing/selftests/x86/protection_keys.c~pkeys-selftests-do-not-assert tools/testing/selftests/x86/protection_keys.c
--- a/tools/testing/selftests/x86/protection_keys.c~pkeys-selftests-do-not-assert	2018-05-09 09:20:18.717698407 -0700
+++ b/tools/testing/selftests/x86/protection_keys.c	2018-05-09 09:20:18.720698407 -0700
@@ -72,10 +72,9 @@ extern void abort_hooks(void);
 				test_nr, iteration_nr);	\
 		dprintf0("errno at assert: %d", errno);	\
 		abort_hooks();			\
-		assert(condition);		\
+		exit(__LINE__);			\
 	}					\
 } while (0)
-#define raw_assert(cond) assert(cond)
 
 void cat_into_file(char *str, char *file)
 {
@@ -87,12 +86,17 @@ void cat_into_file(char *str, char *file
 	 * these need to be raw because they are called under
 	 * pkey_assert()
 	 */
-	raw_assert(fd >= 0);
+	if (fd < 0) {
+		fprintf(stderr, "error opening '%s'\n", str);
+		perror("error: ");
+		exit(__LINE__);
+	}
+
 	ret = write(fd, str, strlen(str));
 	if (ret != strlen(str)) {
 		perror("write to file failed");
 		fprintf(stderr, "filename: '%s' str: '%s'\n", file, str);
-		raw_assert(0);
+		exit(__LINE__);
 	}
 	close(fd);
 }
_

  parent reply	other threads:[~2018-05-09 17:18 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09 17:13 [PATCH 00/13] [v4] x86, pkeys: two protection keys bug fixes Dave Hansen
2018-05-09 17:13 ` [PATCH 01/13] x86/pkeys/selftests: Give better unexpected fault error messages Dave Hansen
2018-05-14 12:40   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` Dave Hansen [this message]
2018-05-14 12:41   ` [tip:x86/urgent] x86/pkeys/selftests: Stop using assert() tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 03/13] x86/pkeys/selftests: Remove dead debugging code, fix dprint_in_signal Dave Hansen
2018-05-14 12:41   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 04/13] x86/pkeys/selftests: Avoid printf-in-signal deadlocks Dave Hansen
2018-05-14 12:42   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 05/13] x86/pkeys/selftests: Allow faults on unknown keys Dave Hansen
2018-05-14 12:42   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 06/13] x86/pkeys/selftests: Factor out "instruction page" Dave Hansen
2018-05-14 12:43   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 07/13] x86/pkeys/selftests: Add PROT_EXEC test Dave Hansen
2018-05-14 12:43   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 08/13] x86/pkeys/selftests: Fix pkey exhaustion test off-by-one Dave Hansen
2018-05-14 12:44   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 09/13] x86/pkeys: Override pkey when moving away from PROT_EXEC Dave Hansen
2018-05-09 17:13   ` Dave Hansen
2018-05-14 12:44   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 10/13] x86/pkeys/selftests: Fix pointer math Dave Hansen
2018-05-14 12:45   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 11/13] x86/pkeys/selftests: Save off 'prot' for allocations Dave Hansen
2018-05-14 12:45   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 12/13] x86/pkeys/selftests: Add a test for pkey 0 Dave Hansen
2018-05-14 12:46   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-09 17:13 ` [PATCH 13/13] x86/pkeys: Do not special case protection key 0 Dave Hansen
2018-05-09 17:13   ` Dave Hansen
2018-05-14 12:46   ` [tip:x86/urgent] " tip-bot for Dave Hansen
2018-05-14  8:29 ` [PATCH 00/13] [v4] x86, pkeys: two protection keys bug fixes Ingo Molnar
2018-05-14  8:29   ` Ingo Molnar
2018-05-14  8:47   ` Ingo Molnar
2018-05-14  8:56   ` [PATCH] x86/pkeys/selftests: Adjust the self-test to fresh distros that export the pkeys ABI Ingo Molnar
2018-05-14  8:56     ` Ingo Molnar
2018-05-14 12:39     ` [tip:x86/urgent] " tip-bot for Ingo Molnar
2018-05-14  8:59   ` [PATCH] x86/mpx/selftests: Adjust the self-test to fresh distros that export the MPX ABI Ingo Molnar
2018-05-14 12:39     ` [tip:x86/urgent] " tip-bot for Ingo Molnar

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=20180509171340.E63EF7DA@viggo.jf.intel.com \
    --to=dave.hansen@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxram@us.ibm.com \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    /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.