From patchwork Thu Jun 21 14:47:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramon Fried X-Patchwork-Id: 932965 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JUfIaURr"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41Bb074ddPz9s2L for ; Fri, 22 Jun 2018 07:47:33 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 825E4C21C2F; Thu, 21 Jun 2018 21:47:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=DATE_IN_PAST_06_12, FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8B932C21C2F; Thu, 21 Jun 2018 21:47:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BB8EFC21C2F; Thu, 21 Jun 2018 21:47:24 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id 6429EC21C2C for ; Thu, 21 Jun 2018 21:47:24 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id a12-v6so4673575wro.1 for ; Thu, 21 Jun 2018 14:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=pA+wR1thgaeaZdd5OUCVTd7y/AM1SXFMDGbRVZPLqFo=; b=JUfIaURrpAmYH3t+nD3ORR2xtn3prOQ5hCpLBZ39Rodtchm58fVAP6FpbAfFlJcT0D oRiKFJgl0MBONCz2fLhgLuXfD+hK0zvtxa+wSiP83lKjBcit5QeiIz6xpSqrNCWnRrTX goMbEBa/92be0MA9QldW6UPOv+zQE5KLkM0NSYR31cIX/IJYQlv1jfcxSV9VtlQ3a/dj Ia0zTowU73kRMEX/+UEBct2WgL00EMV89b/1/1QlDzJRZqMPBFoSh7CONL5xWkPWC3RA q6wRslqPkga2KLTurJgXYF0i9+6XYdgG7gz//bA0RHaDbRsGZoJXJ83nNGwkeBE4Hjzh 8FbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pA+wR1thgaeaZdd5OUCVTd7y/AM1SXFMDGbRVZPLqFo=; b=mIghouIlZOrkOELcCaUMIfmJaG4WPeBA03v/Pt9taNVgpCaP2t2hTDG9YD6B80HLAM 5OXlbtD2JzQx9wHLN4rqJEuXouHDAc46pmOzp1b6z+3w72UmO+fw9Zt4Qw76fPeRIelT TJt9H3OMGz7OYc1HA+zocuSXu+k1NVnE08XBuMgzy3n1WIGDpVGUSWyqud2qgQLuUWTO 1akR10JuIiNhB1QoWRHGTIgNlPeTZKOjG6oN/fXpRGEdVyxbPHu3lKN8iVXQsvyzCcDc XiJvGYfGamLtLZd9Dl/7R1ZL8sRQefeLj+MZlKc4Z04l4uy1BZSiSrBeU4IkUXSu1O9V t60A== X-Gm-Message-State: APt69E2YEqvtJmhb1oipmI1oQ7WGLTpOg/fpldwjwWyAwNprO9XUDbTX hpehOr1HJYCVKNytWWiLVjE= X-Google-Smtp-Source: ADUXVKK023VPt+2+/YJhVDfxPnXwucuSYQO1WSKwBzE9sjuIKuM+AwjQ3i6PwfxC+/u1QWhKBC5VNg== X-Received: by 2002:adf:ba8f:: with SMTP id p15-v6mr24655912wrg.139.1529617643880; Thu, 21 Jun 2018 14:47:23 -0700 (PDT) Received: from localhost.localdomain ([141.226.166.38]) by smtp.gmail.com with ESMTPSA id d3-v6sm5131571wrr.90.2018.06.21.14.47.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 14:47:23 -0700 (PDT) From: Ramon Fried To: Simon Glass , u-boot@lists.denx.de Date: Thu, 21 Jun 2018 17:47:16 +0300 Message-Id: <20180621144716.27976-1-ramon.fried@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [U-Boot] [PATCH] test: Add ut_assertnull macro X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add ut_assertnull macro to include/test/ut.h For testing of functions that returns NULL on errors. Signed-off-by: Ramon Fried Reviewed-by: Simon Glass --- include/test/ut.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/test/ut.h b/include/test/ut.h index 59b23a25a4..fce75fd12a 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -90,6 +90,18 @@ void ut_failf(struct unit_test_state *uts, const char *fname, int line, } \ } +/* Assert that a pointer is NULL */ +#define ut_assertnull(expr) { \ + const void *val = (expr); \ + \ + if (val != NULL) { \ + ut_failf(uts, __FILE__, __LINE__, __func__, \ + #expr " != NULL", \ + "Expected NULL, got %p", val); \ + return CMD_RET_FAILURE; \ + } \ +} + /* Assert that a pointer is not NULL */ #define ut_assertnonnull(expr) { \ const void *val = (expr); \