From patchwork Thu Apr 10 16:56:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 3963651 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C807CBFF02 for ; Thu, 10 Apr 2014 16:58:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2589420819 for ; Thu, 10 Apr 2014 16:58:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A6A02081D for ; Thu, 10 Apr 2014 16:58:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758791AbaDJQ6U (ORCPT ); Thu, 10 Apr 2014 12:58:20 -0400 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 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3AGvK2h030330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 10 Apr 2014 12:57:20 -0400 Received: from hawk.usersys.redhat.com.com (dhcp-1-170.brq.redhat.com [10.34.1.170]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s3AGv4Uq021128; Thu, 10 Apr 2014 12:57:19 -0400 From: Andrew Jones To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: christoffer.dall@linaro.org 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> In-Reply-To: <1397149020-3501-1-git-send-email-drjones@redhat.com> References: <1397149020-3501-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Christoffer Dall --- 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