From patchwork Thu Oct 5 21:57:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beau Belgrave X-Patchwork-Id: 149040 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp587715vqb; Thu, 5 Oct 2023 14:57:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECyJ2rufZ8Tx4MdNQCQ9I4SXEZdeybSSwplIp+oFaRv7fXcaT7+r9/apLu9lVvw4Q5pDns X-Received: by 2002:a05:6808:f13:b0:3a1:db18:401e with SMTP id m19-20020a0568080f1300b003a1db18401emr7950164oiw.1.1696543070202; Thu, 05 Oct 2023 14:57:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696543070; cv=none; d=google.com; s=arc-20160816; b=hDLb5ubPpAK8GP7TPYgqhmhbFzo31w+tB9l9SNYVG9WzevSeU/CLgQuHGV4MDtfpYP cSKvMNqI1+PgxxKutTOZO7h1ZSivfmBEDbxCywjQG5PspEm8CSSDOFreRj5T7vOm84Xy CrUeRcThFxwFK8+Vr5fn9wHA7coajLrldcUb8w55asEyvmr3bbmg4TG1Aq7NEI763nuY 1nplBGVLwv8/VXXUCuGxO1W0nEYj7LMkFAv7zB+QhgElWKKEwmpL8Wx+PoPR+TKluSjx CdsaeFyxYEQDj+4EOUgrHzDwCeUrhZZBwcdlMH2k+BWzGM75/75fDxOdz+jjxmqPFj+W NpQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=XhbfJBWSTRIT9526flXJPlw166baAx2c5A/vZ2PKne0=; fh=z1RKKgNRi1DpNx8ytZBt4nhxDsUkDwTh/X9m+SXQg6s=; b=XHzkLRVpMvS+nVerUrMUu+xXMVMqy+t8PVo4s3gcK5OgPdDiHtcemL2iMSO9fbpX6z h2hldZPrewAjeVTUYp4pZupNzR+v3J7K+g8PDv/jgrQ8rh0e0neLwTvFQiVKSXxtKw+z 7xVxZxQybuOotAFeCkRNbqkwVxbYoRBxYAhIc4V7CGUSsgwZYBrNVgU69kHvC14cdWTL hsqHKjD/oXE4r3rsGeKurTFC3dnYqQDW62GBHsq/fWnM4V7uaBvG/1UWnJfhbMuLTmXg 64GYSFIjWqRNEdhDo+bnnKk13YrJ4tAuyJZPmAbaSa9IJr8o8/uSfrk+AfT3udkVG2QG KH7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=duVWHzgm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id m1-20020a656a01000000b00585adc52bd5si2592161pgu.730.2023.10.05.14.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 14:57:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=duVWHzgm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 2562A8446E7D; Thu, 5 Oct 2023 14:57:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231722AbjJEV5Q (ORCPT + 18 others); Thu, 5 Oct 2023 17:57:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbjJEV5Q (ORCPT ); Thu, 5 Oct 2023 17:57:16 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A23399E; Thu, 5 Oct 2023 14:57:14 -0700 (PDT) Received: from localhost.localdomain (unknown [4.155.48.118]) by linux.microsoft.com (Postfix) with ESMTPSA id 2707820B74C0; Thu, 5 Oct 2023 14:57:14 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2707820B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1696543034; bh=XhbfJBWSTRIT9526flXJPlw166baAx2c5A/vZ2PKne0=; h=From:To:Cc:Subject:Date:From; b=duVWHzgmIH1tGJ2KISci7NPE0i0uFCNAm467XQ7H2Yk8Hh1AAdF56dgTRxtFTKo4z REGn5utMR4dHqbRuKt6bm+i4jrD6cRzNVpK9F64DAFpJ1CWHZM6YmmZspog/iQslF7 ylvrEjLjjUTlcIUAHF/iBIWyv/e/xfzLZuoJb2/A= From: Beau Belgrave To: rostedt@goodmis.org, shuah@kernel.org, mhiramat@kernel.org Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH v3] selftests/user_events: Fix abi_test for BE archs Date: Thu, 5 Oct 2023 21:57:12 +0000 Message-Id: <20231005215712.17942-1-beaub@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 05 Oct 2023 14:57:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778953808826150757 X-GMAIL-MSGID: 1778954346331643016 The abi_test currently uses a long sized test value for enablement checks. On LE this works fine, however, on BE this results in inaccurate assert checks due to a bit being used and assuming it's value is the same on both LE and BE. Use int type for 32-bit values and long type for 64-bit values to ensure appropriate behavior on both LE and BE. Fixes: 60b1af8de8c1 ("tracing/user_events: Add ABI self-test") Signed-off-by: Beau Belgrave Acked-by: Steven Rostedt (Google) --- V3 Changes: Fix missing cast in clone_check(). V2 Changes: Rebase to linux-kselftest/fixes. tools/testing/selftests/user_events/abi_test.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) base-commit: 6f874fa021dfc7bf37f4f37da3a5aaa41fe9c39c diff --git a/tools/testing/selftests/user_events/abi_test.c b/tools/testing/selftests/user_events/abi_test.c index 8202f1327c39..f5575ef2007c 100644 --- a/tools/testing/selftests/user_events/abi_test.c +++ b/tools/testing/selftests/user_events/abi_test.c @@ -47,7 +47,7 @@ static int change_event(bool enable) return ret; } -static int reg_enable(long *enable, int size, int bit) +static int reg_enable(void *enable, int size, int bit) { struct user_reg reg = {0}; int fd = open(data_file, O_RDWR); @@ -69,7 +69,7 @@ static int reg_enable(long *enable, int size, int bit) return ret; } -static int reg_disable(long *enable, int bit) +static int reg_disable(void *enable, int bit) { struct user_unreg reg = {0}; int fd = open(data_file, O_RDWR); @@ -90,7 +90,8 @@ static int reg_disable(long *enable, int bit) } FIXTURE(user) { - long check; + int check; + long check_long; bool umount; }; @@ -99,6 +100,7 @@ FIXTURE_SETUP(user) { change_event(false); self->check = 0; + self->check_long = 0; } FIXTURE_TEARDOWN(user) { @@ -136,9 +138,9 @@ TEST_F(user, bit_sizes) { #if BITS_PER_LONG == 8 /* Allow 0-64 bits for 64-bit */ - ASSERT_EQ(0, reg_enable(&self->check, sizeof(long), 63)); - ASSERT_NE(0, reg_enable(&self->check, sizeof(long), 64)); - ASSERT_EQ(0, reg_disable(&self->check, 63)); + ASSERT_EQ(0, reg_enable(&self->check_long, sizeof(long), 63)); + ASSERT_NE(0, reg_enable(&self->check_long, sizeof(long), 64)); + ASSERT_EQ(0, reg_disable(&self->check_long, 63)); #endif /* Disallowed sizes (everything beside 4 and 8) */ @@ -200,7 +202,7 @@ static int clone_check(void *check) for (i = 0; i < 10; ++i) { usleep(100000); - if (*(long *)check) + if (*(int *)check) return 0; }