From patchwork Sat Jul 15 18:33:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 120829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp297471vqt; Sat, 15 Jul 2023 11:54:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlFc6kCRaQvY21hanIps0nxuj+Uwn9z4yMVikQu2E91PZUO+8OxI2idkOhlPNdcmFQ4gOQo0 X-Received: by 2002:a05:6a00:2488:b0:673:5d1e:6657 with SMTP id c8-20020a056a00248800b006735d1e6657mr9040914pfv.7.1689447295663; Sat, 15 Jul 2023 11:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689447295; cv=none; d=google.com; s=arc-20160816; b=SSft8MdNi3X3xTa+wYzMniEabFSmF1D2IDhhUlZPUmrKPKOYVGvpTPzetyYW8mjqiR B2+NpavfTrErRmmsdAUfkV6ogyrI8tUiH9rsVYkotB4VBTJMItpNjQ//9oNhORCr3GD7 uuVrbMOXmeKxJdZhY4N3z5+mt2n47JSm81jP5egZPyIkveAzKW1c8brDF/zxEjM/qSkw 1l+BDnQvOpBo+zRkfLyw1TSqKDeg6kCOtBtTUn4wXY0SREtazp3jHEiEmtCaNvExdR3q lr4l4GYiSYsrNMa0LD1nBfab2+OoL4sX5CWzS+dIRmC09hlCbtenAFKAbC+3tiOWhIWq QoGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=KROJRe3+XJtb1VMit7ekiZ92BlwcEiBn0atSmDACXFc=; fh=sXngqCw1oXONrSSImRxZmGyzcK67QhJYp1RgY40tBsg=; b=CJQDrfpymau4ujwb3HavPa/hApUTZiqLbNlAdwE71G7ZIXaIToujo0CyseHvlYl8jl S1R4kxFnT273Jn5HKN4cB04U6gGFk6A19D6V5vfZJwHnc3qNyRxlAhZ4PoeoscWX0pXQ fiZG/ZhwVVtXioC3WnkuWzaxq4eOTLgg6Knph+PC+T3rtcRxhV4vyiEQ16OY2TEVtaHz OlfdaFARmQExjKjD9UbLTkh2a6qfncvxUWl4i8g+8tN/p636uafjrRzBon9QZe6O5lgj hpC8pTVZsOgXCjOnIyupB5HmiFfTjx7nW1iZfJJ0UJREH1EcPVPtA6nnm/LXYwTWs1lG 0hKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f5-20020a63f745000000b0055b6a784893si8874687pgk.520.2023.07.15.11.54.41; Sat, 15 Jul 2023 11:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230280AbjGOSdj (ORCPT + 99 others); Sat, 15 Jul 2023 14:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjGOSdi (ORCPT ); Sat, 15 Jul 2023 14:33:38 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F97F128; Sat, 15 Jul 2023 11:33:36 -0700 (PDT) X-QQ-mid: bizesmtp89t1689446007tccdiej5 Received: from linux-lab-host.localdomain ( [119.123.131.162]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 16 Jul 2023 02:33:26 +0800 (CST) X-QQ-SSF: 01200000002000D0W000B00A0000000 X-QQ-FEAT: ILHsT53NKPio8QXj0SePF8Uv6ufub1HmV7VAtAE5IfpljIxcz2xHRSfOkvFRE 5ynY8onEmktjHch/b7w6INeCszX3aPulK5C4mOh+SXNOCRZm2VDiidEH38O5BpM9Ul1NMf6 ARoHScpuEtEDapuBc52c5iWL+AtOnU8ZUXCmTb2b8JLRKm7/qNHyazikg62xSHOdGxJUrjW LMjT8h89SzQxiO+JJHHH3NUXQInpRbZh4v0KeTbgFuPSj1m+5yOkJuHyClou5G4RM5KiyXo 8WbgPMHR81+3koV2C3KK8kPgBuXMtOX7syK20zYWrUAU6VbZKyj4qKcTxku13hB72JAmDUH u9+rqgqk2w5fuNV2+VZ2sQ7rFxMwhwEAMlnYEZqtfPPu63bDbJGo/nlyTEQzmLNXKqs9Hy4 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 3122993213598175928 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, thomas@t-8ch.de Subject: [PATCH v4 15/18] selftests/nolibc: add EXPECT_PTRGE, EXPECT_PTRGT, EXPECT_PTRLE, EXPECT_PTRLT Date: Sun, 16 Jul 2023 02:33:26 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771513887682833763 X-GMAIL-MSGID: 1771513887682833763 4 new pointer compare macros are added, they are similar to the integer compare macros. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 50 ++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index dfadd07ee7d9..3ff706078fbd 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -410,6 +410,56 @@ static int expect_ptrne(const void *expr, int llen, const void *cmp) return ret; } +#define EXPECT_PTRGE(cond, expr, cmp) \ + do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrge(expr, llen, cmp); } while (0) + +static int expect_ptrge(const void *expr, int llen, const void *cmp) +{ + int ret = !(expr >= cmp); + + llen += printf(" = <%p> ", expr); + result(llen, ret ? FAIL : OK); + return ret; +} + +#define EXPECT_PTRGT(cond, expr, cmp) \ + do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrgt(expr, llen, cmp); } while (0) + +static int expect_ptrgt(const void *expr, int llen, const void *cmp) +{ + int ret = !(expr > cmp); + + llen += printf(" = <%p> ", expr); + result(llen, ret ? FAIL : OK); + return ret; +} + + +#define EXPECT_PTRLE(cond, expr, cmp) \ + do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrle(expr, llen, cmp); } while (0) + +static int expect_ptrle(const void *expr, int llen, const void *cmp) +{ + int ret = !(expr <= cmp); + + llen += printf(" = <%p> ", expr); + result(llen, ret ? FAIL : OK); + return ret; +} + + +#define EXPECT_PTRLT(cond, expr, cmp) \ + do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrlt(expr, llen, cmp); } while (0) + +static int expect_ptrlt(const void *expr, int llen, const void *cmp) +{ + int ret = !(expr < cmp); + + llen += printf(" = <%p> ", expr); + result(llen, ret ? FAIL : OK); + return ret; +} + #define EXPECT_PTRER2(cond, expr, expret, experr1, experr2) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrerr2(expr, expret, experr1, experr2, llen); } while (0)