diff mbox

[v4,09/19] libcflat: add abort() and assert()

Message ID 1397149020-3501-10-git-send-email-drjones@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Jones April 10, 2014, 4:56 p.m. UTC
The test framework may have external dependencies. assert() provides
the ability to abort when those dependencies aren't met. However,
assert() should only be used for unlikely conditions. We can provide
more informative messages with printf() for the more likely problems.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/libcflat.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Christoffer Dall June 6, 2014, 6:38 p.m. UTC | #1
On Thu, Apr 10, 2014 at 06:56:50PM +0200, Andrew Jones wrote:
> The test framework may have external dependencies. assert() provides
> the ability to abort when those dependencies aren't met. However,
> assert() should only be used for unlikely conditions. We can provide
> more informative messages with printf() for the more likely problems.
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---

Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 99d1cd533dd03..c7c31be1cc8e5 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -67,4 +67,13 @@  extern long atol(const char *ptr);
 
 void report(const char *msg_fmt, bool pass, ...);
 int report_summary(void);
+
+#define abort() exit(64)		/* 129 exit status from qemu */
+#define assert(cond)							\
+do {									\
+	if (!(cond))							\
+		printf("%s:%d: assert failed\n", __FILE__, __LINE__),	\
+		abort();						\
+} while (0)
+
 #endif