From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH v4 09/19] libcflat: add abort() and assert() Date: Thu, 10 Apr 2014 18:56:50 +0200 Message-ID: <1397149020-3501-10-git-send-email-drjones@redhat.com> References: <1397149020-3501-1-git-send-email-drjones@redhat.com> Cc: christoffer.dall@linaro.org To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:62935 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758753AbaDJQ5W (ORCPT ); Thu, 10 Apr 2014 12:57:22 -0400 In-Reply-To: <1397149020-3501-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 --- lib/libcflat.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- 1.8.1.4